From b97c9242638f5e36f2cebdd2a46cddcb5c551ab7 Mon Sep 17 00:00:00 2001 From: Joonas Bergius Date: Fri, 7 Jun 2024 18:40:49 -0500 Subject: [PATCH] feat: Use wadm-client and wadm-types crates for wadm interactions Signed-off-by: Joonas Bergius --- Cargo.lock | 1067 +++------------------------------- Cargo.toml | 8 +- src/controller.rs | 34 +- src/resources/application.rs | 403 ++++--------- src/services.rs | 39 +- 5 files changed, 230 insertions(+), 1321 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c248c9b..f95b9a1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,16 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "Inflector" -version = "0.11.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" -dependencies = [ - "lazy_static", - "regex", -] - [[package]] name = "addr2line" version = "0.21.0" @@ -81,15 +71,6 @@ dependencies = [ "libc", ] -[[package]] -name = "ansi_term" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" -dependencies = [ - "winapi", -] - [[package]] name = "anstream" version = "0.6.4" @@ -138,12 +119,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "any_ascii" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70033777eb8b5124a81a1889416543dddef2de240019b674c81285a2635a7e1e" - [[package]] name = "anyhow" version = "1.0.75" @@ -156,25 +131,6 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bddcadddf5e9015d310179a59bb28c4d4b9920ad0f11e8e14dbadf654890c9a6" -[[package]] -name = "ascii_tree" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca6c635b3aa665c649ad1415f1573c85957dfa47690ec27aebe7ec17efe3c643" - -[[package]] -name = "async-compression" -version = "0.3.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942c7cd7ae39e91bde4820d74132e9862e62c2f386c3aa90ccf55949f5bad63a" -dependencies = [ - "flate2", - "futures-core", - "memchr", - "pin-project-lite", - "tokio", -] - [[package]] name = "async-nats" version = "0.33.0" @@ -193,8 +149,8 @@ dependencies = [ "regex", "ring 0.17.5", "rustls 0.21.7", - "rustls-native-certs 0.6.3", - "rustls-pemfile 1.0.3", + "rustls-native-certs", + "rustls-pemfile", "rustls-webpki 0.101.6", "serde", "serde_json", @@ -220,66 +176,6 @@ dependencies = [ "syn 2.0.38", ] -[[package]] -name = "atelier_assembler" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7feecf8364a7d1c80f2323ea0d1abee09d7256a91dc5d29a1d171a52c17be36a" -dependencies = [ - "atelier_core", - "atelier_json", - "atelier_smithy", - "atelier_test", - "log", -] - -[[package]] -name = "atelier_core" -version = "0.2.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29c05c6353a26a3e1b7017058a0a99c8f61131cf9a0ecb604dd9b62069b1be75" -dependencies = [ - "error-chain", - "heck 0.3.3", - "lazy_static", - "log", - "paste", - "regex", -] - -[[package]] -name = "atelier_json" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b86bad50f33038fa4dec1f5c4e83bc0a1174c17767defeff76b2eca0028ec4bf" -dependencies = [ - "atelier_core", - "serde_json", -] - -[[package]] -name = "atelier_smithy" -version = "0.2.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56140a8133b56c021ee62e64d35015d1f51b71e0b5cdf401edf78a2a77f2f7e3" -dependencies = [ - "atelier_core", - "log", - "pest", - "pest_ascii_tree", - "pest_derive", -] - -[[package]] -name = "atelier_test" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d81fd306eb92079fce9b7089abaf178c306877b72ec6e679ad331253ea9bfb00" -dependencies = [ - "atelier_core", - "pretty_assertions", -] - [[package]] name = "autocfg" version = "1.1.0" @@ -350,7 +246,7 @@ dependencies = [ "hyper", "pin-project-lite", "rustls 0.20.9", - "rustls-pemfile 1.0.3", + "rustls-pemfile", "tokio", "tokio-rustls 0.23.4", "tower-service", @@ -400,12 +296,6 @@ version = "0.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" -[[package]] -name = "base64" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51" - [[package]] name = "base64ct" version = "1.6.0" @@ -481,48 +371,6 @@ dependencies = [ "serde", ] -[[package]] -name = "camino" -version = "1.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c" -dependencies = [ - "serde", -] - -[[package]] -name = "cargo-platform" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e34637b3140142bdf929fb439e8aa4ebad7651ebf7b1080b3930aa16ac1459ff" -dependencies = [ - "serde", -] - -[[package]] -name = "cargo_metadata" -version = "0.18.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" -dependencies = [ - "camino", - "cargo-platform", - "semver", - "serde", - "serde_json", - "thiserror", -] - -[[package]] -name = "cargo_toml" -version = "0.15.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "599aa35200ffff8f04c1925aa1acc92fa2e08874379ef42e210a80e527e60838" -dependencies = [ - "serde", - "toml 0.7.8", -] - [[package]] name = "cc" version = "1.0.83" @@ -581,7 +429,7 @@ version = "4.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0862016ff20d69b84ef8247369fabf5c008a7417002411897d40ee1f4532b873" dependencies = [ - "heck 0.4.1", + "heck", "proc-macro2", "quote", "syn 2.0.38", @@ -618,32 +466,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" -[[package]] -name = "command-group" -version = "5.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a68fa787550392a9d58f44c21a3022cfb3ea3e2458b7f85d3b399d0ceeccf409" -dependencies = [ - "async-trait", - "nix", - "tokio", - "winapi", -] - -[[package]] -name = "config" -version = "0.13.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23738e11972c7643e4ec947840fc463b6a571afcd3e735bdfce7d03c7a784aca" -dependencies = [ - "async-trait", - "lazy_static", - "nom", - "pathdiff", - "serde", - "toml 0.5.11", -] - [[package]] name = "config" version = "0.14.0" @@ -698,15 +520,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crc32fast" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" -dependencies = [ - "cfg-if", -] - [[package]] name = "crossbeam-channel" version = "0.5.8" @@ -736,16 +549,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "ctor" -version = "0.1.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096" -dependencies = [ - "quote", - "syn 1.0.109", -] - [[package]] name = "ctrlc" version = "3.4.1" @@ -867,12 +670,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "diff" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" - [[package]] name = "digest" version = "0.10.7" @@ -884,54 +681,12 @@ dependencies = [ "subtle", ] -[[package]] -name = "directories" -version = "4.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f51c5d4ddabd36886dd3e1438cb358cdcb0d7c499cb99cb4ac2e38e18b5cb210" -dependencies = [ - "dirs-sys", -] - -[[package]] -name = "dirs" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" -dependencies = [ - "dirs-sys", -] - -[[package]] -name = "dirs-sys" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" -dependencies = [ - "libc", - "redox_users", - "winapi", -] - [[package]] name = "doc-comment" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" -[[package]] -name = "downloader" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d05213e96f184578b5f70105d4d0a644a168e99e12d7bea0b200c15d67b5c182" -dependencies = [ - "futures", - "rand", - "reqwest", - "thiserror", - "tokio", -] - [[package]] name = "dyn-clone" version = "1.0.14" @@ -980,32 +735,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" -[[package]] -name = "errno" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" -dependencies = [ - "libc", - "windows-sys 0.52.0", -] - -[[package]] -name = "error-chain" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d2f06b9cac1506ece98fe3231e3cc9c4410ec3d5b1f24ae1c8946f0742cdefc" -dependencies = [ - "backtrace", - "version_check", -] - -[[package]] -name = "escape_string" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59e867569975c88fdf73833a30bd6e0978aa6ab6bd784b648fcece07450951ba" - [[package]] name = "fancy-regex" version = "0.11.0" @@ -1016,40 +745,12 @@ dependencies = [ "regex", ] -[[package]] -name = "fastrand" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" - [[package]] name = "fiat-crypto" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0870c84016d4b481be5c9f323c24f65e31e901ae618f0e80f4308fb00de1d2d" -[[package]] -name = "filetime" -version = "0.2.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ee447700ac8aa0b2f2bd7bc4462ad686ba06baa6727ac149a2d6277f0d240fd" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall 0.4.1", - "windows-sys 0.52.0", -] - -[[package]] -name = "flate2" -version = "1.0.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" -dependencies = [ - "crc32fast", - "miniz_oxide", -] - [[package]] name = "fnv" version = "1.0.7" @@ -1212,26 +913,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "half" -version = "1.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" - -[[package]] -name = "handlebars" -version = "4.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "faa67bab9ff362228eb3d00bd024a4965d8231bbb7921167f0cfa66c6626b225" -dependencies = [ - "log", - "pest", - "pest_derive", - "serde", - "serde_json", - "thiserror", -] - [[package]] name = "handlebars" version = "5.1.0" @@ -1289,23 +970,11 @@ dependencies = [ "http", ] -[[package]] -name = "heck" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" -dependencies = [ - "unicode-segmentation", -] - [[package]] name = "heck" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" -dependencies = [ - "unicode-segmentation", -] [[package]] name = "hermit-abi" @@ -1438,7 +1107,7 @@ dependencies = [ "hyper", "log", "rustls 0.21.7", - "rustls-native-certs 0.6.3", + "rustls-native-certs", "tokio", "tokio-rustls 0.24.1", ] @@ -1536,15 +1205,6 @@ version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" -[[package]] -name = "is_executable" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa9acdc6d67b75e626ad644734e8bc6df893d9cd2a834129065d3dd6158ea9c8" -dependencies = [ - "winapi", -] - [[package]] name = "iso8601" version = "0.6.1" @@ -1699,7 +1359,7 @@ dependencies = [ "pem", "pin-project", "rustls 0.21.7", - "rustls-pemfile 1.0.3", + "rustls-pemfile", "secrecy", "serde", "serde_json", @@ -1781,38 +1441,12 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" -[[package]] -name = "lexical-sort" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c09e4591611e231daf4d4c685a66cb0410cc1e502027a20ae55f2bb9e997207a" -dependencies = [ - "any_ascii", -] - [[package]] name = "libc" version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" -[[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 0.4.1", -] - -[[package]] -name = "linux-raw-sys" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" - [[package]] name = "lock_api" version = "0.4.11" @@ -1899,16 +1533,6 @@ dependencies = [ "libc", ] -[[package]] -name = "nix-nar" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e412c3138d9fcb384da86b4a068c11bad373441eb5c4b89406de4faf649fa02" -dependencies = [ - "is_executable", - "thiserror", -] - [[package]] name = "nkeys" version = "0.3.2" @@ -1935,15 +1559,6 @@ dependencies = [ "minimal-lexical", ] -[[package]] -name = "normpath" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5831952a9476f2fed74b77d74182fa5ddc4d21c72ec45a333b250e3ed0272804" -dependencies = [ - "windows-sys 0.52.0", -] - [[package]] name = "nu-ansi-term" version = "0.46.0" @@ -2276,15 +1891,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "output_vt100" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "628223faebab4e3e40667ee0b2336d34a5b960ff60ea743ddfdbcf7770bcfb66" -dependencies = [ - "winapi", -] - [[package]] name = "overload" version = "0.1.1" @@ -2309,17 +1915,11 @@ checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.4.1", + "redox_syscall", "smallvec", "windows-targets 0.48.5", ] -[[package]] -name = "paste" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" - [[package]] name = "pathdiff" version = "0.2.1" @@ -2362,18 +1962,6 @@ dependencies = [ "ucd-trie", ] -[[package]] -name = "pest_ascii_tree" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152b393638a9816cd3dedb5aea2fb60ab0b641315aa133cea219c8797e768fc" -dependencies = [ - "ascii_tree", - "escape_string", - "pest", - "pest_derive", -] - [[package]] name = "pest_derive" version = "2.7.5" @@ -2468,18 +2056,6 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "pretty_assertions" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cab0e7c02cf376875e9335e0ba1da535775beb5450d21e1dffca068818ed98b" -dependencies = [ - "ansi_term", - "ctor", - "diff", - "output_vt100", -] - [[package]] name = "proc-macro-error" version = "1.0.4" @@ -2536,22 +2112,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "provider-archive" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d307420d84d6513146612e97d7ca34f54b34c60df9817020da496b885b0085f1" -dependencies = [ - "async-compression", - "data-encoding", - "ring 0.17.5", - "serde_json", - "tokio", - "tokio-stream", - "tokio-tar", - "wascap 0.14.0", -] - [[package]] name = "quote" version = "1.0.33" @@ -2603,15 +2163,6 @@ dependencies = [ "yasna", ] -[[package]] -name = "redox_syscall" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" -dependencies = [ - "bitflags 1.3.2", -] - [[package]] name = "redox_syscall" version = "0.4.1" @@ -2621,17 +2172,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" @@ -2700,7 +2240,7 @@ dependencies = [ "percent-encoding", "pin-project-lite", "rustls 0.21.7", - "rustls-pemfile 1.0.3", + "rustls-pemfile", "serde", "serde_json", "serde_urlencoded", @@ -2747,40 +2287,12 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "rmp" -version = "0.8.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f9860a6cc38ed1da53456442089b4dfa35e7cedaa326df63017af88385e6b20" -dependencies = [ - "byteorder 1.5.0", - "num-traits", - "paste", -] - -[[package]] -name = "rmp-serde" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bffea85eea980d8a74453e5d02a8d93028f3c34725de143085a844ebe953258a" -dependencies = [ - "byteorder 1.5.0", - "rmp", - "serde", -] - [[package]] name = "rustc-demangle" version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" -[[package]] -name = "rustc-hash" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" - [[package]] name = "rustc_version" version = "0.4.0" @@ -2790,19 +2302,6 @@ dependencies = [ "semver", ] -[[package]] -name = "rustix" -version = "0.38.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65e04861e65f21776e67888bfbea442b3642beaa0138fdb1dd7a84a52dffdb89" -dependencies = [ - "bitflags 2.4.1", - "errno", - "libc", - "linux-raw-sys", - "windows-sys 0.52.0", -] - [[package]] name = "rustls" version = "0.20.9" @@ -2847,20 +2346,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" dependencies = [ "openssl-probe", - "rustls-pemfile 1.0.3", - "schannel", - "security-framework", -] - -[[package]] -name = "rustls-native-certs" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f1fb85efa936c42c6d5fc28d2629bb51e4b2f4b8a5211e297d599cc5a093792" -dependencies = [ - "openssl-probe", - "rustls-pemfile 2.1.2", - "rustls-pki-types", + "rustls-pemfile", "schannel", "security-framework", ] @@ -2874,16 +2360,6 @@ dependencies = [ "base64 0.21.4", ] -[[package]] -name = "rustls-pemfile" -version = "2.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" -dependencies = [ - "base64 0.22.0", - "rustls-pki-types", -] - [[package]] name = "rustls-pki-types" version = "1.4.1" @@ -2923,15 +2399,6 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" -[[package]] -name = "same-file" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" -dependencies = [ - "winapi-util", -] - [[package]] name = "schannel" version = "0.1.22" @@ -3032,15 +2499,6 @@ dependencies = [ "serde_derive", ] -[[package]] -name = "serde-transcode" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "590c0e25c2a5bb6e85bf5c1bce768ceb86b316e7a01bdf07d2cb4ec2271990e2" -dependencies = [ - "serde", -] - [[package]] name = "serde-value" version = "0.7.0" @@ -3060,16 +2518,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_cbor" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bef2ebfde456fb76bbcf9f59315333decc4fda0b2b44b420243c11e0f5ec1f5" -dependencies = [ - "half", - "serde", -] - [[package]] name = "serde_derive" version = "1.0.189" @@ -3133,15 +2581,6 @@ dependencies = [ "syn 2.0.38", ] -[[package]] -name = "serde_spanned" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12022b835073e5b11e90a14f86838ceb1c8fb0325b72416845c487ac0fa95e80" -dependencies = [ - "serde", -] - [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -3154,28 +2593,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_with" -version = "2.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07ff71d2c147a7b57362cead5e22f772cd52f6ab31cfcd9edcd7f6aeb2a0afbe" -dependencies = [ - "serde", - "serde_with_macros", -] - -[[package]] -name = "serde_with_macros" -version = "2.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881b6f881b17d13214e5d494c939ebab463d01264ce1811e9d4ac3a882e7695f" -dependencies = [ - "darling", - "proc-macro2", - "quote", - "syn 2.0.38", -] - [[package]] name = "serde_yaml" version = "0.9.25" @@ -3312,15 +2729,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "spdx" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b19b32ed6d899ab23174302ff105c1577e45a06b08d4fe0a9dd13ce804bbbf71" -dependencies = [ - "smallvec", -] - [[package]] name = "spin" version = "0.5.2" @@ -3404,19 +2812,6 @@ dependencies = [ "libc", ] -[[package]] -name = "tempfile" -version = "3.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" -dependencies = [ - "cfg-if", - "fastrand", - "redox_syscall 0.4.1", - "rustix", - "windows-sys 0.48.0", -] - [[package]] name = "thiserror" version = "1.0.55" @@ -3574,20 +2969,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "tokio-tar" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d5714c010ca3e5c27114c1cdeb9d14641ace49874aa5626d7149e47aedace75" -dependencies = [ - "filetime", - "futures-core", - "libc", - "redox_syscall 0.3.5", - "tokio", - "tokio-stream", -] - [[package]] name = "tokio-util" version = "0.7.9" @@ -3606,74 +2987,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "toml" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" -dependencies = [ - "serde", -] - -[[package]] -name = "toml" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd79e69d3b627db300ff956027cc6c3798cef26d22526befdfcd12feeb6d2257" -dependencies = [ - "serde", - "serde_spanned", - "toml_datetime", - "toml_edit 0.19.15", -] - -[[package]] -name = "toml" -version = "0.8.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1a195ec8c9da26928f773888e0742ca3ca1040c6cd859c919c9f59c1954ab35" -dependencies = [ - "serde", - "serde_spanned", - "toml_datetime", - "toml_edit 0.21.0", -] - -[[package]] -name = "toml_datetime" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" -dependencies = [ - "serde", -] - -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap 2.0.2", - "serde", - "serde_spanned", - "toml_datetime", - "winnow", -] - -[[package]] -name = "toml_edit" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03" -dependencies = [ - "indexmap 2.0.2", - "serde", - "serde_spanned", - "toml_datetime", - "winnow", -] - [[package]] name = "tonic" version = "0.9.2" @@ -3904,6 +3217,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e37c4b6cbcc59a8dcd09a6429fbc7890286bcbb79215cea7b38a3c4c0921d93" dependencies = [ "rand", + "serde", ] [[package]] @@ -3942,12 +3256,6 @@ version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" -[[package]] -name = "unicode-width" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" - [[package]] name = "unicode-xid" version = "0.2.4" @@ -4046,9 +3354,9 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wadm" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bd11670372017a613ba62dc4f46e4db75f635d1d6a0ec7cc4f43ab2fc78d97" +checksum = "4e84553b11da0c24f4f20798587d446c1f496816eee05908846ef9974b94e09a" dependencies = [ "anyhow", "async-nats", @@ -4073,18 +3381,65 @@ dependencies = [ "tokio", "tracing", "tracing-futures", + "ulid", "uuid", + "wadm-types", "wasmcloud-control-interface", ] [[package]] -name = "walkdir" -version = "2.4.0" +name = "wadm-client" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54dff43b877842c657447e073a87b9d636fac74b1b97cc3032e946fbd637760c" +dependencies = [ + "anyhow", + "async-nats", + "bytes", + "nkeys", + "once_cell", + "serde", + "serde_json", + "serde_yaml", + "thiserror", + "tokio", + "tracing", + "tracing-futures", + "wadm-types", +] + +[[package]] +name = "wadm-types" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" +checksum = "af535df65c0387b6a8ef521aca58a239af817f03ebf676f91e982b9b919bc513" dependencies = [ - "same-file", - "winapi-util", + "anyhow", + "async-nats", + "async-trait", + "base64 0.21.4", + "bytes", + "chrono", + "cloudevents-sdk", + "futures", + "indexmap 2.0.2", + "jsonschema", + "lazy_static", + "nkeys", + "rand", + "regex", + "semver", + "serde", + "serde_json", + "serde_yaml", + "sha2", + "thiserror", + "tokio", + "tracing", + "tracing-futures", + "ulid", + "uuid", + "wasmcloud-control-interface", ] [[package]] @@ -4110,85 +3465,9 @@ dependencies = [ "ring 0.17.5", "serde", "serde_json", - "wasm-encoder 0.41.2", - "wasm-gen", - "wasmparser 0.121.2", -] - -[[package]] -name = "wascap" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f73a26e9c0c7ae48fda89cc409a169cbce0465e07f5842ee19cd53d909ce167" -dependencies = [ - "data-encoding", - "humantime", - "nkeys", - "nuid 0.4.1", - "ring 0.17.5", - "serde", - "serde_json", - "wasm-encoder 0.203.0", + "wasm-encoder", "wasm-gen", - "wasmparser 0.202.0", -] - -[[package]] -name = "wash-lib" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "374b9bd251b9647479f81f64909c5094c011e553fcd2189a158f69773de00c8c" -dependencies = [ - "anyhow", - "async-compression", - "async-nats", - "bytes", - "cargo_metadata", - "cargo_toml", - "chrono", - "cloudevents-sdk", - "command-group", - "config 0.13.4", - "dirs", - "futures", - "nkeys", - "normpath", - "oci-distribution", - "provider-archive", - "regex", - "reqwest", - "rmp-serde", - "semver", - "serde", - "serde-transcode", - "serde_cbor", - "serde_json", - "serde_with", - "serde_yaml", - "tempfile", - "thiserror", - "time", - "tokio", - "tokio-stream", - "tokio-tar", - "tokio-util", - "toml 0.8.8", - "tracing", - "url", - "wadm", - "walkdir", - "wascap 0.14.0", - "wasm-encoder 0.203.0", - "wasmcloud-component-adapters", - "wasmcloud-control-interface", - "wasmcloud-core", - "wasmparser 0.202.0", - "wat", - "weld-codegen", - "wit-bindgen-core", - "wit-bindgen-go", - "wit-component", - "wit-parser", + "wasmparser", ] [[package]] @@ -4263,15 +3542,6 @@ version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" -[[package]] -name = "wasm-encoder" -version = "0.38.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ad2b51884de9c7f4fe2fd1043fccb8dcad4b1e29558146ee57a144d15779f3f" -dependencies = [ - "leb128", -] - [[package]] name = "wasm-encoder" version = "0.41.2" @@ -4281,24 +3551,6 @@ dependencies = [ "leb128", ] -[[package]] -name = "wasm-encoder" -version = "0.202.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfd106365a7f5f7aa3c1916a98cbb3ad477f5ff96ddb130285a91c6e7429e67a" -dependencies = [ - "leb128", -] - -[[package]] -name = "wasm-encoder" -version = "0.203.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87e3b46a0d9d9143d57aa926c42e2af284b5cb8f0c7b71079afc7a6fca42db50" -dependencies = [ - "leb128", -] - [[package]] name = "wasm-gen" version = "0.1.4" @@ -4309,22 +3561,6 @@ dependencies = [ "leb128", ] -[[package]] -name = "wasm-metadata" -version = "0.202.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "094aea3cb90e09f16ee25a4c0e324b3e8c934e7fd838bfa039aef5352f44a917" -dependencies = [ - "anyhow", - "indexmap 2.0.2", - "serde", - "serde_derive", - "serde_json", - "spdx", - "wasm-encoder 0.202.0", - "wasmparser 0.202.0", -] - [[package]] name = "wasm-streams" version = "0.3.0" @@ -4338,26 +3574,6 @@ dependencies = [ "web-sys", ] -[[package]] -name = "wasmcloud-component-adapters" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e2f03df5ce84548110521426695ac9d4cc5ab591953d9a6dd2165ce9968055a" -dependencies = [ - "anyhow", - "base64 0.21.4", - "futures", - "nix-nar", - "once_cell", - "reqwest", - "serde", - "serde_json", - "sha2", - "tempfile", - "tokio", - "tokio-util", -] - [[package]] name = "wasmcloud-control-interface" version = "1.0.0" @@ -4394,11 +3610,8 @@ dependencies = [ "futures", "hex", "nkeys", - "oci-distribution", "once_cell", - "reqwest", "rustls 0.23.4", - "rustls-native-certs 0.7.0", "serde", "serde_bytes", "sha2", @@ -4407,7 +3620,7 @@ dependencies = [ "tracing", "ulid", "uuid", - "wascap 0.13.0", + "wascap", "wrpc-transport", "wrpc-transport-nats", ] @@ -4421,10 +3634,10 @@ dependencies = [ "axum", "axum-server", "cloudevents-sdk", - "config 0.14.0", + "config", "ctrlc", "futures", - "handlebars 5.1.0", + "handlebars", "json-patch", "k8s-openapi", "kube", @@ -4446,7 +3659,8 @@ dependencies = [ "utoipa", "uuid", "wadm", - "wash-lib", + "wadm-client", + "wadm-types", "wasmcloud-operator-types", ] @@ -4472,38 +3686,6 @@ dependencies = [ "semver", ] -[[package]] -name = "wasmparser" -version = "0.202.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6998515d3cf3f8b980ef7c11b29a9b1017d4cf86b99ae93b546992df9931413" -dependencies = [ - "bitflags 2.4.1", - "indexmap 2.0.2", - "semver", -] - -[[package]] -name = "wast" -version = "69.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1ee37317321afde358e4d7593745942c48d6d17e0e6e943704de9bbee121e7a" -dependencies = [ - "leb128", - "memchr", - "unicode-width", - "wasm-encoder 0.38.1", -] - -[[package]] -name = "wat" -version = "1.0.82" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aeb338ee8dee4d4cd05e6426683f21c5087dc7cfc8903e839ccf48d43332da3c" -dependencies = [ - "wast", -] - [[package]] name = "web-sys" version = "0.3.64" @@ -4540,36 +3722,6 @@ version = "0.25.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1778a42e8b3b90bff8d0f5032bf22250792889a5cdc752aa0020c84abe3aaf10" -[[package]] -name = "weld-codegen" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66385fd8affabb09b678d2f826c78d995789cdb2fbb2dd02e6010dffe298797e" -dependencies = [ - "Inflector", - "anyhow", - "atelier_assembler", - "atelier_core", - "atelier_json", - "atelier_smithy", - "bytes", - "cfg-if", - "clap", - "directories", - "downloader", - "handlebars 4.5.0", - "lazy_static", - "lexical-sort", - "reqwest", - "rustc-hash", - "semver", - "serde", - "serde_json", - "tempfile", - "thiserror", - "toml 0.7.8", -] - [[package]] name = "winapi" version = "0.3.9" @@ -4586,15 +3738,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -[[package]] -name = "winapi-util" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" -dependencies = [ - "winapi", -] - [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" @@ -4742,15 +3885,6 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" -[[package]] -name = "winnow" -version = "0.5.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c830786f7720c2fd27a1a0e27a709dbd3c4d009b56d098fc742d4f4eab91fe2" -dependencies = [ - "memchr", -] - [[package]] name = "winreg" version = "0.50.0" @@ -4761,61 +3895,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "wit-bindgen-c" -version = "0.24.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3fe2356d9a59d62fe6eb201947085d3ccc7ff00de27011e766f1b6f419f4144" -dependencies = [ - "anyhow", - "heck 0.4.1", - "wasm-encoder 0.202.0", - "wasm-metadata", - "wit-bindgen-core", - "wit-component", -] - -[[package]] -name = "wit-bindgen-core" -version = "0.24.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b67e11c950041849a10828c7600ea62a4077c01e8af72e8593253575428f91b" -dependencies = [ - "anyhow", - "wit-parser", -] - -[[package]] -name = "wit-bindgen-go" -version = "0.24.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b513981e5673f4ad884ee61659f81c676e1092dbe96b07c72cc1f2c0c669daf1" -dependencies = [ - "anyhow", - "heck 0.4.1", - "wit-bindgen-c", - "wit-bindgen-core", -] - -[[package]] -name = "wit-component" -version = "0.202.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c836b1fd9932de0431c1758d8be08212071b6bba0151f7bac826dbc4312a2a9" -dependencies = [ - "anyhow", - "bitflags 2.4.1", - "indexmap 2.0.2", - "log", - "serde", - "serde_derive", - "serde_json", - "wasm-encoder 0.202.0", - "wasm-metadata", - "wasmparser 0.202.0", - "wit-parser", -] - [[package]] name = "wit-parser" version = "0.202.0" @@ -4827,11 +3906,7 @@ dependencies = [ "indexmap 2.0.2", "log", "semver", - "serde", - "serde_derive", - "serde_json", "unicode-xid", - "wasmparser 0.202.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 23d708d..a6381e4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,7 +51,8 @@ tracing-subscriber = { workspace = true } utoipa = { workspace = true } uuid = { workspace = true } wadm = { workspace = true } -wash-lib = { workspace = true } +wadm-client = { workspace = true } +wadm-types = { workspace = true } wasmcloud-operator-types = { workspace = true } [workspace.dependencies] @@ -91,8 +92,9 @@ tracing-opentelemetry = "0.20" tracing-subscriber = { version = "0.3", features = ["env-filter", "json"] } utoipa = { version = "4.1", features = ["axum_extras"] } uuid = { version = "1", features = ["v5"] } -wadm = "0.11.0" -wash-lib = "0.20.0" +wadm = "0.12.0" +wadm-client = "0.1.1" +wadm-types = "0.1.0" wasmcloud-operator-types = { version = "*", path = "./crates/types" } [workspace] diff --git a/src/controller.rs b/src/controller.rs index da7ff22..de98f35 100644 --- a/src/controller.rs +++ b/src/controller.rs @@ -1,6 +1,6 @@ use crate::{ - config::OperatorConfig, docker_secret::DockerConfigJson, resources::application::get_client, - services::ServiceWatcher, Error, Result, + config::OperatorConfig, docker_secret::DockerConfigJson, + resources::application::get_nats_client, services::ServiceWatcher, Error, Result, }; use anyhow::bail; use futures::StreamExt; @@ -15,7 +15,7 @@ use k8s_openapi::api::rbac::v1::{PolicyRule, Role, RoleBinding, RoleRef, Subject use k8s_openapi::apimachinery::pkg::apis::meta::v1::LabelSelector; use kube::{ api::{Api, ObjectMeta, Patch, PatchParams}, - client::Client, + client::Client as KubeClient, runtime::{ controller::{Action, Config, Controller}, finalizer::{finalizer, Event as Finalizer}, @@ -48,7 +48,7 @@ pub const WASMCLOUD_OPERATOR_MANAGED_BY_LABEL_REQUIREMENT: &str = "app.kubernetes.io/managed-by=wasmcloud-operator"; pub struct Context { - pub client: Client, + pub client: KubeClient, pub wasmcloud_config: OperatorConfig, pub nats_creds: Arc>>, service_watcher: ServiceWatcher, @@ -114,12 +114,12 @@ pub async fn reconcile(cluster: Arc, ctx: Arc) -> } async fn reconcile_crd(config: &WasmCloudHostConfig, ctx: Arc) -> Result { - let client = ctx.client.clone(); + let kube_client = ctx.client.clone(); let ns = config.namespace().unwrap(); let name = config.name_any(); - let config: Api = Api::namespaced(client.clone(), &ns); + let config: Api = Api::namespaced(kube_client.clone(), &ns); let mut cfg = config.get(&name).await?; - let secrets = Api::::namespaced(client, &ns); + let secrets = Api::::namespaced(kube_client, &ns); let secret = secrets.get(&cfg.spec.secret_name).await.map_err(|e| { warn!("Failed to read secrets: {}", e); @@ -201,7 +201,7 @@ async fn reconcile_crd(config: &WasmCloudHostConfig, ctx: Arc) -> Resul })?; // Start the watcher so that services are automatically created in the cluster. - let nats_client = get_client( + let nats_client = get_nats_client( &cfg.spec.nats_address, &cfg.spec.nats_client_port, ctx.nats_creds.clone(), @@ -916,19 +916,19 @@ fn error_policy(_object: Arc, _error: &Error, _ctx: Arc anyhow::Result<()> { - let client = Client::try_default().await?; + let kube_client = KubeClient::try_default().await?; - let configs = Api::::all(client.clone()); - let cms = Api::::all(client.clone()); - let deployments = Api::::all(client.clone()); - let secrets = Api::::all(client.clone()); - let services = Api::::all(client.clone()); - let pods = Api::::all(client.clone()); + let configs = Api::::all(kube_client.clone()); + let cms = Api::::all(kube_client.clone()); + let deployments = Api::::all(kube_client.clone()); + let secrets = Api::::all(kube_client.clone()); + let services = Api::::all(kube_client.clone()); + let pods = Api::::all(kube_client.clone()); - let watcher = ServiceWatcher::new(client.clone(), state.config.stream_replicas); + let watcher = ServiceWatcher::new(kube_client.clone(), state.config.stream_replicas); let config = Config::default(); let ctx = Context { - client, + client: kube_client, wasmcloud_config: state.config.clone(), nats_creds: state.nats_creds.clone(), service_watcher: watcher, diff --git a/src/resources/application.rs b/src/resources/application.rs index 3e0031d..c2121e0 100644 --- a/src/resources/application.rs +++ b/src/resources/application.rs @@ -2,7 +2,7 @@ use std::collections::{BTreeMap, HashMap, HashSet}; use std::sync::Arc; use anyhow::{anyhow, Error}; -use async_nats::ConnectOptions; +use async_nats::{Client as NatsClient, ConnectError, ConnectOptions}; use axum::{ body::Bytes, extract::{Path, State as AxumState}, @@ -12,7 +12,7 @@ use axum::{ }; use kube::{ api::{Api, ListParams}, - client::Client, + client::Client as KubeClient, core::{ListMeta, ObjectMeta}, }; use secrecy::{ExposeSecret, SecretString}; @@ -21,12 +21,12 @@ use serde_json::json; use tokio::sync::RwLock; use tracing::error; use uuid::Uuid; -use wadm::{ - model::Manifest, - server::{ - DeleteResult, DeployResult, GetResult, ModelSummary, PutResult, StatusResult, StatusType, - }, +use wadm_client::{error::ClientError, Client as WadmClient}; +use wadm_types::{ + api::{ModelSummary, StatusType}, + Manifest, }; + use wasmcloud_operator_types::v1alpha1::WasmCloudHostConfig; use crate::{ @@ -269,11 +269,11 @@ pub async fn create_application( AxumState(state): AxumState, body: Bytes, ) -> impl IntoResponse { - let client = match Client::try_default().await { + let kube_client = match KubeClient::try_default().await { Ok(c) => c, Err(e) => return internal_error(anyhow!("unable to initialize kubernetes client: {}", e)), }; - let configs: Api = Api::namespaced(client, &namespace); + let configs: Api = Api::namespaced(kube_client, &namespace); let cfgs = match configs.list(&ListParams::default()).await { Ok(objs) => objs, Err(e) => return internal_error(anyhow!("Unable to list cosmonic host configs: {}", e)), @@ -286,74 +286,20 @@ pub async fn create_application( Err(resp) => return resp, }; - let model: serde_json::Value = match serde_json::from_slice(&body) { + let wadm_client = WadmClient::from_nats_client(&lattice_id, None, nats_client); + + let manifest: Manifest = match serde_json::from_slice(&body) { Ok(v) => v, Err(e) => return internal_error(anyhow!("unable to decode the patch: {}", e)), }; - let put = - match wash_lib::app::put_model(&nats_client, Some(lattice_id.clone()), &model.to_string()) - .await - { - Ok(res) => res, + let (application_name, _application_version) = + match wadm_client.put_and_deploy_manifest(manifest).await { + Ok(application_bits) => application_bits, Err(e) => return internal_error(anyhow!("could not deploy app: {}", e)), }; - let model_name = match put.result { - PutResult::Created | PutResult::NewVersion => put.name, - _ => { - // TODO(joonas): Add handling for the case where the model version - // might already exist (from prior deploy or otherwise). - return internal_error(anyhow!( - "unexpected response from wadm: result={:?}, message={}", - put.result, - put.message - )); - } - }; - - let deploy = match wash_lib::app::deploy_model( - &nats_client, - Some(lattice_id.clone()), - &model_name, - Some(put.current_version.clone()), - ) - .await - { - Ok(res) => res, - Err(e) => return internal_error(anyhow!("could not deploy app: {}", e)), - }; - - if deploy.result != DeployResult::Acknowledged { - return internal_error(anyhow!( - "unexpected response from wadm: result={:?}, message={}", - deploy.result, - deploy.message - )); - } - - // Get model from WADM for displaying in Kubernetes - let get = match wash_lib::app::get_model_details( - &nats_client, - Some(lattice_id), - &model_name, - Some(put.current_version), - ) - .await - { - Ok(res) => res, - Err(e) => return internal_error(anyhow!("error getting deployed app: {}", e)), - }; - - match get.result { - GetResult::Success => Json(Application::new(model_name)).into_response(), - // Either we received an error or could not find the deployed application, so return an error: - _ => internal_error(anyhow!( - "unexpected response from wadm: result={:?}, message={}", - get.result, - get.message - )), - } + Json(Application::new(application_name)).into_response() } #[utoipa::path(get, path = "/apis/core.oam.dev/v1beta1/applications")] @@ -364,12 +310,12 @@ pub async fn list_all_applications( // TODO(joonas): Use lattices (or perhaps Controller specific/special creds) for instanciating NATS client. // TODO(joonas): Add watch support to stop Argo from spamming this endpoint every second. - let client = match Client::try_default().await { + let kube_client = match KubeClient::try_default().await { Ok(c) => c, Err(e) => return internal_error(anyhow!("unable to initialize kubernetes client: {}", e)), }; - let configs: Api = Api::all(client); + let configs: Api = Api::all(kube_client); let cfgs = match configs.list(&ListParams::default()).await { Ok(objs) => objs, Err(e) => return internal_error(anyhow!("Unable to list cosmonic host configs: {}", e)), @@ -427,11 +373,11 @@ pub async fn list_applications( Path(namespace): Path, AxumState(state): AxumState, ) -> impl IntoResponse { - let client = match Client::try_default().await { + let kube_client = match KubeClient::try_default().await { Ok(c) => c, Err(e) => return internal_error(anyhow!("unable to initialize kubernetes client: {}", e)), }; - let configs: Api = Api::namespaced(client, &namespace); + let configs: Api = Api::namespaced(kube_client, &namespace); let cfgs = match configs.list(&ListParams::default()).await { Ok(objs) => objs, Err(e) => return internal_error(anyhow!("Unable to list cosmonic host configs: {}", e)), @@ -485,7 +431,7 @@ pub async fn list_apps( lattice_id: String, ) -> Result, Error> { let addr = format!("{}:{}", cluster_url, port); - let client = match creds { + let nats_client = match creds { Some(creds) => { ConnectOptions::with_credentials(creds.expose_secret())? .connect(addr) @@ -493,17 +439,16 @@ pub async fn list_apps( } None => ConnectOptions::new().connect(addr).await?, }; - let models = wash_lib::app::get_models(&client, Some(lattice_id)).await?; - - Ok(models) + let wadm_client = WadmClient::from_nats_client(&lattice_id, None, nats_client); + Ok(wadm_client.list_manifests().await?) } -pub async fn get_client( +pub async fn get_nats_client( cluster_url: &str, port: &u16, nats_creds: Arc>>, namespace: NameNamespace, -) -> Result { +) -> Result { let addr = format!("{}:{}", cluster_url, port); let creds = nats_creds.read().await; match creds.get(&namespace) { @@ -527,12 +472,12 @@ pub async fn get_application( Path((namespace, name)): Path<(String, String)>, AxumState(state): AxumState, ) -> impl IntoResponse { - let client = match Client::try_default().await { + let kube_client = match KubeClient::try_default().await { Ok(c) => c, Err(e) => return internal_error(anyhow!("unable to initialize kubernetes client: {}", e)), }; - let configs: Api = Api::namespaced(client, &namespace); + let configs: Api = Api::namespaced(kube_client, &namespace); let cfgs = match configs.list(&ListParams::default()).await { Ok(objs) => objs, Err(e) => return internal_error(anyhow!("unable to list cosmonic host configs: {}", e)), @@ -544,83 +489,58 @@ pub async fn get_application( Ok(data) => data, Err(resp) => return resp, }; - - let get = - match wash_lib::app::get_model_details(&nats_client, Some(lattice_id.clone()), &name, None) - .await - { - Ok(res) => res, - Err(e) => { - return internal_error(anyhow!("unable to request app from wadm: {}", e)); + let wadm_client = WadmClient::from_nats_client(&lattice_id, None, nats_client); + + let manifest = match wadm_client.get_manifest(&name, None).await { + Ok(m) => m, + Err(e) => match e { + ClientError::ManifestLoad(_) + | ClientError::NatsError(_) + | ClientError::ApiError(_) + | ClientError::Other(_) + | ClientError::Serialization(_) => { + return internal_error(anyhow!("unable to request app from wadm: {}", e)) } - }; - - let status = match wash_lib::app::get_model_status( - &nats_client, - Some(lattice_id.clone()), - &name, - ) - .await - { - Ok(res) => res, - Err(e) => { - return internal_error(anyhow!("unable to request app status from wadm: {}", e)); - } + ClientError::NotFound(_) => { + return not_found_error(anyhow!("applications \"{}\" not found", name)) + } + }, }; - - match status.result { - StatusResult::Ok => {} - StatusResult::NotFound => { - return not_found_error(anyhow!("applications \"{}\" not found", name)); - } - StatusResult::Error => { - return internal_error(anyhow!( - "unexpected response from wadm: result={:?}, message={}", - status.result, - status.message - )); - } + let status = match wadm_client.get_manifest_status(&name).await { + Ok(s) => s, + Err(_) => todo!(), }; - if get.result == GetResult::Success { - if let Some(manifest) = get.manifest { - let response = match accept.into() { - As::Table => Json(ApplicationTable::from(vec![manifest])).into_response(), - As::NotSpecified => { - // TODO(joonas): This is a terrible hack, but for now it's what we need to do to satisfy Argo/Kubernetes since WADM doesn't support this metadata. - let mut manifest_value = serde_json::to_value(&manifest).unwrap(); - // TODO(joonas): We should add lattice id to this as well, but we need it in every place where the application is listed. - let ns = format!("{}/{}", &name, &manifest.version()); - let uid = Uuid::new_v5(&Uuid::NAMESPACE_OID, ns.as_bytes()); - manifest_value["metadata"]["uid"] = json!(uid.to_string()); - manifest_value["metadata"]["resourceVersion"] = json!(uid.to_string()); - manifest_value["metadata"]["namespace"] = json!(namespace); - manifest_value["metadata"]["labels"] = json!({ - "app.kubernetes.io/instance": &name - }); - // TODO(joonas): refactor status and the metadata inputs into a struct we could just serialize - // The custom health check we provide for Argo will handle the case where status is missing, so this is fine for now. - if let Some(status) = status.status { - let phase = match status.info.status_type { - StatusType::Undeployed => "Undeployed", - StatusType::Reconciling => "Reconciling", - StatusType::Deployed => "Deployed", - StatusType::Failed => "Failed", - }; - manifest_value["status"] = json!({ - "phase": phase, - }); - } - Json(manifest_value).into_response() - } - // TODO(joonas): Add better error handling here - t => return internal_error(anyhow!("unknown type: {}", t)), + match accept.into() { + As::Table => Json(ApplicationTable::from(vec![manifest])).into_response(), + As::NotSpecified => { + // TODO(joonas): This is a terrible hack, but for now it's what we need to do to satisfy Argo/Kubernetes since WADM doesn't support this metadata. + let mut manifest_value = serde_json::to_value(&manifest).unwrap(); + // TODO(joonas): We should add lattice id to this as well, but we need it in every place where the application is listed. + let ns = format!("{}/{}", &name, &manifest.version()); + let uid = Uuid::new_v5(&Uuid::NAMESPACE_OID, ns.as_bytes()); + manifest_value["metadata"]["uid"] = json!(uid.to_string()); + manifest_value["metadata"]["resourceVersion"] = json!(uid.to_string()); + manifest_value["metadata"]["namespace"] = json!(namespace); + manifest_value["metadata"]["labels"] = json!({ + "app.kubernetes.io/instance": &name + }); + // TODO(joonas): refactor status and the metadata inputs into a struct we could just serialize + // The custom health check we provide for Argo will handle the case where status is missing, so this is fine for now. + let phase = match status.info.status_type { + StatusType::Undeployed => "Undeployed", + StatusType::Reconciling => "Reconciling", + StatusType::Deployed => "Deployed", + StatusType::Failed => "Failed", }; - return response; + manifest_value["status"] = json!({ + "phase": phase, + }); + Json(manifest_value).into_response() } - }; - - not_found_error(anyhow!("applications \"{}\" not found", name)) + // TODO(joonas): Add better error handling here + t => return internal_error(anyhow!("unknown type: {}", t)), + } } #[utoipa::path( @@ -632,11 +552,11 @@ pub async fn patch_application( AxumState(state): AxumState, body: Bytes, ) -> impl IntoResponse { - let client = match Client::try_default().await { + let kube_client = match KubeClient::try_default().await { Ok(c) => c, Err(e) => return internal_error(anyhow!("unable to initialize kubernetes client: {}", e)), }; - let configs: Api = Api::namespaced(client, &namespace); + let configs: Api = Api::namespaced(kube_client, &namespace); let cfgs = match configs.list(&ListParams::default()).await { Ok(objs) => objs, Err(e) => return internal_error(anyhow!("unable to list cosmonic host configs: {}", e)), @@ -648,34 +568,24 @@ pub async fn patch_application( Ok(data) => data, Err(resp) => return resp, }; - - // Fist, check if the model exists. - // TODO(joonas): we should likely fetch the version of the manifest that's running in Kubernetes - // TODO(joonas): Should this use model.status instead of model.get? - let get = - match wash_lib::app::get_model_details(&nats_client, Some(lattice_id.clone()), &name, None) - .await - { - Ok(res) => res, - Err(e) => { - return internal_error(anyhow!("unable to find app: {}", e)); + let wadm_client = WadmClient::from_nats_client(&lattice_id, None, nats_client); + let current_manifest = match wadm_client.get_manifest(&name, None).await { + Ok(m) => m, + Err(e) => match e { + ClientError::ManifestLoad(_) + | ClientError::NatsError(_) + | ClientError::ApiError(_) + | ClientError::Other(_) + | ClientError::Serialization(_) => { + return internal_error(anyhow!("unable to request app from wadm: {}", e)) } - }; - - if get.result != GetResult::Success { - return internal_error(anyhow!( - "unexpected response from wadm: result={:?}, reason={}", - get.result, - get.message - )); - } - - // Prepare manifest for patching - let Some(manifest) = get.manifest else { - return internal_error(anyhow!("no manifest was found for app: {}", &name)); + ClientError::NotFound(_) => { + return not_found_error(anyhow!("applications \"{}\" not found", name)) + } + }, }; - let mut model = serde_json::to_value(manifest).unwrap(); + let mut model = serde_json::to_value(current_manifest).unwrap(); // Parse the Kubernetes-provided RFC 7386 patch let patch: serde_json::Value = match serde_json::from_slice(&body) { Ok(p) => p, @@ -684,52 +594,25 @@ pub async fn patch_application( // Attempt to patch the currently running version json_patch::merge(&mut model, &patch); + let updated_manifest: Manifest = match serde_json::from_value(model) { + Ok(m) => m, + Err(e) => return internal_error(anyhow!("unable to patch the application: {}", e)), + }; - let put = - match wash_lib::app::put_model(&nats_client, Some(lattice_id.clone()), &model.to_string()) - .await - { - Ok(res) => res, - Err(e) => { - return internal_error(anyhow!("could not update manifest for deploy: {}", e)) + match wadm_client.put_and_deploy_manifest(updated_manifest).await { + Ok((app_name, _)) => Json(Application::new(app_name)).into_response(), + Err(e) => match e { + ClientError::NotFound(_) => { + not_found_error(anyhow!("applications \"{}\" not found", &name)) } - }; - - match put.result { - PutResult::NewVersion => {} - _ => { - // For now we have to check the error message to see if we can continue, - // despite getting an error. - if !put.message.contains("already exists") { - return internal_error(anyhow!( - "unexpected response from wadm: result={:?}, message={}", - put.result, - put.message - )); + ClientError::ManifestLoad(_) + | ClientError::NatsError(_) + | ClientError::ApiError(_) + | ClientError::Serialization(_) + | ClientError::Other(_) => { + internal_error(anyhow!("could not update application: {}", e)) } - } - }; - - let deploy = match wash_lib::app::deploy_model( - &nats_client, - Some(lattice_id), - &name, - Some(put.current_version), - ) - .await - { - Ok(res) => res, - Err(e) => return internal_error(anyhow!("could not deploy app: {}", e)), - }; - - match deploy.result { - DeployResult::Acknowledged => Json(Application::new(name)).into_response(), - DeployResult::Error => internal_error(anyhow!( - "unexpected response from wadm: result={:?}, message={}", - deploy.result, - deploy.message - )), - DeployResult::NotFound => not_found_error(anyhow!("applications \"{}\" not found", &name)), + }, } } @@ -741,12 +624,12 @@ pub async fn delete_application( Path((namespace, name)): Path<(String, String)>, AxumState(state): AxumState, ) -> impl IntoResponse { - let client = match Client::try_default().await { + let kube_client = match KubeClient::try_default().await { Ok(c) => c, Err(e) => return internal_error(anyhow!("unable to initialize kubernetes client: {}", e)), }; - let configs: Api = Api::namespaced(client, &namespace); + let configs: Api = Api::namespaced(kube_client, &namespace); let cfgs = match configs.list(&ListParams::default()).await { Ok(objs) => objs, Err(e) => return internal_error(anyhow!("unable to list cosmonic host configs: {}", e)), @@ -759,59 +642,19 @@ pub async fn delete_application( Err(resp) => return resp, }; - // Fist, check if the model exists. - // TODO(joonas): Replace this with wash_lib::app::get_model_status once - // https://github.com/wasmCloud/wasmCloud/pull/1151 ships. - let status = match wash_lib::app::get_model_status( - &nats_client, - Some(lattice_id.clone()), - &name, - ) - .await - { - Ok(res) => res, - Err(e) => { - return internal_error(anyhow!("unable to request app status from wadm: {}", e)); - } - }; - - match status.result { - StatusResult::Ok => { - // Proceed - } - StatusResult::NotFound => { - return not_found_error(anyhow!("apps \"{}\" not found", name)); - } - StatusResult::Error => { - return internal_error(anyhow!( - "unexpected response from status command: result={:?}, message={}", - status.result, - status.message - )); - } - }; - - let delete = match wash_lib::app::delete_model_version( - &nats_client, - Some(lattice_id), - &name, - None, - true, - ) - .await - { - Ok(res) => res, - Err(e) => return internal_error(anyhow!("error deleting app: {}", e)), - }; - - match delete.result { - // TODO(joonas): do we need to handle DeleteResult::Noop differently? - DeleteResult::Deleted | DeleteResult::Noop => Json(Application::new(name)).into_response(), - DeleteResult::Error => internal_error(anyhow!( - "unexpected response from wadm: result={:?}, message={}", - delete.result, - delete.message - )), + let wadm_client = WadmClient::from_nats_client(&lattice_id, None, nats_client); + match wadm_client.delete_manifest(&name, None).await { + Ok(_) => Json(Application::new(name)).into_response(), + Err(e) => match e { + ClientError::NotFound(_) => not_found_error(anyhow!("apps \"{}\" not found", name)), + ClientError::Other(_) + | ClientError::ManifestLoad(_) + | ClientError::NatsError(_) + | ClientError::ApiError(_) + | ClientError::Serialization(_) => { + internal_error(anyhow!("could not delete app: {}", e)) + } + }, } } @@ -819,7 +662,7 @@ async fn get_lattice_connection( cfgs: impl Iterator, state: State, namespace: String, -) -> Result<(async_nats::Client, String), Response> { +) -> Result<(NatsClient, String), Response> { let connection_data = cfgs.map(|cfg| (cfg, namespace.clone())) .filter_map(|(cfg, namespace)| { @@ -832,7 +675,7 @@ async fn get_lattice_connection( }); for (cluster_url, ns, lattice_id, port) in connection_data { - match get_client(&cluster_url, &port, state.nats_creds.clone(), ns).await { + match get_nats_client(&cluster_url, &port, state.nats_creds.clone(), ns).await { Ok(c) => return Ok((c, lattice_id)), Err(e) => { error!(err = %e, %lattice_id, "error connecting to nats"); diff --git a/src/services.rs b/src/services.rs index 4cafd0b..5247377 100644 --- a/src/services.rs +++ b/src/services.rs @@ -25,12 +25,9 @@ use kube::{ use tokio::sync::{mpsc, RwLock}; use tokio_util::sync::CancellationToken; use tracing::{debug, error, warn}; -use wadm::{ - events::{Event, ManifestPublished, ManifestUnpublished}, - model::{self, Manifest, Trait, TraitProperty}, - server::{GetResult, ModelSummary}, -}; -use wash_lib::app; +use wadm::events::{Event, ManifestPublished, ManifestUnpublished}; +use wadm_client::Client as WadmClient; +use wadm_types::{api::ModelSummary, Component, Manifest, Properties, Trait, TraitProperty}; use wasmcloud_operator_types::v1alpha1::WasmCloudHostConfig; use crate::controller::{ @@ -275,26 +272,20 @@ impl ServiceWatcher { /// This intended to be called by the controller whenever it reconciles state. pub async fn reconcile_services(&self, apps: Vec, lattice_id: String) { if let Some(watcher) = self.watchers.read().await.get(lattice_id.as_str()) { + let wadm_client = + WadmClient::from_nats_client(&lattice_id, None, watcher.nats_client.clone()); for app in apps { if app.deployed_version.is_none() { continue; } - match app::get_model_details( - &watcher.nats_client, - Some(lattice_id.clone()), - app.name.as_str(), - app.deployed_version, - ) - .await + match wadm_client + .get_manifest(app.name.as_str(), app.deployed_version.as_deref()) + .await { - Ok(model) => { - if model.result == GetResult::Success { - // TODO handle this or decide on whether or not to return a result at - // all - let _ = watcher.handle_manifest_published(ManifestPublished { - manifest: model.manifest.unwrap(), + Ok(manifest) => { + let _ = watcher.handle_manifest_published(ManifestPublished { + manifest, }).map_err(|e| error!(err = %e, %lattice_id, app = %app.name, "failed to trigger service reconciliation for app")); - } } Err(e) => warn!(err=%e, "Unable to retrieve model"), }; @@ -570,14 +561,12 @@ pub struct HttpServerComponent { /// Finds the httpserver component in a manifest and returns the details needed to create a service fn http_server_component(manifest: &Manifest) -> Option { - let components: Vec<&model::Component> = manifest - .spec - .components - .iter() + let components: Vec<&Component> = manifest + .components() // filter just for the wasmCloud httpserver for now. This should actually just filter for // the http capability .filter(|c| { - if let wadm::model::Properties::Capability { properties } = &c.properties { + if let Properties::Capability { properties } = &c.properties { if properties .image .starts_with("ghcr.io/wasmcloud/http-server")