diff --git a/Cargo.lock b/Cargo.lock index 9fe24b6f..93589f3d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,6 +17,12 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "adler2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" + [[package]] name = "aead" version = "0.5.2" @@ -120,27 +126,39 @@ version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" +[[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" +version = "0.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbc1f1a75fd07f0f517322d103211f12d757658e91676def9a2e688774656c60" +checksum = "f71e5a1bab60f46b0b005f4808b8ee83ef6d577608923de938403393c9a30cf8" dependencies = [ - "base64 0.21.7", + "base64 0.22.1", "bytes", "futures", - "http 0.2.12", "memchr", - "nkeys 0.3.2", + "nkeys", "nuid 0.5.0", "once_cell", + "portable-atomic", "rand", "regex", "ring", - "rustls 0.21.12", - "rustls-native-certs 0.6.3", - "rustls-pemfile 1.0.4", - "rustls-webpki 0.101.7", + "rustls-native-certs", + "rustls-pemfile", + "rustls-webpki", "serde", "serde_json", "serde_nanos", @@ -148,9 +166,10 @@ dependencies = [ "thiserror", "time", "tokio", - "tokio-retry", - "tokio-rustls 0.24.1", + "tokio-rustls", + "tokio-util 0.7.11", "tracing", + "tryhard", "url", ] @@ -195,9 +214,9 @@ checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "aws-lc-rs" -version = "1.8.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ae74d9bd0a7530e8afd1770739ad34b36838829d6ad61818f9230f683f5ad77" +checksum = "2f95446d919226d587817a7d21379e6eb099b97b45110a7f272a444ca5c54070" dependencies = [ "aws-lc-sys", "mirai-annotations", @@ -207,9 +226,9 @@ dependencies = [ [[package]] name = "aws-lc-sys" -version = "0.20.1" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f0e249228c6ad2d240c2dc94b714d711629d52bad946075d8e9b2f5391f0703" +checksum = "b3ddc4a5b231dd6958b140ff3151b6412b3f4321fab354f399eec8f14b06df62" dependencies = [ "bindgen", "cc", @@ -230,7 +249,7 @@ dependencies = [ "cc", "cfg-if", "libc", - "miniz_oxide", + "miniz_oxide 0.7.4", "object", "rustc-demangle", ] @@ -282,7 +301,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "rustc-hash", + "rustc-hash 1.1.0", "shlex", "syn 2.0.68", "which", @@ -341,14 +360,14 @@ dependencies = [ "http-body-util", "hyper 1.4.1", "hyper-named-pipe", - "hyper-rustls 0.27.2", + "hyper-rustls", "hyper-util", "hyperlocal", "log", "pin-project-lite", - "rustls 0.23.10", - "rustls-native-certs 0.7.1", - "rustls-pemfile 2.1.2", + "rustls", + "rustls-native-certs", + "rustls-pemfile", "rustls-pki-types", "serde", "serde_derive", @@ -392,12 +411,6 @@ version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fc10e8cc6b2580fda3f36eb6dc5316657f812a3df879a44a66fc9f0fdbc4855" -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - [[package]] name = "bytes" version = "1.7.2" @@ -575,6 +588,15 @@ dependencies = [ "libc", ] +[[package]] +name = "crc32fast" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" +dependencies = [ + "cfg-if", +] + [[package]] name = "crossbeam-channel" version = "0.5.13" @@ -866,12 +888,34 @@ version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" +[[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 = "fixedbitset" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" +[[package]] +name = "flate2" +version = "1.0.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "324a1be68054ef05ad64b861cc9eaf1d623d2d8cb25b4bf2cb9cdd902b4bf253" +dependencies = [ + "crc32fast", + "miniz_oxide 0.8.0", +] + [[package]] name = "fnv" version = "1.0.7" @@ -1257,20 +1301,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "hyper-rustls" -version = "0.24.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" -dependencies = [ - "futures-util", - "http 0.2.12", - "hyper 0.14.29", - "rustls 0.21.12", - "tokio", - "tokio-rustls 0.24.1", -] - [[package]] name = "hyper-rustls" version = "0.27.2" @@ -1282,12 +1312,13 @@ dependencies = [ "hyper 1.4.1", "hyper-util", "log", - "rustls 0.23.10", - "rustls-native-certs 0.7.1", + "rustls", + "rustls-native-certs", "rustls-pki-types", "tokio", - "tokio-rustls 0.26.0", + "tokio-rustls", "tower-service", + "webpki-roots", ] [[package]] @@ -1489,7 +1520,7 @@ dependencies = [ "parking_lot", "percent-encoding", "regex", - "reqwest", + "reqwest 0.11.27", "serde", "serde_json", "time", @@ -1620,6 +1651,15 @@ dependencies = [ "adler", ] +[[package]] +name = "miniz_oxide" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" +dependencies = [ + "adler2", +] + [[package]] name = "mio" version = "1.0.1" @@ -1644,22 +1684,6 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" -[[package]] -name = "nkeys" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aad178aad32087b19042ee36dfd450b73f5f934fbfb058b59b198684dfec4c47" -dependencies = [ - "byteorder 1.5.0", - "data-encoding", - "ed25519", - "ed25519-dalek", - "getrandom", - "log", - "rand", - "signatory", -] - [[package]] name = "nkeys" version = "0.4.4" @@ -1811,25 +1835,25 @@ dependencies = [ [[package]] name = "oci-distribution" -version = "0.9.4" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ac5b780ce1bd6c3c2ff72a3013f4b2d56d53ae03b20d424e99d2f6556125138" +checksum = "b95a2c51531af0cb93761f66094044ca6ea879320bccd35ab747ff3fcab3f422" dependencies = [ - "futures", + "bytes", + "chrono", "futures-util", - "http 0.2.12", + "http 1.1.0", "http-auth", "jwt", "lazy_static", "olpc-cjson", "regex", - "reqwest", + "reqwest 0.12.5", "serde", "serde_json", "sha2", "thiserror", "tokio", - "tokio-util 0.7.11", "tracing", "unicase", ] @@ -1886,18 +1910,16 @@ dependencies = [ [[package]] name = "opentelemetry" -version = "0.21.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e32339a5dc40459130b3bd269e9892439f55b33e772d2a9d402a789baaf4e8a" +checksum = "1b69a91d4893e713e06f724597ad630f1fa76057a5e1026c0ca67054a9032a76" dependencies = [ "futures-core", "futures-sink", - "indexmap 2.5.0", "js-sys", "once_cell", "pin-project-lite", "thiserror", - "urlencoding", ] [[package]] @@ -1910,7 +1932,7 @@ dependencies = [ "bytes", "http 0.2.12", "opentelemetry 0.17.0", - "reqwest", + "reqwest 0.11.27", ] [[package]] @@ -1927,7 +1949,7 @@ dependencies = [ "opentelemetry-http", "prost", "prost-build", - "reqwest", + "reqwest 0.11.27", "thiserror", "tokio", "tonic", @@ -1936,17 +1958,17 @@ dependencies = [ [[package]] name = "opentelemetry_sdk" -version = "0.21.2" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f16aec8a98a457a52664d69e0091bac3a0abd18ead9b641cb00202ba4e0efe4" +checksum = "ae312d58eaa90a82d2e627fd86e075cf5230b3f11794e2ed74199ebbe572d4fd" dependencies = [ "async-trait", - "crossbeam-channel", "futures-channel", "futures-executor", "futures-util", + "lazy_static", "once_cell", - "opentelemetry 0.21.0", + "opentelemetry 0.23.0", "ordered-float", "percent-encoding", "rand", @@ -1995,7 +2017,7 @@ checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", - "redox_syscall", + "redox_syscall 0.5.2", "smallvec", "windows-targets 0.52.5", ] @@ -2109,6 +2131,12 @@ dependencies = [ "universal-hash", ] +[[package]] +name = "portable-atomic" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d30538d42559de6b034bc76fd6dd4c38961b1ee5c6c56e3808c50128fdbc22ce" + [[package]] name = "powerfmt" version = "0.2.0" @@ -2217,6 +2245,70 @@ dependencies = [ "prost", ] +[[package]] +name = "provider-archive" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa80f73229dbe31f2fc248064b699d37f5edd7a28b5377f06617ce83a8364014" +dependencies = [ + "async-compression", + "data-encoding", + "ring", + "serde_json", + "tokio", + "tokio-stream", + "tokio-tar", + "wascap", +] + +[[package]] +name = "quinn" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c7c5fdde3cdae7203427dc4f0a68fe0ed09833edc525a03456b153b79828684" +dependencies = [ + "bytes", + "pin-project-lite", + "quinn-proto", + "quinn-udp", + "rustc-hash 2.0.0", + "rustls", + "socket2", + "thiserror", + "tokio", + "tracing", +] + +[[package]] +name = "quinn-proto" +version = "0.11.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fadfaed2cd7f389d0161bb73eeb07b7b78f8691047a6f3e73caaeae55310a4a6" +dependencies = [ + "bytes", + "rand", + "ring", + "rustc-hash 2.0.0", + "rustls", + "slab", + "thiserror", + "tinyvec", + "tracing", +] + +[[package]] +name = "quinn-udp" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bffec3605b73c6f1754535084a85229fa8a30f86014e6c81aeec4abb68b0285" +dependencies = [ + "libc", + "once_cell", + "socket2", + "tracing", + "windows-sys 0.52.0", +] + [[package]] name = "quote" version = "1.0.36" @@ -2256,6 +2348,24 @@ dependencies = [ "getrandom", ] +[[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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +dependencies = [ + "bitflags 1.3.2", +] + [[package]] name = "redox_syscall" version = "0.5.2" @@ -2335,7 +2445,6 @@ dependencies = [ "http 0.2.12", "http-body 0.4.6", "hyper 0.14.29", - "hyper-rustls 0.24.2", "ipnet", "js-sys", "log", @@ -2343,15 +2452,53 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls 0.21.12", - "rustls-pemfile 1.0.4", "serde", "serde_json", "serde_urlencoded", - "sync_wrapper", + "sync_wrapper 0.1.2", "system-configuration", "tokio", - "tokio-rustls 0.24.1", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg 0.50.0", +] + +[[package]] +name = "reqwest" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7d6d2a27d57148378eb5e111173f4276ad26340ecc5c49a4a2152167a2d6a37" +dependencies = [ + "base64 0.22.1", + "bytes", + "futures-core", + "futures-util", + "http 1.1.0", + "http-body 1.0.1", + "http-body-util", + "hyper 1.4.1", + "hyper-rustls", + "hyper-util", + "ipnet", + "js-sys", + "log", + "mime", + "once_cell", + "percent-encoding", + "pin-project-lite", + "quinn", + "rustls", + "rustls-pemfile", + "rustls-pki-types", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper 1.0.1", + "tokio", + "tokio-rustls", "tokio-util 0.7.11", "tower-service", "url", @@ -2360,7 +2507,7 @@ dependencies = [ "wasm-streams", "web-sys", "webpki-roots", - "winreg", + "winreg 0.52.0", ] [[package]] @@ -2390,6 +2537,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +[[package]] +name = "rustc-hash" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" + [[package]] name = "rustc_version" version = "0.4.0" @@ -2414,44 +2567,20 @@ dependencies = [ [[package]] name = "rustls" -version = "0.21.12" +version = "0.23.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" -dependencies = [ - "log", - "ring", - "rustls-webpki 0.101.7", - "sct", -] - -[[package]] -name = "rustls" -version = "0.23.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05cff451f60db80f490f3c182b77c35260baace73209e9cdbbe526bfe3a4d402" +checksum = "f2dabaac7466917e566adb06783a81ca48944c6898a1b08b9374106dd671f4c8" dependencies = [ "aws-lc-rs", "log", "once_cell", "ring", "rustls-pki-types", - "rustls-webpki 0.102.4", + "rustls-webpki", "subtle", "zeroize", ] -[[package]] -name = "rustls-native-certs" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" -dependencies = [ - "openssl-probe", - "rustls-pemfile 1.0.4", - "schannel", - "security-framework", -] - [[package]] name = "rustls-native-certs" version = "0.7.1" @@ -2459,21 +2588,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a88d6d420651b496bdd98684116959239430022a115c1240e6c3993be0b15fba" dependencies = [ "openssl-probe", - "rustls-pemfile 2.1.2", + "rustls-pemfile", "rustls-pki-types", "schannel", "security-framework", ] -[[package]] -name = "rustls-pemfile" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" -dependencies = [ - "base64 0.21.7", -] - [[package]] name = "rustls-pemfile" version = "2.1.2" @@ -2492,19 +2612,9 @@ checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" [[package]] name = "rustls-webpki" -version = "0.101.7" +version = "0.102.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" -dependencies = [ - "ring", - "untrusted", -] - -[[package]] -name = "rustls-webpki" -version = "0.102.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff448f7e92e913c4b7d4c6d8e4540a1724b319b4152b8aef6d4cf8339712b33e" +checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9" dependencies = [ "aws-lc-rs", "ring", @@ -2575,22 +2685,21 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" -[[package]] -name = "sct" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" -dependencies = [ - "ring", - "untrusted", -] - [[package]] name = "sdd" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a9c386cfeafd20018fe07344e72dc4787f3432911e6c35d399457d86d2f146c4" +[[package]] +name = "secrecy" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bd1c54ea06cfd2f6b63219704de0b9b4f72dcc2b8fdef820be6cd799780e91e" +dependencies = [ + "zeroize", +] + [[package]] name = "security-framework" version = "2.11.0" @@ -2957,6 +3066,12 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +[[package]] +name = "sync_wrapper" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" + [[package]] name = "system-configuration" version = "0.5.1" @@ -3133,34 +3248,13 @@ dependencies = [ "syn 2.0.68", ] -[[package]] -name = "tokio-retry" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f57eb36ecbe0fc510036adff84824dd3c24bb781e21bfa67b69d556aa85214f" -dependencies = [ - "pin-project", - "rand", - "tokio", -] - -[[package]] -name = "tokio-rustls" -version = "0.24.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" -dependencies = [ - "rustls 0.21.12", - "tokio", -] - [[package]] name = "tokio-rustls" version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ - "rustls 0.23.10", + "rustls", "rustls-pki-types", "tokio", ] @@ -3176,6 +3270,20 @@ 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.6.10" @@ -3198,7 +3306,6 @@ checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" dependencies = [ "bytes", "futures-core", - "futures-io", "futures-sink", "pin-project-lite", "tokio", @@ -3360,18 +3467,18 @@ dependencies = [ [[package]] name = "tracing-opentelemetry" -version = "0.22.0" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c67ac25c5407e7b961fafc6f7e9aa5958fd297aada2d20fa2ae1737357e55596" +checksum = "f68803492bf28ab40aeccaecc7021096bd256baf7ca77c3d425d89b35a7be4e4" dependencies = [ "js-sys", "once_cell", - "opentelemetry 0.21.0", + "opentelemetry 0.23.0", "opentelemetry_sdk", "tracing", "tracing-core", "tracing-subscriber", - "web-time 0.2.4", + "web-time", ] [[package]] @@ -3411,6 +3518,17 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" +[[package]] +name = "tryhard" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c9f0a709784e86923586cff0d872dba54cd2d2e116b3bc57587d15737cfce9d" +dependencies = [ + "futures", + "pin-project-lite", + "tokio", +] + [[package]] name = "typenum" version = "1.17.0" @@ -3426,7 +3544,7 @@ dependencies = [ "getrandom", "rand", "serde", - "web-time 1.1.0", + "web-time", ] [[package]] @@ -3505,12 +3623,6 @@ dependencies = [ "serde", ] -[[package]] -name = "urlencoding" -version = "2.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" - [[package]] name = "utf8parse" version = "0.2.2" @@ -3578,7 +3690,7 @@ dependencies = [ "indexmap 2.5.0", "jsonschema", "lazy_static", - "nkeys 0.4.4", + "nkeys", "rand", "regex", "semver", @@ -3609,7 +3721,7 @@ dependencies = [ "chrono", "clap", "futures", - "nkeys 0.4.4", + "nkeys", "opentelemetry 0.17.0", "opentelemetry-otlp", "schemars", @@ -3637,7 +3749,7 @@ dependencies = [ "async-nats", "bytes", "futures", - "nkeys 0.4.4", + "nkeys", "serde", "serde_json", "serde_yaml", @@ -3662,7 +3774,7 @@ dependencies = [ "indexmap 2.5.0", "jsonschema", "lazy_static", - "nkeys 0.4.4", + "nkeys", "rand", "regex", "schemars", @@ -3692,25 +3804,6 @@ dependencies = [ "try-lock", ] -[[package]] -name = "wascap" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "802ee1beca185fd4d61bcfd937360d1dddacc88fefa39b08209e875d99c95711" -dependencies = [ - "data-encoding", - "humantime", - "log", - "nkeys 0.3.2", - "nuid 0.4.1", - "ring", - "serde", - "serde_json", - "wasm-encoder 0.41.2", - "wasm-gen", - "wasmparser 0.121.2", -] - [[package]] name = "wascap" version = "0.15.0" @@ -3719,14 +3812,14 @@ checksum = "6d394c2c59661bff13bea8bd7c8bf30618bafa671ef9f408ae9c3aa71ede5bb0" dependencies = [ "data-encoding", "humantime", - "nkeys 0.4.4", + "nkeys", "nuid 0.4.1", "ring", "serde", "serde_json", - "wasm-encoder 0.208.1", + "wasm-encoder", "wasm-gen", - "wasmparser 0.202.0", + "wasmparser", ] [[package]] @@ -3801,15 +3894,6 @@ version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" -[[package]] -name = "wasm-encoder" -version = "0.41.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "972f97a5d8318f908dded23594188a90bcd09365986b1163e66d70170e5287ae" -dependencies = [ - "leb128", -] - [[package]] name = "wasm-encoder" version = "0.208.1" @@ -3825,7 +3909,7 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b854b1461005a7b3365742310f7faa3cac3add809d66928c64a40c7e9e842ebb" dependencies = [ - "byteorder 0.5.3", + "byteorder", "leb128", ] @@ -3844,9 +3928,9 @@ dependencies = [ [[package]] name = "wasmcloud-control-interface" -version = "1.0.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa9ce0245be791548d153536d4a849f7db9abc9340657bae00250e8a0f7f6bbc" +checksum = "6f3f68ca2a4f433d05ec51c196a176e8e70d2c0f4a7fcb58a472129760cbf0fd" dependencies = [ "anyhow", "async-nats", @@ -3855,21 +3939,21 @@ dependencies = [ "cloudevents-sdk", "futures", "oci-distribution", - "opentelemetry 0.21.0", + "opentelemetry 0.23.0", "opentelemetry_sdk", "serde", "serde_json", "tokio", "tracing", - "tracing-opentelemetry 0.22.0", + "tracing-opentelemetry 0.24.0", "wasmcloud-core", ] [[package]] name = "wasmcloud-core" -version = "0.5.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a646a51b5c4410c6bd93aecbcc98f24921c88712de4549ab64617d88fb4acb88" +checksum = "7b919220df2d9635ce9d25e25ac52c0d74a504f6e59188f61203a0dd821cb978" dependencies = [ "anyhow", "async-nats", @@ -3877,9 +3961,12 @@ dependencies = [ "bytes", "futures", "hex", - "nkeys 0.3.2", + "nkeys", "once_cell", - "rustls 0.23.10", + "provider-archive", + "rustls", + "rustls-pemfile", + "secrecy", "serde", "serde_bytes", "sha2", @@ -3887,10 +3974,9 @@ dependencies = [ "tower", "tracing", "ulid", + "url", "uuid", - "wascap 0.13.0", - "wrpc-transport", - "wrpc-transport-nats", + "wascap", ] [[package]] @@ -3902,22 +3988,11 @@ dependencies = [ "anyhow", "async-trait", "bytes", - "nkeys 0.4.4", + "nkeys", "serde", "serde_json", "thiserror", - "wascap 0.15.0", -] - -[[package]] -name = "wasmparser" -version = "0.121.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dbe55c8f9d0dbd25d9447a5a889ff90c0cc3feaa7395310d3d826b2c703eaab" -dependencies = [ - "bitflags 2.6.0", - "indexmap 2.5.0", - "semver", + "wascap", ] [[package]] @@ -3941,16 +4016,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "web-time" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa30049b1c872b72c89866d458eae9f20380ab280ffd1b1e18df2d3e2d98cfe0" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - [[package]] name = "web-time" version = "1.1.0" @@ -3963,9 +4028,12 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.25.4" +version = "0.26.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" +checksum = "bd7c23921eeb1713a4e851530e9b9756e4fb0e89978582942612524cf09f01cd" +dependencies = [ + "rustls-pki-types", +] [[package]] name = "which" @@ -4159,6 +4227,16 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "winreg" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" +dependencies = [ + "cfg-if", + "windows-sys 0.48.0", +] + [[package]] name = "wit-bindgen-core" version = "0.24.0" @@ -4226,7 +4304,7 @@ dependencies = [ "serde_derive", "serde_json", "unicode-xid", - "wasmparser 0.202.0", + "wasmparser", ] [[package]] @@ -4247,22 +4325,6 @@ dependencies = [ "wrpc-types", ] -[[package]] -name = "wrpc-transport-nats" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7a40219678cc9e65164487ff3540cddc463d2040950f010bd1d8ce27c8c9a6c" -dependencies = [ - "anyhow", - "async-nats", - "bytes", - "futures", - "tokio", - "tower", - "tracing", - "wrpc-transport", -] - [[package]] name = "wrpc-types" version = "0.6.0" @@ -4299,17 +4361,3 @@ name = "zeroize" version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" -dependencies = [ - "zeroize_derive", -] - -[[package]] -name = "zeroize_derive" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.68", -] diff --git a/Cargo.toml b/Cargo.toml index e6ebefbd..03994389 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,7 +47,7 @@ wadm-types = { workspace = true } [workspace.dependencies] anyhow = "1" -async-nats = "0.33" +async-nats = "0.36" async-trait = "0.1" base64 = "0.22.1" bytes = "1" @@ -86,7 +86,7 @@ uuid = "1" wadm = { version = "0.15.0", path = "./crates/wadm" } wadm-client = { version = "0.4.0", path = "./crates/wadm-client" } wadm-types = { version = "0.4.0", path = "./crates/wadm-types" } -wasmcloud-control-interface = "1.0.0" +wasmcloud-control-interface = { version = "2.0.0" } wasmcloud-secrets-types = "0.2.0" wit-bindgen-wrpc = { version = "0.3.7", default-features = false } diff --git a/crates/wadm-types/src/bindings.rs b/crates/wadm-types/src/bindings.rs index 36be6fe9..c58a546f 100644 --- a/crates/wadm-types/src/bindings.rs +++ b/crates/wadm-types/src/bindings.rs @@ -214,8 +214,8 @@ impl From for wadm::types::ModelSummary { version: summary.version, description: summary.description, deployed_version: summary.deployed_version, - status: summary.status.into(), - status_message: summary.status_message, + status: summary.detailed_status.info.status_type.into(), + status_message: Some(summary.detailed_status.info.message), } } } diff --git a/crates/wadm/src/commands/mod.rs b/crates/wadm/src/commands/mod.rs index 4e1df86d..93514a28 100644 --- a/crates/wadm/src/commands/mod.rs +++ b/crates/wadm/src/commands/mod.rs @@ -6,7 +6,7 @@ use std::{ }; use serde::{Deserialize, Serialize}; -use wasmcloud_control_interface::InterfaceLinkDefinition; +use wasmcloud_control_interface::Link; use crate::{ events::{ComponentScaleFailed, ComponentScaled, Event, ProviderStartFailed, ProviderStarted}, @@ -235,9 +235,9 @@ pub struct PutLink { pub model_name: String, } -impl From for InterfaceLinkDefinition { - fn from(value: PutLink) -> InterfaceLinkDefinition { - InterfaceLinkDefinition { +impl From for Link { + fn from(value: PutLink) -> Link { + Link { source_id: value.source_id, target: value.target, name: value.name, diff --git a/crates/wadm/src/events/types.rs b/crates/wadm/src/events/types.rs index 111bd2b4..a06c70d6 100644 --- a/crates/wadm/src/events/types.rs +++ b/crates/wadm/src/events/types.rs @@ -11,9 +11,7 @@ use std::{ use cloudevents::{AttributesReader, Data, Event as CloudEvent, EventBuilder, EventBuilderV10}; use serde::{Deserialize, Serialize}; use thiserror::Error; -use wasmcloud_control_interface::{ - ComponentDescription, InterfaceLinkDefinition, ProviderDescription, -}; +use wasmcloud_control_interface::{ComponentDescription, Link, ProviderDescription}; use wadm_types::Manifest; @@ -424,7 +422,7 @@ event_impl!( #[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)] pub struct LinkdefSet { #[serde(flatten)] - pub linkdef: InterfaceLinkDefinition, + pub linkdef: Link, } event_impl!(LinkdefSet, "com.wasmcloud.lattice.linkdef_set"); diff --git a/crates/wadm/src/scaler/daemonscaler/mod.rs b/crates/wadm/src/scaler/daemonscaler/mod.rs index 617993d2..ea4a3b68 100644 --- a/crates/wadm/src/scaler/daemonscaler/mod.rs +++ b/crates/wadm/src/scaler/daemonscaler/mod.rs @@ -357,10 +357,10 @@ mod test { sync::Arc, }; - use anyhow::Result; + use anyhow::{anyhow, Result}; use chrono::Utc; use wadm_types::{api::StatusType, Spread, SpreadScalerProperty}; - use wasmcloud_control_interface::{HostInventory, InterfaceLinkDefinition}; + use wasmcloud_control_interface::{HostInventory, Link}; use crate::{ commands::Command, @@ -794,20 +794,19 @@ mod test { // Inserting for heartbeat handling later lattice_source.inventory.write().await.insert( host_id_three.to_string(), - HostInventory { - components: vec![], - friendly_name: "hey".to_string(), - labels: HashMap::from_iter([ + HostInventory::builder() + .friendly_name("hey".into()) + .labels(BTreeMap::from_iter([ ("cloud".to_string(), "purgatory".to_string()), ("location".to_string(), "edge".to_string()), ("region".to_string(), "us-brooks-1".to_string()), - ]), - providers: vec![], - host_id: host_id_three.to_string(), - version: "1.0.0".to_string(), - uptime_human: "what is time really anyway maaaan".to_string(), - uptime_seconds: 42, - }, + ])) + .host_id(host_id_three.into()) + .version("1.0.0".into()) + .uptime_human("what is time really anyway maaaan".into()) + .uptime_seconds(42) + .build() + .map_err(|e| anyhow!("failed to build host inventory: {e}"))?, ); let command_publisher = CommandPublisher::new(NoopPublisher, "doesntmatter"); let status_publisher = StatusPublisher::new(NoopPublisher, None, "doesntmatter"); @@ -957,7 +956,7 @@ mod test { .is_empty()); assert!(blobby_daemonscaler .handle_event(&Event::LinkdefSet(LinkdefSet { - linkdef: InterfaceLinkDefinition::default() + linkdef: Link::default() })) .await? .is_empty()); diff --git a/crates/wadm/src/scaler/spreadscaler/link.rs b/crates/wadm/src/scaler/spreadscaler/link.rs index 7b6206a4..9421ae9a 100644 --- a/crates/wadm/src/scaler/spreadscaler/link.rs +++ b/crates/wadm/src/scaler/spreadscaler/link.rs @@ -149,12 +149,15 @@ where ( true, // TODO(#88): reverse compare too - // Ensure all named configs are the same - linkdef.source_config.iter().all(|config_name| { - self.config.source_config.iter().any(|c| c == config_name) - }) || linkdef.target_config.iter().all(|config_name| { - self.config.target_config.iter().any(|c| c == config_name) - }), + // Ensure all supplied configs (both source and target) are the same + linkdef + .source_config + .iter() + .eq(self.config.source_config.iter()) + && linkdef + .target_config + .iter() + .eq(self.config.target_config.iter()), ) }) .unwrap_or((false, false)); @@ -275,7 +278,7 @@ mod test { vec, }; - use wasmcloud_control_interface::InterfaceLinkDefinition; + use wasmcloud_control_interface::Link; use chrono::Utc; @@ -427,7 +430,7 @@ mod test { let provider_ref = "provider_ref".to_string(); let provider_id = "provider".to_string(); - let linkdef = InterfaceLinkDefinition { + let linkdef = Link { source_id: component_id.to_string(), target: provider_id.to_string(), wit_namespace: "namespace".to_string(), @@ -580,7 +583,7 @@ mod test { let commands = link_scaler .handle_event(&Event::LinkdefSet(LinkdefSet { - linkdef: InterfaceLinkDefinition { + linkdef: Link { // NOTE: contract, link, and provider id matches but the component is different source_id: "nm0001772".to_string(), target: "VASDASD".to_string(), diff --git a/crates/wadm/src/scaler/spreadscaler/mod.rs b/crates/wadm/src/scaler/spreadscaler/mod.rs index 6175b8d2..eda37148 100644 --- a/crates/wadm/src/scaler/spreadscaler/mod.rs +++ b/crates/wadm/src/scaler/spreadscaler/mod.rs @@ -482,7 +482,7 @@ mod test { use anyhow::Result; use chrono::Utc; use wadm_types::{Spread, SpreadScalerProperty}; - use wasmcloud_control_interface::InterfaceLinkDefinition; + use wasmcloud_control_interface::Link; use crate::{ commands::Command, @@ -1499,7 +1499,7 @@ mod test { .is_empty()); assert!(blobby_spreadscaler .handle_event(&Event::LinkdefSet(LinkdefSet { - linkdef: InterfaceLinkDefinition::default() + linkdef: Link::default() })) .await? .is_empty()); diff --git a/crates/wadm/src/storage/snapshot.rs b/crates/wadm/src/storage/snapshot.rs index e4d7426b..2a567da6 100644 --- a/crates/wadm/src/storage/snapshot.rs +++ b/crates/wadm/src/storage/snapshot.rs @@ -3,7 +3,7 @@ use std::sync::Arc; use tokio::sync::RwLock; use tracing::debug; -use wasmcloud_control_interface::InterfaceLinkDefinition; +use wasmcloud_control_interface::Link; use wasmcloud_secrets_types::SecretConfig; use crate::storage::{Component, Host, Provider, ReadStore, StateKind}; @@ -28,7 +28,7 @@ pub struct SnapshotStore { lattice_source: L, lattice_id: String, stored_state: Arc>, - links: Arc>>, + links: Arc>>, } impl Clone for SnapshotStore @@ -165,7 +165,7 @@ where S: Send + Sync, L: Send + Sync, { - async fn get_links(&self) -> anyhow::Result> { + async fn get_links(&self) -> anyhow::Result> { Ok(self.links.read().await.clone()) } } diff --git a/crates/wadm/src/storage/state.rs b/crates/wadm/src/storage/state.rs index d701f5e3..4f9be121 100644 --- a/crates/wadm/src/storage/state.rs +++ b/crates/wadm/src/storage/state.rs @@ -286,8 +286,8 @@ impl From for Host { .into_iter() .map(|component| { ( - component.id, // SAFETY: Unlikely to not fit into a usize, but fallback just in case - component.max_instances.try_into().unwrap_or(usize::MAX), + component.id().into(), // SAFETY: Unlikely to not fit into a usize, but fallback just in case + component.max_instances().try_into().unwrap_or(usize::MAX), ) }) .collect(); @@ -326,9 +326,9 @@ impl From<&HostHeartbeat> for Host { .iter() .map(|component| { ( - component.id.to_owned(), + component.id().to_owned(), // SAFETY: Unlikely to not fit into a usize, but fallback just in case - component.max_instances.try_into().unwrap_or(usize::MAX), + component.max_instances().try_into().unwrap_or(usize::MAX), ) }) .collect(); diff --git a/crates/wadm/src/test_util.rs b/crates/wadm/src/test_util.rs index db587305..313e1b19 100644 --- a/crates/wadm/src/test_util.rs +++ b/crates/wadm/src/test_util.rs @@ -3,7 +3,7 @@ use std::{collections::HashMap, sync::Arc}; use serde::{de::DeserializeOwned, Serialize}; use tokio::sync::RwLock; -use wasmcloud_control_interface::{HostInventory, InterfaceLinkDefinition}; +use wasmcloud_control_interface::{HostInventory, Link}; use wasmcloud_secrets_types::SecretConfig; use crate::publisher::Publisher; @@ -111,7 +111,7 @@ impl crate::storage::Store for TestStore { pub struct TestLatticeSource { pub claims: HashMap, pub inventory: Arc>>, - pub links: Vec, + pub links: Vec, pub config: HashMap>, } @@ -131,7 +131,7 @@ impl InventorySource for TestLatticeSource { #[async_trait::async_trait] impl LinkSource for TestLatticeSource { - async fn get_links(&self) -> anyhow::Result> { + async fn get_links(&self) -> anyhow::Result> { Ok(self.links.clone()) } } diff --git a/crates/wadm/src/workers/command.rs b/crates/wadm/src/workers/command.rs index ba571092..91861a6d 100644 --- a/crates/wadm/src/workers/command.rs +++ b/crates/wadm/src/workers/command.rs @@ -101,9 +101,11 @@ impl Worker for CommandWorker { .map_err(|e| anyhow::anyhow!("{e:?}")); match res { - Ok(ack) if !ack.success => { + Ok(ack) if !ack.succeeded() => { message.nack().await; - Err(WorkError::Other(anyhow::anyhow!("{}", ack.message).into())) + Err(WorkError::Other( + anyhow::anyhow!("{}", ack.message()).into(), + )) } Ok(_) => message.ack().await.map_err(WorkError::from), Err(e) => { diff --git a/crates/wadm/src/workers/event.rs b/crates/wadm/src/workers/event.rs index edf287fd..579c101a 100644 --- a/crates/wadm/src/workers/event.rs +++ b/crates/wadm/src/workers/event.rs @@ -495,46 +495,49 @@ where .into_iter() .map(|component_description| { let instance = HashSet::from_iter([WadmComponentInfo { - count: component_description.max_instances as usize, + count: component_description.max_instances() as usize, annotations: component_description - .annotations - .map(|a| a.into_iter().collect()) + .annotations() + .map(|a| a.clone()) .unwrap_or_default(), }]); - if let Some(component) = components.get(&component_description.id) { + if let Some(component) = components.get(component_description.id()) { // Construct modified Component with new instances included let mut new_instances = component.instances.clone(); new_instances.insert(host_id.to_owned(), instance); let component = Component { instances: new_instances, - reference: component_description.image_ref, - name: component_description.name.unwrap_or(component.name.clone()), + reference: component_description.image_ref().into(), + name: component_description + .name() + .unwrap_or(&component.name) + .into(), ..component.clone() }; - (component_description.id, component) - } else if let Some(claim) = claims.get(&component_description.id) { + (component_description.id().to_string(), component) + } else if let Some(claim) = claims.get(component_description.id()) { ( - component_description.id.clone(), + component_description.id().to_string(), Component { - id: component_description.id, + id: component_description.id().into(), name: claim.name.to_owned(), issuer: claim.issuer.to_owned(), instances: HashMap::from_iter([(host_id.to_owned(), instance)]), - reference: component_description.image_ref, + reference: component_description.image_ref().into(), }, ) } else { debug!("Claims not found for component on host, component is unsigned"); ( - component_description.id.clone(), + component_description.id().to_string(), Component { - id: component_description.id, + id: component_description.id().into(), name: "".to_owned(), issuer: "".to_owned(), instances: HashMap::from_iter([(host_id.to_owned(), instance)]), - reference: component_description.image_ref, + reference: component_description.image_ref().into(), }, ) } @@ -558,12 +561,12 @@ where .iter() .filter_map(|component_description| { if components - .get(&component_description.id) + .get(component_description.id()) // NOTE(brooksmtownsend): This code maps the component to a boolean indicating if it's up-to-date with the heartbeat or not. // If the component matches what the heartbeat says, we return None, otherwise we return Some(component_description). .map(|component| { // If the stored reference isn't what we receive on the heartbeat, update - component_description.image_ref == component.reference + component_description.image_ref() == component.reference && component .instances .get(&host.host_id) @@ -575,14 +578,14 @@ where // Update if annotations or counts are different let annotations: BTreeMap = component_description - .annotations - .clone() + .annotations() + .cloned() .map(|a| a.into_iter().collect()) .unwrap_or_default(); store_instances.get(&annotations).map_or( false, |store_instance| { - component_description.max_instances as usize + component_description.max_instances() as usize == store_instance.count }, ) @@ -1074,8 +1077,8 @@ mod test { .await, ); - let host1_id = "DS1".to_string(); - let host2_id = "starkiller".to_string(); + let host1_id = "DS1"; + let host2_id = "starkiller"; /***********************************************************/ /******************** Host Start Tests *********************/ @@ -1086,7 +1089,7 @@ mod test { lattice_id, &HostStarted { friendly_name: "death-star-42".to_string(), - id: host1_id.clone(), + id: host1_id.into(), labels: labels.clone(), }, ) @@ -1113,7 +1116,7 @@ mod test { lattice_id, &HostStarted { friendly_name: "starkiller-base-2015".to_string(), - id: host2_id.clone(), + id: host2_id.into(), labels: labels2.clone(), }, ) @@ -1155,7 +1158,7 @@ mod test { }), image_ref: "coruscant.galactic.empire/tarkin:0.1.0".into(), component_id: "TARKIN".into(), - host_id: host1_id.clone(), + host_id: host1_id.into(), annotations: BTreeMap::default(), max_instances: 500, }; @@ -1168,14 +1171,14 @@ mod test { .get("TARKIN") .expect("Component should exist in state"); let hosts = store.list::(lattice_id).await.unwrap(); - let host = hosts.get(&host1_id).expect("Host should exist in state"); + let host = hosts.get(host1_id).expect("Host should exist in state"); assert_eq!( host.components.get(&component1_scaled.component_id), Some(&500), "Component count in host should be updated" ); assert_eq!( - component.count_for_host(&host1_id), + component.count_for_host(host1_id), 500, "Component count should be modified with an increase in scale" ); @@ -1190,7 +1193,7 @@ mod test { }), image_ref: "coruscant.galactic.empire/tarkin:0.1.0".into(), component_id: "TARKIN".into(), - host_id: host1_id.clone(), + host_id: host1_id.into(), annotations: BTreeMap::default(), max_instances: 200, }; @@ -1203,14 +1206,14 @@ mod test { .get("TARKIN") .expect("Component should exist in state"); let hosts = store.list::(lattice_id).await.unwrap(); - let host = hosts.get(&host1_id).expect("Host should exist in state"); + let host = hosts.get(host1_id).expect("Host should exist in state"); assert_eq!( host.components.get(&component1_scaled.component_id), Some(&200), "Component count in host should be updated" ); assert_eq!( - component.count_for_host(&host1_id), + component.count_for_host(host1_id), 200, "Component count should be modified with a decrease in scale" ); @@ -1225,7 +1228,7 @@ mod test { }), image_ref: "coruscant.galactic.empire/tarkin:0.1.0".into(), component_id: "TARKIN".into(), - host_id: host1_id.clone(), + host_id: host1_id.into(), annotations: BTreeMap::default(), max_instances: 0, }; @@ -1235,7 +1238,7 @@ mod test { .expect("Should be able to handle component event"); let components = store.list::(lattice_id).await.unwrap(); let hosts = store.list::(lattice_id).await.unwrap(); - let host = hosts.get(&host1_id).expect("Host should exist in state"); + let host = hosts.get(host1_id).expect("Host should exist in state"); assert_eq!( host.components.get(&component1_scaled.component_id), None, @@ -1256,7 +1259,7 @@ mod test { }), image_ref: "coruscant.galactic.empire/tarkin:0.1.0".into(), component_id: "TARKIN".into(), - host_id: host1_id.clone(), + host_id: host1_id.into(), annotations: BTreeMap::default(), max_instances: 1, }; @@ -1269,14 +1272,14 @@ mod test { .get("TARKIN") .expect("Component should exist in state"); let hosts = store.list::(lattice_id).await.unwrap(); - let host = hosts.get(&host1_id).expect("Host should exist in state"); + let host = hosts.get(host1_id).expect("Host should exist in state"); assert_eq!( host.components.get(&component1_scaled.component_id), Some(&1), "Component in host should be readded from scratch" ); assert_eq!( - component.count_for_host(&host1_id), + component.count_for_host(host1_id), 1, "Component count should be modified with an initial start" ); @@ -1284,7 +1287,7 @@ mod test { .handle_component_scaled( lattice_id, &ComponentScaled { - host_id: host2_id.clone(), + host_id: host2_id.into(), ..component1_scaled.clone() }, ) @@ -1300,7 +1303,7 @@ mod test { ..Default::default() }), image_ref: "coruscant.galactic.empire/vader:0.1.0".into(), - host_id: host1_id.clone(), + host_id: host1_id.into(), component_id: "DARTHVADER".into(), annotations: BTreeMap::default(), max_instances: 2, @@ -1314,7 +1317,7 @@ mod test { .handle_component_scaled( lattice_id, &ComponentScaled { - host_id: host2_id.clone(), + host_id: host2_id.into(), ..component2_scaled.clone() }, ) @@ -1334,7 +1337,7 @@ mod test { }), image_ref: "coruscant.galactic.empire/force_choke:0.1.0".into(), provider_id: "CHOKE".into(), - host_id: host1_id.clone(), + host_id: host1_id.into(), annotations: BTreeMap::default(), }; @@ -1347,7 +1350,7 @@ mod test { }), image_ref: "coruscant.galactic.empire/laser:0.1.0".into(), provider_id: "BYEBYEALDERAAN".into(), - host_id: host2_id.clone(), + host_id: host2_id.into(), annotations: BTreeMap::default(), }; @@ -1357,7 +1360,7 @@ mod test { .expect("Should be able to handle provider event"); let providers = store.list::(lattice_id).await.unwrap(); assert_eq!(providers.len(), 1, "Should only be 1 provider in state"); - assert_provider(&providers, &provider1, &[&host1_id]); + assert_provider(&providers, &provider1, &[host1_id]); // Now start the second provider on both hosts (so we can test some things in the next test) worker @@ -1368,7 +1371,7 @@ mod test { .handle_provider_started( lattice_id, &ProviderStarted { - host_id: host1_id.clone(), + host_id: host1_id.into(), provider_id: provider2.provider_id.clone(), ..provider2.clone() }, @@ -1377,12 +1380,12 @@ mod test { .expect("Should be able to handle provider event"); let providers = store.list::(lattice_id).await.unwrap(); assert_eq!(providers.len(), 2, "Should only be 2 providers in state"); - assert_provider(&providers, &provider2, &[&host1_id, &host2_id]); + assert_provider(&providers, &provider2, &[host1_id, host2_id]); // Check that hosts got updated properly let hosts = store.list::(lattice_id).await.unwrap(); assert_eq!(hosts.len(), 2, "Should only have 2 hosts"); - let host = hosts.get(&host1_id).expect("Host should still exist"); + let host = hosts.get(host1_id).expect("Host should still exist"); assert_eq!( host.components.len(), 2, @@ -1393,7 +1396,7 @@ mod test { 2, "Should have two different providers running" ); - let host = hosts.get(&host2_id).expect("Host should still exist"); + let host = hosts.get(host2_id).expect("Host should still exist"); assert_eq!( host.components.len(), 2, @@ -1405,32 +1408,30 @@ mod test { "Should have a single provider running" ); - let component_1_id = "TARKIN".to_string(); - let component_2_id = "DARTHVADER".to_string(); + let component_1_id = "TARKIN"; + let component_2_id = "DARTHVADER"; worker .handle_host_heartbeat( lattice_id, &HostHeartbeat { components: vec![ - ComponentDescription { - id: component_1_id.to_string(), - image_ref: "ref1".to_string(), - annotations: None, - revision: 0, - max_instances: 2, - name: None, - }, - ComponentDescription { - id: component_2_id.to_string(), - image_ref: "ref2".to_string(), - annotations: None, - revision: 0, - max_instances: 2, - name: None, - }, + ComponentDescription::builder() + .id(component_1_id.into()) + .revision(0) + .image_ref("ref1".into()) + .max_instances(2) + .build() + .expect("failed to build description"), + ComponentDescription::builder() + .id(component_2_id.into()) + .revision(0) + .image_ref("ref2".into()) + .max_instances(2) + .build() + .expect("failed to build description"), ], - friendly_name: "death-star-42".to_string(), + friendly_name: "death-star-42".into(), labels: labels.clone(), issuer: "".to_string(), providers: vec![ @@ -1452,7 +1453,7 @@ mod test { uptime_human: "30s".into(), uptime_seconds: 30, version: semver::Version::parse("0.61.0").unwrap(), - host_id: host1_id.clone(), + host_id: host1_id.into(), }, ) .await @@ -1463,22 +1464,20 @@ mod test { lattice_id, &HostHeartbeat { components: vec![ - ComponentDescription { - id: component_1_id.to_string(), - image_ref: "ref1".to_string(), - annotations: None, - revision: 0, - max_instances: 2, - name: None, - }, - ComponentDescription { - id: component_2_id.to_string(), - image_ref: "ref2".to_string(), - annotations: None, - revision: 0, - max_instances: 2, - name: None, - }, + ComponentDescription::builder() + .id(component_1_id.into()) + .image_ref("ref1".into()) + .revision(0) + .max_instances(2) + .build() + .expect("failed to build description"), + ComponentDescription::builder() + .id(component_2_id.into()) + .image_ref("ref2".into()) + .revision(0) + .max_instances(2) + .build() + .expect("failed to build description"), ], issuer: "".to_string(), friendly_name: "starkiller-base-2015".to_string(), @@ -1493,7 +1492,7 @@ mod test { uptime_human: "30s".into(), uptime_seconds: 30, version: semver::Version::parse("0.61.0").unwrap(), - host_id: host2_id.clone(), + host_id: host2_id.into(), }, ) .await @@ -1502,8 +1501,8 @@ mod test { // Check that our component and provider data is still correct. let providers = store.list::(lattice_id).await.unwrap(); assert_eq!(providers.len(), 2, "Should still have 2 providers in state"); - assert_provider(&providers, &provider1, &[&host1_id]); - assert_provider(&providers, &provider2, &[&host1_id, &host2_id]); + assert_provider(&providers, &provider1, &[host1_id]); + assert_provider(&providers, &provider2, &[host1_id, host2_id]); let components = store.list::(lattice_id).await.unwrap(); assert_eq!( @@ -1514,12 +1513,12 @@ mod test { assert_component( &components, &component_1_id, - &[(&host1_id, 2), (&host2_id, 2)], + &[(host1_id, 2), (host2_id, 2)], ); assert_component( &components, &component_2_id, - &[(&host1_id, 2), (&host2_id, 2)], + &[(host1_id, 2), (host2_id, 2)], ); /***********************************************************/ @@ -1531,8 +1530,8 @@ mod test { claims: None, image_ref: "coruscant.galactic.empire/tarkin:0.1.0".into(), annotations: BTreeMap::default(), - component_id: component_1_id.clone(), - host_id: host1_id.clone(), + component_id: component_1_id.into(), + host_id: host1_id.into(), max_instances: 0, }; @@ -1547,24 +1546,24 @@ mod test { 2, "Should still have 2 components in state" ); - assert_component(&components, &component_1_id, &[(&host2_id, 2)]); + assert_component(&components, &component_1_id, &[(host2_id, 2)]); assert_component( &components, &component_2_id, - &[(&host1_id, 2), (&host2_id, 2)], + &[(host1_id, 2), (host2_id, 2)], ); let host = store - .get::(lattice_id, &host2_id) + .get::(lattice_id, host2_id) .await .expect("Should be able to access store") .expect("Should have the host in the store"); - assert_eq!(*host.components.get(&component_1_id).unwrap_or(&0), 2_usize); - assert_eq!(*host.components.get(&component_2_id).unwrap_or(&0), 2_usize); + assert_eq!(*host.components.get(component_1_id).unwrap_or(&0), 2_usize); + assert_eq!(*host.components.get(component_2_id).unwrap_or(&0), 2_usize); // Now stop on the other let stopped2 = ComponentScaled { - host_id: host2_id.clone(), + host_id: host2_id.into(), ..stopped }; @@ -1579,7 +1578,7 @@ mod test { assert_component( &components, &component_2_id, - &[(&host1_id, 2), (&host2_id, 2)], + &[(host1_id, 2), (host2_id, 2)], ); /***********************************************************/ @@ -1593,7 +1592,7 @@ mod test { annotations: BTreeMap::default(), provider_id: provider2.provider_id.clone(), reason: String::new(), - host_id: host1_id.clone(), + host_id: host1_id.into(), }, ) .await @@ -1601,16 +1600,16 @@ mod test { let providers = store.list::(lattice_id).await.unwrap(); assert_eq!(providers.len(), 2, "Should still have 2 providers in state"); - assert_provider(&providers, &provider1, &[&host1_id]); - assert_provider(&providers, &provider2, &[&host2_id]); + assert_provider(&providers, &provider1, &[host1_id]); + assert_provider(&providers, &provider2, &[host2_id]); // Check that hosts got updated properly let hosts = store.list::(lattice_id).await.unwrap(); assert_eq!(hosts.len(), 2, "Should only have 2 hosts"); - let host = hosts.get(&host1_id).expect("Host should still exist"); + let host = hosts.get(host1_id).expect("Host should still exist"); assert_eq!(host.components.len(), 1, "Should have 1 component running"); assert_eq!(host.providers.len(), 1, "Should have 1 provider running"); - let host = hosts.get(&host2_id).expect("Host should still exist"); + let host = hosts.get(host2_id).expect("Host should still exist"); assert_eq!(host.components.len(), 1, "Should have 1 component running"); assert_eq!( host.providers.len(), @@ -1627,43 +1626,39 @@ mod test { *inventory.write().await = HashMap::from_iter([ ( host1_id.to_string(), - HostInventory { - friendly_name: "my-host-3".to_string(), - components: vec![ComponentDescription { - id: component_2_id.to_string(), - image_ref: "ref2".to_string(), - annotations: None, - revision: 0, - max_instances: 2, - name: None, - }], - host_id: host1_id.to_string(), - labels: HashMap::new(), - providers: vec![], - version: semver::Version::parse("0.61.0").unwrap().to_string(), - uptime_human: "60s".into(), - uptime_seconds: 60, - }, + HostInventory::builder() + .friendly_name("my-host-3".into()) + .components(vec![ComponentDescription::builder() + .id(component_2_id.into()) + .image_ref("ref2".into()) + .revision(0) + .max_instances(2) + .build() + .expect("failed to build description")]) + .host_id(host1_id.into()) + .version(semver::Version::parse("0.61.0").unwrap().to_string()) + .uptime_human("60s".into()) + .uptime_seconds(60) + .build() + .expect("failed to build host inventory"), ), ( host2_id.to_string(), - HostInventory { - friendly_name: "my-host-4".to_string(), - components: vec![ComponentDescription { - id: component_2_id.to_string(), - image_ref: "ref2".to_string(), - annotations: None, - revision: 0, - max_instances: 2, - name: None, - }], - host_id: host2_id.to_string(), - labels: HashMap::new(), - providers: vec![], - version: semver::Version::parse("1.2.3").unwrap().to_string(), - uptime_human: "100s".into(), - uptime_seconds: 100, - }, + HostInventory::builder() + .friendly_name("my-host-4".into()) + .components(vec![ComponentDescription::builder() + .id(component_2_id.into()) + .image_ref("ref2".into()) + .revision(0) + .max_instances(2) + .build() + .expect("failed to build description")]) + .host_id(host2_id.into()) + .version(semver::Version::parse("1.2.3").unwrap().to_string()) + .uptime_human("100s".into()) + .uptime_seconds(100) + .build() + .expect("failed to build host inventory"), ), ]); @@ -1672,14 +1667,13 @@ mod test { .handle_host_heartbeat( lattice_id, &HostHeartbeat { - components: vec![ComponentDescription { - id: component_2_id.to_string(), - image_ref: "ref2".to_string(), - annotations: None, - revision: 0, - max_instances: 2, - name: None, - }], + components: vec![ComponentDescription::builder() + .id(component_2_id.into()) + .image_ref("ref2".into()) + .revision(0) + .max_instances(2) + .build() + .expect("failed to build description")], friendly_name: "death-star-42".to_string(), issuer: "".to_string(), labels, @@ -1693,7 +1687,7 @@ mod test { uptime_human: "60s".into(), uptime_seconds: 60, version: semver::Version::parse("0.61.0").unwrap(), - host_id: host1_id.clone(), + host_id: host1_id.into(), }, ) .await @@ -1703,14 +1697,13 @@ mod test { .handle_host_heartbeat( lattice_id, &HostHeartbeat { - components: vec![ComponentDescription { - id: component_2_id.to_string(), - image_ref: "ref2".to_string(), - annotations: None, - revision: 0, - max_instances: 2, - name: None, - }], + components: vec![ComponentDescription::builder() + .id(component_2_id.into()) + .image_ref("ref2".into()) + .revision(0) + .max_instances(2) + .build() + .expect("failed to build description")], friendly_name: "starkiller-base-2015".to_string(), labels: labels2, issuer: "".to_string(), @@ -1724,7 +1717,7 @@ mod test { uptime_human: "60s".into(), uptime_seconds: 60, version: semver::Version::parse("0.61.0").unwrap(), - host_id: host2_id.clone(), + host_id: host2_id.into(), }, ) .await @@ -1733,10 +1726,10 @@ mod test { // Check that the heartbeat kept state consistent let hosts = store.list::(lattice_id).await.unwrap(); assert_eq!(hosts.len(), 2, "Should only have 2 hosts"); - let host = hosts.get(&host1_id).expect("Host should still exist"); + let host = hosts.get(host1_id).expect("Host should still exist"); assert_eq!(host.components.len(), 1, "Should have 1 component running"); assert_eq!(host.providers.len(), 1, "Should have 1 provider running"); - let host = hosts.get(&host2_id).expect("Host should still exist"); + let host = hosts.get(host2_id).expect("Host should still exist"); assert_eq!(host.components.len(), 1, "Should have 1 component running"); assert_eq!( host.providers.len(), @@ -1750,13 +1743,13 @@ mod test { assert_component( &components, &component_2_id, - &[(&host1_id, 2), (&host2_id, 2)], + &[(host1_id, 2), (host2_id, 2)], ); let providers = store.list::(lattice_id).await.unwrap(); assert_eq!(providers.len(), 2, "Should still have 2 providers in state"); - assert_provider(&providers, &provider1, &[&host1_id]); - assert_provider(&providers, &provider2, &[&host2_id]); + assert_provider(&providers, &provider1, &[host1_id]); + assert_provider(&providers, &provider2, &[host2_id]); /***********************************************************/ /********************* Host Stop Tests *********************/ @@ -1767,7 +1760,7 @@ mod test { lattice_id, &HostStopped { labels: HashMap::default(), - id: host1_id.clone(), + id: host1_id.into(), }, ) .await @@ -1775,7 +1768,7 @@ mod test { let hosts = store.list::(lattice_id).await.unwrap(); assert_eq!(hosts.len(), 1, "Should only have 1 host"); - let host = hosts.get(&host2_id).expect("Host should still exist"); + let host = hosts.get(host2_id).expect("Host should still exist"); assert_eq!(host.components.len(), 1, "Should have 1 component running"); assert_eq!( host.providers.len(), @@ -1786,23 +1779,23 @@ mod test { // Double check providers and components are the same let components = store.list::(lattice_id).await.unwrap(); assert_eq!(components.len(), 1, "Should only have 1 component in state"); - assert_component(&components, &component_2_id, &[(&host2_id, 2)]); + assert_component(&components, &component_2_id, &[(host2_id, 2)]); let providers = store.list::(lattice_id).await.unwrap(); assert_eq!(providers.len(), 1, "Should now have 1 provider in state"); - assert_provider(&providers, &provider2, &[&host2_id]); + assert_provider(&providers, &provider2, &[host2_id]); } #[tokio::test] async fn test_discover_running_host() { - let component1_id = "SKYWALKER".to_string(); - let component1_ref = "fakecloud.io/skywalker:0.1.0".to_string(); - let component2_id = "ORGANA".to_string(); - let component2_ref = "fakecloud.io/organa:0.1.0".to_string(); + let component1_id = "SKYWALKER"; + let component1_ref = "fakecloud.io/skywalker:0.1.0"; + let component2_id = "ORGANA"; + let component2_ref = "fakecloud.io/organa:0.1.0"; let lattice_id = "discover_running_host"; let claims = HashMap::from([ ( - component1_id.clone(), + component1_id.into(), Claims { name: "tosche_station".to_string(), capabilities: vec!["wasmcloud:httpserver".to_string()], @@ -1810,7 +1803,7 @@ mod test { }, ), ( - component2_id.clone(), + component2_id.into(), Claims { name: "alderaan".to_string(), capabilities: vec!["wasmcloud:keyvalue".to_string()], @@ -1843,45 +1836,43 @@ mod test { .await, ); - let provider_id = "HYPERDRIVE".to_string(); - let host_id = "WHATAPIECEOFJUNK".to_string(); + let provider_id = "HYPERDRIVE"; + let host_id = "WHATAPIECEOFJUNK"; // NOTE(brooksmtownsend): Painful manual manipulation of host inventory // to satisfy the way we currently query the inventory when handling heartbeats. *inventory.write().await = HashMap::from_iter([( host_id.to_string(), - HostInventory { - friendly_name: "my-host-5".to_string(), - components: vec![ - ComponentDescription { - id: component1_id.to_string(), - image_ref: component1_ref.to_string(), - annotations: None, - revision: 0, - max_instances: 2, - name: None, - }, - ComponentDescription { - id: component2_id.to_string(), - image_ref: component2_ref.to_string(), - annotations: None, - revision: 0, - max_instances: 1, - name: None, - }, - ], - host_id: host_id.to_string(), - labels: HashMap::new(), - providers: vec![ProviderDescription { - id: provider_id.clone(), + HostInventory::builder() + .friendly_name("my-host-5".into()) + .components(vec![ + ComponentDescription::builder() + .id(component1_id.into()) + .image_ref(component1_ref.into()) + .revision(0) + .max_instances(2) + .build() + .expect("failed to build description"), + ComponentDescription::builder() + .id(component2_id.into()) + .image_ref(component2_ref.into()) + .revision(0) + .max_instances(1) + .build() + .expect("failed to build description"), + ]) + .host_id(host_id.into()) + .providers(vec![ProviderDescription { + id: provider_id.into(), annotations: None, image_ref: None, name: None, revision: 0, - }], - version: semver::Version::parse("0.61.0").unwrap().to_string(), - uptime_human: "60s".into(), - uptime_seconds: 60, - }, + }]) + .version(semver::Version::parse("0.61.0").unwrap().to_string()) + .uptime_human("60s".into()) + .uptime_seconds(60) + .build() + .expect("failed to build host inventory"), )]); // Heartbeat with components and providers that don't exist in the store yet @@ -1890,28 +1881,26 @@ mod test { lattice_id, &HostHeartbeat { components: vec![ - ComponentDescription { - id: component1_id.to_string(), - image_ref: component1_ref.to_string(), - annotations: None, - revision: 0, - max_instances: 2, - name: None, - }, - ComponentDescription { - id: component2_id.to_string(), - image_ref: component2_ref.to_string(), - annotations: None, - revision: 0, - max_instances: 1, - name: None, - }, + ComponentDescription::builder() + .id(component1_id.into()) + .image_ref(component1_ref.into()) + .revision(0) + .max_instances(2) + .build() + .expect("failed to build description"), + ComponentDescription::builder() + .id(component2_id.into()) + .image_ref(component2_ref.into()) + .revision(0) + .max_instances(1) + .build() + .expect("failed to build description"), ], friendly_name: "millenium_falcon-1977".to_string(), labels: HashMap::default(), issuer: "".to_string(), providers: vec![ProviderDescription { - id: provider_id.clone(), + id: provider_id.into(), annotations: None, image_ref: None, name: None, @@ -1920,7 +1909,7 @@ mod test { uptime_human: "60s".into(), uptime_seconds: 60, version: semver::Version::parse("0.61.0").unwrap(), - host_id: host_id.clone(), + host_id: host_id.into(), }, ) .await @@ -1931,15 +1920,15 @@ mod test { let components = store.list::(lattice_id).await.unwrap(); assert_eq!(components.len(), 2, "Store should now have two components"); let component = components - .get(&component1_id) + .get(component1_id) .expect("component should exist"); - let expected = claims.get(&component1_id).unwrap(); + let expected = claims.get(component1_id).unwrap(); assert_eq!(component.name, expected.name, "Data should match"); assert_eq!(component.issuer, expected.issuer, "Data should match"); assert_eq!( component .instances - .get(&host_id) + .get(host_id) .expect("Host should exist in count") .get(&BTreeMap::new()) .expect("Should find a component with the correct annotations") @@ -1949,15 +1938,15 @@ mod test { ); let component = components - .get(&component2_id) + .get(component2_id) .expect("Component should exist"); - let expected = claims.get(&component2_id).unwrap(); + let expected = claims.get(component2_id).unwrap(); assert_eq!(component.name, expected.name, "Data should match"); assert_eq!(component.issuer, expected.issuer, "Data should match"); assert_eq!( component .instances - .get(&host_id) + .get(host_id) .expect("Host should exist in count") .len(), 1, @@ -1966,10 +1955,10 @@ mod test { let providers = store.list::(lattice_id).await.unwrap(); assert_eq!(providers.len(), 1, "Should have 1 provider in the store"); - let provider = providers.get(&provider_id).expect("Provider should exist"); + let provider = providers.get(provider_id).expect("Provider should exist"); assert_eq!(provider.id, provider_id, "Data should match"); assert!( - provider.hosts.contains_key(&host_id), + provider.hosts.contains_key(host_id), "Should have found host in provider store" ); } @@ -1997,7 +1986,7 @@ mod test { .await, ); - let host_id = "CLOUDCITY".to_string(); + let host_id = "CLOUDCITY"; // Trigger a provider started and then a health check let provider = ProviderStarted { @@ -2009,7 +1998,7 @@ mod test { }), image_ref: "bespin.lando.inc/tibanna:0.1.0".into(), provider_id: "GAS".into(), - host_id: host_id.clone(), + host_id: host_id.into(), annotations: BTreeMap::default(), }; @@ -2022,7 +2011,7 @@ mod test { lattice_id, &ProviderHealthCheckInfo { provider_id: provider.provider_id.clone(), - host_id: host_id.clone(), + host_id: host_id.into(), }, Some(false), ) @@ -2037,7 +2026,7 @@ mod test { assert!( matches!( prov.hosts - .get(&host_id) + .get(host_id) .expect("Should find status for host"), ProviderStatus::Running ), @@ -2050,7 +2039,7 @@ mod test { lattice_id, &ProviderHealthCheckInfo { provider_id: provider.provider_id.clone(), - host_id: host_id.clone(), + host_id: host_id.into(), }, Some(true), ) @@ -2065,7 +2054,7 @@ mod test { assert!( matches!( prov.hosts - .get(&host_id) + .get(host_id) .expect("Should find status for host"), ProviderStatus::Failed ), @@ -2142,25 +2131,26 @@ mod test { lattice_id, &HostHeartbeat { components: vec![ - ComponentDescription { - id: "jabba".to_string(), - image_ref: "jabba.tatooinecr.io/jabba:latest".to_string(), - name: Some("Da Hutt".to_string()), - annotations: Some(HashMap::from_iter([( + ComponentDescription::builder() + .id("jabba".into()) + .image_ref("jabba.tatooinecr.io/jabba:latest".into()) + .name("Da Hutt".into()) + .annotations(BTreeMap::from_iter([( "da".to_string(), "gobah".to_string(), - )])), - revision: 0, - max_instances: 5, - }, - ComponentDescription { - id: "jabba2".to_string(), - image_ref: "jabba.tatooinecr.io/jabba:latest".to_string(), - name: Some("Da Hutt".to_string()), - annotations: None, - revision: 0, - max_instances: 1, - }, + )])) + .revision(0) + .max_instances(5) + .build() + .expect("failed to build description"), + ComponentDescription::builder() + .id("jabba2".into()) + .image_ref("jabba.tatooinecr.io/jabba:latest".into()) + .name("Da Hutt".into()) + .revision(0) + .max_instances(1) + .build() + .expect("failed to build description"), ], friendly_name: "palace-1983".to_string(), labels: HashMap::default(), diff --git a/crates/wadm/src/workers/event_helpers.rs b/crates/wadm/src/workers/event_helpers.rs index d3da1dbe..d83f9a26 100644 --- a/crates/wadm/src/workers/event_helpers.rs +++ b/crates/wadm/src/workers/event_helpers.rs @@ -6,7 +6,7 @@ use wasmcloud_secrets_types::SecretConfig; use tracing::{debug, instrument, trace, warn}; use wadm_types::api::Status; -use wasmcloud_control_interface::{CtlResponse, HostInventory, InterfaceLinkDefinition}; +use wasmcloud_control_interface::{HostInventory, Link}; use crate::{commands::Command, publisher::Publisher, APP_SPEC_ANNOTATION}; @@ -43,7 +43,7 @@ pub trait InventorySource { /// due to testing, but it does allow us to abstract away the concrete type of the client #[async_trait::async_trait] pub trait LinkSource { - async fn get_links(&self) -> anyhow::Result>; + async fn get_links(&self) -> anyhow::Result>; } /// A trait for anything that can fetch a piece of named configuration @@ -95,11 +95,8 @@ pub fn secret_config_from_map(map: HashMap) -> anyhow::Result anyhow::Result> { match self.get_claims().await.map_err(|e| anyhow::anyhow!("{e}")) { - Ok(CtlResponse { - success: true, - response: Some(claims), - .. - }) => { + Ok(ctl_resp) if ctl_resp.succeeded() => { + let claims = ctl_resp.data().context("missing claims data")?.to_owned(); Ok(claims .into_iter() .filter_map(|mut claim| { @@ -134,13 +131,12 @@ impl InventorySource for wasmcloud_control_interface::Client { .await .map_err(|e| anyhow::anyhow!("{e:?}"))? { - CtlResponse { - success: true, - response: Some(host_inventory), - .. - } => Ok(host_inventory), - CtlResponse { message, .. } => Err(anyhow::anyhow!( - "Failed to get inventory for host {host_id}, {message}" + ctl_resp if ctl_resp.succeeded() && ctl_resp.data().is_some() => Ok(ctl_resp + .into_data() + .context("missing host inventory data")?), + ctl_resp => Err(anyhow::anyhow!( + "Failed to get inventory for host {host_id}, {}", + ctl_resp.message() )), } } @@ -152,18 +148,19 @@ impl InventorySource for wasmcloud_control_interface::Client { // links #[async_trait::async_trait] impl LinkSource for wasmcloud_control_interface::Client { - async fn get_links(&self) -> anyhow::Result> { + async fn get_links(&self) -> anyhow::Result> { match self .get_links() .await .map_err(|e| anyhow::anyhow!("{e:?}"))? { - CtlResponse { - success: true, - response: Some(links), - .. - } => Ok(links), - CtlResponse { message, .. } => Err(anyhow::anyhow!("Failed to get links, {message}")), + ctl_resp if ctl_resp.succeeded() && ctl_resp.data().is_some() => { + Ok(ctl_resp.into_data().context("missing link data")?) + } + ctl_resp => Err(anyhow::anyhow!( + "Failed to get links, {}", + ctl_resp.message() + )), } } } @@ -176,15 +173,13 @@ impl ConfigSource for wasmcloud_control_interface::Client { .await .map_err(|e| anyhow::anyhow!("{e:?}"))? { - CtlResponse { - success: true, - response: Some(config), - .. - } => Ok(Some(config)), + ctl_resp if ctl_resp.succeeded() && ctl_resp.data().is_some() => { + Ok(ctl_resp.into_data()) + } // TODO(https://github.com/wasmCloud/wasmCloud/issues/1906): The control interface should return a None when config isn't found // instead of returning an error. - CtlResponse { message, .. } => { - debug!("Failed to get config for {name}, {message}"); + ctl_resp => { + debug!("Failed to get config for {name}, {}", ctl_resp.message()); Ok(None) } } @@ -199,21 +194,16 @@ impl SecretSource for wasmcloud_control_interface::Client { .await .map_err(|e| anyhow::anyhow!("{e:?}"))? { - CtlResponse { - success: true, - response: Some(secret), - .. - } => secret_config_from_map(secret).map(Some), - CtlResponse { - message, - response: None, - .. - } => { - debug!("Failed to get secret for {name}, {message}"); + ctl_resp if ctl_resp.succeeded() && ctl_resp.data().is_some() => { + secret_config_from_map(ctl_resp.into_data().context("missing secret data")?) + .map(Some) + } + ctl_resp if ctl_resp.data().is_none() => { + debug!("Failed to get secret for {name}, {}", ctl_resp.message()); Ok(None) } - CtlResponse { message, .. } => { - debug!("Failed to get secret for {name}, {message}"); + ctl_resp => { + debug!("Failed to get secret for {name}, {}", ctl_resp.message()); Ok(None) } } diff --git a/tests/command_worker_integration.rs b/tests/command_worker_integration.rs index dd458be8..91896d79 100644 --- a/tests/command_worker_integration.rs +++ b/tests/command_worker_integration.rs @@ -32,12 +32,10 @@ async fn test_commands() { .await .expect("should get hosts back") .first() - .as_ref() .expect("Should be able to find hosts") - .response - .as_ref() - .expect("Should be able to get host") - .id + .data() + .map(|h| h.id()) + .expect("should be able to get host") .to_owned(); let mut sub = nats_client @@ -70,13 +68,13 @@ async fn test_commands() { tokio::time::sleep(std::time::Duration::from_secs(1)).await; // Get the current components and make sure stuff was started - let inventory = ctl_client + let resp_data = ctl_client .get_host_inventory(&host_id) .await .expect("should get host inventory back") - .response - .expect("should have host inventory") - .components; + .into_data() + .expect("should have host inventory"); + let inventory = resp_data.components(); assert_eq!( inventory.len(), 1, @@ -84,17 +82,18 @@ async fn test_commands() { inventory ); assert_eq!( - inventory[0].image_ref, HELLO_IMAGE_REF, + inventory[0].image_ref(), + HELLO_IMAGE_REF, "Should have started the correct component" ); assert_eq!( - inventory[0].max_instances, 2, + inventory[0].max_instances(), + 2, "Should have started the component with correct concurrency" ); assert_eq!( inventory[0] - .annotations - .as_ref() + .annotations() .unwrap() .get(wadm::MANAGED_BY_ANNOTATION) .expect("Should have the managed by annotation"), @@ -103,8 +102,7 @@ async fn test_commands() { ); assert_eq!( inventory[0] - .annotations - .as_ref() + .annotations() .unwrap() .get(wadm::APP_SPEC_ANNOTATION) .expect("Should have the managed by annotation"), @@ -150,13 +148,13 @@ async fn test_commands() { wait_for_event(&mut sub, "health_check_passed").await; // Get the current providers and make sure stuff was started - let inventory = ctl_client + let resp_data = ctl_client .get_host_inventory(&host_id) .await .expect("should get host inventory back") - .response - .expect("should have host inventory") - .providers; + .into_data() + .expect("should have host inventory"); + let inventory = resp_data.providers(); assert_eq!(inventory.len(), 1, "Should only have 1 provider"); assert_eq!( inventory[0].image_ref.as_deref().unwrap(), @@ -211,7 +209,7 @@ async fn test_commands() { .get_links() .await .expect("should get links back") - .response + .into_data() .expect("should have links"); // We could have more than one link due to local testing, so search for the proper link inventory @@ -248,7 +246,7 @@ async fn test_commands() { .get_links() .await .expect("should get links back") - .response + .into_data() .expect("should have links"); // We could have more than one link due to local testing, so search for the proper link assert!( @@ -280,13 +278,13 @@ async fn test_commands() { wait_for_event(&mut sub, "provider_stopped").await; // Get the current providers and make sure stuff was started - let inventory = ctl_client + let resp_data = ctl_client .get_host_inventory(&host_id) .await .expect("should get host inventory back") - .response - .expect("should have host inventory") - .providers; + .into_data() + .expect("should have host inventory"); + let inventory = resp_data.providers(); assert!(inventory.is_empty(), "Should have no providers"); // Stop the component @@ -311,13 +309,13 @@ async fn test_commands() { wait_for_event(&mut sub, "component_scaled").await; // Get the current providers and make sure stuff was started - let inventory = ctl_client + let resp_data = ctl_client .get_host_inventory(&host_id) .await .expect("should get host inventory back") - .response - .expect("should have host inventory") - .components; + .into_data() + .expect("should have host inventory"); + let inventory = resp_data.components(); assert!(inventory.is_empty(), "Should have no components"); } @@ -344,17 +342,14 @@ async fn test_annotation_stop() { .await .unwrap(); - let host_id = ctl_client - .get_hosts() - .await - .unwrap() + let responses = ctl_client.get_hosts().await.unwrap(); + let host_id = responses .first() .expect("Should be able to find hosts") - .response - .as_ref() - .unwrap() - .id - .to_owned(); + .data() + .map(|v| v.id()) + .clone() + .unwrap(); // Start an unmangaged component // NOTE(thomastaylor312): This is a workaround with current behavior where empty annotations @@ -382,7 +377,7 @@ async fn test_annotation_stop() { .publish_command(ScaleComponent { component_id: HELLO_COMPONENT_ID.to_string(), reference: HELLO_IMAGE_REF.to_string(), - host_id: host_id.clone(), + host_id: host_id.into(), count: 2, model_name: "fake".into(), annotations: BTreeMap::from_iter([("fake".to_string(), "wake".to_string())]), @@ -403,18 +398,17 @@ async fn test_annotation_stop() { tokio::time::sleep(std::time::Duration::from_secs(1)).await; // Get the current components and make sure stuff was started - let inventory = ctl_client + let resp_data = ctl_client .get_host_inventory(&host_id) .await .expect("should get host inventory back") - .response - .expect("should have host inventory") - .components; + .into_data() + .expect("should have host inventory"); + let inventory = resp_data.components(); let managed_inventory = inventory .iter() .filter(|c| { - c.annotations - .as_ref() + c.annotations() .is_some_and(|a| a.contains_key(MANAGED_BY_ANNOTATION)) }) .collect::>(); @@ -425,16 +419,17 @@ async fn test_annotation_stop() { "Should only have 1 managed component" ); assert_eq!( - managed_inventory[0].image_ref, HELLO_IMAGE_REF, + managed_inventory[0].image_ref(), + HELLO_IMAGE_REF, "Should have started the correct component" ); assert!(managed_inventory[0] - .annotations - .as_ref() + .annotations() .map(|annotations| annotations.contains_key(MANAGED_BY_ANNOTATION)) .unwrap_or(false)); assert_eq!( - managed_inventory[0].max_instances, 2, + managed_inventory[0].max_instances(), + 2, "Should have started the correct concurrency of components" ); @@ -444,7 +439,7 @@ async fn test_annotation_stop() { component_id: HELLO_COMPONENT_ID.to_owned(), reference: HELLO_IMAGE_REF.to_string(), count: 0, - host_id: host_id.clone(), + host_id: host_id.into(), model_name: "fake".into(), annotations: BTreeMap::from_iter([("fake".to_string(), "wake".to_string())]), config: vec![], @@ -460,20 +455,22 @@ async fn test_annotation_stop() { wait_for_event(&mut sub, "component_scaled").await; // Get the current providers and make sure stuff was started - let inventory = ctl_client + let resp_data = ctl_client .get_host_inventory(&host_id) .await .unwrap() - .response - .unwrap() - .components; + .into_data() + .unwrap(); + let inventory = resp_data.components(); assert_eq!(inventory.len(), 1, "Should only have 1 component"); assert_eq!( - inventory[0].image_ref, HELLO_IMAGE_REF, + inventory[0].image_ref(), + HELLO_IMAGE_REF, "Should have started the correct component" ); assert_eq!( - inventory[0].max_instances, 1, + inventory[0].max_instances(), + 1, "Should have 1 unmanaged component still running" ); } diff --git a/tests/e2e.rs b/tests/e2e.rs index b7c8deae..7d9be67b 100644 --- a/tests/e2e.rs +++ b/tests/e2e.rs @@ -242,9 +242,13 @@ impl ClientInfo { .await .expect("Should be able to fetch hosts") .into_iter() - .filter_map(|host| { - host.response - .map(|resp| (self.ctl_client(lattice_prefix).clone(), resp.id)) + .filter_map(|resp| { + resp.into_data().map(|resp| { + ( + self.ctl_client(lattice_prefix).clone(), + resp.id().to_string(), + ) + }) }) .map(|(client, host_id)| async move { let inventory = client @@ -252,9 +256,9 @@ impl ClientInfo { .await .map_err(|e| anyhow::anyhow!("{e:?}"))?; Ok(( - host_id, + host_id.to_string(), inventory - .response + .into_data() .expect("Should have host inventory response"), )) }); @@ -333,7 +337,7 @@ pub async fn check_config( .get_config(config_name) .await .map_err(|e| anyhow::anyhow!(e))? - .response + .into_data() .expect("Should have config response"); for (key, value) in values { if let Some(expected) = config.get(key) { @@ -357,13 +361,12 @@ pub fn check_components( manifest_name: &str, expected_count: usize, ) -> anyhow::Result<()> { - let all_components = inventory.values().flat_map(|inv| &inv.components); + let all_components = inventory.values().flat_map(|inv| inv.components()); let component_count: usize = all_components .filter(|component| { - component.image_ref == image_ref + component.image_ref() == image_ref && component - .annotations - .as_ref() + .annotations() .and_then(|annotations| { annotations .get(APP_SPEC_ANNOTATION) @@ -371,7 +374,7 @@ pub fn check_components( }) .unwrap_or(false) }) - .map(|component| component.max_instances as usize) + .map(|component| component.max_instances() as usize) .sum(); if component_count != expected_count { anyhow::bail!( @@ -419,7 +422,7 @@ pub fn check_providers( ) -> anyhow::Result<()> { let provider_count = inventory .values() - .flat_map(|inv| &inv.providers) + .flat_map(|inv| inv.providers()) .filter(|provider| { // You can only have 1 provider per host and that could be created by any manifest, // so we can just check the image ref and that it is managed by wadm diff --git a/tests/e2e_multiple_hosts.rs b/tests/e2e_multiple_hosts.rs index 56cae903..fde53966 100644 --- a/tests/e2e_multiple_hosts.rs +++ b/tests/e2e_multiple_hosts.rs @@ -133,7 +133,7 @@ async fn test_no_requirements(client_info: &ClientInfo) { .get_config("hello_simple-httpaddr") .await .map_err(|e| anyhow::anyhow!("should have http provider source config {e}"))? - .response + .into_data() .context("should have http provider source config response")?; assert_eq!( config, @@ -148,7 +148,7 @@ async fn test_no_requirements(client_info: &ClientInfo) { .get_links() .await .map_err(|e| anyhow::anyhow!("{e:?}"))? - .response + .into_data() .context("Should have links")?; if !links.iter().any(|ld| { @@ -206,7 +206,7 @@ async fn test_no_requirements(client_info: &ClientInfo) { .get_links() .await .map_err(|e| anyhow::anyhow!("{e:?}"))? - .response + .into_data() .context("Should have links")?; if !links.is_empty() { @@ -309,7 +309,7 @@ async fn test_complex_app(client_info: &ClientInfo) { .get_config("complex-defaultcode") .await .map_err(|e| anyhow::anyhow!("should have blobby component config: {e:?}"))? - .response + .into_data() .context("should have blobby component config response")?; assert_eq!( blobby_config, @@ -320,7 +320,7 @@ async fn test_complex_app(client_info: &ClientInfo) { .get_config("complex-rootfs") .await .map_err(|e| anyhow::anyhow!("should have target link config {e:?}"))? - .response + .into_data() .context("should have target link config response")?; assert_eq!( blobby_target_config, @@ -331,7 +331,7 @@ async fn test_complex_app(client_info: &ClientInfo) { .get_config("complex-httpaddr") .await .map_err(|e| anyhow::anyhow!("should have source link config {e:?}"))? - .response + .into_data() .context("should have target link config response")?; assert_eq!( http_source_config, @@ -342,7 +342,7 @@ async fn test_complex_app(client_info: &ClientInfo) { .get_config("complex-defaultfs") .await .map_err(|e| anyhow::anyhow!("should have provider config {e:?}"))? - .response + .into_data() .context("should have provider config response")?; assert_eq!( fileserver_config, @@ -362,7 +362,7 @@ async fn test_complex_app(client_info: &ClientInfo) { .get_links() .await .map_err(|e| anyhow::anyhow!("{e:?}"))? - .response + .into_data() .context("Should have links")?; if !links.iter().any(|ld| { @@ -395,12 +395,12 @@ async fn test_complex_app(client_info: &ClientInfo) { // Make sure nothing is running on things it shouldn't be on if inventory.values().any(|inv| { - inv.labels + inv.labels() .get("region") .map(|region| region == "us-taylor-west" || region == "us-brooks-east") .unwrap_or(false) && inv - .providers + .providers() .iter() .any(|prov| prov.id == BLOBSTORE_FS_PROVIDER_ID) }) { @@ -409,7 +409,7 @@ async fn test_complex_app(client_info: &ClientInfo) { let moon_inventory = inventory .values() .find(|inv| { - inv.labels + inv.labels() .get("region") .map(|region| region == "moon") .unwrap_or(false) @@ -417,9 +417,9 @@ async fn test_complex_app(client_info: &ClientInfo) { .unwrap(); if moon_inventory - .components + .components() .iter() - .any(|component| component.id == BLOBBY_COMPONENT_ID) + .any(|component| component.id() == BLOBBY_COMPONENT_ID) { anyhow::bail!("Actors shouldn't be running on the moon"); } @@ -460,16 +460,16 @@ async fn test_stop_host_rebalance(client_info: &ClientInfo) { .expect("Unable to fetch inventory") .into_iter() .filter(|(_, inv)| { - inv.labels + inv.labels() .get("region") .map(|region| region == "us-brooks-east") .unwrap_or(false) }) .max_by_key(|(_, inv)| { - inv.components + inv.components() .iter() - .find(|component| component.id == HELLO_COMPONENT_ID) - .map(|desc| desc.max_instances) + .find(|component| component.id() == HELLO_COMPONENT_ID) + .map(|desc| desc.max_instances()) .unwrap_or(0) }) .map(|(host_id, _)| host_id) diff --git a/tests/e2e_upgrades.rs b/tests/e2e_upgrades.rs index 9ade8a47..2ff9b0cd 100644 --- a/tests/e2e_upgrades.rs +++ b/tests/e2e_upgrades.rs @@ -136,7 +136,7 @@ async fn test_upgrade(client_info: &ClientInfo) { .get_links() .await .map_err(|e| anyhow::anyhow!("{e:?}"))? - .response + .into_data() .context("should have links")?; let http_link = links @@ -305,7 +305,7 @@ async fn test_upgrade(client_info: &ClientInfo) { .get_links() .await .map_err(|e| anyhow::anyhow!("{e:?}"))? - .response + .into_data() .context("should've had links")?; let http_link = links @@ -423,7 +423,7 @@ async fn test_upgrade(client_info: &ClientInfo) { .get_links() .await .map_err(|e| anyhow::anyhow!("{e:?}"))? - .response + .into_data() .context("should've had links")?; let http_link = links