diff --git a/Cargo.lock b/Cargo.lock index 86ede8f69..471fb4cc8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -156,7 +156,7 @@ version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17ae5ebefcc48e7452b4987947920dac9450be1110cadf34d1b8c116bdbaf97c" dependencies = [ - "async-lock 3.2.0", + "async-lock 3.3.0", "async-task", "concurrent-queue 2.4.0", "fastrand 2.0.1", @@ -173,7 +173,7 @@ dependencies = [ "async-channel 2.1.1", "async-executor", "async-io 2.2.2", - "async-lock 3.2.0", + "async-lock 3.3.0", "blocking", "futures-lite 2.2.0", "once_cell", @@ -205,7 +205,7 @@ version = "2.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6afaa937395a620e33dc6a742c593c01aced20aa376ffb0f628121198578ccc7" dependencies = [ - "async-lock 3.2.0", + "async-lock 3.3.0", "cfg-if", "concurrent-queue 2.4.0", "futures-io", @@ -229,9 +229,9 @@ dependencies = [ [[package]] name = "async-lock" -version = "3.2.0" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7125e42787d53db9dd54261812ef17e937c95a51e4d291373b670342fa44310c" +checksum = "d034b430882f8381900d3fe6f0aaa3ad94f2cb4ac519b429692a1bc2dda4ae7b" dependencies = [ "event-listener 4.0.3", "event-listener-strategy", @@ -388,7 +388,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a37913e8dc4ddcc604f0c6d3bf2887c995153af3611de9e23c352b44c1b9118" dependencies = [ "async-channel 2.1.1", - "async-lock 3.2.0", + "async-lock 3.3.0", "async-task", "fastrand 2.0.1", "futures-io", @@ -581,15 +581,15 @@ dependencies = [ [[package]] name = "console" -version = "0.15.7" +version = "0.15.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c926e00cc70edefdc64d3a5ff31cc65bb97a3460097762bd23afb4d8145fccf8" +checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" dependencies = [ "encode_unicode", "lazy_static", "libc", "unicode-width", - "windows-sys 0.45.0", + "windows-sys 0.52.0", ] [[package]] @@ -793,27 +793,6 @@ dependencies = [ "crypto-common", ] -[[package]] -name = "dirs" -version = "5.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" -dependencies = [ - "dirs-sys", -] - -[[package]] -name = "dirs-sys" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" -dependencies = [ - "libc", - "option-ext", - "redox_users", - "windows-sys 0.48.0", -] - [[package]] name = "doc-comment" version = "0.3.3" @@ -1622,17 +1601,6 @@ version = "0.2.152" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" -[[package]] -name = "libredox" -version = "0.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" -dependencies = [ - "bitflags 2.4.1", - "libc", - "redox_syscall", -] - [[package]] name = "linux-raw-sys" version = "0.3.8" @@ -1788,13 +1756,13 @@ dependencies = [ [[package]] name = "metrsd_client" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dde92e4f83602c0d483e321d0d5061484700c32f85b9ede0212ff39d4378353c" +checksum = "7bf9498b3455d6004358238b1fb89d1ec929257b88500bdfe8334652b5e35a8c" dependencies = [ "futures", "metrs_stubs", - "ntex", + "ntex 1.0.0", "serde", "serde_json", "thiserror", @@ -1882,7 +1850,7 @@ dependencies = [ "nanocl_utils", "nanocld_client", "nix 0.27.1", - "ntex", + "ntex 1.0.0", "openssl", "regex", "ring", @@ -1902,7 +1870,7 @@ version = "0.2.0" dependencies = [ "bollard-next", "diesel", - "ntex", + "ntex 1.0.0", "serde_json", "serde_urlencoded", "serde_yaml", @@ -1933,7 +1901,7 @@ dependencies = [ "libc", "log", "nanocl_error", - "ntex", + "ntex 1.0.0", "serde", "serde_json", "utoipa", @@ -1963,7 +1931,7 @@ dependencies = [ "nanocl_utils", "nanocld_client", "notify", - "ntex", + "ntex 1.0.0", "ntex-cors", "rand", "serde", @@ -1984,7 +1952,7 @@ dependencies = [ "futures", "nanocl_error", "nanocl_stubs", - "ntex", + "ntex 1.0.0", "serde", "serde_json", "tokio", @@ -2011,7 +1979,7 @@ dependencies = [ "nanocl_error", "nanocl_utils", "nanocld_client", - "ntex", + "ntex 1.0.0", "openssl", "serde", "serde_json", @@ -2035,7 +2003,7 @@ dependencies = [ "nanocl_utils", "nanocld_client", "notify", - "ntex", + "ntex 1.0.0", "openssl", "serde", "serde_json", @@ -2053,7 +2021,7 @@ dependencies = [ "nanocl_error", "nanocl_utils", "nanocld_client", - "ntex", + "ntex 1.0.0", "openssl", "serde_json", "vpnkitrc", @@ -2117,6 +2085,47 @@ name = "ntex" version = "0.7.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e8da0767496674cfc59663af137b9487a1af597809ba952be07d742f4f75fef" +dependencies = [ + "async-channel 2.1.1", + "base64", + "bitflags 2.4.1", + "encoding_rs", + "httparse", + "httpdate", + "log", + "mime", + "nanorand", + "ntex-bytes", + "ntex-codec", + "ntex-connect 0.3.4", + "ntex-h2 0.4.4", + "ntex-http", + "ntex-io 0.3.17", + "ntex-macros", + "ntex-router", + "ntex-rt", + "ntex-service 1.2.7", + "ntex-tls 0.3.3", + "ntex-tokio 0.3.1", + "ntex-util 0.3.4", + "oneshot", + "percent-encoding", + "pin-project-lite", + "polling 3.3.1", + "regex", + "serde", + "serde_json", + "serde_urlencoded", + "sha-1", + "socket2 0.5.5", + "thiserror", +] + +[[package]] +name = "ntex" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5d57146b1df3f045ef60662a0bf2fd03f830fa37dec9381cb2e18956d21e8eb" dependencies = [ "async-channel 2.1.1", "base64", @@ -2130,18 +2139,18 @@ dependencies = [ "ntex-async-std", "ntex-bytes", "ntex-codec", - "ntex-connect", + "ntex-connect 1.0.0", "ntex-glommio", - "ntex-h2", + "ntex-h2 0.5.0", "ntex-http", - "ntex-io", + "ntex-io 1.0.0", "ntex-macros", "ntex-router", "ntex-rt", - "ntex-service", - "ntex-tls", - "ntex-tokio", - "ntex-util", + "ntex-service 2.0.0", + "ntex-tls 1.0.0", + "ntex-tokio 0.4.0", + "ntex-util 1.0.0", "oneshot", "openssl", "percent-encoding", @@ -2158,15 +2167,15 @@ dependencies = [ [[package]] name = "ntex-async-std" -version = "0.3.2" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35eb118c94b5bc332965887346b84ad6a2b7311708dd26e1d21a82baff678956" +checksum = "f0796d14f7e9a207364cc1fa0a99c45b6151bfe2c60ad9c90f1f625746ec6612" dependencies = [ "async-std", "log", "ntex-bytes", - "ntex-io", - "ntex-util", + "ntex-io 1.0.0", + "ntex-util 1.0.0", "oneshot", "pin-project-lite", ] @@ -2197,45 +2206,63 @@ name = "ntex-connect" version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa9c711a3564135ae0e499882da4a5b6cd8dfdd818dcc57e26e146aec541abe7" +dependencies = [ + "log", + "ntex-bytes", + "ntex-http", + "ntex-io 0.3.17", + "ntex-rt", + "ntex-service 1.2.7", + "ntex-tls 0.3.3", + "ntex-tokio 0.3.1", + "ntex-util 0.3.4", + "thiserror", +] + +[[package]] +name = "ntex-connect" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a95f2470cb20e347c1a46ce647e16a0c896661f4ae09927a861447f828e674bc" dependencies = [ "log", "ntex-async-std", "ntex-bytes", "ntex-glommio", "ntex-http", - "ntex-io", + "ntex-io 1.0.0", "ntex-rt", - "ntex-service", - "ntex-tls", - "ntex-tokio", - "ntex-util", + "ntex-service 2.0.0", + "ntex-tls 1.0.0", + "ntex-tokio 0.4.0", + "ntex-util 1.0.0", "openssl", "thiserror", ] [[package]] name = "ntex-cors" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14642860c40c8bb8adaf20d2a58a45bffa70285106fa4e87313c7f0b240bc21a" +checksum = "4c4049648f0125e6a71a35ee30dd86d7bf2a978d6e56191552e85249e3a98cfa" dependencies = [ "derive_more", "futures", - "ntex", + "ntex 1.0.0", ] [[package]] name = "ntex-glommio" -version = "0.3.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76690401ddbf60cf60581022492141a189c28d1b2f2bc0027ec87f21054a6a5c" +checksum = "1289e0535066445936a9c1b7470c65dd01881776c6bb810638afc505458a9422" dependencies = [ "futures-lite 1.13.0", "glommio", "log", "ntex-bytes", - "ntex-io", - "ntex-util", + "ntex-io 1.0.0", + "ntex-util 1.0.0", "oneshot", ] @@ -2251,12 +2278,34 @@ dependencies = [ "nanorand", "ntex-bytes", "ntex-codec", - "ntex-connect", + "ntex-connect 0.3.4", "ntex-http", - "ntex-io", + "ntex-io 0.3.17", "ntex-rt", - "ntex-service", - "ntex-util", + "ntex-service 1.2.7", + "ntex-util 0.3.4", + "pin-project-lite", + "thiserror", +] + +[[package]] +name = "ntex-h2" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d7eee598e3b94175cef2f8c3818b61460307be543f2d9132aac36ac8d78f3d5" +dependencies = [ + "bitflags 2.4.1", + "fxhash", + "log", + "nanorand", + "ntex-bytes", + "ntex-codec", + "ntex-connect 1.0.0", + "ntex-http", + "ntex-io 1.0.0", + "ntex-rt", + "ntex-service 2.0.0", + "ntex-util 1.0.0", "pin-project-lite", "thiserror", ] @@ -2285,8 +2334,23 @@ dependencies = [ "log", "ntex-bytes", "ntex-codec", - "ntex-service", - "ntex-util", + "ntex-service 1.2.7", + "ntex-util 0.3.4", + "pin-project-lite", +] + +[[package]] +name = "ntex-io" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ab3509390c5e2aa677c6444bc8ab1a57059b6f28b7cf55d48d93ddb39d52e90" +dependencies = [ + "bitflags 2.4.1", + "log", + "ntex-bytes", + "ntex-codec", + "ntex-service 2.0.0", + "ntex-util 1.0.0", "pin-project-lite", ] @@ -2340,6 +2404,15 @@ dependencies = [ "slab", ] +[[package]] +name = "ntex-service" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb1d57a4a9eef574622049b765886a893f2ecc874cde713720bf428977979704" +dependencies = [ + "slab", +] + [[package]] name = "ntex-tls" version = "0.3.3" @@ -2348,9 +2421,23 @@ checksum = "4bfa487eb2ee31f0e3e097f17d6a895add0ee2a1ffd83806e5cca5d40e935536" dependencies = [ "log", "ntex-bytes", - "ntex-io", - "ntex-service", - "ntex-util", + "ntex-io 0.3.17", + "ntex-service 1.2.7", + "ntex-util 0.3.4", + "pin-project-lite", +] + +[[package]] +name = "ntex-tls" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00fc944fdd939dcd8729ae6640efa079737bd6d421d71198ef23299bf8e38c47" +dependencies = [ + "log", + "ntex-bytes", + "ntex-io 1.0.0", + "ntex-service 2.0.0", + "ntex-util 1.0.0", "openssl", "pin-project-lite", ] @@ -2363,8 +2450,22 @@ checksum = "8f9810c166939940255f1e42a50dffb889801fe3fbe84dfd7ab342301338a6c4" dependencies = [ "log", "ntex-bytes", - "ntex-io", - "ntex-util", + "ntex-io 0.3.17", + "ntex-util 0.3.4", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "ntex-tokio" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd222124711e39aac5902abf45edbb385c2152d47230da41f5e5aed448795ed4" +dependencies = [ + "log", + "ntex-bytes", + "ntex-io 1.0.0", + "ntex-util 1.0.0", "pin-project-lite", "tokio", ] @@ -2382,7 +2483,25 @@ dependencies = [ "fxhash", "log", "ntex-rt", - "ntex-service", + "ntex-service 1.2.7", + "pin-project-lite", + "slab", +] + +[[package]] +name = "ntex-util" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d07c0746ae24cd097ed9a75ccec8796af10cc278c312c5ebe950b3ff8aeef18" +dependencies = [ + "bitflags 2.4.1", + "futures-core", + "futures-sink", + "futures-timer", + "fxhash", + "log", + "ntex-rt", + "ntex-service 2.0.0", "pin-project-lite", "slab", ] @@ -2567,12 +2686,6 @@ dependencies = [ "vcpkg", ] -[[package]] -name = "option-ext" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" - [[package]] name = "overload" version = "0.1.1" @@ -2874,17 +2987,6 @@ dependencies = [ "bitflags 1.3.2", ] -[[package]] -name = "redox_users" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" -dependencies = [ - "getrandom", - "libredox", - "thiserror", -] - [[package]] name = "regex" version = "1.10.2" @@ -2978,7 +3080,6 @@ dependencies = [ "proc-macro2", "quote", "rust-embed-utils", - "shellexpand", "syn 2.0.48", "walkdir", ] @@ -3249,15 +3350,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" -[[package]] -name = "shellexpand" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da03fa3b94cc19e3ebfc88c4229c49d8f08cdbd1228870a45f0ffdf84988e14b" -dependencies = [ - "dirs", -] - [[package]] name = "signal-hook" version = "0.3.17" @@ -3400,9 +3492,9 @@ dependencies = [ [[package]] name = "termcolor" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff1bc3d3f05aff0403e8ac0d92ced918ec05b666a43f83297ccef5bea8a3d449" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" dependencies = [ "winapi-util", ] @@ -3739,9 +3831,9 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "utoipa" -version = "4.1.0" +version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ff05e3bac2c9428f57ade702667753ca3f5cf085e2011fe697de5bfd49aa72d" +checksum = "272ebdfbc99111033031d2f10e018836056e4d2c8e2acda76450ec7974269fa7" dependencies = [ "indexmap 2.1.0", "serde", @@ -3752,9 +3844,9 @@ dependencies = [ [[package]] name = "utoipa-gen" -version = "4.1.0" +version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f0b6f4667edd64be0e820d6631a60433a269710b6ee89ac39525b872b76d61d" +checksum = "d3c9f4d08338c1bfa70dde39412a040a884c6f318b3d09aaaf3437a1e52027fc" dependencies = [ "proc-macro-error", "proc-macro2", @@ -3765,9 +3857,9 @@ dependencies = [ [[package]] name = "utoipa-swagger-ui" -version = "5.0.0" +version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f839caa8e09dddc3ff1c3112a91ef7da0601075ba5025d9f33ae99c4cb9b6e51" +checksum = "0b39868d43c011961e04b41623e050aedf2cc93652562ff7935ce0f819aaf2da" dependencies = [ "mime_guess", "regex", @@ -3818,7 +3910,7 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96a18502962df738fb83f4b307573137474270184b68e9226697c535cafa032b" dependencies = [ - "ntex", + "ntex 0.7.17", "serde", "serde_json", ] @@ -3979,15 +4071,6 @@ dependencies = [ "windows-targets 0.52.0", ] -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets 0.42.2", -] - [[package]] name = "windows-sys" version = "0.48.0" @@ -4006,21 +4089,6 @@ dependencies = [ "windows-targets 0.52.0", ] -[[package]] -name = "windows-targets" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" -dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", -] - [[package]] name = "windows-targets" version = "0.48.5" @@ -4051,12 +4119,6 @@ dependencies = [ "windows_x86_64_msvc 0.52.0", ] -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" - [[package]] name = "windows_aarch64_gnullvm" version = "0.48.5" @@ -4069,12 +4131,6 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" -[[package]] -name = "windows_aarch64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" - [[package]] name = "windows_aarch64_msvc" version = "0.48.5" @@ -4087,12 +4143,6 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" -[[package]] -name = "windows_i686_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" - [[package]] name = "windows_i686_gnu" version = "0.48.5" @@ -4105,12 +4155,6 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" -[[package]] -name = "windows_i686_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" - [[package]] name = "windows_i686_msvc" version = "0.48.5" @@ -4123,12 +4167,6 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" -[[package]] -name = "windows_x86_64_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" - [[package]] name = "windows_x86_64_gnu" version = "0.48.5" @@ -4141,12 +4179,6 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" - [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" @@ -4159,12 +4191,6 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" -[[package]] -name = "windows_x86_64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" - [[package]] name = "windows_x86_64_msvc" version = "0.48.5" diff --git a/bin/nanocl/Cargo.toml b/bin/nanocl/Cargo.toml index 8e93935d1..db9d12ed6 100644 --- a/bin/nanocl/Cargo.toml +++ b/bin/nanocl/Cargo.toml @@ -43,7 +43,7 @@ serde_yaml = "0.9" tabled = "0.15" indicatif = "0.17" serde_json = "1.0" -ntex = { version = "0.7", features = ["tokio", "openssl"] } +ntex = { version = "1.0", features = ["tokio", "openssl"] } serde = { version = "1.0", features = ["derive"] } clap = { version = "4.4", features = ["derive", "cargo"] } tokio = { version = "1.34", features = ["fs"] } diff --git a/bin/nanocld/Cargo.toml b/bin/nanocld/Cargo.toml index 2c2fb7d36..e9e5b648c 100644 --- a/bin/nanocld/Cargo.toml +++ b/bin/nanocld/Cargo.toml @@ -58,7 +58,7 @@ clap = { version = "4.4", features = ["derive"] } url = { version = "2", features = ["serde"] } serde = { version = "1.0", features = ["derive"] } uuid = { version = "1.6", features = ["serde", "v4"] } -ntex = { version = "0.7", features = ["tokio", "openssl"] } +ntex = { version = "1.0", features = ["tokio", "openssl"] } diesel = { version = "2.1", features = [ "postgres", "r2d2", @@ -81,7 +81,7 @@ nanocld_client = { version = "0.13", features = ["tokio"] } metrsd_client = "0.5" nanocl_stubs = { version = "0.13", features = ["serde"] } nanocl_utils = { version = "0.4", features = ["unix", "ntex", "logger"] } -utoipa = { version = "4.1", features = ["yaml"], optional = true } +utoipa = { version = "4.2", features = ["yaml"], optional = true } notify = "6.1" -ntex-cors = "0.4" +ntex-cors = "0.5" rand = "0.8" diff --git a/bin/nanocld/specs/swagger.yaml b/bin/nanocld/specs/swagger.yaml index c0f614d6c..d47268052 100644 --- a/bin/nanocld/specs/swagger.yaml +++ b/bin/nanocld/specs/swagger.yaml @@ -2089,6 +2089,7 @@ components: type: string description: Name of the image example: nginx:latest + additionalProperties: false CargoInspect: type: object description: |- @@ -2217,6 +2218,7 @@ components: allOf: - $ref: '#/components/schemas/ReplicationMode' nullable: true + additionalProperties: false CargoSpecUpdate: type: object description: |- @@ -2251,6 +2253,7 @@ components: allOf: - $ref: '#/components/schemas/ReplicationMode' nullable: true + additionalProperties: false CargoSummary: type: object description: |- @@ -3017,6 +3020,7 @@ components: type: string IpAddress: type: string + additionalProperties: false Driver: type: object description: Driver represents a driver (network, logging, secrets). @@ -3203,6 +3207,7 @@ components: - Resource - Secret - Process + - ContainerImage EventKind: type: string description: Kind of event (Error, Normal, Warning), new types could be added in the future. @@ -3913,6 +3918,7 @@ components: allOf: - $ref: '#/components/schemas/UrlRedirect' nullable: true + additionalProperties: false ImageInspect: type: object description: Information about an image in the local image cache. @@ -4251,6 +4257,7 @@ components: items: $ref: '#/components/schemas/Config' description: List of container to run + additionalProperties: false JobSummary: type: object description: Summary of a job (used in list) @@ -4534,6 +4541,7 @@ components: format: int64 nullable: true minimum: 0 + additionalProperties: false MemoryStatsStatsV2: type: object description: |- @@ -4697,6 +4705,7 @@ components: type: integer format: int64 minimum: 0 + additionalProperties: false Metric: type: object description: Metric entry @@ -4956,6 +4965,7 @@ components: Name: type: string description: Name of the namespace + additionalProperties: false NamespaceSummary: type: object description: |- @@ -5412,6 +5422,7 @@ components: format: double description: Http version to use nullable: true + additionalProperties: false ProxyRule: oneOf: - $ref: '#/components/schemas/ProxyRuleHttp' @@ -5446,6 +5457,7 @@ components: type: string description: Path to extra config file to include nullable: true + additionalProperties: false ProxyRuleStream: type: object description: Proxy rules modes @@ -5471,6 +5483,7 @@ components: nullable: true Target: $ref: '#/components/schemas/StreamTarget' + additionalProperties: false ProxySsl: oneOf: - $ref: '#/components/schemas/ProxySslConfig' @@ -5499,6 +5512,7 @@ components: type: string description: Path to the dhparam file nullable: true + additionalProperties: false ProxyStreamProtocol: type: string description: Proxy rules modes @@ -5662,6 +5676,7 @@ components: Number: type: integer minimum: 0 + additionalProperties: false Resource: type: object description: |- @@ -5693,6 +5708,7 @@ components: type: array items: $ref: '#/components/schemas/DnsEntry' + additionalProperties: false ResourceKind: type: object required: @@ -5716,6 +5732,7 @@ components: nullable: true Data: $ref: '#/components/schemas/ResourceKindSpec' + additionalProperties: false ResourceKindInspect: type: object required: @@ -5735,6 +5752,7 @@ components: items: $ref: '#/components/schemas/ResourceKindVersion' description: List of versions available + additionalProperties: false ResourceKindPartial: type: object description: |- @@ -5758,6 +5776,7 @@ components: $ref: '#/components/schemas/Any' Data: $ref: '#/components/schemas/ResourceKindSpec' + additionalProperties: false ResourceKindSpec: type: object description: |- @@ -5773,6 +5792,7 @@ components: type: string description: The service to call when creating, updating or deleting a resource of this kind and version nullable: true + additionalProperties: false ResourceKindVersion: type: object required: @@ -5803,6 +5823,7 @@ components: $ref: '#/components/schemas/Any' Data: $ref: '#/components/schemas/ResourceKindSpec' + additionalProperties: false ResourcePartial: type: object description: Payload used to create a new resource @@ -5827,6 +5848,7 @@ components: description: The metadata of the resource (user defined) additionalProperties: $ref: '#/components/schemas/Any' + additionalProperties: false ResourceProxyRule: type: object description: Define proxy rules to apply @@ -5838,6 +5860,7 @@ components: items: $ref: '#/components/schemas/ProxyRule' description: The rules to apply + additionalProperties: false ResourceSpec: type: object description: The spec of a resource once created in the system @@ -5872,6 +5895,7 @@ components: description: The metadata of the resource (user defined) additionalProperties: $ref: '#/components/schemas/Any' + additionalProperties: false ResourceUpdate: type: object description: Payload used to update a resource @@ -5888,6 +5912,7 @@ components: description: The metadata of the resource as a json object additionalProperties: $ref: '#/components/schemas/Any' + additionalProperties: false ResourcesBlkioWeightDevice: type: object properties: @@ -6021,6 +6046,7 @@ components: description: The secret data additionalProperties: $ref: '#/components/schemas/Any' + additionalProperties: false SecretUpdate: type: object description: This structure is used to update a secret. @@ -6037,6 +6063,7 @@ components: description: The data of the secret as a json object additionalProperties: $ref: '#/components/schemas/Any' + additionalProperties: false StartExecOptions: type: object description: Exec configuration used in the [Create Exec API](Docker::create_exec()) @@ -6108,6 +6135,7 @@ components: $ref: '#/components/schemas/JobPartial' description: List of jobs to create and run nullable: true + additionalProperties: false StatefileArg: type: object description: Statefile argument definition to pass to the Statefile @@ -6125,6 +6153,7 @@ components: type: string description: Default value of the build arg nullable: true + additionalProperties: false Stats: type: object description: Statistics for the container. @@ -6780,6 +6809,7 @@ components: properties: UnixPath: type: string + additionalProperties: false UpstreamTarget: type: object description: Config for targetting a cargo or a vm @@ -6803,6 +6833,7 @@ components: type: boolean description: Disable logging for this target nullable: true + additionalProperties: false UriTarget: type: object required: @@ -6811,6 +6842,7 @@ components: Uri: type: string description: Uri to target + additionalProperties: false UrlRedirect: type: string enum: @@ -6849,6 +6881,7 @@ components: description: 'Virtual size allowed for the disk in GB (default: 20)' nullable: true minimum: 0 + additionalProperties: false VmHostConfig: type: object description: A vm's resources (cpu, memory, network) @@ -6895,6 +6928,7 @@ components: type: boolean description: Use host tun device nullable: true + additionalProperties: false VmImage: type: object required: @@ -6944,6 +6978,7 @@ components: Shrink: type: boolean description: Whether to shrink the image or not + additionalProperties: false VmInspect: type: object description: |- @@ -7095,6 +7130,7 @@ components: allOf: - $ref: '#/components/schemas/VmHostConfig' nullable: true + additionalProperties: false VmSpecUpdate: type: object description: | @@ -7139,6 +7175,7 @@ components: allOf: - $ref: '#/components/schemas/VmHostConfig' nullable: true + additionalProperties: false VmSummary: type: object description: |- diff --git a/bin/nanocld/src/main.rs b/bin/nanocld/src/main.rs index ec361fe85..0188e9e38 100644 --- a/bin/nanocld/src/main.rs +++ b/bin/nanocld/src/main.rs @@ -7,7 +7,7 @@ mod cli; mod config; mod schema; mod models; -mod version; +mod vars; mod utils; mod subsystem; mod repositories; @@ -31,10 +31,10 @@ async fn main() -> std::io::Result<()> { logger::enable_logger("nanocld"); log::info!( "nanocld_{}_v{}-{}:{}", - version::ARCH, - version::VERSION, - version::CHANNEL, - version::COMMIT_ID + vars::ARCH, + vars::VERSION, + vars::CHANNEL, + vars::COMMIT_ID ); // Init config by comparing command line arguments and config file let config = match config::init(&args) { diff --git a/bin/nanocld/src/models/system.rs b/bin/nanocld/src/models/system.rs index 266606740..70f309fa9 100644 --- a/bin/nanocld/src/models/system.rs +++ b/bin/nanocld/src/models/system.rs @@ -12,7 +12,7 @@ use nanocl_stubs::{ system::{Event, EventPartial, NativeEventAction, EventActor, EventKind}, }; -use crate::{version, utils, repositories::generic::*}; +use crate::{vars, utils, repositories::generic::*}; use super::{Pool, EventDb, RawEventEmitter, RawEventClient}; @@ -165,7 +165,7 @@ impl SystemState { docker_api: docker.clone(), config: conf.to_owned(), event_manager: EventManager::new(), - version: version::VERSION.to_owned(), + version: vars::VERSION.to_owned(), }; Ok(system_state) } @@ -222,7 +222,7 @@ impl SystemState { { let actor = actor.clone().into(); let event = EventPartial { - reporting_controller: "nanocl.io/core".to_owned(), + reporting_controller: vars::CONTROLLER_NAME.to_owned(), reporting_node: self.config.hostname.clone(), kind: EventKind::Normal, action: action.to_string(), diff --git a/bin/nanocld/src/objects/cargo.rs b/bin/nanocld/src/objects/cargo.rs index aba5ead87..beefc805d 100644 --- a/bin/nanocld/src/objects/cargo.rs +++ b/bin/nanocld/src/objects/cargo.rs @@ -23,7 +23,7 @@ use crate::{ use super::generic::*; impl ObjProcess for CargoDb { - fn get_kind() -> ProcessKind { + fn get_process_kind() -> ProcessKind { ProcessKind::Cargo } } diff --git a/bin/nanocld/src/objects/generic/process.rs b/bin/nanocld/src/objects/generic/process.rs index 71d1ce6ae..ea457443d 100644 --- a/bin/nanocld/src/objects/generic/process.rs +++ b/bin/nanocld/src/objects/generic/process.rs @@ -21,14 +21,14 @@ use crate::{ /// Represent a object that is treated as a process /// That you can start, restart, stop, logs, etc. pub trait ObjProcess { - fn get_kind() -> ProcessKind; + fn get_process_kind() -> ProcessKind; async fn _emit( kind_key: &str, action: NativeEventAction, state: &SystemState, ) -> HttpResult<()> { - match Self::get_kind() { + match Self::get_process_kind() { ProcessKind::Vm => { let vm = VmDb::transform_read_by_pk(kind_key, &state.pool).await?; state.emit_normal_native_action(&vm, action); @@ -62,7 +62,7 @@ pub trait ObjProcess { item: Config, state: &SystemState, ) -> HttpResult { - let kind = Self::get_kind(); + let kind = Self::get_process_kind(); let mut config = item.clone(); let mut labels = item.labels.to_owned().unwrap_or_default(); labels.insert("io.nanocl".to_owned(), "enabled".to_owned()); diff --git a/bin/nanocld/src/objects/job.rs b/bin/nanocld/src/objects/job.rs index 1afde8489..2acd00f96 100644 --- a/bin/nanocld/src/objects/job.rs +++ b/bin/nanocld/src/objects/job.rs @@ -16,7 +16,7 @@ use crate::{ use super::generic::*; impl ObjProcess for JobDb { - fn get_kind() -> ProcessKind { + fn get_process_kind() -> ProcessKind { ProcessKind::Job } } diff --git a/bin/nanocld/src/objects/vm.rs b/bin/nanocld/src/objects/vm.rs index c0b9051af..c4b50b4dd 100644 --- a/bin/nanocld/src/objects/vm.rs +++ b/bin/nanocld/src/objects/vm.rs @@ -18,7 +18,7 @@ use crate::{ use super::generic::*; impl ObjProcess for VmDb { - fn get_kind() -> ProcessKind { + fn get_process_kind() -> ProcessKind { ProcessKind::Vm } } diff --git a/bin/nanocld/src/services/cargo_image.rs b/bin/nanocld/src/services/cargo_image.rs index b422862b2..a1a4399ed 100644 --- a/bin/nanocld/src/services/cargo_image.rs +++ b/bin/nanocld/src/services/cargo_image.rs @@ -71,8 +71,8 @@ pub async fn create_cargo_image( state: web::types::State, payload: web::types::Json, ) -> HttpResult { - let (from_image, tag) = utils::cargo_image::parse_image_name(&payload.name)?; - let rx_body = utils::cargo_image::pull(&from_image, &tag, &state).await?; + let (from_image, tag) = utils::container_image::parse_name(&payload.name)?; + let rx_body = utils::container_image::pull(&from_image, &tag, &state).await?; Ok( web::HttpResponse::Ok() .keep_alive() diff --git a/bin/nanocld/src/services/mod.rs b/bin/nanocld/src/services/mod.rs index d2a3e16d9..e19d5f5f6 100644 --- a/bin/nanocld/src/services/mod.rs +++ b/bin/nanocld/src/services/mod.rs @@ -48,10 +48,8 @@ pub fn ntex_config(config: &mut web::ServiceConfig) { config.service( web::scope("/{version}") .wrap( - nanocl_utils::ntex::middlewares::Versioning::new( - crate::version::VERSION, - ) - .finish(), + nanocl_utils::ntex::middlewares::Versioning::new(crate::vars::VERSION) + .finish(), ) .configure(exec::ntex_config) .configure(node::ntex_config) @@ -79,45 +77,40 @@ mod tests { use super::ntex_config; - use crate::version; + use crate::vars; use crate::utils::tests::*; #[ntex::test] pub async fn get_version() { - let client = gen_test_client(ntex_config, version::VERSION).await; + let client = gen_test_client(ntex_config, vars::VERSION).await; let mut res = client.send_get("/version", None::).await; test_status_code!(res.status(), http::StatusCode::OK, "version"); let data = res.json::().await.unwrap(); - assert_eq!( - data.arch, - version::ARCH, - "Expect arch to be {}", - version::ARCH - ); + assert_eq!(data.arch, vars::ARCH, "Expect arch to be {}", vars::ARCH); assert_eq!( data.version, - version::VERSION, + vars::VERSION, "Expect version to be {}", - version::VERSION + vars::VERSION ); assert_eq!( data.commit_id, - version::COMMIT_ID, + vars::COMMIT_ID, "Expect commit_id to be {}", - version::COMMIT_ID + vars::COMMIT_ID ); } #[ntex::test] async fn ping() { - let client = gen_test_client(ntex_config, version::VERSION).await; + let client = gen_test_client(ntex_config, vars::VERSION).await; let res = client.send_head("/_ping", None::).await; test_status_code!(res.status(), http::StatusCode::ACCEPTED, "ping"); } #[ntex::test] async fn unhandled_route() { - let client = gen_test_client(ntex_config, version::VERSION).await; + let client = gen_test_client(ntex_config, vars::VERSION).await; let res = client.send_get("/v0.1/unhandled", None::).await; test_status_code!(res.status(), http::StatusCode::NOT_FOUND, "unhandled"); } @@ -129,12 +122,12 @@ mod tests { assert_eq!(res.status(), http::StatusCode::NOT_FOUND); let version = res.headers().get("x-api-version"); assert!(version.is_some()); - assert_eq!(version.unwrap(), version::VERSION); + assert_eq!(version.unwrap(), vars::VERSION); let client = gen_test_client(ntex_config, "xdlol").await; let res = client.send_get("/version", None::).await; assert_eq!(res.status(), http::StatusCode::NOT_FOUND); let version = res.headers().get("x-api-version"); assert!(version.is_some()); - assert_eq!(version.unwrap(), version::VERSION); + assert_eq!(version.unwrap(), vars::VERSION); } } diff --git a/bin/nanocld/src/services/system.rs b/bin/nanocld/src/services/system.rs index 853f985d0..f1a749a9f 100644 --- a/bin/nanocld/src/services/system.rs +++ b/bin/nanocld/src/services/system.rs @@ -4,7 +4,7 @@ use nanocl_error::http::HttpResult; use nanocl_stubs::system::HostInfo; -use crate::version; +use crate::vars; use crate::models::SystemState; /// Get version information @@ -33,10 +33,10 @@ pub async fn get_ping() -> HttpResult { #[web::get("/version")] pub async fn get_version() -> web::HttpResponse { web::HttpResponse::Ok().json(&serde_json::json!({ - "Arch": version::ARCH, - "Channel": version::CHANNEL, - "Version": version::VERSION, - "CommitId": version::COMMIT_ID, + "Arch": vars::ARCH, + "Channel": vars::CHANNEL, + "Version": vars::VERSION, + "CommitId": vars::COMMIT_ID, })) } diff --git a/bin/nanocld/src/subsystem/docker_event.rs b/bin/nanocld/src/subsystem/docker_event.rs index c70c2144c..2747087ed 100644 --- a/bin/nanocld/src/subsystem/docker_event.rs +++ b/bin/nanocld/src/subsystem/docker_event.rs @@ -15,6 +15,7 @@ use nanocl_stubs::system::{ use crate::{ repositories::generic::*, models::{SystemState, ProcessUpdateDb, ProcessDb}, + vars, }; /// Take actions when a docker event is received @@ -36,7 +37,7 @@ async fn exec_docker( log::debug!("event::exec_docker: {action}"); let action = action.as_str(); let mut event = EventPartial { - reporting_controller: "nanocl.io/core".to_owned(), + reporting_controller: vars::CONTROLLER_NAME.to_owned(), reporting_node: state.config.hostname.clone(), kind: EventKind::Normal, action: NativeEventAction::Delete.to_string(), diff --git a/bin/nanocld/src/utils/cargo.rs b/bin/nanocld/src/utils/cargo.rs index 21c3d4734..60e064259 100644 --- a/bin/nanocld/src/utils/cargo.rs +++ b/bin/nanocld/src/utils/cargo.rs @@ -1,7 +1,7 @@ use futures::StreamExt; use futures_util::stream::FuturesUnordered; -use nanocl_error::http::{HttpError, HttpResult}; +use nanocl_error::http::{HttpResult, HttpError}; use bollard_next::{ service::{HostConfig, RestartPolicy, RestartPolicyNameEnum}, @@ -9,10 +9,14 @@ use bollard_next::{ StartContainerOptions, WaitContainerOptions, RemoveContainerOptions, }, }; -use nanocl_stubs::{cargo::Cargo, process::Process}; +use nanocl_stubs::{ + cargo::Cargo, + process::Process, + system::{EventPartial, EventActorKind, EventActor, EventKind}, +}; use crate::{ - utils, + vars, utils, repositories::generic::*, models::{SystemState, CargoDb, SecretDb}, objects::generic::ObjProcess, @@ -96,6 +100,7 @@ pub async fn create_instances( number: usize, state: &SystemState, ) -> HttpResult> { + download_image(cargo, state).await?; execute_before(cargo, state).await?; let mut secret_envs: Vec = Vec::new(); if let Some(secrets) = &cargo.spec.secrets { @@ -233,3 +238,68 @@ pub async fn delete_instances( .into_iter() .collect::>() } + +pub async fn download_image( + cargo: &Cargo, + state: &SystemState, +) -> HttpResult<()> { + let image_name = &cargo.spec.container.image.clone().unwrap_or_default(); + if state.docker_api.inspect_image(image_name).await.is_ok() { + return Ok(()); + } + let (name, tag) = utils::container_image::parse_name(image_name)?; + let mut stream = state.docker_api.create_image( + Some(bollard_next::image::CreateImageOptions { + from_image: name.clone(), + tag: tag.clone(), + ..Default::default() + }), + None, + None, + ); + while let Some(chunk) = stream.next().await { + let chunk = match chunk { + Err(err) => { + let event = EventPartial { + reporting_controller: vars::CONTROLLER_NAME.to_owned(), + reporting_node: state.config.hostname.clone(), + action: "download_image".to_owned(), + reason: "state_sync".to_owned(), + kind: EventKind::Error, + actor: Some(EventActor { + key: cargo.spec.container.image.clone(), + kind: EventActorKind::ContainerImage, + attributes: None, + }), + related: Some(cargo.clone().into()), + note: Some(format!( + "Error while downloading image {image_name} {err}" + )), + metadata: None, + }; + state.spawn_emit_event(event); + return Err(err.into()); + } + Ok(chunk) => chunk, + }; + let event = EventPartial { + reporting_controller: vars::CONTROLLER_NAME.to_owned(), + reporting_node: state.config.hostname.clone(), + action: "download_image".to_owned(), + reason: "state_sync".to_owned(), + kind: EventKind::Normal, + actor: Some(EventActor { + key: cargo.spec.container.image.clone(), + kind: EventActorKind::ContainerImage, + attributes: None, + }), + related: Some(cargo.clone().into()), + note: Some(format!("Downloading image {name}:{tag}")), + metadata: Some(serde_json::json!({ + "state": chunk, + })), + }; + state.spawn_emit_event(event); + } + Ok(()) +} diff --git a/bin/nanocld/src/utils/cargo_image.rs b/bin/nanocld/src/utils/container_image.rs similarity index 94% rename from bin/nanocld/src/utils/cargo_image.rs rename to bin/nanocld/src/utils/container_image.rs index 488084106..2f5d34029 100644 --- a/bin/nanocld/src/utils/cargo_image.rs +++ b/bin/nanocld/src/utils/container_image.rs @@ -10,7 +10,7 @@ use crate::models::SystemState; use super::stream; /// Get the image name and tag from a string -pub fn parse_image_name(name: &str) -> HttpResult<(String, String)> { +pub fn parse_name(name: &str) -> HttpResult<(String, String)> { let image_info: Vec<&str> = name.split(':').collect(); if image_info.len() != 2 { return Err(HttpError::bad_request("Missing tag in image name")); diff --git a/bin/nanocld/src/utils/job.rs b/bin/nanocld/src/utils/job.rs index acea56e85..01363c5c8 100644 --- a/bin/nanocld/src/utils/job.rs +++ b/bin/nanocld/src/utils/job.rs @@ -12,7 +12,7 @@ use nanocl_stubs::{ }; use crate::{ - version, utils, + vars, utils, repositories::generic::*, models::{SystemState, ProcessDb, JobDb}, }; @@ -28,7 +28,7 @@ fn format_cron_job_command(job: &Job, state: &SystemState) -> String { .replace("unix://", ""); format!( "curl -X POST --unix {host} http://localhost/v{}/processes/job/{}/start", - version::VERSION, + vars::VERSION, &job.name ) } diff --git a/bin/nanocld/src/utils/mod.rs b/bin/nanocld/src/utils/mod.rs index d5ab290ae..436237c7b 100644 --- a/bin/nanocld/src/utils/mod.rs +++ b/bin/nanocld/src/utils/mod.rs @@ -7,7 +7,7 @@ pub mod store; pub mod system; pub mod namespace; pub mod cargo; -pub mod cargo_image; +pub mod container_image; pub mod vm; pub mod vm_image; pub mod job; @@ -22,7 +22,7 @@ pub mod tests { use std::env; use ntex::web::{*, self}; - use crate::{services, version::VERSION, models::SystemState}; + use crate::{services, vars::VERSION, models::SystemState}; use nanocl_stubs::config::DaemonConfig; pub use nanocl_utils::ntex::test_client::*; diff --git a/bin/nanocld/src/utils/server.rs b/bin/nanocld/src/utils/server.rs index 7cb063dab..f1124019b 100644 --- a/bin/nanocld/src/utils/server.rs +++ b/bin/nanocld/src/utils/server.rs @@ -3,7 +3,7 @@ use ntex_cors::Cors; use nanocl_utils::ntex::middlewares; -use crate::{version, services, models::SystemState}; +use crate::{vars, services, models::SystemState}; /// This function will generate the HTTP server with the given configuration. /// It will also bind the server to the given address. @@ -23,7 +23,7 @@ pub async fn gen( web::types::PayloadConfig::new(20_000_000_000), // <- limit size of the payload ) .wrap(Cors::new().finish()) - .wrap(middlewares::Versioning::new(version::VERSION).finish()) + .wrap(middlewares::Versioning::new(vars::VERSION).finish()) .wrap(middlewares::SerializeError) // Default logger middleware .wrap(web::middleware::Logger::default()) diff --git a/bin/nanocld/src/utils/system.rs b/bin/nanocld/src/utils/system.rs index 669e92d3f..db1ba1fb0 100644 --- a/bin/nanocld/src/utils/system.rs +++ b/bin/nanocld/src/utils/system.rs @@ -14,7 +14,7 @@ use nanocl_stubs::{ }; use crate::{ - utils, version, + vars, utils, repositories::generic::*, models::{ SystemState, CargoDb, ProcessDb, NamespaceDb, VmImageDb, ProcessUpdateDb, @@ -171,7 +171,7 @@ pub async fn sync_processes(state: &SystemState) -> IoResult<()> { CargoDb::create_from_spec( namespace, &new_cargo, - &format!("v{}", version::VERSION), + &format!("v{}", vars::VERSION), &state.pool, ) .await?; @@ -187,7 +187,7 @@ pub async fn sync_processes(state: &SystemState) -> IoResult<()> { CargoDb::update_from_spec( key, &new_cargo, - &format!("v{}", version::VERSION), + &format!("v{}", vars::VERSION), &state.pool, ) .await?; diff --git a/bin/nanocld/src/version.rs b/bin/nanocld/src/vars.rs similarity index 87% rename from bin/nanocld/src/version.rs rename to bin/nanocld/src/vars.rs index 457fafa98..7c5735eb5 100644 --- a/bin/nanocld/src/version.rs +++ b/bin/nanocld/src/vars.rs @@ -3,16 +3,15 @@ /// * x86_64 /// * aarch64 pub const ARCH: &str = env!("TARGET_ARCH"); - /// This version is the version of the binary. /// * x.x.x pub const VERSION: &str = env!("CARGO_PKG_VERSION"); - /// This commit id is the commit id of the binary. pub const COMMIT_ID: &str = env!("GIT_HASH"); - /// This channel is the channel of the binary. /// eg: /// * stable /// * nightly pub const CHANNEL: &str = env!("CHANNEL"); +/// Controller +pub const CONTROLLER_NAME: &str = "nanocl.io/core"; diff --git a/bin/ncdns/Cargo.toml b/bin/ncdns/Cargo.toml index e89223993..644eed83d 100644 --- a/bin/ncdns/Cargo.toml +++ b/bin/ncdns/Cargo.toml @@ -32,7 +32,7 @@ serde_yaml = "0.9" [dependencies] log = "0.4" clap = { version = "4.4", features = ["derive"] } -ntex = { version = "0.7", features = ["tokio", "openssl"] } +ntex = { version = "1.0", features = ["tokio", "openssl"] } tokio = { version = "1.34", features = ["fs"] } futures = "0.3" serde = { version = "1.0", features = ["derive"] } @@ -40,5 +40,5 @@ serde_json = "1.0" nanocld_client = { version = "0.13", features = ["tokio"] } nanocl_error = { version = "0.2", features = ["io", "http", "http_client"] } nanocl_utils = { version = "0.4", features = ["ntex", "logger", "versioning"] } -utoipa = { version = "4.1", features = ["yaml"], optional = true } +utoipa = { version = "4.2", features = ["yaml"], optional = true } openssl = "0.10" diff --git a/bin/ncdns/specs/swagger.yaml b/bin/ncdns/specs/swagger.yaml index da92b63b7..df97f6b5b 100644 --- a/bin/ncdns/specs/swagger.yaml +++ b/bin/ncdns/specs/swagger.yaml @@ -84,6 +84,7 @@ components: type: string IpAddress: type: string + additionalProperties: false ResourceDnsRule: type: object required: @@ -96,6 +97,7 @@ components: type: array items: $ref: '#/components/schemas/DnsEntry' + additionalProperties: false tags: - name: Rules description: Rules management endpoints. diff --git a/bin/ncproxy/Cargo.toml b/bin/ncproxy/Cargo.toml index 261cf44e9..13931e8b9 100644 --- a/bin/ncproxy/Cargo.toml +++ b/bin/ncproxy/Cargo.toml @@ -40,7 +40,7 @@ bollard-next = "0.15" log = "0.4" liquid = "0.26" clap = { version = "4.4", features = ["derive"] } -ntex = { version = "0.7", features = ["tokio"] } +ntex = { version = "1.0", features = ["tokio"] } tokio = { version = "1.34", features = ["fs"] } serde = "1.0" serde_json = "1.0" @@ -57,7 +57,7 @@ nanocl_error = { version = "0.2", features = [ "serde_json", ] } nanocl_utils = { version = "0.4", features = ["ntex", "logger", "versioning"] } -utoipa = { version = "4.1", features = ["yaml"], optional = true } +utoipa = { version = "4.2", features = ["yaml"], optional = true } chrono = { version = "0.4", default-features = false, features = [ "std", "clock", diff --git a/bin/ncproxy/specs/swagger.yaml b/bin/ncproxy/specs/swagger.yaml index 4d2b8112b..b4f169fe6 100644 --- a/bin/ncproxy/specs/swagger.yaml +++ b/bin/ncproxy/specs/swagger.yaml @@ -94,6 +94,7 @@ components: allOf: - $ref: '#/components/schemas/UrlRedirect' nullable: true + additionalProperties: false LocationTarget: oneOf: - $ref: '#/components/schemas/UpstreamTarget' @@ -122,6 +123,7 @@ components: format: double description: Http version to use nullable: true + additionalProperties: false ProxyRule: oneOf: - $ref: '#/components/schemas/ProxyRuleHttp' @@ -156,6 +158,7 @@ components: type: string description: Path to extra config file to include nullable: true + additionalProperties: false ProxyRuleStream: type: object description: Proxy rules modes @@ -181,6 +184,7 @@ components: nullable: true Target: $ref: '#/components/schemas/StreamTarget' + additionalProperties: false ProxySsl: oneOf: - $ref: '#/components/schemas/ProxySslConfig' @@ -209,6 +213,7 @@ components: type: string description: Path to the dhparam file nullable: true + additionalProperties: false ProxyStreamProtocol: type: string description: Proxy rules modes @@ -226,6 +231,7 @@ components: items: $ref: '#/components/schemas/ProxyRule' description: The rules to apply + additionalProperties: false StreamTarget: oneOf: - $ref: '#/components/schemas/UpstreamTarget' @@ -238,6 +244,7 @@ components: properties: UnixPath: type: string + additionalProperties: false UpstreamTarget: type: object description: Config for targetting a cargo or a vm @@ -261,6 +268,7 @@ components: type: boolean description: Disable logging for this target nullable: true + additionalProperties: false UriTarget: type: object required: @@ -269,6 +277,7 @@ components: Uri: type: string description: Uri to target + additionalProperties: false UrlRedirect: type: string enum: diff --git a/bin/ncvpnkit/Cargo.toml b/bin/ncvpnkit/Cargo.toml index b7deed2f9..def7cd3f0 100644 --- a/bin/ncvpnkit/Cargo.toml +++ b/bin/ncvpnkit/Cargo.toml @@ -16,7 +16,7 @@ nanocl_utils = { version = "0.4", features = ["build_tools"] } [dependencies] log = "0.4" futures-util = "0.3" -ntex = { version = "0.7", features = ["tokio"] } +ntex = { version = "1.0", features = ["tokio"] } vpnkitrc = { version = "0.1", features = ["tokio"] } nanocld_client = { version = "0.13" } nanocl_utils = { version = "0.4", features = ["logger"] } diff --git a/crates/nanocl_error/Cargo.toml b/crates/nanocl_error/Cargo.toml index 2951f6523..7f18219cf 100644 --- a/crates/nanocl_error/Cargo.toml +++ b/crates/nanocl_error/Cargo.toml @@ -25,7 +25,7 @@ serde_urlencoded = ["dep:serde_urlencoded"] tokio = ["dep:tokio"] [dependencies] -ntex = { version = "0.7", optional = true } +ntex = { version = "1.0", optional = true } serde_json = { version = "1.0", optional = true } serde_urlencoded = { version = "0.7", optional = true } diesel = { version = "2.1", default-features = false, optional = true } diff --git a/crates/nanocl_stubs/src/system.rs b/crates/nanocl_stubs/src/system.rs index bbd27541e..56cf3104e 100644 --- a/crates/nanocl_stubs/src/system.rs +++ b/crates/nanocl_stubs/src/system.rs @@ -52,6 +52,7 @@ pub enum EventActorKind { Resource, Secret, Process, + ContainerImage, } impl std::fmt::Display for EventActorKind { @@ -64,6 +65,7 @@ impl std::fmt::Display for EventActorKind { EventActorKind::Resource => write!(f, "Resource"), EventActorKind::Secret => write!(f, "Secret"), EventActorKind::Process => write!(f, "Process"), + EventActorKind::ContainerImage => write!(f, "ContainerImage"), } } } diff --git a/crates/nanocl_utils/Cargo.toml b/crates/nanocl_utils/Cargo.toml index e05326169..ac09bcd4d 100644 --- a/crates/nanocl_utils/Cargo.toml +++ b/crates/nanocl_utils/Cargo.toml @@ -29,14 +29,14 @@ build_tools = ["dep:clap", "dep:clap_mangen"] ntex_test_client = ["dep:ntex", "dep:serde"] [dependencies] -ntex = { version = "0.7", optional = true } +ntex = { version = "1.0", optional = true } log = { version = "0.4", optional = true } env_logger = { version = "0.10", optional = true } serde = { version = "1.0", features = ["derive"], optional = true } serde_json = { version = "1.0", optional = true } futures = { version = "0.3", optional = true } -utoipa = { version = "4.1", features = ["yaml"], optional = true } -utoipa-swagger-ui = { version = "5.0", optional = true } +utoipa = { version = "4.2", features = ["yaml"], optional = true } +utoipa-swagger-ui = { version = "6.0", optional = true } libc = { version = "0.2", optional = true } clap = { version = "4.4", features = ["derive", "cargo"], optional = true } clap_mangen = { version = "0.2", optional = true } diff --git a/crates/nanocl_utils/src/ntex/middlewares/serialize_error.rs b/crates/nanocl_utils/src/ntex/middlewares/serialize_error.rs index 19878abe1..ace2af842 100644 --- a/crates/nanocl_utils/src/ntex/middlewares/serialize_error.rs +++ b/crates/nanocl_utils/src/ntex/middlewares/serialize_error.rs @@ -1,6 +1,6 @@ use ntex::{web, http}; use ntex::util::BytesMut; -use ntex::{Service, Middleware, util::BoxFuture, ServiceCtx}; +use ntex::{Service, Middleware, ServiceCtx}; use ntex::web::{WebRequest, WebResponse, Error, ErrorRenderer}; use futures::StreamExt; @@ -26,36 +26,33 @@ where { type Response = WebResponse; type Error = Error; - type Future<'f> = BoxFuture<'f, Result> where Self: 'f; ntex::forward_poll_ready!(service); - fn call<'a>( - &'a self, + async fn call<'a>( + &self, req: WebRequest, ctx: ServiceCtx<'a, Self>, - ) -> Self::Future<'_> { - Box::pin(async move { - let mut res = ctx.call(&self.service, req).await?; - if res.status() == http::StatusCode::BAD_REQUEST { - let content_type = res.headers().get(http::header::CONTENT_TYPE); - if let Some(content_type) = content_type { - if content_type == "text/plain; charset=utf-8" { - let mut payload = BytesMut::new(); - let mut body = res.take_body(); - while let Some(chunk) = body.next().await { - let chunk = chunk.unwrap_or_default(); - payload.extend_from_slice(&chunk); - } - res = res.into_response(web::HttpResponse::BadRequest().json( + ) -> Result { + let mut res = ctx.call(&self.service, req).await?; + if res.status() == http::StatusCode::BAD_REQUEST { + let content_type = res.headers().get(http::header::CONTENT_TYPE); + if let Some(content_type) = content_type { + if content_type == "text/plain; charset=utf-8" { + let mut payload = BytesMut::new(); + let mut body = res.take_body(); + while let Some(chunk) = body.next().await { + let chunk = chunk.unwrap_or_default(); + payload.extend_from_slice(&chunk); + } + res = res.into_response(web::HttpResponse::BadRequest().json( &serde_json::json!({ "msg": &String::from_utf8_lossy(&payload).replace("Json deserialize error:", "payload"), }), )); - } } } - Ok(res) - }) + } + Ok(res) } } diff --git a/crates/nanocl_utils/src/ntex/middlewares/versioning.rs b/crates/nanocl_utils/src/ntex/middlewares/versioning.rs index 23b8c49e8..da11ebee9 100644 --- a/crates/nanocl_utils/src/ntex/middlewares/versioning.rs +++ b/crates/nanocl_utils/src/ntex/middlewares/versioning.rs @@ -4,7 +4,6 @@ use std::rc::Rc; use ntex::http::header::{HeaderName, HeaderValue}; use ntex::{Service, ServiceCtx, Middleware}; use ntex::web::{WebRequest, WebResponse, Error, ErrorRenderer, HttpResponse}; -use futures::future::{ok, Either, Ready, LocalBoxFuture}; struct Inner { version: String, @@ -69,15 +68,14 @@ where { type Response = WebResponse; type Error = Error; - type Future<'f> = Either>, Ready>> where Self: 'f; ntex::forward_poll_ready!(service); - fn call<'a>( - &'a self, + async fn call<'a>( + &self, mut req: WebRequest, ctx: ServiceCtx<'a, Self>, - ) -> Self::Future<'_> { + ) -> Result { let version = req.match_info_mut().get("version"); let header_name = HeaderName::from_static("x-api-version"); let header_value = HeaderValue::from_str(&self.inner.version) @@ -105,7 +103,7 @@ where .into_body(), ); res.headers_mut().insert(header_name, header_value); - return Either::Right(ok(res)); + return Ok(res); } let minor_number = minor.unwrap().parse::(); let major_number = major.unwrap().parse::(); @@ -125,7 +123,7 @@ where .into_body(), ); res.headers_mut().insert(header_name, header_value); - return Either::Right(ok(res)); + return Ok(res); } let minor_number = minor_number.unwrap(); let major_number = major_number.unwrap(); @@ -144,13 +142,11 @@ where .into_body(), ); res.headers_mut().insert(header_name, header_value); - return Either::Right(ok(res)); + return Ok(res); } } - Either::Left(Box::pin(async move { - let mut res = ctx.call(&self.service, req).await?; - res.headers_mut().insert(header_name, header_value); - Ok(res) - })) + let mut res = ctx.call(&self.service, req).await?; + res.headers_mut().insert(header_name, header_value); + Ok(res) } } diff --git a/crates/nanocld_client/Cargo.toml b/crates/nanocld_client/Cargo.toml index 94c6fac36..048c0cf9f 100644 --- a/crates/nanocld_client/Cargo.toml +++ b/crates/nanocld_client/Cargo.toml @@ -26,7 +26,7 @@ tokio = { version = "1.34", features = ["fs"] } [dependencies] futures = "0.3" serde_json = "1.0" -ntex = { version = "0.7" } +ntex = { version = "1.0" } serde = { version = "1.0", features = ["derive"] } bollard-next = { version = "0.15.4" } nanocl_stubs = { version = "0.13", features = ["serde"] } diff --git a/crates/nanocld_client/src/process.rs b/crates/nanocld_client/src/process.rs index a103b153c..dcca10992 100644 --- a/crates/nanocld_client/src/process.rs +++ b/crates/nanocld_client/src/process.rs @@ -142,7 +142,7 @@ impl NanocldClient { /// let client = NanocldClient::connect_to("http://localhost:8585", None); /// let res = client.kill_process("cargo", "my-cargo", None, None).await; /// ``` - pub async fn kill_cargo( + pub async fn kill_process( &self, kind: &str, name: &str,