From 05c384122eabacc9b8a6cfeab6b6bd014783e3a1 Mon Sep 17 00:00:00 2001 From: Matthew James Briggs Date: Wed, 2 Feb 2022 13:34:37 -0800 Subject: [PATCH 1/8] sources: update tokio to 1.14 lts --- sources/api/apiclient/Cargo.toml | 2 +- sources/api/bootstrap-containers/Cargo.toml | 2 +- sources/api/certdog/Cargo.toml | 2 +- sources/api/corndog/Cargo.toml | 2 +- sources/api/early-boot-config/Cargo.toml | 2 +- sources/api/ecs-settings-applier/Cargo.toml | 2 +- sources/api/host-containers/Cargo.toml | 2 +- sources/api/pluto/Cargo.toml | 2 +- sources/api/schnauzer/Cargo.toml | 2 +- sources/api/servicedog/Cargo.toml | 2 +- sources/api/settings-committer/Cargo.toml | 2 +- sources/api/shibaken/Cargo.toml | 2 +- sources/api/static-pods/Cargo.toml | 2 +- sources/api/sundog/Cargo.toml | 2 +- sources/api/thar-be-settings/Cargo.toml | 2 +- sources/api/thar-be-updates/Cargo.toml | 2 +- sources/imdsclient/Cargo.toml | 2 +- sources/logdog/Cargo.toml | 2 +- 18 files changed, 18 insertions(+), 18 deletions(-) diff --git a/sources/api/apiclient/Cargo.toml b/sources/api/apiclient/Cargo.toml index e27a6fe500c..549f8160d17 100644 --- a/sources/api/apiclient/Cargo.toml +++ b/sources/api/apiclient/Cargo.toml @@ -32,7 +32,7 @@ serde_json = "1.0" signal-hook = "0.3" simplelog = "0.10" snafu = { version = "0.6", features = ["futures"] } -tokio = { version = "~1.8", default-features = false, features = ["fs", "io-std", "io-util", "macros", "rt-multi-thread", "time"] } # LTS +tokio = { version = "~1.14", default-features = false, features = ["fs", "io-std", "io-util", "macros", "rt-multi-thread", "time"] } # LTS tokio-tungstenite = { version = "0.15", default-features = false, features = ["connect"] } toml = "0.5" unindent = "0.1" diff --git a/sources/api/bootstrap-containers/Cargo.toml b/sources/api/bootstrap-containers/Cargo.toml index 1729c74ca30..ef091e3d6fa 100644 --- a/sources/api/bootstrap-containers/Cargo.toml +++ b/sources/api/bootstrap-containers/Cargo.toml @@ -21,7 +21,7 @@ serde = { version = "1.0", features = ["derive"] } serde_json = "1" simplelog = "0.10" snafu = "0.6" -tokio = { version = "~1.8", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS +tokio = { version = "~1.14", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS [build-dependencies] cargo-readme = "3.1" diff --git a/sources/api/certdog/Cargo.toml b/sources/api/certdog/Cargo.toml index ae7919f4876..cf4cdbbba45 100644 --- a/sources/api/certdog/Cargo.toml +++ b/sources/api/certdog/Cargo.toml @@ -21,7 +21,7 @@ serde = { version = "1.0", features = ["derive"] } serde_json = "1" simplelog = "0.10" snafu = "0.6" -tokio = { version = "1", default-features = false, features = ["macros", "rt-multi-thread"] } +tokio = { version = "~1.14", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS x509-parser = "0.11.0" [dev-dependencies] diff --git a/sources/api/corndog/Cargo.toml b/sources/api/corndog/Cargo.toml index c8fed5f4ee7..12ca045f0cd 100644 --- a/sources/api/corndog/Cargo.toml +++ b/sources/api/corndog/Cargo.toml @@ -19,7 +19,7 @@ serde = { version = "1.0", features = ["derive"] } serde_json = "1" simplelog = "0.10" snafu = "0.6" -tokio = { version = "~1.8", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS +tokio = { version = "~1.14", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS [build-dependencies] cargo-readme = "3.1" diff --git a/sources/api/early-boot-config/Cargo.toml b/sources/api/early-boot-config/Cargo.toml index 50dff4ca2f0..28716c27ec0 100644 --- a/sources/api/early-boot-config/Cargo.toml +++ b/sources/api/early-boot-config/Cargo.toml @@ -25,7 +25,7 @@ serde_plain = "1.0" serde-xml-rs = "0.5" simplelog = "0.10" snafu = "0.6" -tokio = { version = "~1.8", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS +tokio = { version = "~1.14", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS toml = "0.5" [target.'cfg(target_arch = "x86_64")'.dependencies] diff --git a/sources/api/ecs-settings-applier/Cargo.toml b/sources/api/ecs-settings-applier/Cargo.toml index a688c5b5878..76dc3613aa6 100644 --- a/sources/api/ecs-settings-applier/Cargo.toml +++ b/sources/api/ecs-settings-applier/Cargo.toml @@ -16,7 +16,7 @@ serde_json = "1" schnauzer = { path = "../schnauzer", version = "0.1.0" } log = "0.4" snafu = "0.6" -tokio = { version = "~1.8", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS +tokio = { version = "~1.14", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS [build-dependencies] cargo-readme = "3.1" diff --git a/sources/api/host-containers/Cargo.toml b/sources/api/host-containers/Cargo.toml index 933cf9c0214..ded9b393cd3 100644 --- a/sources/api/host-containers/Cargo.toml +++ b/sources/api/host-containers/Cargo.toml @@ -20,7 +20,7 @@ serde = { version = "1.0", features = ["derive"] } serde_json = "1" simplelog = "0.10" snafu = "0.6" -tokio = { version = "~1.8", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS +tokio = { version = "~1.14", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS [build-dependencies] cargo-readme = "3.1" diff --git a/sources/api/pluto/Cargo.toml b/sources/api/pluto/Cargo.toml index 8d97cbdc67a..cd951349d5e 100644 --- a/sources/api/pluto/Cargo.toml +++ b/sources/api/pluto/Cargo.toml @@ -18,7 +18,7 @@ rusoto_core = { version = "0.47", default-features = false, features = ["rustls" rusoto_eks = { version = "0.47", default-features = false, features = ["rustls"] } serde_json = "1" snafu = "0.6" -tokio = { version = "~1.8", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS +tokio = { version = "~1.14", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS [build-dependencies] cargo-readme = "3.1" diff --git a/sources/api/schnauzer/Cargo.toml b/sources/api/schnauzer/Cargo.toml index c7a01aae827..bc1b2fd58f2 100644 --- a/sources/api/schnauzer/Cargo.toml +++ b/sources/api/schnauzer/Cargo.toml @@ -24,7 +24,7 @@ percent-encoding = "2.1" serde = { version = "1.0", features = ["derive"] } serde_json = "1" snafu = "0.6" -tokio = { version = "~1.8", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS +tokio = { version = "~1.14", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS url = "2.1" num_cpus = "1.0" diff --git a/sources/api/servicedog/Cargo.toml b/sources/api/servicedog/Cargo.toml index 362dd22bd38..6f2f6f8ca5d 100644 --- a/sources/api/servicedog/Cargo.toml +++ b/sources/api/servicedog/Cargo.toml @@ -20,7 +20,7 @@ serde = { version = "1.0", features = ["derive"] } serde_json = "1" simplelog = "0.10" snafu = "0.6" -tokio = { version = "~1.8", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS +tokio = { version = "~1.14", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS [build-dependencies] cargo-readme = "3.1" diff --git a/sources/api/settings-committer/Cargo.toml b/sources/api/settings-committer/Cargo.toml index 2c472ce1396..6847bb9327d 100644 --- a/sources/api/settings-committer/Cargo.toml +++ b/sources/api/settings-committer/Cargo.toml @@ -18,7 +18,7 @@ log = "0.4" serde = { version = "1.0", features = ["derive"] } serde_json = "1" simplelog = "0.10" -tokio = { version = "~1.8", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS +tokio = { version = "~1.14", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS [build-dependencies] cargo-readme = "3.1" diff --git a/sources/api/shibaken/Cargo.toml b/sources/api/shibaken/Cargo.toml index 7ea27834eae..234930f07ab 100644 --- a/sources/api/shibaken/Cargo.toml +++ b/sources/api/shibaken/Cargo.toml @@ -17,7 +17,7 @@ serde = { version = "1.0", features = ["derive"] } serde_json = "1" simplelog = "0.10" snafu = "0.6" -tokio = { version = "~1.8", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS +tokio = { version = "~1.14", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS [build-dependencies] cargo-readme = "3.1" diff --git a/sources/api/static-pods/Cargo.toml b/sources/api/static-pods/Cargo.toml index d2caf8cfd52..8777decb9d5 100644 --- a/sources/api/static-pods/Cargo.toml +++ b/sources/api/static-pods/Cargo.toml @@ -19,7 +19,7 @@ serde = { version = "1.0", features = ["derive"] } serde_json = "1" simplelog = "0.10" snafu = "0.6" -tokio = { version = "~1.8", default-features = false, features = ["macros", "rt-multi-thread", "time"] } # LTS +tokio = { version = "~1.14", default-features = false, features = ["macros", "rt-multi-thread", "time"] } # LTS tempfile = "3.2.0" [build-dependencies] diff --git a/sources/api/sundog/Cargo.toml b/sources/api/sundog/Cargo.toml index 438873b8d00..4b90c95f62b 100644 --- a/sources/api/sundog/Cargo.toml +++ b/sources/api/sundog/Cargo.toml @@ -20,7 +20,7 @@ serde = { version = "1.0", features = ["derive"] } serde_json = "1" simplelog = "0.10" snafu = "0.6" -tokio = { version = "~1.8", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS +tokio = { version = "~1.14", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS [build-dependencies] cargo-readme = "3.1" diff --git a/sources/api/thar-be-settings/Cargo.toml b/sources/api/thar-be-settings/Cargo.toml index 9174aa79154..5dfadc48c1d 100644 --- a/sources/api/thar-be-settings/Cargo.toml +++ b/sources/api/thar-be-settings/Cargo.toml @@ -22,7 +22,7 @@ schnauzer = { path = "../schnauzer", version = "0.1.0" } serde_json = "1" simplelog = "0.10" snafu = "0.6" -tokio = { version = "~1.8", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS +tokio = { version = "~1.14", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS [build-dependencies] cargo-readme = "3.1" diff --git a/sources/api/thar-be-updates/Cargo.toml b/sources/api/thar-be-updates/Cargo.toml index c98cb72bcd0..cc7fe46cc92 100644 --- a/sources/api/thar-be-updates/Cargo.toml +++ b/sources/api/thar-be-updates/Cargo.toml @@ -29,7 +29,7 @@ signpost = { path = "../../updater/signpost", version = "0.1.0" } simplelog = "0.10" snafu = "0.6.8" tempfile = "3.1.0" -tokio = { version = "~1.8", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS +tokio = { version = "~1.14", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS update_metadata = { path = "../../updater/update_metadata", version = "0.1.0" } [build-dependencies] diff --git a/sources/imdsclient/Cargo.toml b/sources/imdsclient/Cargo.toml index 085b0f7897b..85e73e5a3a8 100644 --- a/sources/imdsclient/Cargo.toml +++ b/sources/imdsclient/Cargo.toml @@ -15,7 +15,7 @@ log = "0.4" reqwest = { version = "0.11.1", default-features = false } serde_json = "1" snafu = "0.6" -tokio = { version = "~1.8", default-features = false, features = ["macros", "rt-multi-thread", "time"] } # LTS +tokio = { version = "~1.14", default-features = false, features = ["macros", "rt-multi-thread", "time"] } # LTS tokio-retry = "0.3" url = "2.1.1" diff --git a/sources/logdog/Cargo.toml b/sources/logdog/Cargo.toml index 7e8a09281f1..10e6097437e 100644 --- a/sources/logdog/Cargo.toml +++ b/sources/logdog/Cargo.toml @@ -21,7 +21,7 @@ shell-words = "1.0.0" snafu = { version = "0.6", features = ["backtraces-impl-backtrace-crate"] } tar = { version = "0.4", default-features = false } tempfile = { version = "3.1.0", default-features = false } -tokio = { version = "~1.8", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS +tokio = { version = "~1.14", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS url = "2.1.1" walkdir = "2.3" From 4f97d194e7f026d2db38ab87a5da733ee21c668c Mon Sep 17 00:00:00 2001 From: Matthew James Briggs Date: Wed, 2 Feb 2022 13:45:33 -0800 Subject: [PATCH 2/8] sources: update actix-web to latest 4.0 rc 2 --- sources/Cargo.lock | 164 ++++++++++++--------- sources/api/apiserver/Cargo.toml | 5 +- sources/api/apiserver/src/bin/apiserver.rs | 2 +- sources/api/apiserver/src/server/mod.rs | 5 +- sources/deny.toml | 5 +- 5 files changed, 105 insertions(+), 76 deletions(-) diff --git a/sources/Cargo.lock b/sources/Cargo.lock index 65a1ad753f9..1e39b635659 100644 --- a/sources/Cargo.lock +++ b/sources/Cargo.lock @@ -45,14 +45,13 @@ dependencies = [ [[package]] name = "actix-http" -version = "3.0.0-beta.11" +version = "3.0.0-rc.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9b510d35f13987537289f38bf136e7e702a5c87cc28760310cc459544f40afd" +checksum = "08aac516b88cb8cfbfa834c76b58607ffac75946d947dcb6a9ffc5673e1e875d" dependencies = [ "actix-codec", "actix-rt", "actix-service", - "actix-tls", "actix-utils", "ahash", "base64", @@ -62,24 +61,20 @@ dependencies = [ "derive_more", "encoding_rs", "futures-core", - "futures-util", "h2", "http", "httparse", "httpdate 1.0.1", - "itoa", + "itoa 1.0.1", "language-tags", "local-channel", "log", "mime", - "once_cell", "percent-encoding", - "pin-project 1.0.8", "pin-project-lite", "rand", - "sha-1 0.9.8", + "sha-1 0.10.0", "smallvec", - "tokio", ] [[package]] @@ -94,9 +89,9 @@ dependencies = [ [[package]] name = "actix-router" -version = "0.5.0-beta.2" +version = "0.5.0-rc.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36b95ce0d76d1aa2f98b681702807475ade0f99bd4552546a6843a966d42ea3d" +checksum = "cb6506dbef336634ff35d994d58daa0a412ea23751f15f9b4dcac4d594b1ed1f" dependencies = [ "bytestring", "firestorm", @@ -108,9 +103,9 @@ dependencies = [ [[package]] name = "actix-rt" -version = "2.4.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a0c218d0a17c120f10ee0c69c9f0c45d87319e8f66b1f065e8412b612fc3e24" +checksum = "cdf3f2183be1241ed4dd22611850b85d38de0b08a09f1f7bcccbd0809084b359" dependencies = [ "actix-macros", "futures-core", @@ -119,17 +114,19 @@ dependencies = [ [[package]] name = "actix-server" -version = "2.0.0-beta.6" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7367665785765b066ad16e1086d26a087f696bc7c42b6f93004ced6cfcf1eeca" +checksum = "d9e7472ac180abb0a8e592b653744345983a7a14f44691c8394a799d0df4dbbf" dependencies = [ "actix-rt", "actix-service", "actix-utils", "futures-core", + "futures-util", "log", - "mio", + "mio 0.8.0", "num_cpus", + "socket2 0.4.2", "tokio", ] @@ -144,23 +141,6 @@ dependencies = [ "pin-project-lite", ] -[[package]] -name = "actix-tls" -version = "3.0.0-beta.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4af84e13e4600829858a3e68079be710d1ada461431e1e4c5ae663479ea0a3c" -dependencies = [ - "actix-codec", - "actix-rt", - "actix-service", - "actix-utils", - "derive_more", - "futures-core", - "http", - "log", - "tokio-util", -] - [[package]] name = "actix-utils" version = "3.0.0" @@ -173,34 +153,30 @@ dependencies = [ [[package]] name = "actix-web" -version = "4.0.0-beta.10" +version = "4.0.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8a4b9d00991d8da308070a5cea7f1bbaa153a91c3fb5567937d99b9f46d601e" +checksum = "73170d019de2d82c0d826c1f315c3106134bd764e9247505ba6f0d78d22dfe9e" dependencies = [ "actix-codec", "actix-http", - "actix-macros", "actix-router", "actix-rt", "actix-server", "actix-service", "actix-utils", - "actix-web-codegen", "ahash", "bytes", "cfg-if", "derive_more", - "either", "encoding_rs", "futures-core", "futures-util", - "itoa", + "itoa 1.0.1", "language-tags", "log", "mime", "once_cell", - "paste", - "pin-project 1.0.8", + "pin-project-lite", "regex", "serde", "serde_json", @@ -213,9 +189,9 @@ dependencies = [ [[package]] name = "actix-web-actors" -version = "4.0.0-beta.7" +version = "4.0.0-beta.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b43c8e03f1877bc010316de455ee479aa0de0ae0717d49041db5f38fa192de" +checksum = "fbf2ef3eae6001ac2fa6690b2f8b152c00b5b8b2248e3e30f82dd2ec1e941345" dependencies = [ "actix", "actix-codec", @@ -224,22 +200,10 @@ dependencies = [ "bytes", "bytestring", "futures-core", - "pin-project 1.0.8", + "pin-project-lite", "tokio", ] -[[package]] -name = "actix-web-codegen" -version = "0.5.0-beta.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfe80a8828fa88a0420dc8fdd4c16b8207326c917f17701881b063eadc2a8d3b" -dependencies = [ - "actix-router", - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "actix_derive" version = "0.6.0" @@ -345,6 +309,7 @@ name = "apiserver" version = "0.1.0" dependencies = [ "actix", + "actix-rt", "actix-web", "actix-web-actors", "bottlerocket-release", @@ -531,6 +496,15 @@ dependencies = [ "generic-array 0.14.4", ] +[[package]] +name = "block-buffer" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1d36a02058e76b040de25a4464ba1c80935655595b661505c8b39b664828b95" +dependencies = [ + "generic-array 0.14.4", +] + [[package]] name = "block-padding" version = "0.1.5" @@ -833,6 +807,15 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "crypto-common" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d6b536309245c849479fba3da410962a43ed8e51c26b729208ec0ac2798d0" +dependencies = [ + "generic-array 0.14.4", +] + [[package]] name = "crypto-mac" version = "0.11.1" @@ -965,6 +948,17 @@ dependencies = [ "generic-array 0.14.4", ] +[[package]] +name = "digest" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b697d66081d42af4fba142d56918a3cb21dc8eb63372c6b85d14f44fb9c5979b" +dependencies = [ + "block-buffer 0.10.0", + "crypto-common", + "generic-array 0.14.4", +] + [[package]] name = "dirs-next" version = "2.0.0" @@ -1137,9 +1131,9 @@ dependencies = [ [[package]] name = "firestorm" -version = "0.4.6" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31586bda1b136406162e381a3185a506cdfc1631708dd40cba2f6628d8634499" +checksum = "4d3d6188b8804df28032815ea256b6955c9625c24da7525f387a7af02fbb8f01" [[package]] name = "flate2" @@ -1375,9 +1369,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.7" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fd819562fcebdac5afc5c113c3ec36f902840b70fd4fc458799c8ce4607ae55" +checksum = "d9f1f717ddc7b2ba36df7e871fd88db79326551d3d6f1fc406fbfd28b582ff8e" dependencies = [ "bytes", "fnv", @@ -1485,7 +1479,7 @@ checksum = "1323096b05d41827dadeaee54c9981958c0f94e670bc94ed80037d1a7b8b186b" dependencies = [ "bytes", "fnv", - "itoa", + "itoa 0.4.8", ] [[package]] @@ -1554,7 +1548,7 @@ dependencies = [ "http-body", "httparse", "httpdate 0.3.2", - "itoa", + "itoa 0.4.8", "pin-project 1.0.8", "socket2 0.3.19", "tokio", @@ -1692,6 +1686,12 @@ version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" +[[package]] +name = "itoa" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" + [[package]] name = "js-sys" version = "0.3.55" @@ -1941,6 +1941,19 @@ dependencies = [ "winapi", ] +[[package]] +name = "mio" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba272f85fa0b41fc91872be579b3bbe0f56b792aa361a380eb669469f68dafb2" +dependencies = [ + "libc", + "log", + "miow", + "ntapi", + "winapi", +] + [[package]] name = "miow" version = "0.3.7" @@ -2966,7 +2979,7 @@ version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e466864e431129c7e0d3476b92f20458e5879919a0596c6472738d9fa2d342f8" dependencies = [ - "itoa", + "itoa 0.4.8", "ryu", "serde", ] @@ -2987,7 +3000,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edfa57a7f8d9c1d260a549e7224100f6c43d43f9103e06dd8b4095a9b2b43ce9" dependencies = [ "form_urlencoded", - "itoa", + "itoa 0.4.8", "ryu", "serde", ] @@ -3051,6 +3064,17 @@ dependencies = [ "opaque-debug 0.3.0", ] +[[package]] +name = "sha-1" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "028f48d513f9678cda28f6e4064755b3fbb2af6acd672f2c209b62323f7aea0f" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.1", +] + [[package]] name = "sha2" version = "0.9.8" @@ -3455,7 +3479,7 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99beeb0daeac2bd1e86ac2c21caddecb244b39a093594da1a661ec2060c7aedd" dependencies = [ - "itoa", + "itoa 0.4.8", "libc", ] @@ -3476,15 +3500,15 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.8.3" +version = "1.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00a287ce596d527f273dea7638a044739234740dbad141e7ed0c62c7d0c9c55a" +checksum = "b9d0183f6f6001549ab68f8c7585093bb732beefbcf6d23a10b9b95c73a1dd49" dependencies = [ "autocfg", "bytes", "libc", "memchr", - "mio", + "mio 0.7.14", "num_cpus", "once_cell", "parking_lot", @@ -3496,9 +3520,9 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "1.5.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "114383b041aa6212c579467afa0075fbbdd0718de036100bc0ba7961d8cb9095" +checksum = "b557f72f448c511a979e2564e55d74e6c4432fc96ff4f6241bc6bded342643b7" dependencies = [ "proc-macro2", "quote", diff --git a/sources/api/apiserver/Cargo.toml b/sources/api/apiserver/Cargo.toml index 8bec7b486ae..5634ef09923 100644 --- a/sources/api/apiserver/Cargo.toml +++ b/sources/api/apiserver/Cargo.toml @@ -11,8 +11,9 @@ exclude = ["README.md"] [dependencies] actix = { version = "0.12", default-features = false, features = ["macros"] } -actix-web = { version = "4.0.0-beta.5", default-features = false } -actix-web-actors = { version = "4.0.0-beta.5", default-features = false } +actix-rt = "2" +actix-web = { version = "4.0.0-rc.2", default-features = false } +actix-web-actors = { version = "4.0.0-beta.11", default-features = false } bytes = "1.1" bottlerocket-release = { path = "../../bottlerocket-release", version = "0.1.0" } datastore = { path = "../datastore", version = "0.1.0" } diff --git a/sources/api/apiserver/src/bin/apiserver.rs b/sources/api/apiserver/src/bin/apiserver.rs index a66a1c1af91..34afbf93997 100644 --- a/sources/api/apiserver/src/bin/apiserver.rs +++ b/sources/api/apiserver/src/bin/apiserver.rs @@ -184,7 +184,7 @@ async fn run() -> Result<()> { // Returning a Result from main makes it print a Debug representation of the error, but with Snafu // we have nice Display representations of the error, so we wrap "main" (run) and print any error. // https://github.com/shepmaster/snafu/issues/110 -#[actix_web::main] +#[actix_rt::main] async fn main() { if let Err(e) = run().await { eprintln!("{}", e); diff --git a/sources/api/apiserver/src/server/mod.rs b/sources/api/apiserver/src/server/mod.rs index 1023d0beb47..d3d103476e3 100644 --- a/sources/api/apiserver/src/server/mod.rs +++ b/sources/api/apiserver/src/server/mod.rs @@ -8,7 +8,7 @@ mod exec; pub use error::Error; use actix_web::{ - body::Body, error::ResponseError, web, App, HttpRequest, HttpResponse, HttpServer, Responder, + body::BoxBody, error::ResponseError, web, App, HttpRequest, HttpResponse, HttpServer, Responder, }; use datastore::{Committed, FilesystemDataStore, Key, Value}; use error::Result; @@ -564,7 +564,7 @@ fn transaction_name(query: &web::Query>) -> &str { // Can also override `render_response` if we want to change headers, content type, etc. impl ResponseError for error::Error { /// Maps our error types to the HTTP error code they should return. - fn error_response(&self) -> HttpResponse { + fn error_response(&self) -> HttpResponse { use error::Error::*; let status_code = match self { // 400 Bad Request @@ -638,6 +638,7 @@ pub(crate) struct SharedData { macro_rules! impl_responder_for { ($for:ident, $self:ident, $serialize_expr:expr) => ( impl Responder for $for { + type Body = BoxBody; fn respond_to($self, _req: &HttpRequest) -> HttpResponse { let body = match serde_json::to_string(&$serialize_expr) { Ok(s) => s, diff --git a/sources/deny.toml b/sources/deny.toml index f4940222b8e..ceb49ec189a 100644 --- a/sources/deny.toml +++ b/sources/deny.toml @@ -65,7 +65,10 @@ skip-tree = [ # actix-http uses older and newer versions of crates like rustc_version and # semver, for build vs. runtime dependencies. - { name = "actix-http", version = "3.0.0-beta.10" }, + { name = "actix-http", version = "3.0.0-rc.1" }, + + # snafu uses older versions of some crates, note we will update to snafu 0.7 soon + { name = "snafu", version = "0.6" }, ] [sources] From 4ccf49c293e31b0cf8e3e6a85328785905d99cd7 Mon Sep 17 00:00:00 2001 From: Matthew James Briggs Date: Wed, 2 Feb 2022 14:51:53 -0800 Subject: [PATCH 3/8] sources: update snafu to 0.7 --- sources/Cargo.lock | 136 +++++++++--------- sources/api/apiclient/Cargo.toml | 2 +- sources/api/apiclient/src/apply.rs | 28 ++-- sources/api/apiclient/src/exec.rs | 43 +++--- sources/api/apiclient/src/exec/connect.rs | 8 +- sources/api/apiclient/src/exec/terminal.rs | 6 +- sources/api/apiclient/src/get.rs | 12 +- sources/api/apiclient/src/lib.rs | 15 +- sources/api/apiclient/src/main.rs | 36 ++--- sources/api/apiclient/src/reboot.rs | 4 +- sources/api/apiclient/src/set.rs | 8 +- sources/api/apiclient/src/update.rs | 16 +-- sources/api/apiserver/Cargo.toml | 2 +- sources/api/apiserver/src/bin/apiserver.rs | 8 +- .../api/apiserver/src/server/controller.rs | 72 +++++----- sources/api/apiserver/src/server/error.rs | 2 +- .../api/apiserver/src/server/exec/child.rs | 26 ++-- sources/api/apiserver/src/server/mod.rs | 74 +++++----- sources/api/bootstrap-containers/Cargo.toml | 2 +- sources/api/bootstrap-containers/src/main.rs | 83 ++++++----- sources/api/certdog/Cargo.toml | 2 +- sources/api/certdog/src/main.rs | 30 ++-- sources/api/corndog/Cargo.toml | 2 +- sources/api/corndog/src/main.rs | 12 +- sources/api/datastore/Cargo.toml | 2 +- .../datastore/src/deserialization/error.rs | 4 +- .../datastore/src/deserialization/pairs.rs | 12 +- sources/api/datastore/src/error.rs | 2 +- sources/api/datastore/src/filesystem.rs | 43 +++--- sources/api/datastore/src/key.rs | 20 +-- sources/api/datastore/src/lib.rs | 4 +- .../api/datastore/src/serialization/error.rs | 4 +- .../api/datastore/src/serialization/mod.rs | 4 +- .../api/datastore/src/serialization/pairs.rs | 35 ++--- sources/api/early-boot-config/Cargo.toml | 2 +- sources/api/early-boot-config/src/main.rs | 10 +- .../api/early-boot-config/src/provider/aws.rs | 27 ++-- .../src/provider/local_file.rs | 6 +- .../early-boot-config/src/provider/vmware.rs | 54 +++---- sources/api/early-boot-config/src/settings.rs | 12 +- sources/api/ecs-settings-applier/Cargo.toml | 2 +- sources/api/ecs-settings-applier/src/ecs.rs | 10 +- sources/api/host-containers/Cargo.toml | 2 +- sources/api/host-containers/src/main.rs | 46 +++--- .../migration/migration-helpers/Cargo.toml | 2 +- .../src/common_migrations.rs | 26 ++-- .../migration-helpers/src/datastore_helper.rs | 28 ++-- .../migration/migration-helpers/src/error.rs | 2 +- .../migration/migration-helpers/src/lib.rs | 2 +- .../kubelet-cpu-manager-state/Cargo.toml | 2 +- .../node-taints-representation/Cargo.toml | 2 +- .../node-taints-representation/src/main.rs | 2 +- sources/api/migration/migrator/Cargo.toml | 2 +- sources/api/migration/migrator/src/error.rs | 2 +- sources/api/migration/migrator/src/main.rs | 81 ++++++----- sources/api/netdog/Cargo.toml | 2 +- sources/api/netdog/src/main.rs | 34 ++--- sources/api/pluto/Cargo.toml | 2 +- sources/api/pluto/src/api.rs | 6 +- sources/api/pluto/src/eks.rs | 8 +- sources/api/pluto/src/main.rs | 54 +++---- sources/api/schnauzer/Cargo.toml | 2 +- sources/api/schnauzer/src/helpers.rs | 103 ++++++------- sources/api/schnauzer/src/lib.rs | 8 +- sources/api/schnauzer/src/main.rs | 25 ++-- sources/api/servicedog/Cargo.toml | 2 +- sources/api/servicedog/src/main.rs | 24 ++-- sources/api/settings-committer/Cargo.toml | 2 +- sources/api/settings-committer/src/main.rs | 8 +- sources/api/shibaken/Cargo.toml | 2 +- sources/api/shibaken/src/main.rs | 16 +-- sources/api/static-pods/Cargo.toml | 2 +- sources/api/static-pods/src/static_pods.rs | 40 +++--- sources/api/storewolf/Cargo.toml | 4 +- sources/api/storewolf/build.rs | 15 +- sources/api/storewolf/merge-toml/Cargo.toml | 2 +- sources/api/storewolf/merge-toml/src/lib.rs | 7 +- sources/api/storewolf/src/lib.rs | 14 +- sources/api/storewolf/src/main.rs | 48 ++++--- sources/api/sundog/Cargo.toml | 2 +- sources/api/sundog/src/main.rs | 48 +++---- sources/api/thar-be-settings/Cargo.toml | 2 +- sources/api/thar-be-settings/src/config.rs | 8 +- sources/api/thar-be-settings/src/error.rs | 6 +- sources/api/thar-be-settings/src/lib.rs | 4 +- sources/api/thar-be-settings/src/main.rs | 6 +- sources/api/thar-be-settings/src/service.rs | 10 +- sources/api/thar-be-updates/Cargo.toml | 2 +- sources/api/thar-be-updates/src/error.rs | 2 +- sources/api/thar-be-updates/src/main.rs | 40 +++--- sources/api/thar-be-updates/src/status.rs | 38 ++--- sources/bottlerocket-release/Cargo.toml | 2 +- sources/bottlerocket-release/src/lib.rs | 7 +- sources/driverdog/Cargo.toml | 2 +- sources/driverdog/src/main.rs | 31 ++-- sources/ghostdog/Cargo.toml | 2 +- sources/ghostdog/src/main.rs | 4 +- sources/growpart/Cargo.toml | 2 +- sources/growpart/src/diskpart.rs | 44 +++--- sources/growpart/src/diskpart/error.rs | 2 +- sources/imdsclient/Cargo.toml | 2 +- sources/imdsclient/src/lib.rs | 35 ++--- sources/logdog/Cargo.toml | 2 +- sources/logdog/src/create_tarball.rs | 12 +- sources/logdog/src/error.rs | 2 +- sources/logdog/src/log_request.rs | 78 +++++----- sources/logdog/src/main.rs | 6 +- sources/metricdog/Cargo.toml | 2 +- sources/metricdog/src/config.rs | 4 +- sources/metricdog/src/error.rs | 2 +- sources/metricdog/src/main.rs | 2 +- sources/metricdog/src/metricdog.rs | 8 +- sources/metricdog/src/service_check.rs | 2 +- sources/models/Cargo.toml | 2 +- sources/models/src/modeled_types/ecs.rs | 6 +- .../models/src/modeled_types/kubernetes.rs | 46 +++--- sources/models/src/modeled_types/mod.rs | 2 +- sources/models/src/modeled_types/shared.rs | 41 +++--- sources/parse-datetime/Cargo.toml | 2 +- sources/parse-datetime/src/lib.rs | 12 +- sources/prairiedog/Cargo.toml | 2 +- sources/prairiedog/src/main.rs | 29 ++-- sources/shimpei/Cargo.toml | 2 +- sources/shimpei/src/main.rs | 18 +-- sources/updater/block-party/Cargo.toml | 2 +- sources/updater/block-party/src/lib.rs | 32 +++-- sources/updater/signpost/Cargo.toml | 2 +- sources/updater/signpost/src/error.rs | 2 +- sources/updater/signpost/src/state.rs | 32 ++--- sources/updater/update_metadata/Cargo.toml | 2 +- sources/updater/update_metadata/src/de.rs | 10 +- sources/updater/update_metadata/src/error.rs | 2 +- sources/updater/update_metadata/src/lib.rs | 26 ++-- sources/updater/updog/Cargo.toml | 2 +- sources/updater/updog/src/bin/updata.rs | 18 +-- sources/updater/updog/src/error.rs | 2 +- sources/updater/updog/src/main.rs | 87 +++++------ tools/Cargo.lock | 47 ++++-- tools/deny.toml | 5 +- 139 files changed, 1249 insertions(+), 1116 deletions(-) diff --git a/sources/Cargo.lock b/sources/Cargo.lock index 1e39b635659..84c1cae0c75 100644 --- a/sources/Cargo.lock +++ b/sources/Cargo.lock @@ -296,7 +296,7 @@ dependencies = [ "serde_json", "signal-hook", "simplelog", - "snafu", + "snafu 0.7.0", "tokio", "tokio-tungstenite", "toml", @@ -331,7 +331,7 @@ dependencies = [ "serde", "serde_json", "simplelog", - "snafu", + "snafu 0.7.0", "thar-be-updates", "toml", "walkdir", @@ -518,7 +518,7 @@ dependencies = [ name = "block-party" version = "0.1.0" dependencies = [ - "snafu", + "snafu 0.7.0", ] [[package]] @@ -536,7 +536,7 @@ dependencies = [ "serde", "serde_json", "simplelog", - "snafu", + "snafu 0.7.0", "tokio", ] @@ -557,7 +557,7 @@ dependencies = [ "log", "semver 1.0.4", "serde", - "snafu", + "snafu 0.7.0", ] [[package]] @@ -640,7 +640,7 @@ dependencies = [ "serde", "serde_json", "simplelog", - "snafu", + "snafu 0.7.0", "tempfile", "tokio", "x509-parser", @@ -744,7 +744,7 @@ dependencies = [ "serde", "serde_json", "simplelog", - "snafu", + "snafu 0.7.0", "tokio", ] @@ -887,7 +887,7 @@ dependencies = [ "percent-encoding", "serde", "serde_json", - "snafu", + "snafu 0.7.0", "toml", "walkdir", ] @@ -1007,7 +1007,7 @@ dependencies = [ "log", "serde", "simplelog", - "snafu", + "snafu 0.7.0", "tempfile", "toml", ] @@ -1039,7 +1039,7 @@ dependencies = [ "serde_json", "serde_plain", "simplelog", - "snafu", + "snafu 0.7.0", "tokio", "toml", "vmw_backdoor", @@ -1055,7 +1055,7 @@ dependencies = [ "schnauzer", "serde", "serde_json", - "snafu", + "snafu 0.7.0", "tokio", ] @@ -1313,7 +1313,7 @@ dependencies = [ "hex-literal", "lazy_static", "signpost", - "snafu", + "snafu 0.7.0", ] [[package]] @@ -1364,7 +1364,7 @@ dependencies = [ "gptman", "inotify", "libc", - "snafu", + "snafu 0.7.0", ] [[package]] @@ -1460,7 +1460,7 @@ dependencies = [ "serde", "serde_json", "simplelog", - "snafu", + "snafu 0.7.0", "tokio", ] @@ -1549,7 +1549,7 @@ dependencies = [ "httparse", "httpdate 0.3.2", "itoa 0.4.8", - "pin-project 1.0.8", + "pin-project", "socket2 0.3.19", "tokio", "tower-service", @@ -1583,7 +1583,7 @@ dependencies = [ "anyhow", "hex", "hyper", - "pin-project 1.0.8", + "pin-project", "tokio", ] @@ -1614,7 +1614,7 @@ dependencies = [ "log", "reqwest", "serde_json", - "snafu", + "snafu 0.7.0", "tokio", "tokio-retry", "tokio-test", @@ -1782,7 +1782,7 @@ dependencies = [ "reqwest", "serde_json", "shell-words", - "snafu", + "snafu 0.7.0", "tar", "tempfile", "tokio", @@ -1852,7 +1852,7 @@ dependencies = [ name = "merge-toml" version = "0.1.0" dependencies = [ - "snafu", + "snafu 0.7.0", "toml", ] @@ -1867,7 +1867,7 @@ dependencies = [ "reqwest", "serde", "simplelog", - "snafu", + "snafu 0.7.0", "structopt", "tempfile", "toml", @@ -1885,7 +1885,7 @@ dependencies = [ "schnauzer", "serde", "serde_json", - "snafu", + "snafu 0.7.0", "toml", ] @@ -1904,7 +1904,7 @@ dependencies = [ "regex", "semver 1.0.4", "simplelog", - "snafu", + "snafu 0.7.0", "storewolf", "tempfile", "tough", @@ -1990,7 +1990,7 @@ dependencies = [ "semver 1.0.4", "serde", "serde_plain", - "snafu", + "snafu 0.7.0", "toml", "url", "x509-parser", @@ -2011,7 +2011,7 @@ dependencies = [ "serde", "serde_json", "serde_plain", - "snafu", + "snafu 0.7.0", ] [[package]] @@ -2046,7 +2046,7 @@ version = "0.1.0" dependencies = [ "migration-helpers", "serde_json", - "snafu", + "snafu 0.7.0", ] [[package]] @@ -2266,7 +2266,7 @@ version = "0.1.0" dependencies = [ "cargo-readme", "chrono", - "snafu", + "snafu 0.7.0", ] [[package]] @@ -2374,33 +2374,13 @@ dependencies = [ "sha-1 0.8.2", ] -[[package]] -name = "pin-project" -version = "0.4.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "918192b5c59119d51e0cd221f4d49dde9112824ba717369e903c97d076083d0f" -dependencies = [ - "pin-project-internal 0.4.28", -] - [[package]] name = "pin-project" version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "576bc800220cc65dac09e99e97b08b358cfab6e17078de8dc5fee223bd2d0c08" dependencies = [ - "pin-project-internal 1.0.8", -] - -[[package]] -name = "pin-project-internal" -version = "0.4.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3be26700300be6d9d23264c73211d8190e755b6b5ca7a1b28230025511b52a5e" -dependencies = [ - "proc-macro2", - "quote", - "syn", + "pin-project-internal", ] [[package]] @@ -2438,7 +2418,7 @@ dependencies = [ "rusoto_core", "rusoto_eks", "serde_json", - "snafu", + "snafu 0.7.0", "tokio", ] @@ -2458,7 +2438,7 @@ dependencies = [ "nix 0.23.0", "signpost", "simplelog", - "snafu", + "snafu 0.7.0", ] [[package]] @@ -2870,7 +2850,7 @@ dependencies = [ "percent-encoding", "serde", "serde_json", - "snafu", + "snafu 0.7.0", "tokio", "url", ] @@ -3019,7 +2999,7 @@ dependencies = [ "serde", "serde_json", "simplelog", - "snafu", + "snafu 0.7.0", "tokio", ] @@ -3035,7 +3015,7 @@ dependencies = [ "serde", "serde_json", "simplelog", - "snafu", + "snafu 0.7.0", "tokio", ] @@ -3105,7 +3085,7 @@ dependencies = [ "serde", "serde_json", "simplelog", - "snafu", + "snafu 0.7.0", "tokio", ] @@ -3117,7 +3097,7 @@ dependencies = [ "log", "nix 0.23.0", "simplelog", - "snafu", + "snafu 0.7.0", ] [[package]] @@ -3155,7 +3135,7 @@ dependencies = [ "hex-literal", "serde", "serde_plain", - "snafu", + "snafu 0.7.0", ] [[package]] @@ -3186,12 +3166,22 @@ name = "snafu" version = "0.6.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eab12d3c261b2308b0d80c26fffb58d17eba81a4be97890101f416b478c79ca7" +dependencies = [ + "doc-comment", + "snafu-derive 0.6.10", +] + +[[package]] +name = "snafu" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2eba135d2c579aa65364522eb78590cdf703176ef71ad4c32b00f58f7afb2df5" dependencies = [ "backtrace", "doc-comment", "futures-core", - "pin-project 0.4.28", - "snafu-derive", + "pin-project", + "snafu-derive 0.7.0", ] [[package]] @@ -3205,6 +3195,18 @@ dependencies = [ "syn", ] +[[package]] +name = "snafu-derive" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a7fe9b0669ef117c5cabc5549638528f36771f058ff977d7689deb517833a75" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "socket2" version = "0.3.19" @@ -3245,7 +3247,7 @@ dependencies = [ "serde", "serde_json", "simplelog", - "snafu", + "snafu 0.7.0", "tempfile", "tokio", ] @@ -3270,7 +3272,7 @@ dependencies = [ "rand", "semver 1.0.4", "simplelog", - "snafu", + "snafu 0.7.0", "toml", "walkdir", ] @@ -3331,7 +3333,7 @@ dependencies = [ "serde", "serde_json", "simplelog", - "snafu", + "snafu 0.7.0", "tokio", ] @@ -3411,7 +3413,7 @@ dependencies = [ "schnauzer", "serde_json", "simplelog", - "snafu", + "snafu 0.7.0", "tokio", ] @@ -3437,7 +3439,7 @@ dependencies = [ "serde_plain", "signpost", "simplelog", - "snafu", + "snafu 0.7.0", "tempfile", "tokio", "update_metadata", @@ -3535,7 +3537,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f57eb36ecbe0fc510036adff84824dd3c24bb781e21bfa67b69d556aa85214f" dependencies = [ - "pin-project 1.0.8", + "pin-project", "rand", "tokio", ] @@ -3583,7 +3585,7 @@ checksum = "511de3f85caf1c98983545490c3d09685fa8eb634e57eec22bb4db271f46cbd8" dependencies = [ "futures-util", "log", - "pin-project 1.0.8", + "pin-project", "tokio", "tungstenite", ] @@ -3631,7 +3633,7 @@ dependencies = [ "serde", "serde_json", "serde_plain", - "snafu", + "snafu 0.6.10", "tempfile", "untrusted", "url", @@ -3757,7 +3759,7 @@ dependencies = [ "serde", "serde_json", "serde_plain", - "snafu", + "snafu 0.7.0", "toml", ] @@ -3779,7 +3781,7 @@ dependencies = [ "signal-hook", "signpost", "simplelog", - "snafu", + "snafu 0.7.0", "structopt", "tempfile", "toml", diff --git a/sources/api/apiclient/Cargo.toml b/sources/api/apiclient/Cargo.toml index 549f8160d17..e4d318c6014 100644 --- a/sources/api/apiclient/Cargo.toml +++ b/sources/api/apiclient/Cargo.toml @@ -31,7 +31,7 @@ serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" signal-hook = "0.3" simplelog = "0.10" -snafu = { version = "0.6", features = ["futures"] } +snafu = { version = "0.7", features = ["futures"] } tokio = { version = "~1.14", default-features = false, features = ["fs", "io-std", "io-util", "macros", "rt-multi-thread", "time"] } # LTS tokio-tungstenite = { version = "0.15", default-features = false, features = ["connect"] } toml = "0.5" diff --git a/sources/api/apiclient/src/apply.rs b/sources/api/apiclient/src/apply.rs index 20224365150..8952c3f32e5 100644 --- a/sources/api/apiclient/src/apply.rs +++ b/sources/api/apiclient/src/apply.rs @@ -49,7 +49,7 @@ where let method = "PATCH"; let (_status, _body) = crate::raw_request(&socket_path, &uri, method, Some(json)) .await - .context(error::Patch { + .context(error::PatchSnafu { input_source, uri, method, @@ -61,7 +61,7 @@ where let method = "POST"; let (_status, _body) = crate::raw_request(&socket_path, &uri, method, None) .await - .context(error::CommitApply { uri })?; + .context(error::CommitApplySnafu { uri })?; Ok(()) } @@ -78,30 +78,30 @@ where let mut output = String::new(); tokio::io::stdin() .read_to_string(&mut output) - .context(error::StdinRead) + .context(error::StdinReadSnafu) .await?; return Ok(output); } // Otherwise, the input should be a URI; parse it to know what kind. // Until reqwest handles file:// URIs: https://github.com/seanmonstar/reqwest/issues/178 - let uri = Url::parse(&input_source).context(error::Uri { + let uri = Url::parse(&input_source).context(error::UriSnafu { input_source: &input_source, })?; if uri.scheme() == "file" { // Turn the URI to a file path, and return a future that reads it. - let path = uri.to_file_path().ok().context(error::FileUri { + let path = uri.to_file_path().ok().context(error::FileUriSnafu { input_source: &input_source, })?; tokio::fs::read_to_string(path) - .context(error::FileRead { input_source }) + .context(error::FileReadSnafu { input_source }) .await } else { // Return a future that contains the text of the (non-file) URI. reqwest::get(uri) .and_then(|response| ready(response.error_for_status())) .and_then(|response| response.text()) - .context(error::Reqwest { + .context(error::ReqwestSnafu { uri: input_source, method: "GET", }) @@ -118,12 +118,12 @@ fn format_change(input: &str, input_source: &str) -> Result { // We need JSON for the API. serde lets us convert between Deserialize-able types by // reusing the deserializer. Turn the TOML value into a JSON value. let d = toml_val.into_deserializer(); - serde_json::Value::deserialize(d).context(error::TomlToJson { input_source })? + serde_json::Value::deserialize(d).context(error::TomlToJsonSnafu { input_source })? } Err(toml_err) => { // TOML failed, try JSON; include the toml parsing error, because if they intended to // give TOML we should still tell them what was wrong with it. - serde_json::from_str(&input).context(error::InputType { + serde_json::from_str(&input).context(error::InputTypeSnafu { input_source, toml_err, }) @@ -134,24 +134,24 @@ fn format_change(input: &str, input_source: &str) -> Result { // neither of which expects it. let json_object = json_val .as_object_mut() - .context(error::ModelType { input_source })?; + .context(error::ModelTypeSnafu { input_source })?; let json_inner = json_object .remove("settings") - .context(error::MissingSettings { input_source })?; + .context(error::MissingSettingsSnafu { input_source })?; // Deserialize into the model to confirm the settings are valid. let _settings = model::Settings::deserialize(&json_inner) - .context(error::ModelDeserialize { input_source })?; + .context(error::ModelDeserializeSnafu { input_source })?; // Return JSON text we can send to the API. - serde_json::to_string(&json_inner).context(error::JsonSerialize { input_source }) + serde_json::to_string(&json_inner).context(error::JsonSerializeSnafu { input_source }) } mod error { use snafu::Snafu; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub enum Error { #[snafu(display("Failed to commit combined settings to '{}': {}", uri, source))] CommitApply { uri: String, source: crate::Error }, diff --git a/sources/api/apiclient/src/exec.rs b/sources/api/apiclient/src/exec.rs index 197e66e922d..229582cd533 100644 --- a/sources/api/apiclient/src/exec.rs +++ b/sources/api/apiclient/src/exec.rs @@ -66,12 +66,12 @@ where // interpreted and turned into signals, etc. The Terminal type manages that for us, and resets // the terminal when it's dropped later. We set this up first so that we don't unnecessarily // talk to the server if it fails. - let terminal = Terminal::new(tty).context(error::Terminal)?; + let terminal = Terminal::new(tty).context(error::TerminalSnafu)?; // Connect to the server over the Unix-domain socket and upgrade to a WebSocket. let ws_stream = websocket_connect(socket_path, "/exec") .await - .context(error::Connect)?; + .context(error::ConnectSnafu)?; // We're going to split the stream into write and read halves so we can manage them with // separate threads, which simplifies the use of blocking calls, not requiring a totally new @@ -103,10 +103,11 @@ where tty: terminal.tty().clone(), }; // Control messages go to the server in a text channel, so we serialize to JSON before sending. - let msg = serde_json::to_string(&ClientMessage::Initialize(init)).context(error::Serialize)?; + let msg = + serde_json::to_string(&ClientMessage::Initialize(init)).context(error::SerializeSnafu)?; ws_tx .unbounded_send(Message::Text(msg)) - .context(error::SendMessage { + .context(error::SendMessageSnafu { kind: "initialization", })?; @@ -255,7 +256,7 @@ impl ReadFromServer { Message::Binary(data) => { trace!("Received {} bytes of output from server", data.len()); let mut stdout = tokio::io::stdout(); - stdout.write_all(&data).await.context(error::WriteOutput)?; + stdout.write_all(&data).await.context(error::WriteOutputSnafu)?; // May not be a full line of output, so flush any bytes we got. Failure here // isn't worthy of stopping the whole process. let _ = stdout.flush().await; @@ -279,12 +280,12 @@ impl ReadFromServer { // anyway. let _ = ret_tx.unbounded_send(ret); } - return error::Close.fail(); + return error::CloseSnafu.fail(); } // Text messages represent encoded control messages from the server. Message::Text(raw_msg) => { let server_message = - serde_json::from_str(&raw_msg).context(error::Deserialize)?; + serde_json::from_str(&raw_msg).context(error::DeserializeSnafu)?; match server_message { // Capacity messages tell us how many messages the server is // willing to receive before it rejects us. @@ -378,7 +379,7 @@ impl ReadFromUser { messages_read += 1; // Send the data to the server in a Binary message without encoding. tx.unbounded_send(Message::Binary(Vec::from(buf))) - .context(error::SendMessage { kind: "user input" })?; + .context(error::SendMessageSnafu { kind: "user input" })?; } // We don't normally get Err, since the server will close connection first, but for // completeness... @@ -398,7 +399,7 @@ impl ReadFromUser { return Ok(()); } else { // Any error other than EOF is a real read error. - Err(e).context(error::ReadFromUser)? + Err(e).context(error::ReadFromUserSnafu)? } } } @@ -420,7 +421,9 @@ impl ReadFromUser { // Read a batch of data at a time; 4k is a balanced number for small and large jobs. let mut buf = [0; 4096]; - let count = stdin.retry_read(&mut buf).context(error::ReadFromUser)?; + let count = stdin + .retry_read(&mut buf) + .context(error::ReadFromUserSnafu)?; // A read of 0 indicates EOF, so we're done. if count == 0 { break; @@ -430,17 +433,17 @@ impl ReadFromUser { // Send the data to the server in a Binary message without encoding. let msg = Vec::from(&buf[..count]); tx.unbounded_send(Message::Binary(msg)) - .context(error::SendMessage { kind: "user input" })?; + .context(error::SendMessageSnafu { kind: "user input" })?; } debug!("Finished reading input"); // Send a ContentComplete message to the server so it can exit the process more cleanly. // This is more important than the TTY case; interactive use typically has users typing // exit, or quit, or ctrl-d... noninteractive programs typically wait for EOF. - let msg = - serde_json::to_string(&ClientMessage::ContentComplete).context(error::Serialize)?; + let msg = serde_json::to_string(&ClientMessage::ContentComplete) + .context(error::SerializeSnafu)?; tx.unbounded_send(Message::Text(msg)) - .context(error::SendMessage { + .context(error::SendMessageSnafu { kind: "content complete", })?; @@ -464,7 +467,7 @@ impl ReadFromUser { let messages_outstanding = messages_read .checked_sub(messages_written) - .context(error::ServerCount { + .context(error::ServerCountSnafu { messages_read, messages_written, })?; @@ -588,8 +591,8 @@ impl HandleSignals { // Set up the signal handler; do this before starting a thread so we can die quickly on // failure. use signal::*; - let signals = - Signals::new(&[SIGWINCH, SIGTERM, SIGINT, SIGQUIT]).context(error::HandleSignals)?; + let signals = Signals::new(&[SIGWINCH, SIGTERM, SIGINT, SIGQUIT]) + .context(error::HandleSignalsSnafu)?; debug!("Spawning thread to manage signals"); thread::spawn(move || { @@ -619,7 +622,7 @@ impl HandleSignals { signal_tx .send(signal) .ok() - .context(error::SendSignal { signal })?; + .context(error::SendSignalSnafu { signal })?; // The signal and our handler have done their job, it's not an error. return Ok(()); } @@ -668,7 +671,7 @@ mod error { use snafu::{IntoError, Snafu}; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub enum Error { // This is used as a sort of marker; the user doesn't need wording about the connection // being closed because the process will end, and if because of an error, they'll see that. @@ -726,7 +729,7 @@ mod error { // This allows for the nice usage of err_into() on our WebSocket stream. impl From for Error { fn from(e: tokio_tungstenite::tungstenite::Error) -> Self { - ReadWebSocket.into_error(e) + ReadWebSocketSnafu.into_error(e) } } } diff --git a/sources/api/apiclient/src/exec/connect.rs b/sources/api/apiclient/src/exec/connect.rs index 062bed7c1d0..77fc4e7a68f 100644 --- a/sources/api/apiclient/src/exec/connect.rs +++ b/sources/api/apiclient/src/exec/connect.rs @@ -30,7 +30,7 @@ where // WebSocket afterward. let response = UnixClient.call(uri).await.map_err(|e| { // hyper-unix-connector doesn't have its own error type; not worth bringing in 'anyhow' - error::Connect { + error::ConnectSnafu { socket: socket_path.as_ref(), message: e.to_string(), } @@ -51,12 +51,12 @@ where // WebSocket stream that we can use to talk to the server, and the HTTP response. let (ws_stream, resp) = client_async(ws_request, response) .await - .context(error::Upgrade)?; + .context(error::UpgradeSnafu)?; // We only use the HTTP response to confirm that we switched protocols correctly. ensure!( resp.status() == StatusCode::SWITCHING_PROTOCOLS, - error::Protocol { + error::ProtocolSnafu { code: resp.status() } ); @@ -70,7 +70,7 @@ pub(crate) mod error { use std::path::PathBuf; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub enum Error { #[snafu(display("Failed to connect to server at {}: {}", socket.display(), message))] Connect { socket: PathBuf, message: String }, diff --git a/sources/api/apiclient/src/exec/terminal.rs b/sources/api/apiclient/src/exec/terminal.rs index 925ab3aa076..d1d6951758b 100644 --- a/sources/api/apiclient/src/exec/terminal.rs +++ b/sources/api/apiclient/src/exec/terminal.rs @@ -59,7 +59,7 @@ impl Terminal { // Get the current settings of the user's terminal so we can restore them later. let current_termios = - tcgetattr(STDOUT_FILENO).context(error::TermAttr { op: "get" })?; + tcgetattr(STDOUT_FILENO).context(error::TermAttrSnafu { op: "get" })?; debug!("Setting terminal to raw mode, sorry about the carriage returns"); let mut new_termios = current_termios.clone(); @@ -70,7 +70,7 @@ impl Terminal { // We make the change 'NOW' because we don't expect any input/output yet, and so should // have nothing to FLUSH. tcsetattr(STDOUT_FILENO, SetArg::TCSANOW, &new_termios) - .context(error::TermAttr { op: "set" })?; + .context(error::TermAttrSnafu { op: "set" })?; orig_termios = Some(current_termios); } @@ -100,7 +100,7 @@ pub(crate) mod error { use snafu::Snafu; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub enum Error { #[snafu(display("Have TTY, but failed to {} terminal attributes: {}", op, source))] TermAttr { op: String, source: nix::Error }, diff --git a/sources/api/apiclient/src/get.rs b/sources/api/apiclient/src/get.rs index 79a36e4f290..454f6f6129d 100644 --- a/sources/api/apiclient/src/get.rs +++ b/sources/api/apiclient/src/get.rs @@ -18,8 +18,8 @@ where let method = "GET"; let (_status, body) = crate::raw_request(&socket_path, &uri, method, None) .await - .context(error::Request { uri, method })?; - let value = serde_json::from_str(&body).context(error::ResponseJson { body })?; + .context(error::RequestSnafu { uri, method })?; + let value = serde_json::from_str(&body).context(error::ResponseJsonSnafu { body })?; results.push(value); } @@ -30,7 +30,7 @@ where merge_json(&mut merge_into, merge_from); merge_into }) - .context(error::NoPrefixes) + .context(error::NoPrefixesSnafu) } /// Fetches the given URI from the API and returns the result as an untyped Value. @@ -41,15 +41,15 @@ where let method = "GET"; let (_status, body) = crate::raw_request(&socket_path, &uri, method, None) .await - .context(error::Request { uri, method })?; - serde_json::from_str(&body).context(error::ResponseJson { body }) + .context(error::RequestSnafu { uri, method })?; + serde_json::from_str(&body).context(error::ResponseJsonSnafu { body }) } mod error { use snafu::Snafu; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub enum Error { #[snafu(display("Must give prefixes to query"))] NoPrefixes, diff --git a/sources/api/apiclient/src/lib.rs b/sources/api/apiclient/src/lib.rs index b40af23d66c..fb04c4a46f7 100644 --- a/sources/api/apiclient/src/lib.rs +++ b/sources/api/apiclient/src/lib.rs @@ -32,7 +32,7 @@ mod error { use snafu::Snafu; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub enum Error { #[snafu(display("Failed to build request: {}", source))] RequestSetup { source: http::Error }, @@ -89,7 +89,7 @@ where // Error if the response status is in not in the 2xx range. ensure!( status.is_success(), - error::ResponseStatus { + error::ResponseStatusSnafu { method: method.as_ref(), code: status, uri: uri.as_ref(), @@ -131,17 +131,20 @@ where .uri(&uri) .header(header::CONTENT_TYPE, "application/json") .body(Body::from(request_data)) - .context(error::RequestSetup)?; + .context(error::RequestSetupSnafu)?; // Send request. - let res = client.request(request).await.context(error::RequestSend)?; + let res = client + .request(request) + .await + .context(error::RequestSendSnafu)?; let status = res.status(); // Read streaming response body into a string. let body_bytes = body::to_bytes(res.into_body()) .await - .context(error::ResponseBodyRead)?; - let body = String::from_utf8(body_bytes.to_vec()).context(error::NonUtf8Response)?; + .context(error::ResponseBodyReadSnafu)?; + let body = String::from_utf8(body_bytes.to_vec()).context(error::NonUtf8ResponseSnafu)?; Ok((status, body)) } diff --git a/sources/api/apiclient/src/main.rs b/sources/api/apiclient/src/main.rs index b7f398c29a7..bba8c0ef417 100644 --- a/sources/api/apiclient/src/main.rs +++ b/sources/api/apiclient/src/main.rs @@ -566,7 +566,7 @@ fn parse_update_cancel_args(args: Vec) -> UpdateSubcommand { async fn check(args: &Args) -> Result { let output = update::check(&args.socket_path) .await - .context(error::UpdateCheck)?; + .context(error::UpdateCheckSnafu)?; match serde_json::from_str::(&output) { Ok(value) => println!("{:#}", value), @@ -600,14 +600,14 @@ fn massage_set_input(input_map: HashMap) -> Result(&in_val) { - serialize_scalar(&b).context(error::Serialize)? + serialize_scalar(&b).context(error::SerializeSnafu)? } else if let Ok(u) = serde_json::from_str::(&in_val) { - serialize_scalar(&u).context(error::Serialize)? + serialize_scalar(&u).context(error::SerializeSnafu)? } else if let Ok(f) = serde_json::from_str::(&in_val) { - serialize_scalar(&f).context(error::Serialize)? + serialize_scalar(&f).context(error::SerializeSnafu)? } else { // No deserialization, already a string, just serialize - serialize_scalar(&in_val).context(error::Serialize)? + serialize_scalar(&in_val).context(error::SerializeSnafu)? }; massaged_map.insert(key, serialized); } @@ -631,14 +631,14 @@ async fn run() -> Result<()> { TerminalMode::Stderr, ColorChoice::Auto, ) - .context(error::Logger)?; + .context(error::LoggerSnafu)?; match subcommand { Subcommand::Raw(raw) => { let (status, body) = apiclient::raw_request(&args.socket_path, &raw.uri, &raw.method, raw.data) .await - .context(error::Request { + .context(error::RequestSnafu { uri: &raw.uri, method: &raw.method, })?; @@ -656,13 +656,13 @@ async fn run() -> Result<()> { Subcommand::Apply(apply) => { apply::apply(&args.socket_path, apply.input_sources) .await - .context(error::Apply)?; + .context(error::ApplySnafu)?; } Subcommand::Exec(exec) => { exec::exec(&args.socket_path, exec.command, exec.target, exec.tty) .await - .context(error::Exec)?; + .context(error::ExecSnafu)?; } Subcommand::Get(get) => { @@ -670,7 +670,7 @@ async fn run() -> Result<()> { GetArgs::Uri(uri) => get::get_uri(&args.socket_path, uri).await, GetArgs::Prefixes(prefixes) => get::get_prefixes(&args.socket_path, prefixes).await, }; - let value = result.context(error::Get)?; + let value = result.context(error::GetSnafu)?; let pretty = serde_json::to_string_pretty(&value).expect("JSON Value already validated as JSON"); println!("{}", pretty); @@ -679,7 +679,7 @@ async fn run() -> Result<()> { Subcommand::Reboot(_reboot) => { reboot::reboot(&args.socket_path) .await - .context(error::Reboot)?; + .context(error::RebootSnafu)?; } Subcommand::Set(set) => { @@ -694,18 +694,18 @@ async fn run() -> Result<()> { // The data store deserialization code understands how to turn the key names // (a.b.c) and serialized values into the nested Settings structure. settings = datastore::deserialization::from_map(&massaged_map) - .context(error::DeserializeMap)?; + .context(error::DeserializeMapSnafu)?; } SetArgs::Json(json) => { // No processing to do on JSON input; the format determines the types. serde // can turn a Value into the nested Settings structure itself. - settings = serde_json::from_value(json).context(error::DeserializeJson)?; + settings = serde_json::from_value(json).context(error::DeserializeJsonSnafu)?; } }; set::set(&args.socket_path, &settings) .await - .context(error::Set)?; + .context(error::SetSnafu)?; } Subcommand::Update(subcommand) => match subcommand { @@ -725,14 +725,14 @@ async fn run() -> Result<()> { update::apply(&args.socket_path) .await - .context(error::UpdateApply)?; + .context(error::UpdateApplySnafu)?; // If the user requested it, and if we applied an update, reboot. (update::apply // will fail if no update was available or it couldn't apply the update.) if apply.reboot { reboot::reboot(&args.socket_path) .await - .context(error::Reboot)?; + .context(error::RebootSnafu)?; } else { info!("Update has been applied and will take effect on next reboot."); } @@ -741,7 +741,7 @@ async fn run() -> Result<()> { UpdateSubcommand::Cancel(_cancel) => { update::cancel(&args.socket_path) .await - .context(error::UpdateCancel)?; + .context(error::UpdateCancelSnafu)?; } }, } @@ -765,7 +765,7 @@ mod error { use snafu::Snafu; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub(crate) enum Error { #[snafu(display("Failed to apply settings: {}", source))] Apply { source: apply::Error }, diff --git a/sources/api/apiclient/src/reboot.rs b/sources/api/apiclient/src/reboot.rs index 83d1d627819..c092ac87ec7 100644 --- a/sources/api/apiclient/src/reboot.rs +++ b/sources/api/apiclient/src/reboot.rs @@ -11,7 +11,7 @@ where let method = "POST"; let (_status, _body) = crate::raw_request(&socket_path, uri, method, None) .await - .context(error::Request { uri, method })?; + .context(error::RequestSnafu { uri, method })?; info!("Rebooting, goodbye..."); Ok(()) @@ -21,7 +21,7 @@ mod error { use snafu::Snafu; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub enum Error { #[snafu(display("Failed {} request to '{}': {}", method, uri, source))] Request { diff --git a/sources/api/apiclient/src/set.rs b/sources/api/apiclient/src/set.rs index d3fc893b397..8ee097564eb 100644 --- a/sources/api/apiclient/src/set.rs +++ b/sources/api/apiclient/src/set.rs @@ -16,17 +16,17 @@ where // Send the settings changes to the server. let uri = format!("/settings?tx={}", transaction); let method = "PATCH"; - let request_body = serde_json::to_string(&settings).context(error::Serialize)?; + let request_body = serde_json::to_string(&settings).context(error::SerializeSnafu)?; let (_status, _body) = crate::raw_request(&socket_path, &uri, method, Some(request_body)) .await - .context(error::Request { uri, method })?; + .context(error::RequestSnafu { uri, method })?; // Commit the transaction and apply it to the system. let uri = format!("/tx/commit_and_apply?tx={}", transaction); let method = "POST"; let (_status, _body) = crate::raw_request(&socket_path, &uri, method, None) .await - .context(error::Request { uri, method })?; + .context(error::RequestSnafu { uri, method })?; Ok(()) } @@ -35,7 +35,7 @@ mod error { use snafu::Snafu; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub enum Error { #[snafu(display("Unable to serialize data: {}", source))] Serialize { source: serde_json::Error }, diff --git a/sources/api/apiclient/src/update.rs b/sources/api/apiclient/src/update.rs index 89891cc82c9..449ca4c0e23 100644 --- a/sources/api/apiclient/src/update.rs +++ b/sources/api/apiclient/src/update.rs @@ -84,7 +84,7 @@ where &WaitPolicy::new(Duration::from_millis(500), 2 * 60 * 10), ) .await - .context(error::PrepareUpdate)?; + .context(error::PrepareUpdateSnafu)?; info!("Setting the update active so it will apply on the next reboot..."); let (_body, _status) = wait_request( @@ -186,7 +186,7 @@ where // Fetch the initial status of the API so we know when it's changed. let (code, initial_body) = raw_request_unchecked(&socket_path, "/updates/status", "GET", None) .await - .context(error::GetStatus)?; + .context(error::GetStatusSnafu)?; // The timestamp is the primary field we use to notice a change. // The first call to the update API on a new system will return a 404, which is fine. @@ -196,7 +196,7 @@ where response_field(&["most_recent_command", "timestamp"], &initial_body) .unwrap_or_else(|| "first call".to_string()) } else { - return error::MissingStatus { + return error::MissingStatusSnafu { code, body: initial_body, } @@ -207,7 +207,7 @@ where // Make the real request the user wanted. let (_code, response_body) = raw_request(&socket_path, &url, &method, data) .await - .context(error::Request { command_name })?; + .context(error::RequestSnafu { command_name })?; // Note: we've now made the real request the user asked for, and the rest is our bookkeeping to // wait for it to finish. We're more careful with retries and don't want to early-exit with ?. @@ -226,7 +226,7 @@ where attempt += 1; ensure!( attempt < wait.max_attempts, - error::TimedOut { + error::TimedOutSnafu { waited: format!("{:?}", wait.between_attempts * wait.max_attempts), method: method.as_ref(), url: url.as_ref(), @@ -234,7 +234,7 @@ where ); ensure!( failures < max_failures, - error::StatusCheck { + error::StatusCheckSnafu { failures, method: method.as_ref(), url: url.as_ref(), @@ -296,7 +296,7 @@ where // If the command wasn't successful, give as much info as we can from the status. ensure!( after_status == "Success", - error::Command { + error::CommandSnafu { command_name, stderr: response_field(&["most_recent_command", "stderr"], &status_body) .unwrap_or_else(|| "".to_string()), @@ -319,7 +319,7 @@ mod error { use snafu::Snafu; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub enum Error { #[snafu(display( "{} attempt failed with status '{}' ({}): {}", diff --git a/sources/api/apiserver/Cargo.toml b/sources/api/apiserver/Cargo.toml index 5634ef09923..7261e2d82ca 100644 --- a/sources/api/apiserver/Cargo.toml +++ b/sources/api/apiserver/Cargo.toml @@ -31,7 +31,7 @@ semver = "1.0" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" simplelog = "0.10" -snafu = "0.6" +snafu = "0.7" thar-be-updates = { path = "../thar-be-updates", version = "0.1.0" } walkdir = "2.2" diff --git a/sources/api/apiserver/src/bin/apiserver.rs b/sources/api/apiserver/src/bin/apiserver.rs index 34afbf93997..7d1cad72b94 100644 --- a/sources/api/apiserver/src/bin/apiserver.rs +++ b/sources/api/apiserver/src/bin/apiserver.rs @@ -28,7 +28,7 @@ mod error { use snafu::Snafu; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(crate)")] + #[snafu(visibility(pub(crate)))] pub(crate) enum Error { #[snafu(display("Datastore does not exist, did storewolf run?"))] NonexistentDatastore, @@ -147,12 +147,12 @@ async fn run() -> Result<()> { let args = parse_args(env::args()); // SimpleLogger will send errors to stderr and anything less to stdout. - SimpleLogger::init(args.log_level, LogConfig::default()).context(error::Logger)?; + SimpleLogger::init(args.log_level, LogConfig::default()).context(error::LoggerSnafu)?; // Make sure the datastore exists ensure!( Path::new(&args.datastore_path).exists(), - error::NonexistentDatastore + error::NonexistentDatastoreSnafu ); // Access to the data store is controlled through a RwLock, allowing many readers, but a @@ -178,7 +178,7 @@ async fn run() -> Result<()> { args.exec_socket_path, ) .await - .context(error::Server) + .context(error::ServerSnafu) } // Returning a Result from main makes it print a Debug representation of the error, but with Snafu diff --git a/sources/api/apiserver/src/server/controller.rs b/sources/api/apiserver/src/server/controller.rs index d5182941405..3746d65ee9b 100644 --- a/sources/api/apiserver/src/server/controller.rs +++ b/sources/api/apiserver/src/server/controller.rs @@ -23,9 +23,11 @@ pub(crate) fn list_transactions(datastore: &D) -> Result> where D: DataStore, { - datastore.list_transactions().context(error::DataStore { - op: "list_transactions", - }) + datastore + .list_transactions() + .context(error::DataStoreSnafu { + op: "list_transactions", + }) } /// Build a Settings based on pending data in the datastore; the Settings will be empty if there @@ -50,7 +52,7 @@ pub(crate) fn delete_transaction( ) -> Result> { datastore .delete_transaction(transaction) - .context(error::DataStore { + .context(error::DataStoreSnafu { op: "delete_pending", }) } @@ -83,7 +85,7 @@ pub(crate) fn get_settings(datastore: &D, committed: &Committed) - get_prefix(datastore, committed, "settings.", None) .transpose() // None is not OK here - we always have *some* settings - .context(error::MissingData { prefix: "settings" })? + .context(error::MissingDataSnafu { prefix: "settings" })? } /// Build a Settings based on the data in the datastore that begins with the given prefix. @@ -108,7 +110,7 @@ pub(crate) fn get_settings_prefix>( // The "os" APIs don't deal with the data store at all, they just read a release field. /// Build a BottlerocketRelease using the bottlerocket-release library. pub(crate) fn get_os_info() -> Result { - BottlerocketRelease::new().context(error::ReleaseData) + BottlerocketRelease::new().context(error::ReleaseDataSnafu) } /// Build a BottlerocketRelease using the bottlerocket-release library, returning only the fields @@ -131,7 +133,7 @@ where // field names. Strip off the structure-level prefix. let field_prefix = prefix.trim_start_matches("os."); - let os = BottlerocketRelease::new().context(error::ReleaseData)?; + let os = BottlerocketRelease::new().context(error::ReleaseDataSnafu)?; // Turn into a serde Value we can manipulate. let val = serde_json::to_value(os).expect("struct to value can't fail"); @@ -162,7 +164,7 @@ pub(crate) fn get_services(datastore: &D) -> Result { ) .transpose() // None is not OK here - we always have services - .context(error::MissingData { prefix: "services" })? + .context(error::MissingDataSnafu { prefix: "services" })? } /// Build a Services based on the data in the datastore, returning only the fields that start with @@ -201,7 +203,7 @@ pub(crate) fn get_configuration_files(datastore: &D) -> Result( let mut data = HashMap::new(); for key_str in keys { trace!("Pulling value from datastore for key: {}", key_str); - let key = Key::new(KeyType::Data, &key_str).context(error::NewKey { + let key = Key::new(KeyType::Data, &key_str).context(error::NewKeySnafu { key_type: "data", name: *key_str, })?; let value = match datastore .get_key(&key, committed) - .context(error::DataStore { op: "get_key" })? + .context(error::DataStoreSnafu { op: "get_key" })? { Some(v) => v, // TODO: confirm we want to skip requested keys if not populated, or error @@ -288,7 +291,7 @@ pub(crate) fn get_settings_keys( data.insert(key, value); } - let settings = from_map(&data).context(error::Deserialization { + let settings = from_map(&data).context(error::DeserializationSnafu { given: "given keys", })?; Ok(settings) @@ -337,19 +340,19 @@ where let item_data = datastore .get_prefix(&item_prefix, committed) - .with_context(|| error::DataStore { + .with_context(|_| error::DataStoreSnafu { op: format!("get_prefix '{}' for {:?}", &item_prefix, committed), })?; ensure!( !item_data.is_empty(), - error::ListKeys { + error::ListKeysSnafu { requested: item_prefix } ); let item = from_map_with_prefix(Some(item_prefix.clone()), &item_data) - .context(error::Deserialization { given: item_prefix })?; + .context(error::DeserializationSnafu { given: item_prefix })?; result.insert(name.to_string(), item); } @@ -363,13 +366,14 @@ pub(crate) fn set_settings( transaction: &str, ) -> Result<()> { trace!("Serializing Settings to write to data store"); - let pairs = to_pairs(settings).context(error::DataStoreSerialization { given: "Settings" })?; + let pairs = + to_pairs(settings).context(error::DataStoreSerializationSnafu { given: "Settings" })?; let pending = Committed::Pending { tx: transaction.into(), }; datastore .set_keys(&pairs, &pending) - .context(error::DataStore { op: "set_keys" }) + .context(error::DataStoreSnafu { op: "set_keys" }) } // This is not as nice as get_settings, which uses Serializer/Deserializer to properly use the @@ -381,7 +385,7 @@ pub(crate) fn get_metadata_for_data_keys>( data_key_strs: &HashSet<&str>, ) -> Result> { trace!("Getting metadata '{}'", md_key_str.as_ref()); - let md_key = Key::new(KeyType::Meta, md_key_str.as_ref()).context(error::NewKey { + let md_key = Key::new(KeyType::Meta, md_key_str.as_ref()).context(error::NewKeySnafu { key_type: "meta", name: md_key_str.as_ref(), })?; @@ -389,7 +393,7 @@ pub(crate) fn get_metadata_for_data_keys>( let mut result = HashMap::new(); for data_key_str in data_key_strs { trace!("Pulling metadata from datastore for key: {}", data_key_str); - let data_key = Key::new(KeyType::Data, data_key_str).context(error::NewKey { + let data_key = Key::new(KeyType::Data, data_key_str).context(error::NewKeySnafu { key_type: "data", name: *data_key_str, })?; @@ -404,7 +408,7 @@ pub(crate) fn get_metadata_for_data_keys>( }; trace!("Deserializing scalar from metadata"); let value: Value = deserialize_scalar::<_, ScalarError>(&value_str) - .context(error::InvalidMetadata { key: md_key.name() })?; + .context(error::InvalidMetadataSnafu { key: md_key.name() })?; result.insert(data_key.to_string(), value); } @@ -420,7 +424,7 @@ pub(crate) fn get_metadata_for_all_data_keys>( trace!("Getting metadata '{}'", md_key_str.as_ref()); let meta_map = datastore .get_metadata_prefix("", &Some(md_key_str)) - .context(error::DataStore { + .context(error::DataStoreSnafu { op: "get_metadata_prefix", })?; @@ -429,7 +433,7 @@ pub(crate) fn get_metadata_for_all_data_keys>( for (meta_key, value_str) in metadata { trace!("Deserializing scalar from metadata"); let value: Value = deserialize_scalar::<_, ScalarError>(&value_str).context( - error::InvalidMetadata { + error::InvalidMetadataSnafu { key: meta_key.name(), }, )?; @@ -446,7 +450,7 @@ where { datastore .commit_transaction(transaction) - .context(error::DataStore { op: "commit" }) + .context(error::DataStoreSnafu { op: "commit" }) } /// Launches the config applier to make appropriate changes to the system based on any settings @@ -464,7 +468,7 @@ where // Prepare input to config applier; it uses the changed keys to update the right config trace!("Serializing the commit's changed keys: {:?}", keys_limit); let cmd_input = - serde_json::to_string(&keys_limit).context(error::CommandSerialization { + serde_json::to_string(&keys_limit).context(error::CommandSerializationSnafu { given: "commit's changed keys", })?; @@ -478,23 +482,23 @@ where //.stdout() //.stderr() .spawn() - .context(error::ConfigApplierStart)?; + .context(error::ConfigApplierStartSnafu)?; // Send changed keys to config applier trace!("Sending changed keys"); cmd.stdin .as_mut() - .context(error::ConfigApplierStdin)? + .context(error::ConfigApplierStdinSnafu)? .write_all(cmd_input.as_bytes()) - .context(error::ConfigApplierWrite)?; + .context(error::ConfigApplierWriteSnafu)?; // The config applier forks quickly; this wait ensures we don't get a zombie from its // initial process. Its child is reparented to init and init waits for that one. - let status = cmd.wait().context(error::ConfigApplierWait)?; + let status = cmd.wait().context(error::ConfigApplierWaitSnafu)?; // Similarly, this is just checking that it was able to fork, not checking its work. ensure!( status.success(), - error::ConfigApplierFork { + error::ConfigApplierForkSnafu { code: status .code() .map(|i| i.to_string()) @@ -513,10 +517,10 @@ where //.stdout() //.stderr() .status() - .context(error::ConfigApplierStart)?; + .context(error::ConfigApplierStartSnafu)?; ensure!( status.success(), - error::ConfigApplierFork { + error::ConfigApplierForkSnafu { code: status .code() .map(|i| i.to_string()) @@ -533,7 +537,7 @@ pub(crate) fn dispatch_update_command(args: &[&str]) -> Result { let status = Command::new("/usr/bin/thar-be-updates") .args(args) .status() - .context(error::UpdateDispatcher)?; + .context(error::UpdateDispatcherSnafu)?; if status.success() { return Ok(HttpResponse::NoContent().finish()); } diff --git a/sources/api/apiserver/src/server/error.rs b/sources/api/apiserver/src/server/error.rs index 4060e8da3e7..3146edc57d7 100644 --- a/sources/api/apiserver/src/server/error.rs +++ b/sources/api/apiserver/src/server/error.rs @@ -9,7 +9,7 @@ use std::string::String; // We want server (router/handler) and controller errors together so it's easy to define response // error codes for all the high-level types of errors that could happen during a request. #[derive(Debug, Snafu)] -#[snafu(visibility = "pub(super)")] +#[snafu(visibility(pub(super)))] pub enum Error { // Systemd Notification errors #[snafu(display("Systemd notify error: {}", source))] diff --git a/sources/api/apiserver/src/server/exec/child.rs b/sources/api/apiserver/src/server/exec/child.rs index a0e18eabf3f..46c7005de5a 100644 --- a/sources/api/apiserver/src/server/exec/child.rs +++ b/sources/api/apiserver/src/server/exec/child.rs @@ -125,12 +125,12 @@ impl ChildHandles { command.env("TERM", "screen"); debug!("Spawning command for exec request: {:?}", command); - let mut child = command.spawn().context(error::Spawn)?; + let mut child = command.spawn().context(error::SpawnSnafu)?; // `Command` returns pid as u32, but we want i32 to deal with nix. let pid_raw = i32::try_from(child.id()) .ok() - .context(error::InvalidPid { given: child.id() })?; + .context(error::InvalidPidSnafu { given: child.id() })?; let pid = Pid::from_raw(pid_raw); debug!("Spawned child has pid {}", pid); @@ -145,7 +145,7 @@ impl ChildHandles { // Now that the process is spawned, if we created a PTY, close its slave fd in the // parent process, or reads of the master side will block. if let Some(close_fd) = child_fds.close_fd { - close(close_fd).context(error::CloseFd)?; + close(close_fd).context(error::CloseFdSnafu)?; } // `ctr` doesn't (yet) send initial PTY size to containerd, requiring us to send a @@ -168,7 +168,11 @@ impl ChildHandles { // available until after the child is spawned, so ChildFds can't do it. let write_fd = match child_fds.write_fd { Some(write_fd) => write_fd, - None => child.stdin.take().context(error::NoStdin)?.into_raw_fd(), + None => child + .stdin + .take() + .context(error::NoStdinSnafu)? + .into_raw_fd(), }; // Set up the thread that writes input from the WebSocket to the child. @@ -270,9 +274,9 @@ impl ChildFds { // Create a PTY with openpty, starting with a size if the user gave one. let pty = if let Some(size) = tty_init.size { let size = WinSize::from(size); - openpty(Some(&size), None).context(error::OpenPty)? + openpty(Some(&size), None).context(error::OpenPtySnafu)? } else { - openpty(None, None).context(error::OpenPty)? + openpty(None, None).context(error::OpenPtySnafu)? }; // The "master" end of a PTY represents a user typing at a physical terminal; we connect // that to the user over the WebSocket. The "slave" end is connected to the process @@ -324,7 +328,7 @@ impl ChildFds { // Instead, create an OS-level pipe; the child will write both stdout and stderr to one end // of the pipe and the parent will read from the other. The child doesn't need access to // our end of the pipe so we use CLOEXEC to have it closed in the child automatically. - let (read_fd, write_fd) = pipe2(OFlag::O_CLOEXEC).context(error::CreatePipe)?; + let (read_fd, write_fd) = pipe2(OFlag::O_CLOEXEC).context(error::CreatePipeSnafu)?; // Make a duplicate for stderr. dup() sets CLOEXEC for us. let write_fd_dup = dup(write_fd)?; @@ -351,13 +355,13 @@ impl ChildFds { /// Set CLOEXEC on the given file descriptor so it's automatically closed in child processes. fn cloexec(fd: RawFd) -> Result<()> { // First, get the current settings. - let flags = fcntl(fd, FcntlArg::F_GETFD).context(error::Fcntl)?; + let flags = fcntl(fd, FcntlArg::F_GETFD).context(error::FcntlSnafu)?; // Turn the result into the nix type; can't fail, the bits just came from fcntl. let mut flags = FdFlag::from_bits(flags).expect("F_GETFD result not valid FdFlag?"); // Set CLOEXEC. flags.set(FdFlag::FD_CLOEXEC, true); // Update the settings on the fd. - fcntl(fd, FcntlArg::F_SETFD(flags)).context(error::Fcntl)?; + fcntl(fd, FcntlArg::F_SETFD(flags)).context(error::FcntlSnafu)?; Ok(()) } @@ -368,7 +372,7 @@ fn dup(fd: RawFd) -> Result { let minimum_fd = 0; // Create the requested duplicate. Use fcntl rather than unistd::dup so we can immediately set // CLOEXEC, automatically closing this FD in any child process. - fcntl(fd, FcntlArg::F_DUPFD_CLOEXEC(minimum_fd)).context(error::DupFd) + fcntl(fd, FcntlArg::F_DUPFD_CLOEXEC(minimum_fd)).context(error::DupFdSnafu) } /// WriteToChild is responsible for accepting user input from a channel connected to the WebSocket @@ -581,7 +585,7 @@ mod error { use std::io; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub(crate) enum Error { #[snafu(display( "Failed to close file descriptor, which could lead to a hang: {}", diff --git a/sources/api/apiserver/src/server/mod.rs b/sources/api/apiserver/src/server/mod.rs index d3d103476e3..8b734001bda 100644 --- a/sources/api/apiserver/src/server/mod.rs +++ b/sources/api/apiserver/src/server/mod.rs @@ -38,9 +38,9 @@ fn notify_unix_socket_ready() -> Result<()> { .arg("--ready") .arg("--no-block") .status() - .context(error::SystemdNotify)? + .context(error::SystemdNotifySnafu)? .success(), - error::SystemdNotifyStatus + error::SystemdNotifyStatusSnafu ); env::remove_var("NOTIFY_SOCKET"); } else { @@ -124,24 +124,24 @@ where }) .workers(threads) .bind_uds(socket_path.as_ref()) - .context(error::BindSocket { + .context(error::BindSocketSnafu { path: socket_path.as_ref(), })?; // If the socket needs to be chowned to a group to grant further access, that can be passed // as a parameter. if let Some(gid) = socket_gid { - chown(socket_path.as_ref(), None, Some(gid)).context(error::SetGroup { gid })?; + chown(socket_path.as_ref(), None, Some(gid)).context(error::SetGroupSnafu { gid })?; } let mode = 0o0660; let perms = Permissions::from_mode(mode); - set_permissions(socket_path.as_ref(), perms).context(error::SetPermissions { mode })?; + set_permissions(socket_path.as_ref(), perms).context(error::SetPermissionsSnafu { mode })?; // Notify system manager the UNIX socket has been initialized, so other service units can proceed notify_unix_socket_ready()?; - http_server.run().await.context(error::ServerStart) + http_server.run().await.context(error::ServerStartSnafu) } // =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= @@ -166,7 +166,7 @@ async fn get_model( return get_model_prefix(data, prefix).await; } - let datastore = data.ds.read().ok().context(error::DataStoreLock)?; + let datastore = data.ds.read().ok().context(error::DataStoreLockSnafu)?; // Fetch all the data and build a Model. let settings = Some(controller::get_settings(&*datastore, &Committed::Live)?); @@ -190,10 +190,10 @@ async fn get_model( /// Helper for get_model that handles the case of matching a user-specified prefix. async fn get_model_prefix(data: web::Data, prefix: &str) -> Result { if prefix.is_empty() { - return error::EmptyInput { input: "prefix" }.fail(); + return error::EmptyInputSnafu { input: "prefix" }.fail(); } - let datastore = data.ds.read().ok().context(error::DataStoreLock)?; + let datastore = data.ds.read().ok().context(error::DataStoreLockSnafu)?; // Fetch all the data. // Note that we don't add a prefix (for example "settings.") to the given prefix before passing @@ -242,14 +242,14 @@ async fn get_settings( query: web::Query>, data: web::Data, ) -> Result { - let datastore = data.ds.read().ok().context(error::DataStoreLock)?; + let datastore = data.ds.read().ok().context(error::DataStoreLockSnafu)?; let settings = if let Some(keys_str) = query.get("keys") { let keys = comma_separated("keys", keys_str)?; controller::get_settings_keys(&*datastore, &keys, &Committed::Live) } else if let Some(mut prefix) = query.get("prefix") { if prefix.is_empty() { - return error::EmptyInput { input: "prefix" }.fail(); + return error::EmptyInputSnafu { input: "prefix" }.fail(); } // When retrieving from /settings, the settings prefix is implied, so we add it if it // wasn't given. @@ -273,13 +273,13 @@ async fn patch_settings( data: web::Data, ) -> Result { let transaction = transaction_name(&query); - let mut datastore = data.ds.write().ok().context(error::DataStoreLock)?; + let mut datastore = data.ds.write().ok().context(error::DataStoreLockSnafu)?; controller::set_settings(&mut *datastore, &settings, transaction)?; Ok(HttpResponse::NoContent().finish()) // 204 } async fn get_transaction_list(data: web::Data) -> Result { - let datastore = data.ds.read().ok().context(error::DataStoreLock)?; + let datastore = data.ds.read().ok().context(error::DataStoreLockSnafu)?; let data = controller::list_transactions(&*datastore)?; Ok(TransactionListResponse(data)) } @@ -290,7 +290,7 @@ async fn get_transaction( data: web::Data, ) -> Result { let transaction = transaction_name(&query); - let datastore = data.ds.read().ok().context(error::DataStoreLock)?; + let datastore = data.ds.read().ok().context(error::DataStoreLockSnafu)?; let data = controller::get_transaction(&*datastore, transaction)?; Ok(SettingsResponse(data)) } @@ -301,7 +301,7 @@ async fn delete_transaction( data: web::Data, ) -> Result { let transaction = transaction_name(&query); - let mut datastore = data.ds.write().ok().context(error::DataStoreLock)?; + let mut datastore = data.ds.write().ok().context(error::DataStoreLockSnafu)?; let deleted = controller::delete_transaction(&mut *datastore, transaction)?; Ok(ChangedKeysResponse(deleted)) } @@ -313,12 +313,12 @@ async fn commit_transaction( data: web::Data, ) -> Result { let transaction = transaction_name(&query); - let mut datastore = data.ds.write().ok().context(error::DataStoreLock)?; + let mut datastore = data.ds.write().ok().context(error::DataStoreLockSnafu)?; let changes = controller::commit_transaction(&mut *datastore, transaction)?; if changes.is_empty() { - return error::CommitWithNoPending.fail(); + return error::CommitWithNoPendingSnafu.fail(); } Ok(ChangedKeysResponse(changes)) @@ -345,12 +345,12 @@ async fn commit_transaction_and_apply( data: web::Data, ) -> Result { let transaction = transaction_name(&query); - let mut datastore = data.ds.write().ok().context(error::DataStoreLock)?; + let mut datastore = data.ds.write().ok().context(error::DataStoreLockSnafu)?; let changes = controller::commit_transaction(&mut *datastore, transaction)?; if changes.is_empty() { - return error::CommitWithNoPending.fail(); + return error::CommitWithNoPendingSnafu.fail(); } let key_names = changes.iter().map(|k| k.name()).collect(); @@ -368,7 +368,7 @@ async fn get_os_info( ) -> Result { let os = if let Some(mut prefix) = query.get("prefix") { if prefix.is_empty() { - return error::EmptyInput { input: "prefix" }.fail(); + return error::EmptyInputSnafu { input: "prefix" }.fail(); } // When retrieving from /os, the "os" prefix is implied, so we add it if it wasn't given. let with_prefix = format!("os.{}", prefix); @@ -391,19 +391,19 @@ async fn get_affected_services( ) -> Result { if let Some(keys_str) = query.get("keys") { let data_keys = comma_separated("keys", keys_str)?; - let datastore = data.ds.read().ok().context(error::DataStoreLock)?; + let datastore = data.ds.read().ok().context(error::DataStoreLockSnafu)?; let resp = controller::get_metadata_for_data_keys(&*datastore, "affected-services", &data_keys)?; Ok(MetadataResponse(resp)) } else { - return error::MissingInput { input: "keys" }.fail(); + return error::MissingInputSnafu { input: "keys" }.fail(); } } /// Get all settings that have setting-generator metadata async fn get_setting_generators(data: web::Data) -> Result { - let datastore = data.ds.read().ok().context(error::DataStoreLock)?; + let datastore = data.ds.read().ok().context(error::DataStoreLockSnafu)?; let resp = controller::get_metadata_for_all_data_keys(&*datastore, "setting-generator")?; Ok(MetadataResponse(resp)) } @@ -415,12 +415,12 @@ async fn get_templates( ) -> Result { if let Some(keys_str) = query.get("keys") { let data_keys = comma_separated("keys", keys_str)?; - let datastore = data.ds.read().ok().context(error::DataStoreLock)?; + let datastore = data.ds.read().ok().context(error::DataStoreLockSnafu)?; let resp = controller::get_metadata_for_data_keys(&*datastore, "template", &data_keys)?; Ok(MetadataResponse(resp)) } else { - return error::MissingInput { input: "keys" }.fail(); + return error::MissingInputSnafu { input: "keys" }.fail(); } } @@ -430,14 +430,14 @@ async fn get_services( query: web::Query>, data: web::Data, ) -> Result { - let datastore = data.ds.read().ok().context(error::DataStoreLock)?; + let datastore = data.ds.read().ok().context(error::DataStoreLockSnafu)?; let resp = if let Some(names_str) = query.get("names") { let names = comma_separated("names", names_str)?; controller::get_services_names(&*datastore, &names, &Committed::Live) } else if let Some(mut prefix) = query.get("prefix") { if prefix.is_empty() { - return error::EmptyInput { input: "prefix" }.fail(); + return error::EmptyInputSnafu { input: "prefix" }.fail(); } // When retrieving from /services, the services prefix is implied, so we add it if it // wasn't given. @@ -461,14 +461,14 @@ async fn get_configuration_files( query: web::Query>, data: web::Data, ) -> Result { - let datastore = data.ds.read().ok().context(error::DataStoreLock)?; + let datastore = data.ds.read().ok().context(error::DataStoreLockSnafu)?; let resp = if let Some(names_str) = query.get("names") { let names = comma_separated("names", names_str)?; controller::get_configuration_files_names(&*datastore, &names, &Committed::Live) } else if let Some(mut prefix) = query.get("prefix") { if prefix.is_empty() { - return error::EmptyInput { input: "prefix" }.fail(); + return error::EmptyInputSnafu { input: "prefix" }.fail(); } // When retrieving from /configuration-files, the configuration-files prefix is implied, so // we add it if it wasn't given. @@ -487,16 +487,18 @@ async fn get_configuration_files( /// Get the update status from 'thar-be-updates' async fn get_update_status() -> Result { - let lockfile = File::create(UPDATE_LOCKFILE).context(error::UpdateLockOpen)?; - lockfile.try_lock_shared().context(error::UpdateShareLock)?; + let lockfile = File::create(UPDATE_LOCKFILE).context(error::UpdateLockOpenSnafu)?; + lockfile + .try_lock_shared() + .context(error::UpdateShareLockSnafu)?; let result = thar_be_updates::status::get_update_status(&lockfile); match result { Ok(update_status) => Ok(UpdateStatusResponse(update_status)), Err(e) => match e { thar_be_updates::error::Error::NoStatusFile { .. } => { - error::UninitializedUpdateStatus.fail() + error::UninitializedUpdateStatusSnafu.fail() } - _ => error::UpdateError.fail(), + _ => error::UpdateSnafu.fail(), }, } } @@ -528,10 +530,10 @@ async fn reboot() -> Result { .arg("-r") .arg("now") .output() - .context(error::Shutdown)?; + .context(error::ShutdownSnafu)?; ensure!( output.status.success(), - error::Reboot { + error::RebootSnafu { exit_code: match output.status.code() { Some(code) => code, None => output.status.signal().unwrap_or(1), @@ -548,7 +550,7 @@ async fn reboot() -> Result { fn comma_separated<'a>(key_name: &'static str, input: &'a str) -> Result> { if input.is_empty() { - return error::EmptyInput { input: key_name }.fail(); + return error::EmptyInputSnafu { input: key_name }.fail(); } Ok(input.split(',').collect()) } diff --git a/sources/api/bootstrap-containers/Cargo.toml b/sources/api/bootstrap-containers/Cargo.toml index ef091e3d6fa..d2172d9bc58 100644 --- a/sources/api/bootstrap-containers/Cargo.toml +++ b/sources/api/bootstrap-containers/Cargo.toml @@ -20,7 +20,7 @@ models = { path = "../../models", version = "0.1.0" } serde = { version = "1.0", features = ["derive"] } serde_json = "1" simplelog = "0.10" -snafu = "0.6" +snafu = "0.7" tokio = { version = "~1.14", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS [build-dependencies] diff --git a/sources/api/bootstrap-containers/src/main.rs b/sources/api/bootstrap-containers/src/main.rs index fff1bd0b1d6..75c7b848f42 100644 --- a/sources/api/bootstrap-containers/src/main.rs +++ b/sources/api/bootstrap-containers/src/main.rs @@ -160,15 +160,15 @@ fn parse_args(args: env::Args) -> Result<(Args, Subcommand)> { match arg.as_ref() { // Global args "--log-level" => { - let log_level = iter.next().context(error::Usage { + let log_level = iter.next().context(error::UsageSnafu { message: "Did not give argument to --log-level", })?; - global_args.log_level = - LevelFilter::from_str(&log_level).context(error::LogLevel { log_level })?; + global_args.log_level = LevelFilter::from_str(&log_level) + .context(error::LogLevelSnafu { log_level })?; } "-s" | "--socket-path" => { - global_args.socket_path = iter.next().context(error::Usage { + global_args.socket_path = iter.next().context(error::UsageSnafu { message: "Did not give argument to --socket-path", })? } @@ -189,13 +189,13 @@ fn parse_args(args: env::Args) -> Result<(Args, Subcommand)> { Some("create-containers") => Ok((global_args, Subcommand::CreateContainers {})), Some("mark-bootstrap") => Ok((global_args, parse_mark_bootstrap_args(subcommand_args)?)), None => { - return error::Usage { + return error::UsageSnafu { message: format!("Missing subcommand"), } .fail() } Some(x) => { - return error::Usage { + return error::UsageSnafu { message: format!("Unknown subcommand '{}'", x), } .fail() @@ -212,19 +212,19 @@ fn parse_mark_bootstrap_args(args: Vec) -> Result { while let Some(arg) = iter.next() { match arg.as_ref() { "--container-id" => { - container_id = Some(iter.next().context(error::Usage { + container_id = Some(iter.next().context(error::UsageSnafu { message: "Did not give argument to --container-id", })?); } "--mode" => { - mode = Some(iter.next().context(error::Usage { + mode = Some(iter.next().context(error::UsageSnafu { message: "Did not give argument to --mode", })?); } x => { - return error::Usage { + return error::UsageSnafu { message: format!("Unexpected argument '{}'", x), } .fail() @@ -232,11 +232,11 @@ fn parse_mark_bootstrap_args(args: Vec) -> Result { } } - let container_id = container_id.context(error::Usage { + let container_id = container_id.context(error::UsageSnafu { message: format!("Did not give argument to --container-id"), })?; - let mode = mode.context(error::Usage { + let mode = mode.context(error::UsageSnafu { message: format!("Did not give argument to --mode"), })?; @@ -244,7 +244,7 @@ fn parse_mark_bootstrap_args(args: Vec) -> Result { container_id: container_id, // Fail if 'mode' is invalid mode: BootstrapContainerMode::try_from(mode.to_string()) - .context(error::BootstrapContainerMode)?, + .context(error::BootstrapContainerModeSnafu)?, })) } @@ -264,7 +264,7 @@ where let source = container_details .source .as_ref() - .context(error::MissingField { + .context(error::MissingFieldSnafu { name, field: "source", })?; @@ -275,17 +275,17 @@ where // Create the directory regardless if user data was provided for the container let dir = Path::new(PERSISTENT_STORAGE_DIR).join(name); - fs::create_dir_all(&dir).context(error::Mkdir { dir: &dir })?; + fs::create_dir_all(&dir).context(error::MkdirSnafu { dir: &dir })?; // If user data was specified, decode it and write it out if let Some(user_data) = &container_details.user_data { debug!("Decoding user data for container '{}'", name); let decoded_bytes = - base64::decode(user_data.as_bytes()).context(error::Base64Decode { name })?; + base64::decode(user_data.as_bytes()).context(error::Base64DecodeSnafu { name })?; let path = dir.join("user-data"); debug!("Storing user data in {}", path.display()); - fs::write(path, decoded_bytes).context(error::UserDataWrite { name })?; + fs::write(path, decoded_bytes).context(error::UserDataWriteSnafu { name })?; } // Start/stop the container according to the 'mode' setting @@ -352,15 +352,19 @@ where let env_path = Path::new(ENV_FILE_DIR).join(env_filename); let mut output = String::new(); - writeln!(output, "CTR_SOURCE={}", source.as_ref()).context(error::WriteConfigurationValue { - value: source.as_ref(), - })?; - writeln!(output, "CTR_MODE={}", mode.as_ref()).context(error::WriteConfigurationValue { - value: mode.as_ref(), - })?; + writeln!(output, "CTR_SOURCE={}", source.as_ref()).context( + error::WriteConfigurationValueSnafu { + value: source.as_ref(), + }, + )?; + writeln!(output, "CTR_MODE={}", mode.as_ref()).context( + error::WriteConfigurationValueSnafu { + value: mode.as_ref(), + }, + )?; debug!("Writing environment file for unit '{}'", name); - fs::write(&env_path, output).context(error::WriteConfigurationFile { path: env_path })?; + fs::write(&env_path, output).context(error::WriteConfigurationFileSnafu { path: env_path })?; // Build unit's drop-in file, used to override the unit's configurations let mut output = String::new(); @@ -371,13 +375,14 @@ where // Override the type of dependency the `configured` target has in the unit let dependency = if essential { "RequiredBy" } else { "WantedBy" }; - writeln!(output, "[Install]").context(error::WriteConfigurationValue { value: "[Install]" })?; + writeln!(output, "[Install]") + .context(error::WriteConfigurationValueSnafu { value: "[Install]" })?; writeln!(output, "{}=configured.target", dependency) - .context(error::WriteConfigurationValue { value: dependency })?; + .context(error::WriteConfigurationValueSnafu { value: dependency })?; debug!("Writing drop-in file for {}", name); - fs::create_dir_all(&drop_in_dir).context(error::Mkdir { dir: &drop_in_dir })?; + fs::create_dir_all(&drop_in_dir).context(error::MkdirSnafu { dir: &drop_in_dir })?; fs::write(&drop_in_path, output) - .context(error::WriteConfigurationFile { path: drop_in_path })?; + .context(error::WriteConfigurationFileSnafu { path: drop_in_path })?; Ok(()) } @@ -395,12 +400,12 @@ where let uri = constants::API_SETTINGS_URI; let (_code, response_body) = apiclient::raw_request(&socket_path, uri, method, None) .await - .context(error::APIRequest { method, uri })?; + .context(error::APIRequestSnafu { method, uri })?; // Build a Settings struct from the response string debug!("Deserializing response"); let settings: model::Settings = - serde_json::from_str(&response_body).context(error::ResponseJson { method, uri })?; + serde_json::from_str(&response_body).context(error::ResponseJsonSnafu { method, uri })?; // If bootstrap containers aren't defined, return an empty map Ok(settings.bootstrap_containers.unwrap_or_default()) @@ -473,14 +478,14 @@ where command.args(args); let output = command .output() - .context(error::ExecutionFailure { command })?; + .context(error::ExecutionFailureSnafu { command })?; trace!("stdout: {}", String::from_utf8_lossy(&output.stdout)); trace!("stderr: {}", String::from_utf8_lossy(&output.stderr)); ensure!( output.status.success(), - error::CommandFailure { bin_path, output } + error::CommandFailureSnafu { bin_path, output } ); Ok(()) } @@ -502,7 +507,7 @@ where ensure!( failed == 0, - error::ManageContainersFailed { + error::ManageContainersFailedSnafu { failed, tried: bootstrap_containers.len() } @@ -527,19 +532,19 @@ where // the boot where it was created. if mode != "always" { let formatted = format!("settings.bootstrap-containers.{}.mode", container_id); - let key = - Key::new(KeyType::Data, &formatted).context(error::KeyFormat { key: formatted })?; - let value = serialize_scalar(&"off".to_string()).context(error::Serialize)?; + let key = Key::new(KeyType::Data, &formatted) + .context(error::KeyFormatSnafu { key: formatted })?; + let value = serialize_scalar(&"off".to_string()).context(error::SerializeSnafu)?; let mut map = HashMap::new(); map.insert(key, value); let settings: model::Settings = datastore::deserialization::from_map(&map) - .context(error::SettingsDeserialize { settings: map })?; + .context(error::SettingsDeserializeSnafu { settings: map })?; info!("Turning off container '{}'", container_id); apiclient::set::set(socket_path, &settings) .await - .context(error::Set)?; + .context(error::SetSnafu)?; } Ok(()) @@ -549,7 +554,7 @@ async fn run() -> Result<()> { let (args, subcommand) = parse_args(env::args())?; // SimpleLogger will send errors to stderr and anything less to stdout. - SimpleLogger::init(args.log_level, LogConfig::default()).context(error::Logger)?; + SimpleLogger::init(args.log_level, LogConfig::default()).context(error::LoggerSnafu)?; info!("bootstrap-containers started"); @@ -593,7 +598,7 @@ mod error { use std::process::{Command, Output}; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub(super) enum Error { #[snafu(display("Error sending {} to {}: {}", method, uri, source))] APIRequest { diff --git a/sources/api/certdog/Cargo.toml b/sources/api/certdog/Cargo.toml index cf4cdbbba45..7995fc58702 100644 --- a/sources/api/certdog/Cargo.toml +++ b/sources/api/certdog/Cargo.toml @@ -20,7 +20,7 @@ models = { path = "../../models", version = "0.1.0" } serde = { version = "1.0", features = ["derive"] } serde_json = "1" simplelog = "0.10" -snafu = "0.6" +snafu = "0.7" tokio = { version = "~1.14", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS x509-parser = "0.11.0" diff --git a/sources/api/certdog/src/main.rs b/sources/api/certdog/src/main.rs index aaf60767da4..5eb34dbb330 100644 --- a/sources/api/certdog/src/main.rs +++ b/sources/api/certdog/src/main.rs @@ -68,12 +68,12 @@ where let uri = constants::API_SETTINGS_URI; let (_code, response_body) = apiclient::raw_request(&socket_path, uri, method, None) .await - .context(error::APIRequest { method, uri })?; + .context(error::APIRequestSnafu { method, uri })?; // Build a Settings struct from the response string debug!("Deserializing response"); let settings: model::Settings = - serde_json::from_str(&response_body).context(error::ResponseJson { uri })?; + serde_json::from_str(&response_body).context(error::ResponseJsonSnafu { uri })?; split_bundles(settings.pki.unwrap_or_default()) } @@ -95,7 +95,7 @@ fn split_bundles( } let name = name.as_ref(); - let decoded = base64::decode(data.as_bytes()).context(error::Base64Decode { name })?; + let decoded = base64::decode(data.as_bytes()).context(error::Base64DecodeSnafu { name })?; // Each record in the API could include one or more certificates let mut pems = pems_from_iter(x509_parser::pem::Pem::iter_from_buffer(&decoded))?; @@ -127,7 +127,7 @@ where let trusted_store = trusted_store.as_ref(); // The default bundle includes the certificates shipped with the OS - let default_bundle = fs::File::open(source_bundle).context(error::ReadSourceBundle { + let default_bundle = fs::File::open(source_bundle).context(error::ReadSourceBundleSnafu { path: source_bundle, })?; let reader = BufReader::new(default_bundle); @@ -141,7 +141,7 @@ where // Write a PEM formatted bundle from trusted certificates fs::write(&trusted_store, pems_to_string(&trusted_bundle)?) - .context(error::UpdateTrustedStore)?; + .context(error::UpdateTrustedStoreSnafu)?; Ok(()) } @@ -153,7 +153,7 @@ where { let mut vec: Vec = Vec::new(); for pem in iter { - let pem = pem.context(error::ParsePEM)?; + let pem = pem.context(error::ParsePEMSnafu)?; vec.push(pem); } Ok(vec) @@ -164,7 +164,7 @@ fn pems_to_string(pems: &Vec) -> Result { let mut out = String::new(); for pem in pems { - writeln!(out, "{}", pem_to_string(pem)?).context(error::WritePemString)?; + writeln!(out, "{}", pem_to_string(pem)?).context(error::WritePemStringSnafu)?; } Ok(out) @@ -176,17 +176,19 @@ fn pem_to_string(pem: &x509_parser::pem::Pem) -> Result { // A comment will be added before the PEM formatted string to identify the certificate. if let Some(comment) = comment_for_pem(&pem)? { - writeln!(out, "# {}", comment).context(error::WritePemString)?; + writeln!(out, "# {}", comment).context(error::WritePemStringSnafu)?; } - writeln!(out, "{} {}{}", PEM_HEADER, pem.label, PEM_SUFFIX).context(error::WritePemString)?; + writeln!(out, "{} {}{}", PEM_HEADER, pem.label, PEM_SUFFIX) + .context(error::WritePemStringSnafu)?; let encoded = base64::encode(&pem.contents); let bytes = encoded.as_bytes(); for chunk in bytes.chunks(64) { let chunk = String::from_utf8_lossy(chunk); - writeln!(out, "{}", chunk).context(error::WritePemString)?; + writeln!(out, "{}", chunk).context(error::WritePemStringSnafu)?; } - writeln!(out, "{} {}{}", PEM_FOOTER, pem.label, PEM_SUFFIX).context(error::WritePemString)?; + writeln!(out, "{} {}{}", PEM_FOOTER, pem.label, PEM_SUFFIX) + .context(error::WritePemStringSnafu)?; Ok(out) } @@ -194,7 +196,7 @@ fn pem_to_string(pem: &x509_parser::pem::Pem) -> Result { /// Returns a string from the common name, organizational unit or organization /// fields in the certificate fn comment_for_pem(pem: &x509_parser::pem::Pem) -> Result> { - let cert = pem.parse_x509().context(error::ParseX509Certificate)?; + let cert = pem.parse_x509().context(error::ParseX509CertificateSnafu)?; let subject = cert.tbs_certificate.subject; let comment = subject .iter_common_name() @@ -211,7 +213,7 @@ async fn run() -> Result<()> { let args: Args = argh::from_env(); // SimpleLogger will send errors to stderr and anything less to stdout. - SimpleLogger::init(args.log_level, LogConfig::default()).context(error::Logger)?; + SimpleLogger::init(args.log_level, LogConfig::default()).context(error::LoggerSnafu)?; info!("certdog started"); let certificate_bundles = get_certificate_bundles(&args.socket_path).await?; @@ -240,7 +242,7 @@ mod error { use std::path::PathBuf; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub(super) enum Error { #[snafu(display("Error sending {} to {}: {}", method, uri, source))] APIRequest { diff --git a/sources/api/corndog/Cargo.toml b/sources/api/corndog/Cargo.toml index 12ca045f0cd..6a15628987e 100644 --- a/sources/api/corndog/Cargo.toml +++ b/sources/api/corndog/Cargo.toml @@ -18,7 +18,7 @@ models = { path = "../../models", version = "0.1.0" } serde = { version = "1.0", features = ["derive"] } serde_json = "1" simplelog = "0.10" -snafu = "0.6" +snafu = "0.7" tokio = { version = "~1.14", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS [build-dependencies] diff --git a/sources/api/corndog/src/main.rs b/sources/api/corndog/src/main.rs index b46d6c22b9e..b693ca347be 100644 --- a/sources/api/corndog/src/main.rs +++ b/sources/api/corndog/src/main.rs @@ -33,7 +33,7 @@ async fn run() -> Result<()> { let args = parse_args(env::args()); // SimpleLogger will send errors to stderr and anything less to stdout. - SimpleLogger::init(args.log_level, LogConfig::default()).context(error::Logger)?; + SimpleLogger::init(args.log_level, LogConfig::default()).context(error::LoggerSnafu)?; // If the user has kernel settings, apply them. let model = get_model(args.socket_path).await?; @@ -72,10 +72,10 @@ where trace!("{}ing from {}", method, uri); let (code, response_body) = apiclient::raw_request(socket_path, &uri, method, None) .await - .context(error::APIRequest { method, uri })?; + .context(error::APIRequestSnafu { method, uri })?; if !code.is_success() { - return error::APIResponse { + return error::APIResponseSnafu { method, uri, code, @@ -85,7 +85,7 @@ where } trace!("JSON response: {}", response_body); - serde_json::from_str(&response_body).context(error::ResponseJson { method, uri }) + serde_json::from_str(&response_body).context(error::ResponseJsonSnafu { method, uri }) } fn sysctl_path(name: S) -> PathBuf @@ -141,7 +141,7 @@ fn set_lockdown(lockdown: &str) -> Result<()> { return Ok(()); } - fs::write(LOCKDOWN_PATH, lockdown).context(error::Lockdown { current, lockdown }) + fs::write(LOCKDOWN_PATH, lockdown).context(error::LockdownSnafu { current, lockdown }) } /// The Linux kernel provides human-readable output like `[none] integrity confidentiality` when @@ -251,7 +251,7 @@ mod error { use std::io; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub(super) enum Error { #[snafu(display("Error {}ing to {}: {}", method, uri, source))] APIRequest { diff --git a/sources/api/datastore/Cargo.toml b/sources/api/datastore/Cargo.toml index ae1fb6b1d72..5d1d30dfd9e 100644 --- a/sources/api/datastore/Cargo.toml +++ b/sources/api/datastore/Cargo.toml @@ -15,7 +15,7 @@ log = "0.4" percent-encoding = "2.1" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -snafu = "0.6" +snafu = "0.7" walkdir = "2.2" [build-dependencies] diff --git a/sources/api/datastore/src/deserialization/error.rs b/sources/api/datastore/src/deserialization/error.rs index 3ea5049b4d1..cb192c9d57d 100644 --- a/sources/api/datastore/src/deserialization/error.rs +++ b/sources/api/datastore/src/deserialization/error.rs @@ -5,7 +5,7 @@ use crate::{Error as DataStoreError, ScalarError}; /// Potential errors from deserialization. #[derive(Debug, Snafu)] -#[snafu(visibility = "pub")] +#[snafu(visibility(pub))] pub enum Error { // This error variant is required to implement ser::Error for serde. #[snafu(display("Error during deserialization: {}", msg))] @@ -42,7 +42,7 @@ pub type Result = std::result::Result; impl de::Error for Error { fn custom(msg: T) -> Self { - Message { + MessageSnafu { msg: msg.to_string(), } .into_error(NoSource) diff --git a/sources/api/datastore/src/deserialization/pairs.rs b/sources/api/datastore/src/deserialization/pairs.rs index 5e4b525632b..e1f91f8cd55 100644 --- a/sources/api/datastore/src/deserialization/pairs.rs +++ b/sources/api/datastore/src/deserialization/pairs.rs @@ -88,7 +88,7 @@ where let key_prefix = match prefix { None => None, Some(ref p) => { - Some(Key::new(KeyType::Data, p).context(error::InvalidPrefix { prefix: p })?) + Some(Key::new(KeyType::Data, p).context(error::InvalidPrefixSnafu { prefix: p })?) } }; let de = CompoundDeserializer::new( @@ -132,7 +132,7 @@ where trace!("Handing off to scalar deserializer for deserialize_any"); scalar_deserializer .deserialize_any(visitor) - .context(error::DeserializeScalar) + .context(error::DeserializeScalarSnafu) } ValueDeserializer::Compound(compound_deserializer) => { compound_deserializer.deserialize_map(visitor) @@ -151,7 +151,7 @@ where trace!("Handing off to scalar deserializer for deserialize_option"); scalar_deserializer .deserialize_option(visitor) - .context(error::DeserializeScalar) + .context(error::DeserializeScalarSnafu) } ValueDeserializer::Compound(compound_deserializer) => { compound_deserializer.deserialize_option(visitor) @@ -206,7 +206,7 @@ where } fn bad_root() -> Result { - error::BadRoot.fail() + error::BadRootSnafu.fail() } impl<'de, K, S, BH> serde::de::Deserializer<'de> for CompoundDeserializer<'de, K, S, BH> @@ -239,7 +239,7 @@ where // this initial 'path' creation is the only place we take the struct name from // serde, per above comment. Key::from_segments(KeyType::Data, &[name.to_lowercase()]) - .context(error::InvalidPrefix { prefix: name })?, + .context(error::InvalidPrefixSnafu { prefix: name })?, ); } trace!("Path after name check: {:?}", self.path); @@ -254,7 +254,7 @@ where let mut new_keys = HashSet::new(); for key in self.keys { new_keys.insert(key.strip_prefix_segments(&path.segments()).context( - error::StripPrefix { + error::StripPrefixSnafu { prefix: path.name(), name: key.name(), }, diff --git a/sources/api/datastore/src/error.rs b/sources/api/datastore/src/error.rs index cd6bb794365..d1c7207ae1a 100644 --- a/sources/api/datastore/src/error.rs +++ b/sources/api/datastore/src/error.rs @@ -6,7 +6,7 @@ use super::{serialization, ScalarError}; /// Possible errors from datastore operations. #[derive(Debug, Snafu)] -#[snafu(visibility = "pub")] +#[snafu(visibility(pub))] pub enum Error { #[snafu(display("Error serializing {}: {} ", given, source))] Serialization { diff --git a/sources/api/datastore/src/filesystem.rs b/sources/api/datastore/src/filesystem.rs index 71d86edd2c7..eb16c32a564 100644 --- a/sources/api/datastore/src/filesystem.rs +++ b/sources/api/datastore/src/filesystem.rs @@ -68,7 +68,7 @@ impl FilesystemDataStore { // Confirm no path traversal outside of base ensure!( path != *base_path && path.starts_with(base_path), - error::PathTraversal { name: key.name() } + error::PathTraversalSnafu { name: key.name() } ); Ok(path) @@ -91,9 +91,12 @@ impl FilesystemDataStore { // we don't think "a.b" is actually two segments, for example. // Metadata keys only have a single segment, and we encode that as a single path // component, so we don't need the quotes in the filename. - let raw_key_name = metadata_key.segments().get(0).context(error::Internal { - msg: "metadata key with no segments", - })?; + let raw_key_name = metadata_key + .segments() + .get(0) + .context(error::InternalSnafu { + msg: "metadata key with no segments", + })?; let encoded_meta = encode_path_component(raw_key_name); path_str.push(METADATA_KEY_PREFIX); @@ -124,7 +127,7 @@ impl FilesystemDataStore { Ok(()) => {} Err(e) => { if e.kind() != io::ErrorKind::NotFound { - return Err(e).context(error::DeleteKey { path }); + return Err(e).context(error::DeleteKeySnafu { path }); } } } @@ -192,7 +195,7 @@ where // decode_utf8 will only fail if someone messed with the filesystem contents directly // and created a filename that contains percent-encoded bytes that are invalid UTF-8. .ok() - .context(error::Corruption { + .context(error::CorruptionSnafu { path: path.as_ref(), msg: format!("invalid UTF-8 in encoded segment '{}'", segment), }) @@ -208,7 +211,7 @@ fn read_file_for_key(key: &Key, path: &Path) -> Result> { return Ok(None); } - Err(e).context(error::KeyRead { key: key.name() }) + Err(e).context(error::KeyReadSnafu { key: key.name() }) } } } @@ -217,15 +220,15 @@ fn read_file_for_key(key: &Key, path: &Path) -> Result> { /// arbitrarily dotted keys without needing to create fixed structure first. fn write_file_mkdir>(path: PathBuf, data: S) -> Result<()> { // create key prefix directory if necessary - let dirname = path.parent().with_context(|| error::Internal { + let dirname = path.parent().with_context(|| error::InternalSnafu { msg: format!( "Given path to write without proper prefix: {}", path.display() ), })?; - fs::create_dir_all(dirname).context(error::Io { path: dirname })?; + fs::create_dir_all(dirname).context(error::IoSnafu { path: dirname })?; - fs::write(&path, data.as_ref().as_bytes()).context(error::Io { path: &path }) + fs::write(&path, data.as_ref().as_bytes()).context(error::IoSnafu { path: &path }) } /// KeyPath represents the filesystem path to a data or metadata key, relative to the base path of @@ -263,13 +266,13 @@ impl KeyPath { let key_path_raw = entry .path() .strip_prefix(strip_path_prefix) - .context(error::Path)?; + .context(error::PathSnafu)?; // If from_path doesn't think this is an OK key, we'll return Ok(None), otherwise the KeyPath Ok(Self::from_path(key_path_raw).ok()) } fn from_path(path: &Path) -> Result { - let path_str = path.to_str().context(error::Corruption { + let path_str = path.to_str().context(error::CorruptionSnafu { msg: "Non-UTF8 path", path, })?; @@ -277,7 +280,7 @@ impl KeyPath { // Split the data and metadata parts. // Any dots in key names are encoded. let mut keys = path_str.splitn(2, '.'); - let data_key_raw = keys.next().context(error::Internal { + let data_key_raw = keys.next().context(error::InternalSnafu { msg: "KeyPath given empty path", })?; // Turn the data path into a dotted key @@ -326,7 +329,7 @@ fn find_populated_key_paths>( match committed { // No live keys; something must be wrong because we create a default datastore. Committed::Live => { - return error::Corruption { + return error::CorruptionSnafu { msg: "Live datastore missing", path: base, } @@ -357,7 +360,7 @@ fn find_populated_key_paths>( // For anything we find, confirm it matches the user's filters, and add it to results. for entry in walker { - let entry = entry.context(error::ListKeys)?; + let entry = entry.context(error::ListKeysSnafu)?; if let Some(kp) = KeyPath::from_entry(&entry, &base)? { if !kp.data_key.name().starts_with(prefix.as_ref()) { trace!( @@ -423,7 +426,7 @@ impl DataStore for FilesystemDataStore { let mut result = HashMap::new(); for key_path in key_paths { let data_key = key_path.data_key; - let meta_key = key_path.metadata_key.context(error::Internal { + let meta_key = key_path.metadata_key.context(error::InternalSnafu { msg: format!("Found meta key path with no dot: {}", data_key), })?; @@ -504,7 +507,7 @@ impl DataStore for FilesystemDataStore { // Remove pending debug!("Removing old pending keys"); let path = self.base_path(&pending); - fs::remove_dir_all(&path).context(error::Io { path })?; + fs::remove_dir_all(&path).context(error::IoSnafu { path })?; Ok(pending_keys) } @@ -529,7 +532,7 @@ impl DataStore for FilesystemDataStore { if let Err(e) = fs::remove_dir_all(&path) { // If path doesn't exist, it's fine, we'll just return an empty list. if e.kind() != io::ErrorKind::NotFound { - return Err(e).context(error::Io { path }); + return Err(e).context(error::IoSnafu { path }); } } @@ -560,14 +563,14 @@ impl DataStore for FilesystemDataStore { break; } } - return Err(e).context(error::ListKeys); + return Err(e).context(error::ListKeysSnafu); } }; if entry.file_type().is_dir() { // The directory name should be valid UTF-8, encoded by encode_path_component, // or the data store has been corrupted. - let file_name = entry.file_name().to_str().context(error::Corruption { + let file_name = entry.file_name().to_str().context(error::CorruptionSnafu { msg: "Non-UTF8 path", path: entry.path(), })?; diff --git a/sources/api/datastore/src/key.rs b/sources/api/datastore/src/key.rs index 2dbfe5ca8b5..181e62715d3 100644 --- a/sources/api/datastore/src/key.rs +++ b/sources/api/datastore/src/key.rs @@ -107,7 +107,7 @@ impl Key { let prefix = prefix.as_ref(); ensure!( prefix != self.name, - error::InvalidKey { + error::InvalidKeySnafu { name: "", msg: format!("strip_prefix of '{}' matches key", prefix) } @@ -199,7 +199,7 @@ impl Key { ensure!( name.len() <= MAX_KEY_NAME_LENGTH, - error::KeyTooLong { + error::KeyTooLongSnafu { name, max: MAX_KEY_NAME_LENGTH, } @@ -209,7 +209,7 @@ impl Key { KeyType::Data => { ensure!( segments.len() >= 1, - error::InvalidKey { + error::InvalidKeySnafu { name, msg: "data keys must have at least one segment", } @@ -218,7 +218,7 @@ impl Key { KeyType::Meta => { ensure!( segments.len() == 1, - error::InvalidKey { + error::InvalidKeySnafu { name, msg: "meta keys may only have one segment", } @@ -249,7 +249,7 @@ impl Key { ensure!( !name.is_empty(), - error::InvalidKey { + error::InvalidKeySnafu { name, msg: "cannot be empty", } @@ -276,7 +276,7 @@ impl Key { // Segments can't be empty. ensure!( !segment.is_empty(), - error::InvalidKey { + error::InvalidKeySnafu { name, msg: "empty key segment", } @@ -290,7 +290,7 @@ impl Key { if Self::valid_character(c) { segment.push(c); } else { - return error::InvalidKey { + return error::InvalidKeySnafu { name, msg: format!("invalid character in key: '{}'", c), } @@ -301,14 +301,14 @@ impl Key { ensure!( !in_quotes, - error::InvalidKey { + error::InvalidKeySnafu { name, msg: "unbalanced quotes", } ); ensure!( !segment.is_empty(), - error::InvalidKey { + error::InvalidKeySnafu { name, msg: "ends with separator", } @@ -332,7 +332,7 @@ impl Key { for chr in segment.chars() { ensure!( chr == KEY_SEPARATOR || Self::valid_character(chr), - error::InvalidKey { + error::InvalidKeySnafu { // Give an understandable key name in the error, even if it's invalid name: segments.join("."), msg: format!("Segment '{}' contains invalid character '{}'", segment, chr), diff --git a/sources/api/datastore/src/lib.rs b/sources/api/datastore/src/lib.rs index ebcb10f9fe6..0321a50d02f 100644 --- a/sources/api/datastore/src/lib.rs +++ b/sources/api/datastore/src/lib.rs @@ -184,7 +184,7 @@ pub trait DataStore { trace!("Pulling value from datastore for key: {}", key); let value = self .get_key(&key, committed)? - .context(error::ListedKeyNotPresent { key: key.name() })?; + .context(error::ListedKeyNotPresentSnafu { key: key.name() })?; result.insert(key, value); } @@ -228,7 +228,7 @@ pub trait DataStore { &data_key ); let value = self.get_metadata(&meta_key, &data_key)?.context( - error::ListedMetaNotPresent { + error::ListedMetaNotPresentSnafu { meta_key: meta_key.name(), data_key: data_key.name(), }, diff --git a/sources/api/datastore/src/serialization/error.rs b/sources/api/datastore/src/serialization/error.rs index b9cd6972ffc..abe11e388b2 100644 --- a/sources/api/datastore/src/serialization/error.rs +++ b/sources/api/datastore/src/serialization/error.rs @@ -5,7 +5,7 @@ use crate::ScalarError; /// Potential errors from serialization. #[derive(Debug, Snafu)] -#[snafu(visibility = "pub")] +#[snafu(visibility(pub))] pub enum Error { // This error variant is required to implement ser::Error for serde. #[snafu(display("Error during serialization: {}", msg))] @@ -41,7 +41,7 @@ pub type Result = std::result::Result; impl ser::Error for Error { fn custom(msg: T) -> Self { - Message { + MessageSnafu { msg: msg.to_string(), } .into_error(NoSource) diff --git a/sources/api/datastore/src/serialization/mod.rs b/sources/api/datastore/src/serialization/mod.rs index bb8a94094a4..107843c3a5f 100644 --- a/sources/api/datastore/src/serialization/mod.rs +++ b/sources/api/datastore/src/serialization/mod.rs @@ -31,7 +31,7 @@ impl MapKeySerializer { /// Most types are invalid map keys (only strings are OK) so we need to return an error in most /// cases. This simplifies the creation of that error, with a customizable message for the type. fn bad_key(typename: &str) -> Result { - error::BadMapKey { typename }.fail() + error::BadMapKeySnafu { typename }.fail() } #[rustfmt::skip] @@ -54,7 +54,7 @@ impl ser::Serializer for &MapKeySerializer { let key = Key::from_segments(KeyType::Data, &[value]) .map_err(|e| { debug!("MapKeySerializer got invalid key name: {}", value); - error::InvalidKey { msg: format!("{}", e) }.into_error(NoSource) + error::InvalidKeySnafu { msg: format!("{}", e) }.into_error(NoSource) })?; trace!("MapKeySerializer got OK key: {}", key); Ok(key.to_string()) diff --git a/sources/api/datastore/src/serialization/pairs.rs b/sources/api/datastore/src/serialization/pairs.rs index 19e4b212787..892ae284ba9 100644 --- a/sources/api/datastore/src/serialization/pairs.rs +++ b/sources/api/datastore/src/serialization/pairs.rs @@ -37,7 +37,7 @@ where { let prefix = prefix.as_ref(); let prefix_key = Key::new(KeyType::Data, prefix).map_err(|e| { - error::InvalidKey { + error::InvalidKeySnafu { msg: format!("Prefix '{}' not valid as Key: {}", prefix, e), } .into_error(NoSource) @@ -84,17 +84,18 @@ impl<'a> Serializer<'a> { /// This helps us handle the cases where we have to have an existing prefix in order to output a /// value. It creates an explanatory error if the given prefix is None. fn expect_prefix(maybe_prefix: Option, value: &str) -> Result { - maybe_prefix.context(error::MissingPrefix { value }) + maybe_prefix.context(error::MissingPrefixSnafu { value }) } /// Serializes a concrete value and saves it to the output, assuming we have a prefix. macro_rules! concrete_output { ($self:expr, $value:expr) => { trace!("Serializing scalar at prefix {:?}", $self.prefix); - let value = - serialize_scalar::<_, ScalarError>(&$value).with_context(|| error::Serialization { + let value = serialize_scalar::<_, ScalarError>(&$value).with_context(|_| { + error::SerializationSnafu { given: format!("concrete value '{}'", $value), - })?; + } + })?; let prefix = expect_prefix($self.prefix, &value)?; $self.output.insert(prefix, value); return Ok(()); @@ -104,7 +105,7 @@ macro_rules! concrete_output { /// Several types are invalid for our serialization so we commonly need to return an error. This /// simplifies the creation of that error, with a customizable message for the type. fn bad_type(typename: &str) -> Result { - error::InvalidType { typename }.fail() + error::InvalidTypeSnafu { typename }.fail() } #[rustfmt::skip] @@ -157,7 +158,7 @@ impl<'a> ser::Serializer for Serializer<'a> { None => { trace!("Had no prefix, starting with struct name: {}", name); let key = Key::from_segments(KeyType::Data, &[&name]) - .map_err(|e| error::InvalidKey { + .map_err(|e| error::InvalidKeySnafu { msg: format!("struct '{}' not valid as Key: {}", name, e) }.into_error(NoSource))?; Some(key) @@ -209,7 +210,7 @@ impl<'a> ser::Serializer for Serializer<'a> { fn key_append_or_create(old_prefix: &Option, key: &Key) -> Result { if let Some(old_prefix) = old_prefix { old_prefix.append_key(&key).map_err(|e| { - error::InvalidKey { + error::InvalidKeySnafu { msg: format!( "appending '{}' to '{}' is invalid as Key: {}", key, old_prefix, e @@ -249,7 +250,7 @@ impl<'a> ser::SerializeMap for Serializer<'a> { // Note: we use 'new', not 'from_segments', because we just serialized into a string, // meaning it's in quoted form. let key = Key::new(KeyType::Data, &key_str).map_err(|e| { - error::InvalidKey { + error::InvalidKeySnafu { msg: format!("serialized map key '{}' not valid as Key: {}", &key_str, e), } .into_error(NoSource) @@ -273,7 +274,7 @@ impl<'a> ser::SerializeMap for Serializer<'a> { ); value.serialize(Serializer::new(self.output, Some(key))) } - None => error::Internal { + None => error::InternalSnafu { msg: "Attempted to serialize value without key", } .fail(), @@ -298,7 +299,7 @@ impl<'a> ser::SerializeStruct for Serializer<'a> { T: ?Sized + Serialize, { let key = Key::from_segments(KeyType::Data, &[&key_str]).map_err(|e| { - error::InvalidKey { + error::InvalidKeySnafu { msg: format!("struct field '{}' not valid as Key: {}", key_str, e), } .into_error(NoSource) @@ -356,10 +357,11 @@ impl<'a> ser::SerializeSeq for FlatSerializer<'a> { T: ?Sized + Serialize, { trace!("Serializing element of list"); - self.list - .push(serde_json::to_string(value).context(error::Serialization { + self.list.push( + serde_json::to_string(value).context(error::SerializationSnafu { given: "list element", - })?); + })?, + ); Ok(()) } @@ -367,7 +369,7 @@ impl<'a> ser::SerializeSeq for FlatSerializer<'a> { let mut originals: Vec = Vec::new(); trace!("Deserializing elements of list"); for original in self.list { - originals.push(original.parse().context(error::Deserialization { + originals.push(original.parse().context(error::DeserializationSnafu { given: "list element", })?); } @@ -375,7 +377,8 @@ impl<'a> ser::SerializeSeq for FlatSerializer<'a> { trace!("Serializing list"); self.output.insert( self.prefix, - serde_json::to_string(&originals).context(error::Serialization { given: "list" })?, + serde_json::to_string(&originals) + .context(error::SerializationSnafu { given: "list" })?, ); Ok(()) diff --git a/sources/api/early-boot-config/Cargo.toml b/sources/api/early-boot-config/Cargo.toml index 28716c27ec0..83b462f46e5 100644 --- a/sources/api/early-boot-config/Cargo.toml +++ b/sources/api/early-boot-config/Cargo.toml @@ -24,7 +24,7 @@ serde_json = "1" serde_plain = "1.0" serde-xml-rs = "0.5" simplelog = "0.10" -snafu = "0.6" +snafu = "0.7" tokio = { version = "~1.14", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS toml = "0.5" diff --git a/sources/api/early-boot-config/src/main.rs b/sources/api/early-boot-config/src/main.rs index fb38d1a0d1b..87db0843922 100644 --- a/sources/api/early-boot-config/src/main.rs +++ b/sources/api/early-boot-config/src/main.rs @@ -102,7 +102,7 @@ async fn run() -> Result<()> { let args = parse_args(env::args()); // SimpleLogger will send errors to stderr and anything less to stdout. - SimpleLogger::init(args.log_level, LogConfig::default()).context(error::Logger)?; + SimpleLogger::init(args.log_level, LogConfig::default()).context(error::LoggerSnafu)?; info!("early-boot-config started"); @@ -116,7 +116,7 @@ async fn run() -> Result<()> { for settings_json in Platform .platform_data() .await - .context(error::ProviderError)? + .context(error::ProviderSnafu)? { // Don't send an empty request to the API if settings_json.json.is_empty() { @@ -129,10 +129,10 @@ async fn run() -> Result<()> { let (code, response_body) = apiclient::raw_request(&args.socket_path, uri, method, Some(settings_json.json)) .await - .context(error::APIRequest { method, uri })?; + .context(error::APIRequestSnafu { method, uri })?; ensure!( code.is_success(), - error::Response { + error::ResponseSnafu { method, uri, code, @@ -167,7 +167,7 @@ mod error { use snafu::Snafu; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub(super) enum Error { #[snafu(display("Error {}ing '{}': {}", method, uri, source))] APIRequest { diff --git a/sources/api/early-boot-config/src/provider/aws.rs b/sources/api/early-boot-config/src/provider/aws.rs index 620cc44b55c..930200ddf64 100644 --- a/sources/api/early-boot-config/src/provider/aws.rs +++ b/sources/api/early-boot-config/src/provider/aws.rs @@ -20,16 +20,20 @@ impl AwsDataProvider { /// Fetches user data, which is expected to be in TOML form and contain a `[settings]` section, /// returning a SettingsJson representing the inside of that section. async fn user_data(client: &mut ImdsClient) -> Result> { - let user_data_raw = match client.fetch_userdata().await.context(error::ImdsRequest)? { + let user_data_raw = match client + .fetch_userdata() + .await + .context(error::ImdsRequestSnafu)? + { Some(user_data_raw) => user_data_raw, None => return Ok(None), }; let user_data_str = expand_slice_maybe(&user_data_raw) - .context(error::Decompression { what: "user data" })?; + .context(error::DecompressionSnafu { what: "user data" })?; trace!("Received user data: {}", user_data_str); let json = SettingsJson::from_toml_str(&user_data_str, "user data").context( - error::SettingsToJSON { + error::SettingsToJSONSnafu { from: "instance user data", }, )?; @@ -44,13 +48,14 @@ impl AwsDataProvider { let region = if Path::new(file).exists() { info!("{} found at {}, using it", desc, file); - let data = fs::read_to_string(file).context(error::InputFileRead { path: file })?; + let data = + fs::read_to_string(file).context(error::InputFileReadSnafu { path: file })?; let iid: serde_json::Value = - serde_json::from_str(&data).context(error::DeserializeJson)?; + serde_json::from_str(&data).context(error::DeserializeJsonSnafu)?; iid.get("region") - .context(error::IdentityDocMissingData { missing: "region" })? + .context(error::IdentityDocMissingDataSnafu { missing: "region" })? .as_str() - .context(error::WrongType { + .context(error::WrongTypeSnafu { field_name: "region", expected_type: "string", })? @@ -59,8 +64,8 @@ impl AwsDataProvider { client .fetch_region() .await - .context(error::ImdsRequest)? - .context(error::ImdsMissingRegion)? + .context(error::ImdsRequestSnafu)? + .context(error::ImdsMissingRegionSnafu)? }; trace!( "Retrieved region from instance identity document: {}", @@ -69,7 +74,7 @@ impl AwsDataProvider { let val = json!({ "aws": {"region": region} }); - let json = SettingsJson::from_val(&val, desc).context(error::SettingsToJSON { + let json = SettingsJson::from_val(&val, desc).context(error::SettingsToJSONSnafu { from: "instance identity document", })?; Ok(Some(json)) @@ -114,7 +119,7 @@ mod error { use std::path::PathBuf; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub(crate) enum Error { #[snafu(display("Failed to decompress {}: {}", what, source))] Decompression { what: String, source: io::Error }, diff --git a/sources/api/early-boot-config/src/provider/local_file.rs b/sources/api/early-boot-config/src/provider/local_file.rs index 5d75f3c4509..74069f5376b 100644 --- a/sources/api/early-boot-config/src/provider/local_file.rs +++ b/sources/api/early-boot-config/src/provider/local_file.rs @@ -15,7 +15,7 @@ pub(crate) fn local_file_user_data( info!("'{}' exists, using it", USER_DATA_FILE); // Read the file, decompressing it if compressed. - let user_data_str = expand_file_maybe(USER_DATA_FILE).context(error::InputFileRead { + let user_data_str = expand_file_maybe(USER_DATA_FILE).context(error::InputFileReadSnafu { path: USER_DATA_FILE, })?; @@ -24,7 +24,7 @@ pub(crate) fn local_file_user_data( } let json = SettingsJson::from_toml_str(&user_data_str, "user data").context( - error::SettingsToJSON { + error::SettingsToJSONSnafu { from: USER_DATA_FILE, }, )?; @@ -38,7 +38,7 @@ mod error { use std::path::PathBuf; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub(crate) enum Error { #[snafu(display("Unable to read input file '{}': {}", path.display(), source))] InputFileRead { path: PathBuf, source: io::Error }, diff --git a/sources/api/early-boot-config/src/provider/vmware.rs b/sources/api/early-boot-config/src/provider/vmware.rs index 354c93110aa..ad3b8a63504 100644 --- a/sources/api/early-boot-config/src/provider/vmware.rs +++ b/sources/api/early-boot-config/src/provider/vmware.rs @@ -53,8 +53,8 @@ impl VmwareDataProvider { ensure!( user_data_files.next().is_none(), - error::UserDataFileCount { - location: Self::CD_ROM_MOUNT + error::UserDataFileCountSnafu { + place: Self::CD_ROM_MOUNT } ); @@ -68,7 +68,7 @@ impl VmwareDataProvider { Some(_) => unreachable!(), None => { // Read the file, decompressing it if compressed. - expand_file_maybe(&user_data_file).context(error::InputFileRead { + expand_file_maybe(&user_data_file).context(error::InputFileReadSnafu { path: &user_data_file, })? } @@ -91,7 +91,7 @@ impl VmwareDataProvider { } let json = SettingsJson::from_toml_str(&user_data_str, "user data from CD-ROM").context( - error::SettingsToJSON { + error::SettingsToJsonSnafu { from: user_data_file.display().to_string(), }, )?; @@ -107,12 +107,12 @@ impl VmwareDataProvider { // fn ovf_user_data>(path: P) -> Result { let path = path.as_ref(); - let file = File::open(path).context(error::InputFileRead { path })?; + let file = File::open(path).context(error::InputFileReadSnafu { path })?; let reader = OptionalCompressionReader::new(BufReader::new(file)); // Deserialize the OVF file, dropping everything we don't care about let ovf: Environment = - serde_xml_rs::from_reader(reader).context(error::XmlDeserialize { path })?; + serde_xml_rs::from_reader(reader).context(error::XmlDeserializeSnafu { path })?; // We have seen the keys in the `Property` section be "namespaced" like "oe:key" or // "of:key". Since we aren't trying to validate the schema beyond the presence of the @@ -130,12 +130,12 @@ impl VmwareDataProvider { } // Base64 decode the &str - let decoded_bytes = base64::decode(&base64_str).context(error::Base64Decode { + let decoded_bytes = base64::decode(&base64_str).context(error::Base64DecodeSnafu { what: "OVF user data", })?; // Decompress the data if it's compressed - let decoded = expand_slice_maybe(&decoded_bytes).context(error::Decompression { + let decoded = expand_slice_maybe(&decoded_bytes).context(error::DecompressionSnafu { what: "OVF user data", })?; @@ -147,19 +147,19 @@ impl VmwareDataProvider { info!("Attempting to retrieve user data via guestinfo interface"); // It would be extremely odd to get here and not be on VMware, but check anyway - ensure!(vmw_backdoor::is_vmware_cpu(), error::NotVmware); + ensure!(vmw_backdoor::is_vmware_cpu(), error::NotVmwareSnafu); // `guestinfo.userdata.encoding` informs us how to handle the data in the // `guestinfo.userdata` field let maybe_encoding = Self::backdoor_get_bytes(Self::GUESTINFO_USERDATA_ENCODING)?; let user_data_encoding: UserDataEncoding = match maybe_encoding { Some(val) => { - let encoding_str = String::from_utf8(val).context(error::InvalidUtf8 { + let encoding_str = String::from_utf8(val).context(error::InvalidUtf8Snafu { what: Self::GUESTINFO_USERDATA_ENCODING, })?; info!("Found user data encoding: {}", encoding_str); - serde_plain::from_str(&encoding_str).context(error::UnknownEncoding { + serde_plain::from_str(&encoding_str).context(error::UnknownEncodingSnafu { encoding: encoding_str, })? } @@ -190,23 +190,23 @@ impl VmwareDataProvider { // Decompresses the data if it is gzip'ed let mut output = String::new(); let mut compression_reader = OptionalCompressionReader::new(decoder); - compression_reader - .read_to_string(&mut output) - .context(error::Decompression { + compression_reader.read_to_string(&mut output).context( + error::DecompressionSnafu { what: "guestinfo user data", - })?; + }, + )?; output } UserDataEncoding::Raw => { - String::from_utf8(user_data_bytes).context(error::InvalidUtf8 { + String::from_utf8(user_data_bytes).context(error::InvalidUtf8Snafu { what: Self::GUESTINFO_USERDATA, })? } }; let json = SettingsJson::from_toml_str(&user_data_string, "user data from guestinfo") - .context(error::SettingsToJSON { from: "guestinfo" })?; + .context(error::SettingsToJsonSnafu { from: "guestinfo" })?; Ok(Some(json)) } @@ -225,16 +225,18 @@ impl VmwareDataProvider { ); vmw_backdoor::probe_backdoor() }) - .context(error::Backdoor { + .context(error::BackdoorSnafu { op: "probe and acquire access", })?; - let mut erpc = backdoor.open_enhanced_chan().context(error::Backdoor { - op: "open eRPC channel", - })?; + let mut erpc = backdoor + .open_enhanced_chan() + .context(error::BackdoorSnafu { + op: "open eRPC channel", + })?; erpc.get_guestinfo(key.as_bytes()) - .context(error::GuestInfo { what: key }) + .context(error::GuestInfoSnafu { what: key }) } } @@ -316,7 +318,7 @@ mod error { use std::path::PathBuf; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub(crate) enum Error { #[snafu(display("VMware backdoor: failed to '{}': '{}'", op, source))] Backdoor { @@ -354,7 +356,7 @@ mod error { NotVmware, #[snafu(display("Unable to serialize settings from {}: {}", from, source))] - SettingsToJSON { + SettingsToJson { from: String, source: crate::settings::Error, }, @@ -365,8 +367,8 @@ mod error { source: serde_plain::Error, }, - #[snafu(display("Found multiple user data files in '{}', expected 1", location))] - UserDataFileCount { location: String }, + #[snafu(display("Found multiple user data files in '{}', expected 1", place))] + UserDataFileCount { place: String }, #[snafu(display("Unable to deserialize XML from: '{}': {}", path.display(), source))] XmlDeserialize { diff --git a/sources/api/early-boot-config/src/settings.rs b/sources/api/early-boot-config/src/settings.rs index c1fe5404c92..137331c6063 100644 --- a/sources/api/early-boot-config/src/settings.rs +++ b/sources/api/early-boot-config/src/settings.rs @@ -23,7 +23,7 @@ impl SettingsJson { S: Into, { Ok(Self { - json: serde_json::to_string(&data).context(error::SettingsToJSON)?, + json: serde_json::to_string(&data).context(error::SettingsToJSONSnafu)?, desc: desc.into(), }) } @@ -39,11 +39,13 @@ impl SettingsJson { S2: Into, { let mut val: toml::Value = - toml::from_str(&data.as_ref()).context(error::TOMLUserDataParse)?; - let table = val.as_table_mut().context(error::UserDataNotTomlTable)?; + toml::from_str(&data.as_ref()).context(error::TOMLUserDataParseSnafu)?; + let table = val + .as_table_mut() + .context(error::UserDataNotTomlTableSnafu)?; let inner = table .remove("settings") - .context(error::UserDataMissingSettings)?; + .context(error::UserDataMissingSettingsSnafu)?; SettingsJson::from_val(&inner, desc) } @@ -53,7 +55,7 @@ mod error { use snafu::Snafu; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(crate)")] + #[snafu(visibility(pub(crate)))] pub(crate) enum Error { #[snafu(display("Error serializing settings to JSON: {}", source))] SettingsToJSON { source: serde_json::error::Error }, diff --git a/sources/api/ecs-settings-applier/Cargo.toml b/sources/api/ecs-settings-applier/Cargo.toml index 76dc3613aa6..2c5f7d9f545 100644 --- a/sources/api/ecs-settings-applier/Cargo.toml +++ b/sources/api/ecs-settings-applier/Cargo.toml @@ -15,7 +15,7 @@ serde = {version = "1.0", features = ["derive"]} serde_json = "1" schnauzer = { path = "../schnauzer", version = "0.1.0" } log = "0.4" -snafu = "0.6" +snafu = "0.7" tokio = { version = "~1.14", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS [build-dependencies] diff --git a/sources/api/ecs-settings-applier/src/ecs.rs b/sources/api/ecs-settings-applier/src/ecs.rs index fbb4baf56f1..99375f9c193 100644 --- a/sources/api/ecs-settings-applier/src/ecs.rs +++ b/sources/api/ecs-settings-applier/src/ecs.rs @@ -69,13 +69,13 @@ async fn run() -> Result<()> { debug!("Requesting settings values"); let settings = schnauzer::get_settings(&args.socket_path) .await - .context(error::Settings)?; + .context(error::SettingsSnafu)?; debug!("settings = {:#?}", settings.settings); let ecs = settings .settings .and_then(|s| s.ecs) - .context(error::Model)?; + .context(error::ModelSnafu)?; let mut config = ECSConfig { cluster: ecs.cluster, @@ -115,10 +115,10 @@ async fn run() -> Result<()> { .insert(key.to_string(), value.to_string()); } } - let serialized = serde_json::to_string(&config).context(error::Serialization)?; + let serialized = serde_json::to_string(&config).context(error::SerializationSnafu)?; debug!("serialized = {}", serialized); - write_to_disk(DEFAULT_ECS_CONFIG_PATH, serialized).context(error::FS { + write_to_disk(DEFAULT_ECS_CONFIG_PATH, serialized).context(error::FSSnafu { path: DEFAULT_ECS_CONFIG_PATH, })?; Ok(()) @@ -183,7 +183,7 @@ mod error { use snafu::Snafu; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub(super) enum Error { #[snafu(display("Failed to read settings: {}", source))] Settings { diff --git a/sources/api/host-containers/Cargo.toml b/sources/api/host-containers/Cargo.toml index ded9b393cd3..eb93fe33d1d 100644 --- a/sources/api/host-containers/Cargo.toml +++ b/sources/api/host-containers/Cargo.toml @@ -19,7 +19,7 @@ models = { path = "../../models", version = "0.1.0" } serde = { version = "1.0", features = ["derive"] } serde_json = "1" simplelog = "0.10" -snafu = "0.6" +snafu = "0.7" tokio = { version = "~1.14", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS [build-dependencies] diff --git a/sources/api/host-containers/src/main.rs b/sources/api/host-containers/src/main.rs index b55cc806ede..eb92d91147d 100644 --- a/sources/api/host-containers/src/main.rs +++ b/sources/api/host-containers/src/main.rs @@ -43,7 +43,7 @@ mod error { use std::process::{Command, Output}; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub(super) enum Error { #[snafu(display("Error sending {} to {}: {}", method, uri, source))] APIRequest { @@ -147,10 +147,10 @@ where let uri = constants::API_SETTINGS_URI; let (code, response_body) = apiclient::raw_request(&socket_path, uri, method, None) .await - .context(error::APIRequest { method, uri })?; + .context(error::APIRequestSnafu { method, uri })?; ensure!( code.is_success(), - error::APIResponse { + error::APIResponseSnafu { method, uri, code, @@ -160,7 +160,7 @@ where // Build a Settings struct from the response string let settings: model::Settings = - serde_json::from_str(&response_body).context(error::ResponseJson { method, uri })?; + serde_json::from_str(&response_body).context(error::ResponseJsonSnafu { method, uri })?; // If host containers aren't defined, return an empty map Ok(settings.host_containers.unwrap_or_default()) @@ -254,7 +254,7 @@ where command.args(args); let output = command .output() - .context(error::ExecutionFailure { command })?; + .context(error::ExecutionFailureSnafu { command })?; let stdout = String::from_utf8_lossy(&output.stdout).to_string(); @@ -263,7 +263,7 @@ where ensure!( output.status.success(), - error::CommandFailure { bin_path, output } + error::CommandFailureSnafu { bin_path, output } ); Ok(stdout) } @@ -280,18 +280,19 @@ where let mut output = String::new(); writeln!(output, "CTR_SUPERPOWERED={}", superpowered) - .context(error::EnvFileBuildFailed { name })?; + .context(error::EnvFileBuildFailedSnafu { name })?; writeln!(output, "CTR_SOURCE={}", source.as_ref()) - .context(error::EnvFileBuildFailed { name })?; + .context(error::EnvFileBuildFailedSnafu { name })?; writeln!( output, "\n# Just for reference; service is enabled or disabled by host-containers service" ) - .context(error::EnvFileBuildFailed { name })?; - writeln!(output, "# CTR_ENABLED={}", enabled).context(error::EnvFileBuildFailed { name })?; + .context(error::EnvFileBuildFailedSnafu { name })?; + writeln!(output, "# CTR_ENABLED={}", enabled) + .context(error::EnvFileBuildFailedSnafu { name })?; - fs::write(&path, output).context(error::EnvFileWriteFailed { path })?; + fs::write(&path, output).context(error::EnvFileWriteFailedSnafu { path })?; Ok(()) } @@ -364,10 +365,13 @@ where { // Get basic settings, as retrieved from API. let name = name.as_ref(); - let source = image_details.source.as_ref().context(error::MissingField { - name, - field: "source", - })?; + let source = image_details + .source + .as_ref() + .context(error::MissingFieldSnafu { + name, + field: "source", + })?; let enabled = image_details.enabled.unwrap_or(false); let superpowered = image_details.superpowered.unwrap_or(false); @@ -378,17 +382,17 @@ where // Create the directory regardless if user data was provided for the container let dir = Path::new(PERSISTENT_STORAGE_BASE_DIR).join(name); - fs::create_dir_all(&dir).context(error::Mkdir { dir: &dir })?; + fs::create_dir_all(&dir).context(error::MkdirSnafu { dir: &dir })?; fs::set_permissions(&dir, fs::Permissions::from_mode(0o700)) - .context(error::SetPermissions { name })?; + .context(error::SetPermissionsSnafu { name })?; // If user data was specified, unencode it and write it out before we start the container. if let Some(user_data) = &image_details.user_data { let decoded_bytes = - base64::decode(user_data.as_bytes()).context(error::Base64Decode { name })?; + base64::decode(user_data.as_bytes()).context(error::Base64DecodeSnafu { name })?; let path = dir.join("user-data"); - fs::write(path, decoded_bytes).context(error::UserDataWrite { name })?; + fs::write(path, decoded_bytes).context(error::UserDataWriteSnafu { name })?; } // Write the environment file needed for the systemd service to have details about this @@ -488,7 +492,7 @@ async fn run() -> Result<()> { let changed_settings: Vec<&str> = changed_settings_env.split_whitespace().collect(); // SimpleLogger will send errors to stderr and anything less to stdout. - SimpleLogger::init(args.log_level, LogConfig::default()).context(error::Logger)?; + SimpleLogger::init(args.log_level, LogConfig::default()).context(error::LoggerSnafu)?; info!("host-containers started"); @@ -507,7 +511,7 @@ async fn run() -> Result<()> { ensure!( failed == 0, - error::ManageContainersFailed { + error::ManageContainersFailedSnafu { failed, tried: host_containers.len() } diff --git a/sources/api/migration/migration-helpers/Cargo.toml b/sources/api/migration/migration-helpers/Cargo.toml index e39fa9b8d61..87d2395a926 100644 --- a/sources/api/migration/migration-helpers/Cargo.toml +++ b/sources/api/migration/migration-helpers/Cargo.toml @@ -15,7 +15,7 @@ handlebars = "4.1" schnauzer = { path = "../../schnauzer", version = "0.1.0" } serde = "1.0.104" serde_json = "1.0" -snafu = "0.6" +snafu = "0.7" toml = "0.5" [dev-dependencies] diff --git a/sources/api/migration/migration-helpers/src/common_migrations.rs b/sources/api/migration/migration-helpers/src/common_migrations.rs index 475c3e5de8b..d14468b5735 100644 --- a/sources/api/migration/migration-helpers/src/common_migrations.rs +++ b/sources/api/migration/migration-helpers/src/common_migrations.rs @@ -320,7 +320,7 @@ impl Migration for ReplaceListsMigration { .iter() .map(|v| v.as_str()) .collect::>>() - .with_context(|| error::ReplaceListContents { + .with_context(|| error::ReplaceListContentsSnafu { setting: replacement.setting, data: data.clone(), })?; @@ -363,7 +363,7 @@ impl Migration for ReplaceListsMigration { .iter() .map(|v| v.as_str()) .collect::>>() - .with_context(|| error::ReplaceListContents { + .with_context(|| error::ReplaceListContentsSnafu { setting: replacement.setting, data: data.clone(), })?; @@ -594,7 +594,7 @@ impl ReplaceTemplateMigration { // The prefixes we want to make available; these each have to be deserialized below. if k.starts_with("settings.") || k.starts_with("os.") { datastore.insert( - datastore::Key::new(datastore::KeyType::Data, k).context(error::NewKey)?, + datastore::Key::new(datastore::KeyType::Data, k).context(error::NewKeySnafu)?, // We want the serialized form here, to work with the datastore deserialization code. // to_string on a Value gives the serialized form. v.to_string(), @@ -609,11 +609,11 @@ impl ReplaceTemplateMigration { Some("settings".to_string()), &datastore, ) - .context(error::DeserializeDatastore)?; + .context(error::DeserializeDatastoreSnafu)?; // Same for "os.*" let os_data: HashMap = datastore::deserialization::from_map_with_prefix(Some("os".to_string()), &datastore) - .context(error::DeserializeDatastore)?; + .context(error::DeserializeDatastoreSnafu)?; let mut structured_data = HashMap::new(); structured_data.insert("settings", settings_data); @@ -647,20 +647,20 @@ impl ReplaceTemplateMigration { "template".to_string(), serde_json::Value::String(incoming_template.to_string()), ); - let registry = - schnauzer::build_template_registry().context(error::BuildTemplateRegistry)?; + let registry = schnauzer::build_template_registry() + .context(error::BuildTemplateRegistrySnafu)?; // Structure the input migration data into its hierarchical representation needed by render_template let input_data = self.structure_migration_data(&input.data)?; // Generate settings data using the setting's outgoing template so we can confirm // it matches our expected value; if not, the user has changed it and we should stop. let generated_old_data = registry .render_template(template, &input_data) - .context(error::RenderTemplate { template })?; + .context(error::RenderTemplateSnafu { template })?; if generated_old_data == *outgoing_setting_data { // Generate settings data using the setting's incoming template let generated_new_data = registry .render_template(incoming_template, &input_data) - .context(error::RenderTemplate { template })?; + .context(error::RenderTemplateSnafu { template })?; println!( "Changing value of '{}' from '{}' to '{}'", self.setting, outgoing_setting_data, generated_new_data @@ -693,7 +693,7 @@ impl Migration for ReplaceTemplateMigration { if let Some(input_value) = input.data.get(self.setting) { let data = input_value .as_str() - .context(error::NonStringSettingDataType { + .context(error::NonStringSettingDataTypeSnafu { setting: self.setting, })?; println!( @@ -718,7 +718,7 @@ impl Migration for ReplaceTemplateMigration { if let Some(input_value) = input.data.get(self.setting) { let data = input_value .as_str() - .context(error::NonStringSettingDataType { + .context(error::NonStringSettingDataTypeSnafu { setting: self.setting, })?; println!( @@ -872,7 +872,7 @@ impl Migration for ReplaceMetadataListsMigration { .iter() .map(|v| v.as_str()) .collect::>>() - .with_context(|| error::ReplaceMetadataListContents { + .with_context(|| error::ReplaceMetadataListContentsSnafu { setting: replacement.setting, metadata: replacement.metadata, data: data.clone(), @@ -926,7 +926,7 @@ impl Migration for ReplaceMetadataListsMigration { .iter() .map(|v| v.as_str()) .collect::>>() - .with_context(|| error::ReplaceMetadataListContents { + .with_context(|| error::ReplaceMetadataListContentsSnafu { setting: replacement.setting, metadata: replacement.metadata, data: data.clone(), diff --git a/sources/api/migration/migration-helpers/src/datastore_helper.rs b/sources/api/migration/migration-helpers/src/datastore_helper.rs index c19f0ad84a6..ea6a0f4ffa5 100644 --- a/sources/api/migration/migration-helpers/src/datastore_helper.rs +++ b/sources/api/migration/migration-helpers/src/datastore_helper.rs @@ -22,7 +22,7 @@ pub(crate) fn get_input_data( ) -> Result { let raw_data = datastore .get_prefix("", committed) - .with_context(|| error::GetData { + .with_context(|_| error::GetDataSnafu { committed: committed.clone(), })?; @@ -35,16 +35,16 @@ pub(crate) fn get_input_data( // Deserialize values to Value so there's a consistent input type. (We can't specify item // types because we'd have to know the model structure.) let value = - deserialize_scalar(&value_str).context(error::Deserialize { input: value_str })?; + deserialize_scalar(&value_str).context(error::DeserializeSnafu { input: value_str })?; data.insert(key_name.clone(), value); } // We also want to make "os.*" values, like variant and arch, available to migrations. - let release = BottlerocketRelease::new().context(error::BottlerocketRelease)?; - let os_pairs = to_pairs_with_prefix("os", &release).context(error::SerializeRelease)?; + let release = BottlerocketRelease::new().context(error::BottlerocketReleaseSnafu)?; + let os_pairs = to_pairs_with_prefix("os", &release).context(error::SerializeReleaseSnafu)?; for (data_key, value_str) in os_pairs.into_iter() { let value = - deserialize_scalar(&value_str).context(error::Deserialize { input: value_str })?; + deserialize_scalar(&value_str).context(error::DeserializeSnafu { input: value_str })?; data.insert(data_key.name().clone(), value); } @@ -54,7 +54,7 @@ pub(crate) fn get_input_data( if let Committed::Live = committed { let raw_metadata = datastore .get_metadata_prefix("", &None as &Option<&str>) - .context(error::GetMetadata)?; + .context(error::GetMetadataSnafu)?; for (data_key, meta_map) in raw_metadata.into_iter() { // See notes above about storing key Strings and Values. let data_key_name = data_key.name(); @@ -64,7 +64,7 @@ pub(crate) fn get_input_data( for (metadata_key, value_str) in meta_map.into_iter() { let metadata_key_name = metadata_key.name(); let value = deserialize_scalar(&value_str) - .context(error::Deserialize { input: value_str })?; + .context(error::DeserializeSnafu { input: value_str })?; data_entry.insert(metadata_key_name.clone(), value); } } @@ -85,11 +85,11 @@ pub(crate) fn set_output_data( let mut data = HashMap::new(); for (data_key_name, raw_value) in &input.data { // See notes above about storing key Strings and Values. - let data_key = Key::new(KeyType::Data, data_key_name).context(error::InvalidKey { + let data_key = Key::new(KeyType::Data, data_key_name).context(error::InvalidKeySnafu { key_type: KeyType::Data, key: data_key_name, })?; - let value = serialize_scalar(raw_value).context(error::Serialize)?; + let value = serialize_scalar(raw_value).context(error::SerializeSnafu)?; data.insert(data_key, value); } @@ -98,24 +98,24 @@ pub(crate) fn set_output_data( // * We're either about to reboot or just have, and the settings applier will run afterward datastore .set_keys(&data, committed) - .context(error::DataStoreWrite)?; + .context(error::DataStoreWriteSnafu)?; // Set metadata in a loop (currently no batch API) for (data_key_name, meta_map) in &input.metadata { - let data_key = Key::new(KeyType::Data, data_key_name).context(error::InvalidKey { + let data_key = Key::new(KeyType::Data, data_key_name).context(error::InvalidKeySnafu { key_type: KeyType::Data, key: data_key_name, })?; for (metadata_key_name, raw_value) in meta_map.into_iter() { let metadata_key = - Key::new(KeyType::Meta, metadata_key_name).context(error::InvalidKey { + Key::new(KeyType::Meta, metadata_key_name).context(error::InvalidKeySnafu { key_type: KeyType::Meta, key: metadata_key_name, })?; - let value = serialize_scalar(&raw_value).context(error::Serialize)?; + let value = serialize_scalar(&raw_value).context(error::SerializeSnafu)?; datastore .set_metadata(&metadata_key, &data_key, value) - .context(error::DataStoreWrite)?; + .context(error::DataStoreWriteSnafu)?; } } diff --git a/sources/api/migration/migration-helpers/src/error.rs b/sources/api/migration/migration-helpers/src/error.rs index 395788c3b2c..37d786d8eab 100644 --- a/sources/api/migration/migration-helpers/src/error.rs +++ b/sources/api/migration/migration-helpers/src/error.rs @@ -5,7 +5,7 @@ use std::path::PathBuf; /// Error contains the errors that can happen in the migration helper functions and in migrations. #[derive(Debug, Snafu)] -#[snafu(visibility = "pub")] +#[snafu(visibility(pub))] pub enum Error { #[snafu(display("Unable to get system release data: {}", source))] BottlerocketRelease { source: bottlerocket_release::Error }, diff --git a/sources/api/migration/migration-helpers/src/lib.rs b/sources/api/migration/migration-helpers/src/lib.rs index 0c4f5f5c975..f798c71bb3c 100644 --- a/sources/api/migration/migration-helpers/src/lib.rs +++ b/sources/api/migration/migration-helpers/src/lib.rs @@ -94,7 +94,7 @@ pub fn run_migration(mut migration: impl Migration, args: &Args) -> Result<()> { let mut committeds = vec![Committed::Live]; let transactions = source .list_transactions() - .context(error::ListTransactions)?; + .context(error::ListTransactionsSnafu)?; committeds.extend(transactions.into_iter().map(|tx| Committed::Pending { tx })); for committed in committeds { diff --git a/sources/api/migration/migrations/archived/v1.1.3/kubelet-cpu-manager-state/Cargo.toml b/sources/api/migration/migrations/archived/v1.1.3/kubelet-cpu-manager-state/Cargo.toml index eeb8e4dcb08..cdf551b5695 100644 --- a/sources/api/migration/migrations/archived/v1.1.3/kubelet-cpu-manager-state/Cargo.toml +++ b/sources/api/migration/migrations/archived/v1.1.3/kubelet-cpu-manager-state/Cargo.toml @@ -10,4 +10,4 @@ exclude = ["README.md"] [dependencies] migration-helpers = { path = "../../../migration-helpers" } -snafu = "0.6" +snafu = "0.7" diff --git a/sources/api/migration/migrations/v1.6.0/node-taints-representation/Cargo.toml b/sources/api/migration/migrations/v1.6.0/node-taints-representation/Cargo.toml index 5eaadc65042..35a83b9b12d 100644 --- a/sources/api/migration/migrations/v1.6.0/node-taints-representation/Cargo.toml +++ b/sources/api/migration/migrations/v1.6.0/node-taints-representation/Cargo.toml @@ -11,4 +11,4 @@ exclude = ["README.md"] [dependencies] migration-helpers = { path = "../../../migration-helpers", version = "0.1.0"} serde_json = "1" -snafu = "0.6" +snafu = "0.7" diff --git a/sources/api/migration/migrations/v1.6.0/node-taints-representation/src/main.rs b/sources/api/migration/migrations/v1.6.0/node-taints-representation/src/main.rs index c99fbaf219a..e0840ed800d 100644 --- a/sources/api/migration/migrations/v1.6.0/node-taints-representation/src/main.rs +++ b/sources/api/migration/migrations/v1.6.0/node-taints-representation/src/main.rs @@ -61,7 +61,7 @@ impl Migration for ChangeNodeTaintsType { .cloned() .unwrap_or_default() .as_str() - .context(error::NonStringSettingDataType { + .context(error::NonStringSettingDataTypeSnafu { setting: taint_key.to_string(), })? .to_string(), diff --git a/sources/api/migration/migrator/Cargo.toml b/sources/api/migration/migrator/Cargo.toml index 3032126f8b9..a7e3f6f4e89 100644 --- a/sources/api/migration/migrator/Cargo.toml +++ b/sources/api/migration/migrator/Cargo.toml @@ -19,7 +19,7 @@ rand = { version = "0.8", default-features = false, features = ["std", "std_rng" regex = "1.1" semver = "1.0" simplelog = "0.10" -snafu = "0.6" +snafu = "0.7" tough = "0.12" update_metadata = { path = "../../../updater/update_metadata", version = "0.1.0" } url = "2.1.1" diff --git a/sources/api/migration/migrator/src/error.rs b/sources/api/migration/migrator/src/error.rs index defe65d60b6..df44bb2ad12 100644 --- a/sources/api/migration/migrator/src/error.rs +++ b/sources/api/migration/migrator/src/error.rs @@ -8,7 +8,7 @@ use std::process::Output; /// Error contains the errors that can happen during migration. #[derive(Debug, Snafu)] -#[snafu(visibility = "pub(crate)")] +#[snafu(visibility(pub(crate)))] pub(crate) enum Error { #[snafu(display("Internal error: {}", msg))] Internal { msg: String }, diff --git a/sources/api/migration/migrator/src/main.rs b/sources/api/migration/migrator/src/main.rs index 793409c8356..9429ac503fb 100644 --- a/sources/api/migration/migrator/src/main.rs +++ b/sources/api/migration/migrator/src/main.rs @@ -73,25 +73,27 @@ where // Find the current patch version link, which contains our full version number let current = datastore_dir.join("current"); - let major = - datastore_dir.join(fs::read_link(¤t).context(error::LinkRead { link: current })?); - let minor = datastore_dir.join(fs::read_link(&major).context(error::LinkRead { link: major })?); - let patch = datastore_dir.join(fs::read_link(&minor).context(error::LinkRead { link: minor })?); + let major = datastore_dir + .join(fs::read_link(¤t).context(error::LinkReadSnafu { link: current })?); + let minor = + datastore_dir.join(fs::read_link(&major).context(error::LinkReadSnafu { link: major })?); + let patch = + datastore_dir.join(fs::read_link(&minor).context(error::LinkReadSnafu { link: minor })?); // Pull out the basename of the path, which contains the version let version_os_str = patch .file_name() - .context(error::DataStoreLinkToRoot { path: &patch })?; + .context(error::DataStoreLinkToRootSnafu { path: &patch })?; let mut version_str = version_os_str .to_str() - .context(error::DataStorePathNotUTF8 { path: &patch })?; + .context(error::DataStorePathNotUTF8Snafu { path: &patch })?; // Allow 'v' at the start so the links have clearer names for humans if version_str.starts_with('v') { version_str = &version_str[1..]; } - Version::parse(version_str).context(error::InvalidDataStoreVersion { path: &patch }) + Version::parse(version_str).context(error::InvalidDataStoreVersionSnafu { path: &patch }) } pub(crate) fn run(args: &Args) -> Result<()> { @@ -99,7 +101,7 @@ pub(crate) fn run(args: &Args) -> Result<()> { let datastore_dir = args .datastore_path .parent() - .context(error::DataStoreLinkToRoot { + .context(error::DataStoreLinkToRootSnafu { path: &args.datastore_path, })?; @@ -128,7 +130,7 @@ pub(crate) fn run(args: &Args) -> Result<()> { })?; // open a reader to the root.json file - let root_file = File::open(&args.root_path).with_context(|| error::OpenRoot { + let root_file = File::open(&args.root_path).with_context(|_| error::OpenRootSnafu { path: args.root_path.clone(), })?; @@ -155,11 +157,11 @@ pub(crate) fn run(args: &Args) -> Result<()> { // if the targets expired between updog downloading them and now. .expiration_enforcement(ExpirationEnforcement::Unsafe) .load() - .context(error::RepoLoad)?; + .context(error::RepoLoadSnafu)?; let manifest = load_manifest(&repo)?; let migrations = update_metadata::find_migrations(¤t_version, &args.migrate_to_version, &manifest) - .context(error::FindMigrations)?; + .context(error::FindMigrationsSnafu)?; if migrations.is_empty() { // Not all new OS versions need to change the data store format. If there's been no @@ -203,7 +205,7 @@ where .with_file_name(format!("v{}_{}", new_version, rando())); ensure!( !to.exists(), - error::NewVersionAlreadyExists { + error::NewVersionAlreadyExistsSnafu { version: new_version.clone(), path: to } @@ -246,26 +248,26 @@ where let migration = migration.as_ref(); let migration = migration .try_into() - .context(error::TargetName { target: migration })?; + .context(error::TargetNameSnafu { target: migration })?; // get the migration from the repo let lz4_bytes = repository .read_target(&migration) - .context(error::LoadMigration { + .context(error::LoadMigrationSnafu { migration: migration.raw(), })? - .context(error::MigrationNotFound { + .context(error::MigrationNotFoundSnafu { migration: migration.raw(), })?; // Add an LZ4 decoder so the bytes will be deflated on read - let mut reader = lz4::Decoder::new(lz4_bytes).context(error::Lz4Decode { + let mut reader = lz4::Decoder::new(lz4_bytes).context(error::Lz4DecodeSnafu { migration: migration.raw(), })?; // Create a sealed command with pentacle, so we can run the verified bytes from memory let mut command = - pentacle::SealedCommand::new(&mut reader).context(error::SealMigration)?; + pentacle::SealedCommand::new(&mut reader).context(error::SealMigrationSnafu)?; // Point each migration in the right direction, and at the given data store. command.arg(direction.to_string()); @@ -285,7 +287,7 @@ where info!("Running migration command: {:?}", command); - let output = command.output().context(error::StartMigration)?; + let output = command.output().context(error::StartMigrationSnafu)?; if !output.stdout.is_empty() { debug!( @@ -303,7 +305,10 @@ where debug!("No migration stderr"); } - ensure!(output.status.success(), error::MigrationFailure { output }); + ensure!( + output.status.success(), + error::MigrationFailureSnafu { output } + ); source_datastore = &target_datastore; } @@ -345,7 +350,7 @@ where let to_dir = to_datastore .as_ref() .parent() - .context(error::DataStoreLinkToRoot { + .context(error::DataStoreLinkToRootSnafu { path: to_datastore.as_ref(), })?; // We need a file descriptor for the directory so we can fsync after the symlink swap. @@ -356,7 +361,7 @@ where // (mode doesn't matter for opening a directory) Mode::empty(), ) - .context(error::DataStoreDirOpen { path: &to_dir })?; + .context(error::DataStoreDirOpenSnafu { path: &to_dir })?; // Get a unique temporary path in the directory; we need this to atomically swap. let temp_link = to_dir.join(rando()); @@ -386,22 +391,22 @@ where let to_target = to_datastore .as_ref() .file_name() - .context(error::DataStoreLinkToRoot { + .context(error::DataStoreLinkToRootSnafu { path: to_datastore.as_ref(), })?; let patch_target = patch_version_link .file_name() - .context(error::DataStoreLinkToRoot { + .context(error::DataStoreLinkToRootSnafu { path: to_datastore.as_ref(), })?; let minor_target = minor_version_link .file_name() - .context(error::DataStoreLinkToRoot { + .context(error::DataStoreLinkToRootSnafu { path: to_datastore.as_ref(), })?; let major_target = major_version_link .file_name() - .context(error::DataStoreLinkToRoot { + .context(error::DataStoreLinkToRootSnafu { path: to_datastore.as_ref(), })?; @@ -416,10 +421,10 @@ where // Create a symlink from the patch version to the new data store. We create it at a temporary // path so we can atomically swap it into the real path with a rename call. // This will point at, for example, /path/to/datastore/v1.5.2_0123456789abcdef - symlink(&to_target, &temp_link).context(error::LinkCreate { path: &temp_link })?; + symlink(&to_target, &temp_link).context(error::LinkCreateSnafu { path: &temp_link })?; // Atomically swap the link into place, so that the patch version link points to the new data // store copy. - fs::rename(&temp_link, &patch_version_link).context(error::LinkSwap { + fs::rename(&temp_link, &patch_version_link).context(error::LinkSwapSnafu { link: &patch_version_link, })?; @@ -433,10 +438,10 @@ where // Create a symlink from the minor version to the new patch version. // This will point at, for example, /path/to/datastore/v1.5.2 - symlink(&patch_target, &temp_link).context(error::LinkCreate { path: &temp_link })?; + symlink(&patch_target, &temp_link).context(error::LinkCreateSnafu { path: &temp_link })?; // Atomically swap the link into place, so that the minor version link points to the new patch // version. - fs::rename(&temp_link, &minor_version_link).context(error::LinkSwap { + fs::rename(&temp_link, &minor_version_link).context(error::LinkSwapSnafu { link: &minor_version_link, })?; @@ -450,10 +455,10 @@ where // Create a symlink from the major version to the new minor version. // This will point at, for example, /path/to/datastore/v1.5 - symlink(&minor_target, &temp_link).context(error::LinkCreate { path: &temp_link })?; + symlink(&minor_target, &temp_link).context(error::LinkCreateSnafu { path: &temp_link })?; // Atomically swap the link into place, so that the major version link points to the new minor // version. - fs::rename(&temp_link, &major_version_link).context(error::LinkSwap { + fs::rename(&temp_link, &major_version_link).context(error::LinkSwapSnafu { link: &major_version_link, })?; @@ -467,9 +472,9 @@ where // Create a symlink from 'current' to the new major version. // This will point at, for example, /path/to/datastore/v1 - symlink(&major_target, &temp_link).context(error::LinkCreate { path: &temp_link })?; + symlink(&major_target, &temp_link).context(error::LinkCreateSnafu { path: &temp_link })?; // Atomically swap the link into place, so that 'current' points to the new major version. - fs::rename(&temp_link, ¤t_version_link).context(error::LinkSwap { + fs::rename(&temp_link, ¤t_version_link).context(error::LinkSwapSnafu { link: ¤t_version_link, })?; @@ -491,12 +496,14 @@ where fn load_manifest(repository: &tough::Repository) -> Result { let target = "manifest.json"; - let target = target.try_into().context(error::TargetName { target })?; + let target = target + .try_into() + .context(error::TargetNameSnafu { target })?; Manifest::from_json( repository .read_target(&target) - .context(error::ManifestLoad)? - .context(error::ManifestNotFound)?, + .context(error::ManifestLoadSnafu)? + .context(error::ManifestNotFoundSnafu)?, ) - .context(error::ManifestParse) + .context(error::ManifestParseSnafu) } diff --git a/sources/api/netdog/Cargo.toml b/sources/api/netdog/Cargo.toml index 05f3fddede1..9b4f2f6c66d 100644 --- a/sources/api/netdog/Cargo.toml +++ b/sources/api/netdog/Cargo.toml @@ -19,7 +19,7 @@ regex = "1.1" serde = { version = "1.0", features = ["derive"] } serde_json = "1" serde_plain = "1.0" -snafu = "0.6" +snafu = "0.7" [build-dependencies] cargo-readme = "3.1" diff --git a/sources/api/netdog/src/main.rs b/sources/api/netdog/src/main.rs index 2365f36db35..692325311e9 100644 --- a/sources/api/netdog/src/main.rs +++ b/sources/api/netdog/src/main.rs @@ -171,12 +171,12 @@ where P: AsRef, { let lease_file = lease_file.as_ref(); - let f = File::open(lease_file).context(error::LeaseReadFailed { path: lease_file })?; + let f = File::open(lease_file).context(error::LeaseReadFailedSnafu { path: lease_file })?; let f = BufReader::new(f); let mut env = Vec::new(); for line in f.lines() { - let line = line.context(error::LeaseReadFailed { path: lease_file })?; + let line = line.context(error::LeaseReadFailedSnafu { path: lease_file })?; // We ignore any line that does not match the regex. for cap in LEASE_PARAM.captures_iter(&line) { let key = cap.name("key").map(|k| k.as_str()); @@ -192,7 +192,7 @@ where // feed in the key/value pairs from the lease file and get a `LeaseInfo` struct. If not all // expected values are present in the file, it will fail; any extra values are ignored. Ok(envy::from_iter::<_, LeaseInfo>(env) - .context(error::LeaseParseFailed { path: lease_file })?) + .context(error::LeaseParseFailedSnafu { path: lease_file })?) } /// Write resolver configuration for libc. @@ -200,20 +200,22 @@ fn write_resolv_conf(dns_servers: &[&IpAddr], dns_search: &Option>) let mut output = String::new(); if let Some(s) = dns_search { - writeln!(output, "search {}", s.join(" ")).context(error::ResolvConfBuildFailed)?; + writeln!(output, "search {}", s.join(" ")).context(error::ResolvConfBuildFailedSnafu)?; } for n in dns_servers { - writeln!(output, "nameserver {}", n).context(error::ResolvConfBuildFailed)?; + writeln!(output, "nameserver {}", n).context(error::ResolvConfBuildFailedSnafu)?; } - fs::write(RESOLV_CONF, output).context(error::ResolvConfWriteFailed { path: RESOLV_CONF })?; + fs::write(RESOLV_CONF, output) + .context(error::ResolvConfWriteFailedSnafu { path: RESOLV_CONF })?; Ok(()) } /// Persist the current IP address to file fn write_current_ip(ip: &IpAddr) -> Result<()> { - fs::write(CURRENT_IP, ip.to_string()).context(error::CurrentIpWriteFailed { path: CURRENT_IP }) + fs::write(CURRENT_IP, ip.to_string()) + .context(error::CurrentIpWriteFailedSnafu { path: CURRENT_IP }) } fn install(args: InstallArgs) -> Result<()> { @@ -249,10 +251,10 @@ fn remove(args: RemoveArgs) -> Result<()> { /// Return the current IP address as JSON (intended for use as a settings generator) fn node_ip() -> Result<()> { - let ip_string = - fs::read_to_string(CURRENT_IP).context(error::CurrentIpReadFailed { path: CURRENT_IP })?; + let ip_string = fs::read_to_string(CURRENT_IP) + .context(error::CurrentIpReadFailedSnafu { path: CURRENT_IP })?; // Validate that we read a proper IP address - let _ = IpAddr::from_str(&ip_string).context(error::IpFromString { ip: &ip_string })?; + let _ = IpAddr::from_str(&ip_string).context(error::IpFromStringSnafu { ip: &ip_string })?; // sundog expects JSON-serialized output Ok(print_json(ip_string)?) @@ -262,9 +264,9 @@ fn node_ip() -> Result<()> { /// /// The result is returned as JSON. (intended for use as a settings generator) fn generate_hostname() -> Result<()> { - let ip_string = - fs::read_to_string(CURRENT_IP).context(error::CurrentIpReadFailed { path: CURRENT_IP })?; - let ip = IpAddr::from_str(&ip_string).context(error::IpFromString { ip: &ip_string })?; + let ip_string = fs::read_to_string(CURRENT_IP) + .context(error::CurrentIpReadFailedSnafu { path: CURRENT_IP })?; + let ip = IpAddr::from_str(&ip_string).context(error::IpFromStringSnafu { ip: &ip_string })?; let hostname = match lookup_addr(&ip) { Ok(hostname) => hostname, Err(e) => { @@ -283,14 +285,14 @@ where S: AsRef + Serialize, { let val = val.as_ref(); - let output = serde_json::to_string(val).context(error::JsonSerialize { output: val })?; + let output = serde_json::to_string(val).context(error::JsonSerializeSnafu { output: val })?; println!("{}", output); Ok(()) } /// Sets the hostname for the system fn set_hostname(args: SetHostnameArgs) -> Result<()> { - fs::write(KERNEL_HOSTNAME, args.hostname).context(error::HostnameWriteFailed { + fs::write(KERNEL_HOSTNAME, args.hostname).context(error::HostnameWriteFailedSnafu { path: KERNEL_HOSTNAME, })?; Ok(()) @@ -326,7 +328,7 @@ mod error { use std::path::PathBuf; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] #[allow(clippy::enum_variant_names)] pub(super) enum Error { #[snafu(display("Failed to read lease data in '{}': {}", path.display(), source))] diff --git a/sources/api/pluto/Cargo.toml b/sources/api/pluto/Cargo.toml index cd951349d5e..6c46b0e9ca3 100644 --- a/sources/api/pluto/Cargo.toml +++ b/sources/api/pluto/Cargo.toml @@ -17,7 +17,7 @@ models = { path = "../../models", version = "0.1.0" } rusoto_core = { version = "0.47", default-features = false, features = ["rustls"] } rusoto_eks = { version = "0.47", default-features = false, features = ["rustls"] } serde_json = "1" -snafu = "0.6" +snafu = "0.7" tokio = { version = "~1.14", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS [build-dependencies] diff --git a/sources/api/pluto/src/api.rs b/sources/api/pluto/src/api.rs index da9441b7bf4..62616a62803 100644 --- a/sources/api/pluto/src/api.rs +++ b/sources/api/pluto/src/api.rs @@ -37,9 +37,9 @@ mod inner { let (_status, response_body) = apiclient::raw_request(constants::API_SOCKET, uri, "GET", None) .await - .context(ApiClient { uri })?; + .context(ApiClientSnafu { uri })?; - serde_json::from_str(&response_body).context(SettingsJson) + serde_json::from_str(&response_body).context(SettingsJsonSnafu) } /// Gets the info that we need to know about the EKS cluster from the Bottlerocket API. @@ -77,6 +77,6 @@ mod inner { } pub(crate) async fn get_aws_k8s_info() -> Result { - WrongVariant.fail() + WrongVariantSnafu.fail() } } diff --git a/sources/api/pluto/src/eks.rs b/sources/api/pluto/src/eks.rs index ddf46561ca3..d15c3bd7204 100644 --- a/sources/api/pluto/src/eks.rs +++ b/sources/api/pluto/src/eks.rs @@ -31,7 +31,7 @@ pub(super) async fn get_cluster_network_config( region: &str, cluster: &str, ) -> Result { - let parsed_region = Region::from_str(region).context(RegionParse { region })?; + let parsed_region = Region::from_str(region).context(RegionParseSnafu { region })?; let client = EksClient::new(parsed_region); let describe_cluster = rusoto_eks::DescribeClusterRequest { name: cluster.to_owned(), @@ -40,11 +40,11 @@ pub(super) async fn get_cluster_network_config( client .describe_cluster(describe_cluster) .await - .context(DescribeCluster {})? + .context(DescribeClusterSnafu {})? .cluster - .context(Missing { field: "cluster" })? + .context(MissingSnafu { field: "cluster" })? .kubernetes_network_config - .context(Missing { + .context(MissingSnafu { field: "kubernetes_network_config", }) } diff --git a/sources/api/pluto/src/main.rs b/sources/api/pluto/src/main.rs index 6500e2dac23..e62ff4db22f 100644 --- a/sources/api/pluto/src/main.rs +++ b/sources/api/pluto/src/main.rs @@ -59,7 +59,7 @@ mod error { use std::net::AddrParseError; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub(super) enum PlutoError { #[snafu(display( "Unable to retrieve cluster name and AWS region from Bottlerocket API: {}", @@ -138,19 +138,19 @@ async fn get_max_pods(client: &mut ImdsClient) -> Result { let instance_type = client .fetch_instance_type() .await - .context(error::ImdsRequest)? - .context(error::ImdsNone { + .context(error::ImdsRequestSnafu)? + .context(error::ImdsNoneSnafu { what: "instance_type", })?; // Find the corresponding maximum number of pods supported by this instance type - let file = BufReader::new( - File::open(ENI_MAX_PODS_PATH).context(error::EniMaxPodsFile { + let file = BufReader::new(File::open(ENI_MAX_PODS_PATH).context( + error::EniMaxPodsFileSnafu { path: ENI_MAX_PODS_PATH, - })?, - ); + }, + )?); for line in file.lines() { - let line = line.context(error::IoReadLine)?; + let line = line.context(error::IoReadLineSnafu)?; // Skip the comments in the file if line.trim_start().starts_with('#') { continue; @@ -160,7 +160,7 @@ async fn get_max_pods(client: &mut ImdsClient) -> Result { return Ok(tokens[1].to_string()); } } - error::NoInstanceTypeMaxPods { instance_type }.fail() + error::NoInstanceTypeMaxPodsSnafu { instance_type }.fail() } /// Returns the cluster's DNS address. @@ -171,12 +171,12 @@ async fn get_max_pods(client: &mut ImdsClient) -> Result { /// blocks to return one of two default addresses. async fn get_cluster_dns_ip(client: &mut ImdsClient) -> Result { // Retrieve the kubernetes network configuration for the EKS cluster - if let Ok(aws_k8s_info) = api::get_aws_k8s_info().await.context(error::AwsInfo) { + if let Ok(aws_k8s_info) = api::get_aws_k8s_info().await.context(error::AwsInfoSnafu) { if let (Some(region), Some(cluster_name)) = (aws_k8s_info.region, aws_k8s_info.cluster_name) { if let Ok(config) = eks::get_cluster_network_config(®ion, &cluster_name) .await - .context(error::EksError) + .context(error::EksSnafu) { // Derive cluster-dns-ip from the service IPv4 CIDR if let Some(ipv4_cidr) = config.service_ipv_4_cidr { @@ -202,7 +202,7 @@ fn get_dns_from_ipv4_cidr(cidr: &str) -> Result { let mut split: Vec<&str> = cidr.split('.').collect(); ensure!( split.len() == 4, - error::CidrParse { + error::CidrParseSnafu { cidr, reason: format!("expected 4 components but found {}", split.len()) } @@ -218,12 +218,12 @@ async fn get_ipv4_cluster_dns_ip_from_imds_mac(client: &mut ImdsClient) -> Resul let mac = client .fetch_mac_addresses() .await - .context(error::ImdsRequest)? - .context(error::ImdsNone { + .context(error::ImdsRequestSnafu)? + .context(error::ImdsNoneSnafu { what: "mac addresses", })? .first() - .context(error::ImdsNone { + .context(error::ImdsNoneSnafu { what: "mac addresses", })? .clone(); @@ -232,12 +232,12 @@ async fn get_ipv4_cluster_dns_ip_from_imds_mac(client: &mut ImdsClient) -> Resul let cidr_block = client .fetch_cidr_blocks_for_mac(&mac) .await - .context(error::ImdsRequest)? - .context(error::ImdsNone { + .context(error::ImdsRequestSnafu)? + .context(error::ImdsNoneSnafu { what: "CIDR blocks", })? .first() - .context(error::ImdsNone { + .context(error::ImdsNoneSnafu { what: "CIDR blocks", })? .clone(); @@ -256,12 +256,12 @@ async fn get_ipv4_cluster_dns_ip_from_imds_mac(client: &mut ImdsClient) -> Resul async fn get_node_ip(client: &mut ImdsClient) -> Result { // Retrieve the user specified cluster DNS IP if it's specified, otherwise use the pluto-generated // cluster DNS IP - let aws_k8s_info = api::get_aws_k8s_info().await.context(error::AwsInfo)?; + let aws_k8s_info = api::get_aws_k8s_info().await.context(error::AwsInfoSnafu)?; let cluster_dns_ip = if let Some(ip) = aws_k8s_info.cluster_dns_ip { ip.to_owned() } else { let ip = get_cluster_dns_ip(client).await?; - IpAddr::from_str(ip.as_str()).context(error::BadIp { ip })? + IpAddr::from_str(ip.as_str()).context(error::BadIpSnafu { ip })? }; // If the cluster DNS IP is an IPv4 address, retrieve the IPv4 address for the instance. @@ -270,16 +270,16 @@ async fn get_node_ip(client: &mut ImdsClient) -> Result { IpAddr::V4(_) => client .fetch_local_ipv4_address() .await - .context(error::ImdsRequest)? - .context(error::ImdsNone { + .context(error::ImdsRequestSnafu)? + .context(error::ImdsNoneSnafu { what: "node ipv4 address", }), IpAddr::V6(_) => { return client .fetch_primary_ipv6_address() .await - .context(error::ImdsRequest)? - .context(error::ImdsNone { + .context(error::ImdsRequestSnafu)? + .context(error::ImdsNoneSnafu { what: "ipv6s associated with primary network interface", }); } @@ -325,13 +325,13 @@ async fn run() -> Result<()> { let max_pods = serde_json::to_string( &setting .parse::() - .context(error::ParseToU32 { setting: &setting })?, + .context(error::ParseToU32Snafu { setting: &setting })?, ) - .context(error::OutputJson { output: &setting })?; + .context(error::OutputJsonSnafu { output: &setting })?; println!("{}", max_pods); } else { let output = - serde_json::to_string(&setting).context(error::OutputJson { output: &setting })?; + serde_json::to_string(&setting).context(error::OutputJsonSnafu { output: &setting })?; println!("{}", output); } Ok(()) diff --git a/sources/api/schnauzer/Cargo.toml b/sources/api/schnauzer/Cargo.toml index bc1b2fd58f2..063ef762317 100644 --- a/sources/api/schnauzer/Cargo.toml +++ b/sources/api/schnauzer/Cargo.toml @@ -23,7 +23,7 @@ models = { path = "../../models", version = "0.1.0" } percent-encoding = "2.1" serde = { version = "1.0", features = ["derive"] } serde_json = "1" -snafu = "0.6" +snafu = "0.7" tokio = { version = "~1.14", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS url = "2.1" num_cpus = "1.0" diff --git a/sources/api/schnauzer/src/helpers.rs b/sources/api/schnauzer/src/helpers.rs index f447a710b54..b657bc4da2a 100644 --- a/sources/api/schnauzer/src/helpers.rs +++ b/sources/api/schnauzer/src/helpers.rs @@ -111,7 +111,7 @@ mod error { use snafu::Snafu; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub(super) enum TemplateHelperError { #[snafu(display( "Expected ecr helper to be called with either 'registry' or 'region', got '{}'", @@ -267,33 +267,35 @@ pub fn base64_decode( let base64_value = helper .param(0) .map(|v| v.value()) - .context(error::Internal { + .context(error::InternalSnafu { msg: "Found no params after confirming there is one param", })?; trace!("Base64 value from template: {}", base64_value); // Create an &str from the serde_json::Value - let base64_str = base64_value.as_str().context(error::InvalidTemplateValue { - expected: "string", - value: base64_value.to_owned(), - template: template_name.to_owned(), - })?; + let base64_str = base64_value + .as_str() + .context(error::InvalidTemplateValueSnafu { + expected: "string", + value: base64_value.to_owned(), + template: template_name.to_owned(), + })?; trace!("Base64 string from template: {}", base64_str); // Base64 decode the &str - let decoded_bytes = base64::decode(&base64_str).context(error::Base64Decode { + let decoded_bytes = base64::decode(&base64_str).context(error::Base64DecodeSnafu { template: template_name.to_owned(), })?; // Create a valid utf8 str - let decoded = std::str::from_utf8(&decoded_bytes).context(error::InvalidUTF8 { + let decoded = std::str::from_utf8(&decoded_bytes).context(error::InvalidUTF8Snafu { base64_string: base64_str.to_string(), template: template_name.to_owned(), })?; trace!("Decoded base64: {}", decoded); // Write the string out to the template - out.write(decoded).context(error::TemplateWrite { + out.write(decoded).context(error::TemplateWriteSnafu { template: template_name.to_owned(), })?; Ok(()) @@ -332,7 +334,7 @@ pub fn join_map( let join_key_val = get_param(helper, 0)?; let join_key = join_key_val .as_str() - .with_context(|| error::InvalidTemplateValue { + .with_context(|| error::InvalidTemplateValueSnafu { expected: "string", value: join_key_val.to_owned(), template: template_name.to_owned(), @@ -342,7 +344,7 @@ pub fn join_map( let join_pairs_val = get_param(helper, 1)?; let join_pairs = join_pairs_val .as_str() - .with_context(|| error::InvalidTemplateValue { + .with_context(|| error::InvalidTemplateValueSnafu { expected: "string", value: join_pairs_val.to_owned(), template: template_name.to_owned(), @@ -353,7 +355,7 @@ pub fn join_map( let fail_behavior_str = fail_behavior_val .as_str() - .with_context(|| error::InvalidTemplateValue { + .with_context(|| error::InvalidTemplateValueSnafu { expected: "string", value: join_pairs_val.to_owned(), template: template_name.to_owned(), @@ -390,7 +392,7 @@ pub fn join_map( return Ok(()); } } - let map = map_value.as_object().context(error::Internal { + let map = map_value.as_object().context(error::InternalSnafu { msg: "Already confirmed map is_object but as_object failed", })?; trace!("Map to join: {:?}", map); @@ -436,7 +438,7 @@ pub fn join_map( trace!("Joined output: {}", joined); // Write the string out to the template - out.write(&joined).context(error::TemplateWrite { + out.write(&joined).context(error::TemplateWriteSnafu { template: template_name.to_owned(), })?; Ok(()) @@ -468,9 +470,11 @@ pub fn join_node_taints( return Ok(()); } - let node_taints = node_taints_value.as_object().context(error::Internal { - msg: "Already confirmed map is_object but as_object failed", - })?; + let node_taints = node_taints_value + .as_object() + .context(error::InternalSnafu { + msg: "Already confirmed map is_object but as_object failed", + })?; trace!("node taints to join: {:?}", node_taints); // Join the key/value pairs for node taints @@ -519,7 +523,7 @@ pub fn join_node_taints( trace!("Joined output: {}", joined); // Write the string out to the template - out.write(&joined).context(error::TemplateWrite { + out.write(&joined).context(error::TemplateWriteSnafu { template: template_name.to_owned(), })?; @@ -585,7 +589,7 @@ pub fn default( }; // Write the string out to the template - out.write(&value).context(error::TemplateWrite { + out.write(&value).context(error::TemplateWriteSnafu { template: template_name.to_owned(), })?; Ok(()) @@ -630,7 +634,7 @@ pub fn ecr_prefix( // get the region parameter, which is probably given by the template value // settings.aws.region. regardless, we expect it to be a string. let aws_region = get_param(helper, 0)?; - let aws_region = aws_region.as_str().with_context(|| error::EcrRegion { + let aws_region = aws_region.as_str().with_context(|| error::EcrRegionSnafu { value: aws_region.to_owned(), template: template_name, })?; @@ -640,7 +644,7 @@ pub fn ecr_prefix( // write it to the template out.write(&ecr_registry) - .with_context(|| error::TemplateWrite { + .with_context(|_| error::TemplateWriteSnafu { template: template_name.to_owned(), })?; @@ -683,7 +687,7 @@ pub fn pause_prefix( // get the region parameter, which is probably given by the template value // settings.aws.region. regardless, we expect it to be a string. let aws_region = get_param(helper, 0)?; - let aws_region = aws_region.as_str().with_context(|| error::EcrRegion { + let aws_region = aws_region.as_str().with_context(|| error::EcrRegionSnafu { value: aws_region.to_owned(), template: template_name, })?; @@ -693,7 +697,7 @@ pub fn pause_prefix( // write it to the template out.write(&pause_registry) - .with_context(|| error::TemplateWrite { + .with_context(|_| error::TemplateWriteSnafu { template: template_name.to_owned(), })?; @@ -715,21 +719,22 @@ pub fn host( let url_val = get_param(helper, 0)?; let url_str = url_val .as_str() - .with_context(|| error::InvalidTemplateValue { + .with_context(|| error::InvalidTemplateValueSnafu { expected: "string", value: url_val.to_owned(), template: template_name.to_owned(), })?; - let url = Url::parse(url_str).context(error::UrlParse { + let url = Url::parse(url_str).context(error::UrlParseSnafu { url_str, template: template_name, })?; - let url_host = url.host_str().context(error::UrlHost { url_str })?; + let url_host = url.host_str().context(error::UrlHostSnafu { url_str })?; // write it to the template - out.write(&url_host).with_context(|| error::TemplateWrite { - template: template_name.to_owned(), - })?; + out.write(&url_host) + .with_context(|_| error::TemplateWriteSnafu { + template: template_name.to_owned(), + })?; Ok(()) } @@ -754,7 +759,7 @@ pub fn goarch( let arch_val = get_param(helper, 0)?; let arch_str = arch_val .as_str() - .with_context(|| error::InvalidTemplateValue { + .with_context(|| error::InvalidTemplateValueSnafu { expected: "string", value: arch_val.to_owned(), template: template_name.to_owned(), @@ -772,9 +777,10 @@ pub fn goarch( }; // write it to the template - out.write(&goarch).with_context(|| error::TemplateWrite { - template: template_name.to_owned(), - })?; + out.write(&goarch) + .with_context(|_| error::TemplateWriteSnafu { + template: template_name.to_owned(), + })?; Ok(()) } @@ -804,7 +810,7 @@ pub fn join_array( let delimiter_param = get_param(helper, 0)?; let delimiter = delimiter_param .as_str() - .with_context(|| error::JoinStringsWrongType { + .with_context(|| error::JoinStringsWrongTypeSnafu { expected_type: "string", value: delimiter_param.to_owned(), template: template_name, @@ -814,7 +820,7 @@ pub fn join_array( let array_param = get_param(helper, 1)?; let array = array_param .as_array() - .with_context(|| error::JoinStringsWrongType { + .with_context(|| error::JoinStringsWrongTypeSnafu { expected_type: "array", value: array_param.to_owned(), template: template_name, @@ -828,7 +834,7 @@ pub fn join_array( result.push_str( format!( "\"{}\"", - value.as_str().context(error::JoinStringsWrongType { + value.as_str().context(error::JoinStringsWrongTypeSnafu { expected_type: "string", value: array.to_owned(), template: template_name, @@ -839,9 +845,10 @@ pub fn join_array( } // write it to the template - out.write(&result).with_context(|| error::TemplateWrite { - template: template_name.to_owned(), - })?; + out.write(&result) + .with_context(|_| error::TemplateWriteSnafu { + template: template_name.to_owned(), + })?; Ok(()) } @@ -882,7 +889,7 @@ pub fn kube_reserve_memory( }; let max_num_pods = max_num_pods .as_u64() - .with_context(|| error::ConvertNumber { + .with_context(|| error::ConvertNumberSnafu { what: "number of pods", number: max_num_pods.to_string(), target: "u64", @@ -909,7 +916,7 @@ pub fn kube_reserve_memory( // write it to the template out.write(&memory_to_reserve) - .with_context(|| error::TemplateWrite { + .with_context(|_| error::TemplateWriteSnafu { template: template_name.to_owned(), })?; @@ -953,7 +960,7 @@ pub fn kube_reserve_cpu( // write it to the template out.write(&cpu_to_reserve) - .with_context(|| error::TemplateWrite { + .with_context(|_| error::TemplateWriteSnafu { template: template_name.to_owned(), })?; @@ -983,7 +990,7 @@ pub fn add_unresolvable_hostname( let hostname_value = helper .param(0) .map(|v| v.value()) - .context(error::Internal { + .context(error::InternalSnafu { msg: "Found no params after confirming there is one param", })?; trace!("Hostname value from template: {}", hostname_value); @@ -991,7 +998,7 @@ pub fn add_unresolvable_hostname( // Create an &str from the serde_json::Value let hostname_str = hostname_value .as_str() - .context(error::InvalidTemplateValue { + .context(error::InvalidTemplateValueSnafu { expected: "string", value: hostname_value.to_owned(), template: template_name.to_owned(), @@ -1024,7 +1031,7 @@ pub fn add_unresolvable_hostname( let ipv6_entry = format!("{} {}", IPV6_LOCALHOST, hostname_str); let entries = format!("{}\n{}", ipv4_entry, ipv6_entry); - out.write(&entries).context(error::TemplateWrite { + out.write(&entries).context(error::TemplateWriteSnafu { template: template_name.to_owned(), })?; } @@ -1039,7 +1046,7 @@ fn get_param<'a>(helper: &'a Helper<'_, '_>, idx: usize) -> Result<&'a Value, Re Ok(helper .param(idx) .map(|v| v.value()) - .context(error::MissingParam { + .context(error::MissingParamSnafu { index: idx, helper_name: helper.name(), })?) @@ -1099,7 +1106,7 @@ fn pause_registry>(region: S) -> String { /// Calculates and returns the amount of CPU to reserve fn kube_cpu_helper(num_cores: usize) -> Result { let num_cores = - u16::try_from(num_cores).context(error::ConvertUsizeToU16 { number: num_cores })?; + u16::try_from(num_cores).context(error::ConvertUsizeToU16Snafu { number: num_cores })?; let millicores_unit = "m"; let cpu_to_reserve = match num_cores { 0 => 0.0, diff --git a/sources/api/schnauzer/src/lib.rs b/sources/api/schnauzer/src/lib.rs index 187ba57e51f..2350c4eec37 100644 --- a/sources/api/schnauzer/src/lib.rs +++ b/sources/api/schnauzer/src/lib.rs @@ -21,7 +21,7 @@ pub mod error { use snafu::Snafu; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub enum Error { #[snafu(display("Error {}ing to {}: {}", method, uri, source))] APIRequest { @@ -81,10 +81,10 @@ where trace!("{}ing from {}", method, uri); let (code, response_body) = apiclient::raw_request(socket_path, &uri, method, None) .await - .context(error::APIRequest { method, uri: &uri })?; + .context(error::APIRequestSnafu { method, uri: &uri })?; if !code.is_success() { - return error::APIResponse { + return error::APIResponseSnafu { method, uri, code, @@ -94,7 +94,7 @@ where } trace!("JSON response: {}", response_body); - serde_json::from_str(&response_body).context(error::ResponseJson { method, uri }) + serde_json::from_str(&response_body).context(error::ResponseJsonSnafu { method, uri }) } /// Requests all settings from the API so they can be used as the data source for a handlebars diff --git a/sources/api/schnauzer/src/main.rs b/sources/api/schnauzer/src/main.rs index 4506e65c81f..32121aef6a4 100644 --- a/sources/api/schnauzer/src/main.rs +++ b/sources/api/schnauzer/src/main.rs @@ -29,7 +29,7 @@ mod error { use snafu::Snafu; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub(super) enum Error { #[snafu(display("Error {}ing to {}: {}", method, uri, source))] APIRequest { @@ -93,10 +93,10 @@ async fn get_metadata(key: &str, meta: &str) -> Result { let method = "GET"; let (code, response_body) = apiclient::raw_request(constants::API_SOCKET, &uri, method, None) .await - .context(error::APIRequest { method, uri })?; + .context(error::APIRequestSnafu { method, uri })?; ensure!( code.is_success(), - error::Response { + error::ResponseSnafu { method, uri, code, @@ -106,22 +106,22 @@ async fn get_metadata(key: &str, meta: &str) -> Result { // Metadata responses are of the form `{"data_key": METADATA}` so we pull out the value. let mut response_map: HashMap = - serde_json::from_str(&response_body).context(error::DeserializeJson)?; + serde_json::from_str(&response_body).context(error::DeserializeJsonSnafu)?; let response_val = response_map .remove(key) - .context(error::MissingMetadata { meta, key })?; + .context(error::MissingMetadataSnafu { meta, key })?; // Ensure it's a non-empty string let response_str = response_val .as_str() - .with_context(|| error::MetadataWrongType { + .with_context(|| error::MetadataWrongTypeSnafu { meta, expected: "string", value: response_val.to_string(), })?; ensure!( !response_str.is_empty(), - error::MissingMetadata { meta, key } + error::MissingMetadataSnafu { meta, key } ); Ok(response_str.to_string()) } @@ -145,24 +145,25 @@ fn parse_args(mut args: env::Args) -> String { async fn run() -> Result<()> { let setting_name = parse_args(env::args()); - let registry = schnauzer::build_template_registry().context(error::BuildTemplateRegistry)?; + let registry = + schnauzer::build_template_registry().context(error::BuildTemplateRegistrySnafu)?; let template = get_metadata(&setting_name, "templates").await?; let settings = schnauzer::get_settings(constants::API_SOCKET) .await - .context(error::GetSettings)?; + .context(error::GetSettingsSnafu)?; let setting = registry .render_template(&template, &settings) - .context(error::RenderTemplate { + .context(error::RenderTemplateSnafu { setting_name, template, })?; // sundog expects JSON-serialized output so that many types can be represented, allowing the // API model to use more accurate types. - let output = - serde_json::to_string(&setting).context(error::SerializeOutput { output: &setting })?; + let output = serde_json::to_string(&setting) + .context(error::SerializeOutputSnafu { output: &setting })?; println!("{}", output); Ok(()) diff --git a/sources/api/servicedog/Cargo.toml b/sources/api/servicedog/Cargo.toml index 6f2f6f8ca5d..98ac6310c56 100644 --- a/sources/api/servicedog/Cargo.toml +++ b/sources/api/servicedog/Cargo.toml @@ -19,7 +19,7 @@ models = { path = "../../models", version = "0.1.0" } serde = { version = "1.0", features = ["derive"] } serde_json = "1" simplelog = "0.10" -snafu = "0.6" +snafu = "0.7" tokio = { version = "~1.14", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS [build-dependencies] diff --git a/sources/api/servicedog/src/main.rs b/sources/api/servicedog/src/main.rs index c3af1cef40c..de727e58d17 100644 --- a/sources/api/servicedog/src/main.rs +++ b/sources/api/servicedog/src/main.rs @@ -37,7 +37,7 @@ mod error { use datastore::{self, serialization}; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub(super) enum Error { #[snafu(display("Error sending {} to {}: {}", method, uri, source))] APIRequest { @@ -119,7 +119,7 @@ impl SettingState { "true" => Ok(SettingState::Enabled), "false" => Ok(SettingState::Disabled), other => { - return error::UnknownSettingState { + return error::UnknownSettingStateSnafu { setting: setting.as_ref(), state: other, } @@ -140,19 +140,19 @@ where S: AsRef, { let key_str = key_str.as_ref(); - let key = Key::new(KeyType::Data, key_str).context(error::InvalidKey { key: key_str })?; + let key = Key::new(KeyType::Data, key_str).context(error::InvalidKeySnafu { key: key_str })?; debug!("Querying the API for setting: {}", key_str); let uri = format!("{}?keys={}", constants::API_SETTINGS_URI, key_str); let (code, response_body) = apiclient::raw_request(constants::API_SOCKET, &uri, "GET", None) .await - .context(error::APIRequest { + .context(error::APIRequestSnafu { method: "GET", uri: uri.to_string(), })?; ensure!( code.is_success(), - error::APIResponse { + error::APIResponseSnafu { method: "GET", uri, code, @@ -161,20 +161,20 @@ where ); // Build a Settings struct from the response string - let settings: model::Settings = - serde_json::from_str(&response_body).context(error::ResponseJson { method: "GET", uri })?; + let settings: model::Settings = serde_json::from_str(&response_body) + .context(error::ResponseJsonSnafu { method: "GET", uri })?; // Serialize the Settings struct into key/value pairs. This builds the dotted // string representation of the setting let setting_keypair = - to_pairs_with_prefix("settings", &settings).context(error::SerializeSettings)?; + to_pairs_with_prefix("settings", &settings).context(error::SerializeSettingsSnafu)?; debug!("Retrieved setting keypair: {:#?}", &setting_keypair); // (Hopefully) get the value from the map using the dotted string supplied // to the function Ok(setting_keypair .get(&key) - .context(error::NonexistentSetting { setting: key_str })? + .context(error::NonexistentSettingSnafu { setting: key_str })? .to_string()) } @@ -237,11 +237,11 @@ where command.args(args); let output = command .output() - .context(error::ExecutionFailure { command })?; + .context(error::ExecutionFailureSnafu { command })?; ensure!( output.status.success(), - error::SystemdCommandFailure { output } + error::SystemdCommandFailureSnafu { output } ); Ok(()) } @@ -321,7 +321,7 @@ async fn run() -> Result<()> { let args = parse_args(env::args()); // SimpleLogger will send errors to stderr and anything less to stdout. - SimpleLogger::init(args.log_level, LogConfig::default()).context(error::Logger)?; + SimpleLogger::init(args.log_level, LogConfig::default()).context(error::LoggerSnafu)?; info!("servicedog started for unit {}", &args.systemd_unit); diff --git a/sources/api/settings-committer/Cargo.toml b/sources/api/settings-committer/Cargo.toml index 6847bb9327d..de9bfb009e9 100644 --- a/sources/api/settings-committer/Cargo.toml +++ b/sources/api/settings-committer/Cargo.toml @@ -12,7 +12,7 @@ exclude = ["README.md"] [dependencies] apiclient = { path = "../apiclient", version = "0.1.0" } constants = { path = "../../constants", version = "0.1.0" } -snafu = "0.6" +snafu = "0.7" http = "0.2" log = "0.4" serde = { version = "1.0", features = ["derive"] } diff --git a/sources/api/settings-committer/src/main.rs b/sources/api/settings-committer/src/main.rs index 8ef9f9db714..e5414ac9476 100644 --- a/sources/api/settings-committer/src/main.rs +++ b/sources/api/settings-committer/src/main.rs @@ -30,7 +30,7 @@ mod error { /// Potential errors during user data management. #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub(super) enum SettingsCommitterError { #[snafu(display("Error sending {} to {}: {}", method, uri, source))] APIRequest { @@ -103,7 +103,7 @@ async fn commit_pending_settings>(socket_path: S, transaction: &st info!("settings-committer found no settings changes to commit"); return Ok(()); } else { - return error::APIResponse { + return error::APIResponseSnafu { method: "POST", uri, code, @@ -114,7 +114,7 @@ async fn commit_pending_settings>(socket_path: S, transaction: &st } // Any other type of error means we couldn't even make the request. _ => { - return Err(e).context(error::APIRequest { + return Err(e).context(error::APIRequestSnafu { method: "POST", uri, }); @@ -203,7 +203,7 @@ async fn run() -> Result<()> { let args = parse_args(env::args()); // SimpleLogger will send errors to stderr and anything less to stdout. - SimpleLogger::init(args.log_level, LogConfig::default()).context(error::Logger)?; + SimpleLogger::init(args.log_level, LogConfig::default()).context(error::LoggerSnafu)?; info!("Checking pending settings."); check_pending_settings(&args.socket_path, &args.transaction).await; diff --git a/sources/api/shibaken/Cargo.toml b/sources/api/shibaken/Cargo.toml index 234930f07ab..1081f0fb90a 100644 --- a/sources/api/shibaken/Cargo.toml +++ b/sources/api/shibaken/Cargo.toml @@ -16,7 +16,7 @@ log = "0.4" serde = { version = "1.0", features = ["derive"] } serde_json = "1" simplelog = "0.10" -snafu = "0.6" +snafu = "0.7" tokio = { version = "~1.14", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS [build-dependencies] diff --git a/sources/api/shibaken/src/main.rs b/sources/api/shibaken/src/main.rs index 05d0abbee34..5e7eac9e2b3 100644 --- a/sources/api/shibaken/src/main.rs +++ b/sources/api/shibaken/src/main.rs @@ -46,7 +46,7 @@ async fn fetch_public_keys_from_imds() -> Result> { let public_keys = client .fetch_public_ssh_keys() .await - .context(error::ImdsClient)? + .context(error::ImdsClientSnafu)? .unwrap_or_else(Vec::new); Ok(public_keys) } @@ -74,17 +74,17 @@ fn parse_args(args: env::Args) -> Result { while let Some(arg) = iter.next() { match arg.as_ref() { "--log-level" => { - let log_level_str = iter.next().context(error::Usage { + let log_level_str = iter.next().context(error::UsageSnafu { message: "Did not give argument to --log-level", })?; log_level = Some( LevelFilter::from_str(&log_level_str) - .context(error::LogLevel { log_level_str })?, + .context(error::LogLevelSnafu { log_level_str })?, ); } x => { - return error::Usage { + return error::UsageSnafu { message: format!("unexpected argument '{}'", x), } .fail() @@ -108,7 +108,7 @@ async fn run() -> Result<()> { TerminalMode::Stderr, ColorChoice::Auto, ) - .context(error::Logger)?; + .context(error::LoggerSnafu)?; info!("shibaken started"); @@ -118,7 +118,7 @@ async fn run() -> Result<()> { info!("Generating user-data"); // Serialize user_data to a JSON string that can be read by the admin container. - let user_data_json = serde_json::to_string(&user_data).context(error::SerializeJson)?; + let user_data_json = serde_json::to_string(&user_data).context(error::SerializeJsonSnafu)?; debug!("{}", &user_data_json); info!("Encoding user-data"); @@ -130,7 +130,7 @@ async fn run() -> Result<()> { info!("Outputting base64-encoded user-data"); // sundog expects JSON-serialized output so that many types can be represented, allowing the // API model to use more accurate types. - let output = serde_json::to_string(&user_data_base64).context(error::SerializeJson)?; + let output = serde_json::to_string(&user_data_base64).context(error::SerializeJsonSnafu)?; println!("{}", output); @@ -163,7 +163,7 @@ mod error { use snafu::Snafu; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub(super) enum Error { #[snafu(display("IMDS request failed: {}", source))] ImdsRequest { source: imdsclient::Error }, diff --git a/sources/api/static-pods/Cargo.toml b/sources/api/static-pods/Cargo.toml index 8777decb9d5..e794cdaa578 100644 --- a/sources/api/static-pods/Cargo.toml +++ b/sources/api/static-pods/Cargo.toml @@ -18,7 +18,7 @@ schnauzer = { path = "../schnauzer", version = "0.1.0" } serde = { version = "1.0", features = ["derive"] } serde_json = "1" simplelog = "0.10" -snafu = "0.6" +snafu = "0.7" tokio = { version = "~1.14", default-features = false, features = ["macros", "rt-multi-thread", "time"] } # LTS tempfile = "3.2.0" diff --git a/sources/api/static-pods/src/static_pods.rs b/sources/api/static-pods/src/static_pods.rs index 2717121dbaa..6b08a6fd440 100644 --- a/sources/api/static-pods/src/static_pods.rs +++ b/sources/api/static-pods/src/static_pods.rs @@ -36,13 +36,13 @@ where debug!("Requesting settings values"); let settings = schnauzer::get_settings(socket_path) .await - .context(error::RetrieveSettings)? + .context(error::RetrieveSettingsSnafu)? .settings - .context(error::MissingSettings)?; + .context(error::MissingSettingsSnafu)?; Ok(settings .kubernetes - .context(error::MissingSettings)? + .context(error::MissingSettingsSnafu)? .static_pods) } @@ -56,19 +56,19 @@ where let manifest = manifest.as_ref(); let target_dir = Path::new(STATIC_POD_DIR); - fs::create_dir_all(&target_dir).context(error::Mkdir { dir: &target_dir })?; + fs::create_dir_all(&target_dir).context(error::MkdirSnafu { dir: &target_dir })?; // Create a temporary directory adjacent to the static pods directory. This directory will be // automatically cleaned-up as soon as it goes out of scope. - let tmp_dir = TempDir::new_in(ETC_KUBE_DIR).context(error::CreateTempdir)?; + let tmp_dir = TempDir::new_in(ETC_KUBE_DIR).context(error::CreateTempdirSnafu)?; // Create the pod manifest file as a temporary file in an adjacent temp directory first and // finish writing to it before swapping any files out in the target static pods directory. let mut temp_manifest_file = - NamedTempFile::new_in(tmp_dir.path()).context(error::CreateTempfile)?; + NamedTempFile::new_in(tmp_dir.path()).context(error::CreateTempfileSnafu)?; temp_manifest_file .write(manifest) - .context(error::ManifestWrite { name })?; + .context(error::ManifestWriteSnafu { name })?; let target_path = target_dir.join(name); debug!( @@ -78,7 +78,7 @@ where // Create the file if it does not exist. If it does exist, atomically replace it. temp_manifest_file .persist(&target_path) - .context(error::PersistPodManifest { path: target_path })?; + .context(error::PersistPodManifestSnafu { path: target_path })?; Ok(()) } @@ -91,7 +91,7 @@ where let name = name.as_ref(); let path = Path::new(STATIC_POD_DIR).join(name); if path.exists() { - fs::remove_file(path).context(error::ManifestDelete { name })?; + fs::remove_file(path).context(error::ManifestDeleteSnafu { name })?; } Ok(()) @@ -103,18 +103,22 @@ where { // Get basic settings, as retrieved from API. let name = name.as_ref(); - let enabled = pod_info.enabled.context(error::MissingField { + let enabled = pod_info.enabled.context(error::MissingFieldSnafu { name, field: "enabled", })?; if enabled { - let manifest = pod_info.manifest.as_ref().context(error::MissingField { - name, - field: "manifest", - })?; + let manifest = pod_info + .manifest + .as_ref() + .context(error::MissingFieldSnafu { + name, + field: "manifest", + })?; - let manifest = base64::decode(manifest.as_bytes()).context(error::Base64Decode { name })?; + let manifest = + base64::decode(manifest.as_bytes()).context(error::Base64DecodeSnafu { name })?; info!("Writing static pod '{}' to '{}'", name, STATIC_POD_DIR); @@ -134,7 +138,7 @@ async fn run() -> Result<()> { let args = parse_args(env::args())?; // SimpleLogger will send errors to stderr and anything less to stdout. - SimpleLogger::init(args.log_level, LogConfig::default()).context(error::Logger)?; + SimpleLogger::init(args.log_level, LogConfig::default()).context(error::LoggerSnafu)?; info!("static-pods started"); @@ -150,7 +154,7 @@ async fn run() -> Result<()> { ensure!( failed == 0, - error::ManageStaticPodsFailed { + error::ManageStaticPodsFailedSnafu { failed, tried: static_pods.len() } @@ -247,7 +251,7 @@ mod error { use std::path::PathBuf; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub(super) enum Error { #[snafu(display("{}", message))] Usage { message: String }, diff --git a/sources/api/storewolf/Cargo.toml b/sources/api/storewolf/Cargo.toml index 91515449f79..2f5ca12daf5 100644 --- a/sources/api/storewolf/Cargo.toml +++ b/sources/api/storewolf/Cargo.toml @@ -18,7 +18,7 @@ models = { path = "../../models", version = "0.1.0" } rand = { version = "0.8", default-features = false, features = ["std", "std_rng"] } semver = "1.0" simplelog = "0.10" -snafu = "0.6" +snafu = "0.7" toml = "0.5" [build-dependencies] @@ -30,7 +30,7 @@ merge-toml = { path = "merge-toml", version = "0.1.0" } # runs twice, once for the above dependency and once for this build-dependency, # so it's important that it remains reentrant. models = { path = "../../models", version = "0.1.0" } -snafu = "0.6" +snafu = "0.7" toml = "0.5" walkdir = "2" diff --git a/sources/api/storewolf/build.rs b/sources/api/storewolf/build.rs index 0b4dfe32a3c..b7f7a368e93 100644 --- a/sources/api/storewolf/build.rs +++ b/sources/api/storewolf/build.rs @@ -70,24 +70,25 @@ fn generate_defaults_toml() -> Result<()> { // Merge the files into a single TOML value, in order. let mut defaults = Value::Table(Map::new()); for entry in walker { - let entry = entry.context(error::ListFiles { dir: DEFAULTS_DIR })?; + let entry = entry.context(error::ListFilesSnafu { dir: DEFAULTS_DIR })?; // Reflect that we need to rerun if any of the default settings files have changed. println!("cargo:rerun-if-changed={}", entry.path().display()); - let data = fs::read_to_string(entry.path()).context(error::File { + let data = fs::read_to_string(entry.path()).context(error::FileSnafu { op: "read", path: entry.path(), })?; - let value = toml::from_str(&data).context(error::TomlDeserialize { path: entry.path() })?; - merge_values(&mut defaults, &value).context(error::TomlMerge)?; + let value = + toml::from_str(&data).context(error::TomlDeserializeSnafu { path: entry.path() })?; + merge_values(&mut defaults, &value).context(error::TomlMergeSnafu)?; } // Serialize to disk for storewolf to read. - let data = toml::to_string(&defaults).context(error::TomlSerialize)?; + let data = toml::to_string(&defaults).context(error::TomlSerializeSnafu)?; let out_dir = std::env::var("OUT_DIR").expect("OUT_DIR not set; are you not using cargo?"); let path = Path::new(&out_dir).join("defaults.toml"); - fs::write(&path, &data).context(error::File { op: "write", path })?; + fs::write(&path, &data).context(error::FileSnafu { op: "write", path })?; Ok(()) } @@ -97,7 +98,7 @@ mod error { use std::path::PathBuf; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub(super) enum Error { #[snafu(display("Failed to {} {}: {}", op, path.display(), source))] File { diff --git a/sources/api/storewolf/merge-toml/Cargo.toml b/sources/api/storewolf/merge-toml/Cargo.toml index b191e334698..8cbbd433ddf 100644 --- a/sources/api/storewolf/merge-toml/Cargo.toml +++ b/sources/api/storewolf/merge-toml/Cargo.toml @@ -7,5 +7,5 @@ edition = "2018" publish = false [dependencies] -snafu = "0.6" +snafu = "0.7" toml = "0.5" diff --git a/sources/api/storewolf/merge-toml/src/lib.rs b/sources/api/storewolf/merge-toml/src/lib.rs index 9eb42137fbf..f6171e0258d 100644 --- a/sources/api/storewolf/merge-toml/src/lib.rs +++ b/sources/api/storewolf/merge-toml/src/lib.rs @@ -15,7 +15,10 @@ use toml::{map::Entry, Value}; pub fn merge_values<'a>(merge_into: &'a mut Value, merge_from: &'a Value) -> Result<()> { // If the types of left and right don't match, we have inconsistent models, and shouldn't try // to merge them. - ensure!(merge_into.same_type(&merge_from), error::DataTypeMismatch); + ensure!( + merge_into.same_type(&merge_from), + error::DataTypeMismatchSnafu + ); match merge_from { // If we see a scalar, we replace the left with the right. We treat arrays like scalars so @@ -55,7 +58,7 @@ mod error { use snafu::Snafu; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub enum Error { #[snafu(display("Cannot merge mismatched data types in given TOML"))] DataTypeMismatch {}, diff --git a/sources/api/storewolf/src/lib.rs b/sources/api/storewolf/src/lib.rs index 7456d4d8b32..a04465dfc6e 100644 --- a/sources/api/storewolf/src/lib.rs +++ b/sources/api/storewolf/src/lib.rs @@ -17,7 +17,7 @@ pub mod error { /// Public error type for `libstorewolf` #[derive(Debug, Snafu)] - #[snafu(visibility = "pub")] + #[snafu(visibility(pub))] pub enum Error { #[snafu(display("Unable to create directory at '{}': {}", path.display(), source))] DirectoryCreation { path: PathBuf, source: io::Error }, @@ -52,7 +52,7 @@ pub fn create_new_datastore>( let version = match version { Some(v) => v, None => { - let br = BottlerocketRelease::new().context(error::ReleaseVersion)?; + let br = BottlerocketRelease::new().context(error::ReleaseVersionSnafu)?; br.version_id } }; @@ -89,25 +89,25 @@ pub fn create_new_datastore>( let current_path = base_path.as_ref().join("current"); // Create the path to the datastore, i.e /path/to/datastore/v1.5_0123456789abcdef - fs::create_dir_all(&data_store_path).context(error::DirectoryCreation { + fs::create_dir_all(&data_store_path).context(error::DirectoryCreationSnafu { path: &base_path.as_ref(), })?; // Build our symlink chain (See example in docstring above) // /path/to/datastore/v1.5.2 -> v1.5.2_0123456789abcdef - symlink(&data_store_filename, &patch_version_path).context(error::LinkCreate { + symlink(&data_store_filename, &patch_version_path).context(error::LinkCreateSnafu { path: &patch_version_path, })?; // /path/to/datastore/v1.5 -> v1.5.2 - symlink(&patch_version_filename, &minor_version_path).context(error::LinkCreate { + symlink(&patch_version_filename, &minor_version_path).context(error::LinkCreateSnafu { path: &minor_version_path, })?; // /path/to/datastore/v1 -> v1.5 - symlink(&minor_version_filename, &major_version_path).context(error::LinkCreate { + symlink(&minor_version_filename, &major_version_path).context(error::LinkCreateSnafu { path: &major_version_path, })?; // /path/to/datastore/current -> v1 - symlink(&major_version_filename, ¤t_path).context(error::LinkCreate { + symlink(&major_version_filename, ¤t_path).context(error::LinkCreateSnafu { path: ¤t_path, })?; Ok(data_store_path) diff --git a/sources/api/storewolf/src/main.rs b/sources/api/storewolf/src/main.rs index baf59464963..e6934c8eed9 100644 --- a/sources/api/storewolf/src/main.rs +++ b/sources/api/storewolf/src/main.rs @@ -39,7 +39,7 @@ mod error { /// Potential errors during execution #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub(super) enum StorewolfError { #[snafu(display("Unable to clear pending transactions: {}", source))] DeletePending { source: io::Error }, @@ -164,14 +164,14 @@ fn parse_metadata_toml(md_toml_val: toml::Value) -> Result> // An array or string means we're ready to create a model::Metadata val @ toml::Value::Array(_) | val @ toml::Value::String(_) => { // Get the metadata key from the end of the path - let md_key = path.pop().context(error::Internal { + let md_key = path.pop().context(error::InternalSnafu { msg: "parse_metadata_toml found empty 'path' in the to_process vec - is 'metadata' not a Table?", })?; // Make sure that the path contains more than 1 item, i.e. ["settings", "motd"] ensure!( path.len() >= 1, - error::Internal { + error::InternalSnafu { msg: format!( "Cannot create empty metadata data key - is root not a Table?" ) @@ -186,15 +186,17 @@ fn parse_metadata_toml(md_toml_val: toml::Value) -> Result> ); // Ensure the metadata/data keys don't contain newline chars - let md = SingleLineString::try_from(md_key).context(error::SingleLineString)?; - let key = SingleLineString::try_from(data_key).context(error::SingleLineString)?; + let md = + SingleLineString::try_from(md_key).context(error::SingleLineStringSnafu)?; + let key = + SingleLineString::try_from(data_key).context(error::SingleLineStringSnafu)?; // Create the Metadata struct def_metadatas.push(model::Metadata { key, md, val }) } // We don't recognize any other values yet, something is awry - _ => return error::DefaultsMetadataUnexpectedFormat {}.fail(), + _ => return error::DefaultsMetadataUnexpectedFormatSnafu {}.fail(), }; } Ok(def_metadatas) @@ -226,19 +228,19 @@ fn populate_default_datastore>( debug!("Gathering existing data from the datastore"); existing_metadata = datastore .list_populated_metadata("", &None as &Option<&str>) - .context(error::QueryMetadata)?; + .context(error::QueryMetadataSnafu)?; existing_data = datastore .list_populated_keys("", &datastore::Committed::Live) - .context(error::QueryData)?; + .context(error::QueryDataSnafu)?; } else { info!("Creating datastore at: {}", &live_path.display()); - create_new_datastore(&base_path, version).context(error::DatastoreCreation)?; + create_new_datastore(&base_path, version).context(error::DatastoreCreationSnafu)?; } // Here we read in the merged settings file built by build.rs. let defaults_str = include_str!(concat!(env!("OUT_DIR"), "/defaults.toml")); let mut defaults_val: toml::Value = - toml::from_str(defaults_str).context(error::DefaultsFormatting { + toml::from_str(defaults_str).context(error::DefaultsFormattingSnafu { path: concat!(env!("OUT_DIR"), "/defaults.toml"), })?; @@ -246,7 +248,7 @@ fn populate_default_datastore>( // of `shared_defaults_val` let table = defaults_val .as_table_mut() - .context(error::DefaultsNotTable)?; + .context(error::DefaultsNotTableSnafu)?; let maybe_metadata_val = table.remove("metadata"); let maybe_settings_val = table.remove("settings"); @@ -257,7 +259,7 @@ fn populate_default_datastore>( debug!("Serializing default settings and writing new ones to datastore"); let def_settings_table = def_settings_val .as_table() - .context(error::DefaultSettingsNotTable)?; + .context(error::DefaultSettingsNotTableSnafu)?; // The default settings were removed from the "settings" key of the // defaults table above. We still need them under a "settings" key @@ -265,7 +267,7 @@ fn populate_default_datastore>( // "settings.foo.bar" and not just "foo.bar". We use a HashMap // to rebuild the nested structure. let def_settings = to_pairs_with_prefix("settings", &def_settings_table).context( - error::Serialization { + error::SerializationSnafu { given: "default settings", }, )?; @@ -288,7 +290,7 @@ fn populate_default_datastore>( }; datastore .set_keys(&settings_to_write, &pending) - .context(error::WriteKeys)?; + .context(error::WriteKeysSnafu)?; } // If we have metadata, write it out to the datastore in Live state @@ -314,11 +316,11 @@ fn populate_default_datastore>( let mut metadata_to_write = HashSet::new(); for def_metadata in def_metadatas { let model::Metadata { key, md, val } = def_metadata; - let data_key = Key::new(KeyType::Data, &key).context(error::InvalidKey { + let data_key = Key::new(KeyType::Data, &key).context(error::InvalidKeySnafu { key_type: KeyType::Data, key, })?; - let md_key = Key::new(KeyType::Meta, &md).context(error::InvalidKey { + let md_key = Key::new(KeyType::Meta, &md).context(error::InvalidKeySnafu { key_type: KeyType::Meta, key: md, })?; @@ -328,8 +330,8 @@ fn populate_default_datastore>( let def_metadata_keypair = (&data_key, &md_key); if !existing_metadata.contains(&def_metadata_keypair) { let value = - datastore::serialize_scalar::<_, ScalarError>(&val).with_context(|| { - error::SerializeScalar { + datastore::serialize_scalar::<_, ScalarError>(&val).with_context(|_| { + error::SerializeScalarSnafu { given: format!("metadata value '{}'", val), } })?; @@ -345,14 +347,14 @@ fn populate_default_datastore>( let (md, key, val) = metadata; datastore .set_metadata(&md, &key, val) - .context(error::WriteMetadata)?; + .context(error::WriteMetadataSnafu)?; } } // If any other defaults remain (configuration files, services, etc), // write them to the datastore in Live state debug!("Serializing other defaults and writing new ones to datastore"); - let defaults = to_pairs(&defaults_val).context(error::Serialization { + let defaults = to_pairs(&defaults_val).context(error::SerializationSnafu { given: "other defaults", })?; @@ -370,7 +372,7 @@ fn populate_default_datastore>( ); datastore .set_keys(&other_defaults_to_write, &datastore::Committed::Live) - .context(error::WriteKeys)?; + .context(error::WriteKeysSnafu)?; } Ok(()) } @@ -455,7 +457,7 @@ fn run() -> Result<()> { let args = parse_args(env::args()); // SimpleLogger will send errors to stderr and anything less to stdout. - SimpleLogger::init(args.log_level, LogConfig::default()).context(error::Logger)?; + SimpleLogger::init(args.log_level, LogConfig::default()).context(error::LoggerSnafu)?; info!("Storewolf started"); @@ -467,7 +469,7 @@ fn run() -> Result<()> { // If there are no pending settings, the directory won't exist. // Ignore the error in this case. if e.kind() != io::ErrorKind::NotFound { - Err(e).context(error::DeletePending)? + Err(e).context(error::DeletePendingSnafu)? } } diff --git a/sources/api/sundog/Cargo.toml b/sources/api/sundog/Cargo.toml index 4b90c95f62b..92ae32565fd 100644 --- a/sources/api/sundog/Cargo.toml +++ b/sources/api/sundog/Cargo.toml @@ -19,7 +19,7 @@ models = { path = "../../models", version = "0.1.0" } serde = { version = "1.0", features = ["derive"] } serde_json = "1" simplelog = "0.10" -snafu = "0.6" +snafu = "0.7" tokio = { version = "~1.14", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS [build-dependencies] diff --git a/sources/api/sundog/src/main.rs b/sources/api/sundog/src/main.rs index ee142020d12..7179f30609f 100644 --- a/sources/api/sundog/src/main.rs +++ b/sources/api/sundog/src/main.rs @@ -33,7 +33,7 @@ mod error { /// Potential errors during dynamic settings retrieval #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub(super) enum SundogError { #[snafu(display("Failed to start generator '{}': {}", program, source))] CommandFailure { @@ -160,10 +160,10 @@ where debug!("Requesting setting generators from API"); let (code, response_body) = apiclient::raw_request(socket_path.as_ref(), uri, "GET", None) .await - .context(error::APIRequest { method: "GET", uri })?; + .context(error::APIRequestSnafu { method: "GET", uri })?; ensure!( code.is_success(), - error::APIResponse { + error::APIResponseSnafu { method: "GET", uri, code, @@ -171,8 +171,8 @@ where } ); - let generators: HashMap = - serde_json::from_str(&response_body).context(error::ResponseJson { method: "GET", uri })?; + let generators: HashMap = serde_json::from_str(&response_body) + .context(error::ResponseJsonSnafu { method: "GET", uri })?; trace!("Generators: {:?}", &generators); Ok(generators) @@ -193,10 +193,10 @@ where let (code, response_body) = apiclient::raw_request(socket_path.as_ref(), uri, "GET", None) .await - .context(error::APIRequest { method: "GET", uri })?; + .context(error::APIRequestSnafu { method: "GET", uri })?; ensure!( code.is_success(), - error::APIResponse { + error::APIResponseSnafu { method: "GET", uri, code, @@ -205,13 +205,13 @@ where ); // Build a Settings struct from the response. - let settings: model::Settings = - serde_json::from_str(&response_body).context(error::ResponseJson { method: "GET", uri })?; + let settings: model::Settings = serde_json::from_str(&response_body) + .context(error::ResponseJsonSnafu { method: "GET", uri })?; // Serialize the Settings struct into key/value pairs. This builds the dotted // string representation of the setting let settings_keypairs = - to_pairs_with_prefix("settings", &settings).context(error::SerializeSettings)?; + to_pairs_with_prefix("settings", &settings).context(error::SerializeSettingsSnafu)?; // Put the setting into our hashset of populated keys for (k, _) in settings_keypairs { @@ -241,7 +241,7 @@ where // For each generator, run it and capture the output for (setting_str, generator) in generators { - let setting = Key::new(KeyType::Data, &setting_str).context(error::InvalidKey { + let setting = Key::new(KeyType::Data, &setting_str).context(error::InvalidKeySnafu { key_type: KeyType::Data, key: &setting_str, })?; @@ -256,14 +256,14 @@ where // Split on space, assume the first item is the command // and the rest are args. let mut command_strings = generator.split_whitespace(); - let command = command_strings.next().context(error::InvalidCommand { + let command = command_strings.next().context(error::InvalidCommandSnafu { command: generator.as_str(), })?; let result = process::Command::new(command) .args(command_strings) .output() - .context(error::CommandFailure { + .context(error::CommandFailureSnafu { program: generator.as_str(), })?; @@ -272,7 +272,7 @@ where match result.status.code() { Some(0) => {} Some(1) => { - return error::FailedSettingGenerator { + return error::FailedSettingGeneratorSnafu { program: generator.as_str(), code: 1.to_string(), stderr: String::from_utf8_lossy(&result.stderr), @@ -287,7 +287,7 @@ where continue; } Some(x) => { - return error::UnexpectedReturnCode { + return error::UnexpectedReturnCodeSnafu { program: generator.as_str(), code: x.to_string(), stderr: String::from_utf8_lossy(&result.stderr), @@ -297,7 +297,7 @@ where // A process will return None if terminated by a signal, regard this as // a failure since we could have incomplete data None => { - return error::FailedSettingGenerator { + return error::FailedSettingGeneratorSnafu { program: generator.as_str(), code: "signal", stderr: String::from_utf8_lossy(&result.stderr), @@ -312,7 +312,7 @@ where // // First, we pull the raw string from the process output. let output_raw = str::from_utf8(&result.stdout) - .context(error::GeneratorOutput { + .context(error::GeneratorOutputSnafu { program: generator.as_str(), })? .trim() @@ -321,7 +321,7 @@ where // Next, we deserialize the text into a Value that can represent any JSON type. let output_value: serde_json::Value = - serde_json::from_str(&output_raw).context(error::CommandJson { + serde_json::from_str(&output_raw).context(error::CommandJsonSnafu { generator: &generator, input: &output_raw, })?; @@ -332,7 +332,7 @@ where // We have to go through the round-trip of serialization because the data store // serialization format may not be the same as the format we choose for sundog. let serialized_output = - datastore::serialize_scalar(&output_value).context(error::SerializeScalar { + datastore::serialize_scalar(&output_value).context(error::SerializeScalarSnafu { value: output_value, })?; trace!("Serialized output: {}", &serialized_output); @@ -343,7 +343,7 @@ where // The API takes a properly nested Settings struct, so deserialize our map to a Settings // and ensure it is correct let settings_struct: model::Settings = - deserialization::from_map(&settings).context(error::Deserialize)?; + deserialization::from_map(&settings).context(error::DeserializeSnafu)?; Ok(settings_struct) } @@ -354,7 +354,7 @@ where S: AsRef, { // Serialize our Settings struct to the JSON wire format - let request_body = serde_json::to_string(&settings).context(error::SerializeRequest)?; + let request_body = serde_json::to_string(&settings).context(error::SerializeRequestSnafu)?; let uri = &format!( "{}?tx={}", @@ -366,10 +366,10 @@ where let (code, response_body) = apiclient::raw_request(socket_path.as_ref(), uri, method, Some(request_body)) .await - .context(error::APIRequest { method, uri })?; + .context(error::APIRequestSnafu { method, uri })?; ensure!( code.is_success(), - error::APIResponse { + error::APIResponseSnafu { method, uri, code, @@ -446,7 +446,7 @@ async fn run() -> Result<()> { let args = parse_args(env::args()); // SimpleLogger will send errors to stderr and anything less to stdout. - SimpleLogger::init(args.log_level, LogConfig::default()).context(error::Logger)?; + SimpleLogger::init(args.log_level, LogConfig::default()).context(error::LoggerSnafu)?; info!("Sundog started"); diff --git a/sources/api/thar-be-settings/Cargo.toml b/sources/api/thar-be-settings/Cargo.toml index 5dfadc48c1d..2a843a7731b 100644 --- a/sources/api/thar-be-settings/Cargo.toml +++ b/sources/api/thar-be-settings/Cargo.toml @@ -21,7 +21,7 @@ nix = "0.23" schnauzer = { path = "../schnauzer", version = "0.1.0" } serde_json = "1" simplelog = "0.10" -snafu = "0.6" +snafu = "0.7" tokio = { version = "~1.14", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS [build-dependencies] diff --git a/sources/api/thar-be-settings/src/config.rs b/sources/api/thar-be-settings/src/config.rs index e1129ab1995..9f5faadb5a4 100644 --- a/sources/api/thar-be-settings/src/config.rs +++ b/sources/api/thar-be-settings/src/config.rs @@ -22,7 +22,7 @@ where let uri = "/configuration-files"; let config_files: model::ConfigurationFiles = schnauzer::get_json(socket_path, uri, query) .await - .context(error::GetJson { uri })?; + .context(error::GetJsonSnafu { uri })?; Ok(config_files) } @@ -59,7 +59,7 @@ pub fn render_config_files( let try_rendered = registry.render(&name, &settings); if strict { - let rendered = try_rendered.context(error::TemplateRender { template: name })?; + let rendered = try_rendered.context(error::TemplateRenderSnafu { template: name })?; rendered_configs.push(RenderedConfigFile::new(&metadata.path, rendered)); } else { match try_rendered { @@ -102,13 +102,13 @@ impl RenderedConfigFile { /// Writes the rendered template at the proper location fn write_to_disk(&self) -> Result<()> { if let Some(dirname) = self.path.parent() { - fs::create_dir_all(dirname).context(error::TemplateWrite { + fs::create_dir_all(dirname).context(error::TemplateWriteSnafu { path: dirname, pathtype: "directory", })?; }; - fs::write(&self.path, self.rendered.as_bytes()).context(error::TemplateWrite { + fs::write(&self.path, self.rendered.as_bytes()).context(error::TemplateWriteSnafu { path: &self.path, pathtype: "file", }) diff --git a/sources/api/thar-be-settings/src/error.rs b/sources/api/thar-be-settings/src/error.rs index 7e6b1e219d0..b01a3dfc339 100644 --- a/sources/api/thar-be-settings/src/error.rs +++ b/sources/api/thar-be-settings/src/error.rs @@ -5,11 +5,11 @@ use std::path::PathBuf; /// Potential errors during configuration application #[derive(Debug, Snafu)] -#[snafu(visibility = "pub(crate)")] +#[snafu(visibility(pub(crate)))] pub enum Error { - #[snafu(display("Failed to read changed settings from {}", location))] + #[snafu(display("Failed to read changed settings from {}", from))] ReadInput { - location: &'static str, + from: &'static str, source: io::Error, }, diff --git a/sources/api/thar-be-settings/src/lib.rs b/sources/api/thar-be-settings/src/lib.rs index a26c05ae8bd..d1f8ce02f3b 100644 --- a/sources/api/thar-be-settings/src/lib.rs +++ b/sources/api/thar-be-settings/src/lib.rs @@ -35,13 +35,13 @@ pub fn get_changed_settings() -> Result> { let mut input = String::new(); io::stdin() .read_to_string(&mut input) - .context(error::ReadInput { location: "stdin" })?; + .context(error::ReadInputSnafu { from: "stdin" })?; trace!("Raw input from stdin: {}", &input); // Settings should be a vec of strings debug!("Parsing stdin as JSON"); let changed_settings: HashSet = - serde_json::from_str(&input).context(error::InvalidInput { + serde_json::from_str(&input).context(error::InvalidInputSnafu { reason: "Input must be a JSON array of strings", input, })?; diff --git a/sources/api/thar-be-settings/src/main.rs b/sources/api/thar-be-settings/src/main.rs index f4fbe6f63e3..dcd9fc1dd01 100644 --- a/sources/api/thar-be-settings/src/main.rs +++ b/sources/api/thar-be-settings/src/main.rs @@ -18,7 +18,7 @@ mod error { use std::path::PathBuf; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub(super) enum Error { #[snafu(display("Logger setup error: {}", source))] Logger { source: log::SetLoggerError }, @@ -143,7 +143,7 @@ async fn write_config_files( ); template_registry .register_template_file(&name, metadata.template_path.as_ref()) - .context(error::TemplateRegister { + .context(error::TemplateRegisterSnafu { name: name.as_str(), path: metadata.template_path.as_ref(), })?; @@ -170,7 +170,7 @@ async fn write_config_files( async fn run(args: Args) -> Result<(), Box> { // SimpleLogger will send errors to stderr and anything less to stdout. - SimpleLogger::init(args.log_level, LogConfig::default()).context(error::Logger)?; + SimpleLogger::init(args.log_level, LogConfig::default()).context(error::LoggerSnafu)?; info!("thar-be-settings started"); diff --git a/sources/api/thar-be-settings/src/service.rs b/sources/api/thar-be-settings/src/service.rs index 7bbaa9dfe2e..2d323faa4d9 100644 --- a/sources/api/thar-be-settings/src/service.rs +++ b/sources/api/thar-be-settings/src/service.rs @@ -104,7 +104,7 @@ where let setting_to_services_map: HashMap> = schnauzer::get_json(socket_path, uri, Some(query)) .await - .context(error::GetJson { uri })?; + .context(error::GetJsonSnafu { uri })?; trace!("API response: {:?}", &setting_to_services_map); Ok(setting_to_services_map) @@ -127,7 +127,7 @@ where let uri = "/services"; let service_map: model::Services = schnauzer::get_json(socket_path, uri, query) .await - .context(error::GetJson { uri })?; + .context(error::GetJsonSnafu { uri })?; trace!("Service metadata: {:?}", &service_map); Ok(service_map) @@ -160,7 +160,7 @@ impl ServiceRestart for Service { let mut command_strings = restart_command.split(' '); let command = command_strings .next() - .context(error::InvalidRestartCommand { + .context(error::InvalidRestartCommandSnafu { command: restart_command.as_str(), })?; trace!("Command: {}", &command); @@ -176,14 +176,14 @@ impl ServiceRestart for Service { } let result = process_command .output() - .context(error::CommandExecutionFailure { + .context(error::CommandExecutionFailureSnafu { command: restart_command.as_str(), })?; // If the restart command exited nonzero, call it a failure ensure!( result.status.success(), - error::FailedRestartCommand { + error::FailedRestartCommandSnafu { command: restart_command.as_str(), stderr: String::from_utf8_lossy(&result.stderr), } diff --git a/sources/api/thar-be-updates/Cargo.toml b/sources/api/thar-be-updates/Cargo.toml index cc7fe46cc92..0bf454c05fa 100644 --- a/sources/api/thar-be-updates/Cargo.toml +++ b/sources/api/thar-be-updates/Cargo.toml @@ -27,7 +27,7 @@ serde_json = "1.0.53" serde_plain = "1.0" signpost = { path = "../../updater/signpost", version = "0.1.0" } simplelog = "0.10" -snafu = "0.6.8" +snafu = "0.7" tempfile = "3.1.0" tokio = { version = "~1.14", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS update_metadata = { path = "../../updater/update_metadata", version = "0.1.0" } diff --git a/sources/api/thar-be-updates/src/error.rs b/sources/api/thar-be-updates/src/error.rs index bd2487d6445..6d150325899 100644 --- a/sources/api/thar-be-updates/src/error.rs +++ b/sources/api/thar-be-updates/src/error.rs @@ -7,7 +7,7 @@ use std::path::PathBuf; pub type Result = std::result::Result; #[derive(Debug, Snafu)] -#[snafu(visibility = "pub")] +#[snafu(visibility(pub))] pub enum Error { #[snafu(display("Failed to create tempfile for writing status: {}", source))] CreateTempfile { source: std::io::Error }, diff --git a/sources/api/thar-be-updates/src/main.rs b/sources/api/thar-be-updates/src/main.rs index 1d9a1ee4046..e7ba8462a7f 100644 --- a/sources/api/thar-be-updates/src/main.rs +++ b/sources/api/thar-be-updates/src/main.rs @@ -124,7 +124,7 @@ fn parse_args(args: std::env::Args) -> Args { fn lock_exclusive(lockfile: &File) -> Result<()> { lockfile .try_lock_exclusive() - .context(error::UpdateLockHeld { + .context(error::UpdateLockHeldSnafu { path: UPDATE_LOCKFILE, })?; debug!("Obtained exclusive lock"); @@ -144,9 +144,9 @@ fn write_update_status(update_status: &UpdateStatus) -> Result<()> { // Create the status file as a temporary file first and finish writing to it // before swapping the old status file out let status_file_tempfile = - NamedTempFile::new_in(UPDATE_STATUS_DIR).context(error::CreateTempfile)?; + NamedTempFile::new_in(UPDATE_STATUS_DIR).context(error::CreateTempfileSnafu)?; serde_json::to_writer_pretty(&status_file_tempfile, update_status).context( - error::StatusWrite { + error::StatusWriteSnafu { path: status_file_tempfile.path(), }, )?; @@ -154,7 +154,7 @@ fn write_update_status(update_status: &UpdateStatus) -> Result<()> { debug!("Updating status file in '{}'", UPDATE_STATUS_FILE); tempfile_path .persist(UPDATE_STATUS_FILE) - .context(error::CreateStatusFile { + .context(error::CreateStatusFileSnafu { path: UPDATE_STATUS_FILE, })?; Ok(()) @@ -173,7 +173,7 @@ macro_rules! fork_and_return { Ok(ForkResult::Child) => $child_process, Err(e) => { eprintln!("{}", e); - error::Fork.fail() + error::ForkSnafu.fail() } } }; @@ -187,14 +187,14 @@ fn refresh(status: &mut UpdateStatus, socket_path: &str) -> Result { let output = Command::new("updog") .args(&["whats", "--all", "--json"]) .output() - .context(error::Updog)?; + .context(error::UpdogSnafu)?; status.set_recent_command_info(UpdateCommand::Refresh, &output); if !output.status.success() { warn!("Failed to check for updates with updog"); return Ok(false); } let update_info: Vec = - serde_json::from_slice(&output.stdout).context(error::UpdateInfo)?; + serde_json::from_slice(&output.stdout).context(error::UpdateInfoSnafu)?; status.update_available_updates(socket_path, update_info) }) } @@ -205,16 +205,16 @@ fn prepare(status: &mut UpdateStatus) -> Result<()> { debug!("Spawning 'updog update-image'"); let chosen_update = status .chosen_update() - .context(error::UpdateDoesNotExist)? + .context(error::UpdateDoesNotExistSnafu)? .clone(); let output = Command::new("updog") .arg("update-image") .output() - .context(error::Updog)?; + .context(error::UpdogSnafu)?; status.set_recent_command_info(UpdateCommand::Prepare, &output); if !output.status.success() { warn!("Failed to prepare the update with updog"); - return error::PrepareUpdate.fail(); + return error::PrepareUpdateSnafu.fail(); } status.set_staging_partition_image_info(chosen_update); Ok(()) @@ -228,11 +228,11 @@ fn activate(status: &mut UpdateStatus) -> Result<()> { let output = Command::new("updog") .arg("update-apply") .output() - .context(error::Updog)?; + .context(error::UpdogSnafu)?; status.set_recent_command_info(UpdateCommand::Activate, &output); if !output.status.success() { warn!("Failed to activate the update with updog"); - return error::ActivateUpdate.fail(); + return error::ActivateUpdateSnafu.fail(); } status.mark_staging_partition_next_to_boot() }) @@ -245,11 +245,11 @@ fn deactivate(status: &mut UpdateStatus) -> Result<()> { let output = Command::new("updog") .arg("update-revert") .output() - .context(error::Updog)?; + .context(error::UpdogSnafu)?; status.set_recent_command_info(UpdateCommand::Deactivate, &output); if !output.status.success() { warn!("Failed to deactivate the update with updog"); - return error::DeactivateUpdate.fail(); + return error::DeactivateUpdateSnafu.fail(); } status.unmark_staging_partition_next_to_boot() }) @@ -284,7 +284,7 @@ fn drive_state_machine( // Make sure the chosen update exists ensure!( update_status.chosen_update().is_some(), - error::UpdateDoesNotExist + error::UpdateDoesNotExistSnafu ); prepare(update_status)?; // If we succeed in preparing the update, we transition to `Staged` @@ -295,7 +295,7 @@ fn drive_state_machine( // Make sure there's an update image written to the inactive partition ensure!( update_status.staging_partition().is_some(), - error::StagingPartition + error::StagingPartitionSnafu ); activate(update_status)?; // If we succeed in activating the update, we transition to `Ready` @@ -306,7 +306,7 @@ fn drive_state_machine( // Make sure there's an update image written to the inactive partition ensure!( update_status.staging_partition().is_some(), - error::StagingPartition + error::StagingPartitionSnafu ); deactivate(update_status)?; // If we succeed in deactivating the update, we transition to `Staged` @@ -314,7 +314,7 @@ fn drive_state_machine( } // Everything else is disallowed _ => { - return error::DisallowCommand { + return error::DisallowCommandSnafu { command: operation.clone(), state: update_status.update_state().to_owned(), } @@ -330,10 +330,10 @@ fn run() -> Result<()> { let args = parse_args(env::args()); // SimpleLogger will send errors to stderr and anything less to stdout. - SimpleLogger::init(args.log_level, LogConfig::default()).context(error::Logger)?; + SimpleLogger::init(args.log_level, LogConfig::default()).context(error::LoggerSnafu)?; // Open the lockfile for concurrency control, create it if it doesn't exist - let lockfile = File::create(UPDATE_LOCKFILE).context(error::UpdateLockFile { + let lockfile = File::create(UPDATE_LOCKFILE).context(error::UpdateLockFileSnafu { path: UPDATE_LOCKFILE, })?; // Obtain an exclusive lock for upcoming operations to the status file diff --git a/sources/api/thar-be-updates/src/status.rs b/sources/api/thar-be-updates/src/status.rs index d51ced15e3a..e50bf9d48f3 100644 --- a/sources/api/thar-be-updates/src/status.rs +++ b/sources/api/thar-be-updates/src/status.rs @@ -97,11 +97,11 @@ impl Default for UpdateStatus { /// This takes the update lock file as an parameter to signal to caller that the update /// lock needs to be obtained before calling this. pub fn get_update_status(_lockfile: &File) -> Result { - let status_file = File::open(UPDATE_STATUS_FILE).context(error::NoStatusFile { + let status_file = File::open(UPDATE_STATUS_FILE).context(error::NoStatusFileSnafu { path: UPDATE_STATUS_FILE, })?; Ok( - serde_json::from_reader(status_file).context(error::StatusParse { + serde_json::from_reader(status_file).context(error::StatusParseSnafu { path: UPDATE_STATUS_FILE, })?, ) @@ -117,12 +117,13 @@ fn get_settings(socket_path: &str) -> Result { let uri = "/settings"; let method = "GET"; - let rt = Runtime::new().context(error::Runtime)?; + let rt = Runtime::new().context(error::RuntimeSnafu)?; let try_response_body = rt.block_on(async { apiclient::raw_request(&socket_path, uri, method, None).await }); - let (_code, response_body) = try_response_body.context(error::APIRequest { method, uri })?; + let (_code, response_body) = + try_response_body.context(error::APIRequestSnafu { method, uri })?; - serde_json::from_str(&response_body).context(error::ResponseJson { uri }) + serde_json::from_str(&response_body).context(error::ResponseJsonSnafu { uri }) } // This is how the UpdateStatus is stored on disk @@ -164,7 +165,7 @@ impl UpdateStatus { /// Updates the active partition set information pub fn update_active_partition_info(&mut self) -> Result<()> { // Get current OS release info to determine active partition image information - let os_info = BottlerocketRelease::new().context(error::ReleaseVersion)?; + let os_info = BottlerocketRelease::new().context(error::ReleaseVersionSnafu)?; let active_image = UpdateImage { arch: os_info.arch, version: os_info.version_id, @@ -173,9 +174,9 @@ impl UpdateStatus { // Get partition set information. We can infer the version of the image in the active // partition set by checking the os release information - let gpt_state = State::load().context(error::PartitionTableRead)?; + let gpt_state = State::load().context(error::PartitionTableReadSnafu)?; let active_set = gpt_state.active(); - let next_set = gpt_state.next().context(error::NoneSetToBoot)?; + let next_set = gpt_state.next().context(error::NoneSetToBootSnafu)?; self.active_partition = Some(StagedImage { image: active_image, next_to_boot: active_set == next_set, @@ -196,12 +197,12 @@ impl UpdateStatus { if let Some(staging_partition) = &mut self.staging_partition { staging_partition.set_next_to_boot(true); } else { - return error::StagingPartition {}.fail(); + return error::StagingPartitionSnafu {}.fail(); } if let Some(active_partition) = &mut self.active_partition { active_partition.set_next_to_boot(false); } else { - return error::ActivePartition {}.fail(); + return error::ActivePartitionSnafu {}.fail(); } Ok(()) } @@ -211,12 +212,12 @@ impl UpdateStatus { if let Some(staging_partition) = &mut self.staging_partition { staging_partition.set_next_to_boot(false); } else { - return error::StagingPartition {}.fail(); + return error::StagingPartitionSnafu {}.fail(); } if let Some(active_partition) = &mut self.active_partition { active_partition.set_next_to_boot(true); } else { - return error::ActivePartition {}.fail(); + return error::ActivePartitionSnafu {}.fail(); } Ok(()) } @@ -246,7 +247,7 @@ impl UpdateStatus { pub fn get_latest_update( updates: Vec, ) -> Result> { - let os_info = BottlerocketRelease::new().context(error::ReleaseVersion)?; + let os_info = BottlerocketRelease::new().context(error::ReleaseVersionSnafu)?; for update in updates { // If the current running version is greater than the max version ever published, // or moves us to a valid version <= the maximum version, update. @@ -274,7 +275,7 @@ impl UpdateStatus { let locked_version: FriendlyVersion = serde_json::from_value( settings["updates"]["version-lock"].to_owned(), ) - .context(error::GetSetting { + .context(error::GetSettingSnafu { setting: "/settings/updates/version-lock", })?; @@ -289,11 +290,12 @@ impl UpdateStatus { return Ok(true); } } else { - let chosen_version = - FriendlyVersion::try_into(locked_version.to_owned()).context(error::SemVer { + let chosen_version = FriendlyVersion::try_into(locked_version.to_owned()).context( + error::SemVerSnafu { version: locked_version, - })?; - let os_info = BottlerocketRelease::new().context(error::ReleaseVersion)?; + }, + )?; + let os_info = BottlerocketRelease::new().context(error::ReleaseVersionSnafu)?; if chosen_version != os_info.version_id { for update in &updates { if update.version == chosen_version { diff --git a/sources/bottlerocket-release/Cargo.toml b/sources/bottlerocket-release/Cargo.toml index a3d5f0fe62d..a82517e8bb4 100644 --- a/sources/bottlerocket-release/Cargo.toml +++ b/sources/bottlerocket-release/Cargo.toml @@ -13,7 +13,7 @@ envy = "0.4" log = "0.4" semver = { version = "1.0", features = ["serde"] } serde = { version = "1.0", features = ["derive"] } -snafu = "0.6" +snafu = "0.7" [build-dependencies] cargo-readme = "3.1" diff --git a/sources/bottlerocket-release/src/lib.rs b/sources/bottlerocket-release/src/lib.rs index de6bb635513..9f3316e6279 100644 --- a/sources/bottlerocket-release/src/lib.rs +++ b/sources/bottlerocket-release/src/lib.rs @@ -37,7 +37,7 @@ mod error { use std::path::PathBuf; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub enum Error { #[snafu(display("Unable to read release file '{}': {}", path.display(), source))] ReadReleaseFile { path: PathBuf, source: io::Error }, @@ -60,7 +60,8 @@ impl BottlerocketRelease { { let path = path.as_ref(); - let release_data = fs::read_to_string(path).context(error::ReadReleaseFile { path })?; + let release_data = + fs::read_to_string(path).context(error::ReadReleaseFileSnafu { path })?; // Split and process each line let mut pairs: Vec<(String, String)> = release_data @@ -95,6 +96,6 @@ impl BottlerocketRelease { // Add information from other sources pairs.push(("arch".to_string(), ARCH.to_string())); - envy::from_iter(pairs).context(error::LoadReleaseData { path }) + envy::from_iter(pairs).context(error::LoadReleaseDataSnafu { path }) } } diff --git a/sources/driverdog/Cargo.toml b/sources/driverdog/Cargo.toml index c2f9079599f..9c103283439 100644 --- a/sources/driverdog/Cargo.toml +++ b/sources/driverdog/Cargo.toml @@ -12,7 +12,7 @@ exclude = ["README.md"] argh = "0.1.3" log = "0.4" simplelog = "0.10" -snafu = "0.6" +snafu = "0.7" serde = { version = "1.0", features = ["derive"] } tempfile = "3.2.0" toml = "0.5.8" diff --git a/sources/driverdog/src/main.rs b/sources/driverdog/src/main.rs index 7874be4bb94..162a7864b24 100644 --- a/sources/driverdog/src/main.rs +++ b/sources/driverdog/src/main.rs @@ -110,7 +110,7 @@ fn link_modules_sets( if let Some(target) = target { let driver_config = modules_sets .get(&target) - .context(error::MissingModuleSet { target })?; + .context(error::MissingModuleSetSnafu { target })?; link_modules(&driver_config, &kernel_version)?; } else { // Link all the modules sets if no target module was given @@ -135,7 +135,7 @@ where .join(&kernel_version) .join(&driver_config.lib_modules_path); // Directory to store temp artifacts - let build_dir = tempfile::tempdir().context(error::TmpDir)?; + let build_dir = tempfile::tempdir().context(error::TmpDirSnafu)?; // This script is used to link the kernel module let common_module_script = Path::new(KERNEL_SOURCES) .join(&kernel_version) @@ -190,7 +190,7 @@ where let object_file_path = build_dir.join(object_file); if !object_file_path.exists() { let from = driver_path.join(object_file); - fs::copy(&from, &object_file_path).context(error::Copy { + fs::copy(&from, &object_file_path).context(error::CopySnafu { from: &from, to: &object_file_path, })?; @@ -207,7 +207,7 @@ where "-o".to_string(), kernel_module_path .to_str() - .context(error::InvalidModulePath { + .context(error::InvalidModulePathSnafu { path: &kernel_module_path, })? .to_string(), @@ -292,7 +292,7 @@ fn load_modules_sets( if let Some(target) = target { let driver_config = modules_sets .get(&target) - .context(error::MissingModuleSet { target })?; + .context(error::MissingModuleSetSnafu { target })?; load_modules(&driver_config)? } // Load all the modules sets if no target module was given @@ -334,7 +334,7 @@ where command.args(args); let output = command .output() - .context(error::ExecutionFailure { command })?; + .context(error::ExecutionFailureSnafu { command })?; let stdout = String::from_utf8_lossy(&output.stdout).to_string(); trace!("stdout: {}", stdout); @@ -342,7 +342,7 @@ where ensure!( output.status.success(), - error::CommandFailure { bin_path, output } + error::CommandFailureSnafu { bin_path, output } ); Ok(stdout) @@ -350,7 +350,7 @@ where fn setup_logger(args: &Args) -> Result<()> { let log_level = args.log_level.unwrap_or(LevelFilter::Info); - SimpleLogger::init(log_level, LogConfig::default()).context(error::Logger) + SimpleLogger::init(log_level, LogConfig::default()).context(error::LoggerSnafu) } fn run() -> Result<()> { @@ -359,14 +359,17 @@ fn run() -> Result<()> { let driver_config_path = Path::new(&args.driver_config_path); let mut all_modules_sets: HashMap = HashMap::new(); - for entry in driver_config_path.read_dir().context(error::ReadPath { - path: driver_config_path, - })? { + for entry in driver_config_path + .read_dir() + .context(error::ReadPathSnafu { + path: driver_config_path, + })? + { if let Ok(entry) = entry { let path = entry.path(); let modules_sets: HashMap = - toml::from_slice(&fs::read(&path).context(error::ReadPath { path: &path })?) - .context(error::Deserialize { path: &path })?; + toml::from_slice(&fs::read(&path).context(error::ReadPathSnafu { path: &path })?) + .context(error::DeserializeSnafu { path: &path })?; all_modules_sets.extend(modules_sets); } @@ -392,7 +395,7 @@ mod error { use std::process::{Command, Output}; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub(super) enum Error { #[snafu(display("'{}' failed - stderr: {}", bin_path, String::from_utf8_lossy(&output.stderr)))] diff --git a/sources/ghostdog/Cargo.toml b/sources/ghostdog/Cargo.toml index ba31b254f63..159533bc666 100644 --- a/sources/ghostdog/Cargo.toml +++ b/sources/ghostdog/Cargo.toml @@ -14,7 +14,7 @@ gptman = { version = "0.8.2", default-features = false } hex-literal = "0.3.0" lazy_static = "1.2" signpost = { path = "../updater/signpost", version = "0.1.0" } -snafu = "0.6" +snafu = "0.7" [build-dependencies] cargo-readme = "3.1" diff --git a/sources/ghostdog/src/main.rs b/sources/ghostdog/src/main.rs index b7f2b9d9880..7bd55c48318 100644 --- a/sources/ghostdog/src/main.rs +++ b/sources/ghostdog/src/main.rs @@ -41,7 +41,7 @@ fn run() -> Result<()> { match args.subcommand { SubCommand::Scan(scan_args) => { let path = scan_args.device; - let mut f = fs::File::open(&path).context(error::DeviceOpen { path })?; + let mut f = fs::File::open(&path).context(error::DeviceOpenSnafu { path })?; let device_type = find_device_type(&mut f)?; emit_device_type(&device_type); } @@ -107,7 +107,7 @@ fn main() { mod error { use snafu::Snafu; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub(super) enum Error { #[snafu(display("Failed to open '{}': {}", path.display(), source))] DeviceOpen { diff --git a/sources/growpart/Cargo.toml b/sources/growpart/Cargo.toml index 12cdfa4a0cf..73a7806d43c 100644 --- a/sources/growpart/Cargo.toml +++ b/sources/growpart/Cargo.toml @@ -10,7 +10,7 @@ exclude = ["README.md"] [dependencies] gptman = { version = "0.8.2", default-features = false } -snafu = "0.6" +snafu = "0.7" libc = "0.2" block-party = { path = "../updater/block-party", version = "0.1.0" } inotify = "0.9" diff --git a/sources/growpart/src/diskpart.rs b/sources/growpart/src/diskpart.rs index 5f65a69e465..420f0f741c8 100644 --- a/sources/growpart/src/diskpart.rs +++ b/sources/growpart/src/diskpart.rs @@ -34,7 +34,7 @@ impl DiskPart { let used_partitions = gpt.iter().filter(|(_num, part)| part.is_used()).count(); ensure!( used_partitions == 1, - error::MultiplePartitions { + error::MultiplePartitionsSnafu { path, count: used_partitions } @@ -61,7 +61,7 @@ impl DiskPart { // Remove all existing partitions so that the space shows up as free. gpt.remove(part) - .context(error::RemovePartition { part, path })?; + .context(error::RemovePartitionSnafu { part, path })?; // First usable LBA is just after the primary label. We want partitions aligned on 1 MB // boundaries, so the first one occurs at 2048 sectors. @@ -71,7 +71,7 @@ impl DiskPart { // us the last LBA, which we must solve for next. let max_size: u64 = gpt .get_maximum_partition_size() - .context(error::FindMaxSize { path })?; + .context(error::FindMaxSizeSnafu { path })?; // We know the first LBA, and we know the sector count, so we can calculate the last LBA. let ending_lba = starting_lba + max_size - 1; @@ -95,16 +95,16 @@ impl DiskPart { let mut f = fs::OpenOptions::new() .write(true) .open(path) - .context(error::DeviceOpen { path })?; + .context(error::DeviceOpenSnafu { path })?; self.gpt .header .update_from(&mut f, self.gpt.sector_size) - .context(error::UpdateGeometry { path })?; + .context(error::UpdateGeometrySnafu { path })?; self.gpt .write_into(&mut f) - .context(error::WritePartitionTable { path })?; + .context(error::WritePartitionTableSnafu { path })?; println!("wrote partition table to {}", path.display()); @@ -123,19 +123,21 @@ impl DiskPart { { let path = path.as_ref(); - let partition_path = fs::canonicalize(path).context(error::CanonicalizeLink { path })?; + let partition_path = + fs::canonicalize(path).context(error::CanonicalizeLinkSnafu { path })?; - let partition_device = - BlockDevice::from_device_node(&partition_path).context(error::FindBlockDevice { + let partition_device = BlockDevice::from_device_node(&partition_path).context( + error::FindBlockDeviceSnafu { path: &partition_path, - })?; + }, + )?; let disk = partition_device .disk() - .context(error::FindDisk { + .context(error::FindDiskSnafu { path: &partition_path, })? - .context(error::NotPartition { + .context(error::NotPartitionSnafu { path: &partition_path, })?; @@ -148,8 +150,8 @@ impl DiskPart { P: AsRef, { let path = path.as_ref(); - let mut f = fs::File::open(path).context(error::DeviceOpen { path })?; - let gpt = GPT::find_from(&mut f).context(error::ReadPartitionTable { path })?; + let mut f = fs::File::open(path).context(error::DeviceOpenSnafu { path })?; + let gpt = GPT::find_from(&mut f).context(error::ReadPartitionTableSnafu { path })?; Ok(gpt) } } @@ -167,18 +169,22 @@ impl WatchPart { P: AsRef, { let path = path.as_ref(); - let dirname = path.parent().context(error::FindParentDirectory { path })?; + let dirname = path + .parent() + .context(error::FindParentDirectorySnafu { path })?; - let filename = path.file_name().context(error::FindFileName { path })?; + let filename = path + .file_name() + .context(error::FindFileNameSnafu { path })?; let filename = Path::new(filename).to_path_buf(); // When the kernel reloads the partition table, we expect two events, when udev deletes and // then recreates the path. This isn't synchronized with our code, so to avoid races we need // to watch for both events. - let mut inotify = Inotify::init().context(error::InitInotify)?; + let mut inotify = Inotify::init().context(error::InitInotifySnafu)?; inotify .add_watch(&dirname, WatchMask::CREATE | WatchMask::DELETE) - .context(error::AddInotifyWatch)?; + .context(error::AddInotifyWatchSnafu)?; Ok(WatchPart { inotify, filename }) } @@ -193,7 +199,7 @@ impl WatchPart { let events = self .inotify .read_events_blocking(&mut buf) - .context(error::ReadInotifyEvents)?; + .context(error::ReadInotifyEventsSnafu)?; for event in events { if let Some(event_file) = event.name { diff --git a/sources/growpart/src/diskpart/error.rs b/sources/growpart/src/diskpart/error.rs index b8f2797264a..c46ebace870 100644 --- a/sources/growpart/src/diskpart/error.rs +++ b/sources/growpart/src/diskpart/error.rs @@ -1,7 +1,7 @@ use snafu::Snafu; #[derive(Debug, Snafu)] -#[snafu(visibility = "pub")] +#[snafu(visibility(pub))] pub enum Error { #[snafu(display("Failed to canonicalize link for '{}': {}", path.display(), source))] CanonicalizeLink { diff --git a/sources/imdsclient/Cargo.toml b/sources/imdsclient/Cargo.toml index 85e73e5a3a8..fb4392d7543 100644 --- a/sources/imdsclient/Cargo.toml +++ b/sources/imdsclient/Cargo.toml @@ -14,7 +14,7 @@ http = "0.2" log = "0.4" reqwest = { version = "0.11.1", default-features = false } serde_json = "1" -snafu = "0.6" +snafu = "0.7" tokio = { version = "~1.14", default-features = false, features = ["macros", "rt-multi-thread", "time"] } # LTS tokio-retry = "0.3" url = "2.1.1" diff --git a/sources/imdsclient/src/lib.rs b/sources/imdsclient/src/lib.rs index ed47df51fc8..3a54ae48bfc 100644 --- a/sources/imdsclient/src/lib.rs +++ b/sources/imdsclient/src/lib.rs @@ -90,7 +90,8 @@ impl ImdsClient { Some(response) => response, None => return Ok(None), }; - let identity_document: Value = serde_json::from_slice(&response).context(error::Serde)?; + let identity_document: Value = + serde_json::from_slice(&response).context(error::SerdeSnafu)?; let region = identity_document .get("region") .and_then(|value| value.as_str()) @@ -134,9 +135,9 @@ impl ImdsClient { let mac = self .fetch_mac_addresses() .await? - .context(error::MacAddresses)? + .context(error::MacAddressesSnafu)? .first() - .context(error::MacAddresses)? + .context(error::MacAddressesSnafu)? .clone(); // Get the IPv6 addresses associated with the primary network interface. @@ -188,7 +189,7 @@ impl ImdsClient { let public_key_text = self .fetch_string(&target) .await? - .context(error::KeyNotFound { target })?; + .context(error::KeyNotFoundSnafu { target })?; let public_key = public_key_text.trim_end(); // Simple check to see if the text is probably an ssh key. if public_key.starts_with("ssh") { @@ -223,7 +224,7 @@ impl ImdsClient { { match self.fetch_imds(PINNED_SCHEMA, end_target).await? { Some(response_body) => Ok(Some( - String::from_utf8(response_body).context(error::NonUtf8Response)?, + String::from_utf8(response_body).context(error::NonUtf8ResponseSnafu)?, )), None => Ok(None), } @@ -259,7 +260,7 @@ impl ImdsClient { .header("X-aws-ec2-metadata-token", session_token) .send() .await - .context(error::Request { + .context(error::RequestSnafu { method: "GET", uri: &uri, })?; @@ -271,7 +272,7 @@ impl ImdsClient { let response_body = response .bytes() .await - .context(error::ResponseBody { + .context(error::ResponseBodySnafu { method: "GET", uri: &uri, code, @@ -291,14 +292,14 @@ impl ImdsClient { StatusCode::UNAUTHORIZED => { warn!("IMDS request unauthorized"); self.clear_token()?; - error::TokenInvalid.fail() + error::TokenInvalidSnafu.fail() } code => { let response_body = response .bytes() .await - .context(error::ResponseBody { + .context(error::ResponseBodySnafu { method: "GET", uri: &uri, code, @@ -309,7 +310,7 @@ impl ImdsClient { trace!("Response: {:?}", response_str); - error::Response { + error::ResponseSnafu { method: "GET", uri: &uri, code, @@ -321,7 +322,7 @@ impl ImdsClient { }), ) .await - .context(error::TimeoutFetchIMDS)? + .context(error::TimeoutFetchIMDSSnafu)? } /// Fetches a new session token and writes it to the current ImdsClient. @@ -334,7 +335,7 @@ impl ImdsClient { .map_err(|_| error::Error::FailedWriteToken {})? = Some(written_token.clone()); Ok(written_token) } - None => error::FailedWriteToken.fail(), + None => error::FailedWriteTokenSnafu.fail(), } } @@ -415,15 +416,15 @@ async fn fetch_token( .header("X-aws-ec2-metadata-token-ttl-seconds", "60") .send() .await - .context(error::Request { + .context(error::RequestSnafu { method: "PUT", uri: &uri, })?; let code = response.status(); - ensure!(code == StatusCode::OK, error::FailedFetchToken); + ensure!(code == StatusCode::OK, error::FailedFetchTokenSnafu); - let response_body = response.text().await.context(error::ResponseBody { + let response_body = response.text().await.context(error::ResponseBodySnafu { method: "PUT", uri: &uri, code, @@ -432,7 +433,7 @@ async fn fetch_token( }), ) .await - .context(error::TimeoutFetchToken)? + .context(error::TimeoutFetchTokenSnafu)? } mod error { @@ -450,7 +451,7 @@ mod error { } #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] // snafu doesn't yet support the lifetimes used by std::sync::PoisonError. pub enum Error { diff --git a/sources/logdog/Cargo.toml b/sources/logdog/Cargo.toml index 10e6097437e..224bf6f92c8 100644 --- a/sources/logdog/Cargo.toml +++ b/sources/logdog/Cargo.toml @@ -18,7 +18,7 @@ models = { path = "../models", version = "0.1.0" } reqwest = { version = "0.11.1", default-features = false, features = ["blocking", "rustls-tls"] } serde_json = "1" shell-words = "1.0.0" -snafu = { version = "0.6", features = ["backtraces-impl-backtrace-crate"] } +snafu = { version = "0.7", features = ["backtraces-impl-backtrace-crate"] } tar = { version = "0.4", default-features = false } tempfile = { version = "3.1.0", default-features = false } tokio = { version = "~1.14", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS diff --git a/sources/logdog/src/create_tarball.rs b/sources/logdog/src/create_tarball.rs index cf767a8b1ae..c4c37005978 100644 --- a/sources/logdog/src/create_tarball.rs +++ b/sources/logdog/src/create_tarball.rs @@ -18,25 +18,25 @@ where let outfile = outfile.as_ref(); // ensure the output directory exists. - let outdir = outfile.parent().context(error::RootAsFile)?; - fs::create_dir_all(outdir).context(error::CreateOutputDirectory { path: outdir })?; + let outdir = outfile.parent().context(error::RootAsFileSnafu)?; + fs::create_dir_all(outdir).context(error::CreateOutputDirectorySnafu { path: outdir })?; // ensure the outfile will not be written to the input dir. ensure!( indir != outdir, - error::TarballOutputIsInInputDir { indir, outfile } + error::TarballOutputIsInInputDirSnafu { indir, outfile } ); // compress files and create the tarball. - let tarfile = File::create(outfile).context(error::TarballFileCreate { path: outfile })?; + let tarfile = File::create(outfile).context(error::TarballFileCreateSnafu { path: outfile })?; let encoder = GzEncoder::new(tarfile, Compression::default()); let mut tarball = tar::Builder::new(encoder); tarball .append_dir_all(crate::TARBALL_DIRNAME, indir) - .context(error::TarballWrite { path: outfile })?; + .context(error::TarballWriteSnafu { path: outfile })?; tarball .finish() - .context(error::TarballClose { path: indir }) + .context(error::TarballCloseSnafu { path: indir }) } #[cfg(test)] diff --git a/sources/logdog/src/error.rs b/sources/logdog/src/error.rs index 7a51ef974e5..f096c3b4dba 100644 --- a/sources/logdog/src/error.rs +++ b/sources/logdog/src/error.rs @@ -8,7 +8,7 @@ use reqwest::Url; use snafu::{Backtrace, Snafu}; #[derive(Debug, Snafu)] -#[snafu(visibility = "pub(crate)")] +#[snafu(visibility(pub(crate)))] pub(crate) enum Error { #[snafu(display("Error calling Bottlerocket API '{}': {}", uri, source))] ApiClient { diff --git a/sources/logdog/src/log_request.rs b/sources/logdog/src/log_request.rs index 5fd623867f3..0e0698a9c31 100644 --- a/sources/logdog/src/log_request.rs +++ b/sources/logdog/src/log_request.rs @@ -114,20 +114,22 @@ where { let request = request.as_ref(); let mut iter = request.splitn(3, ' '); - let mode = iter.next().context(error::ModeMissing)?; + let mode = iter.next().context(error::ModeMissingSnafu)?; let req = if mode == "glob" { // for glob request format is "glob " LogRequest { mode, filename: "", - instructions: iter.next().context(error::PatternMissing)?, + instructions: iter.next().context(error::PatternMissingSnafu)?, } } else { // Get the second token (output filename) and put the remainder of the // log request into the instructions field (or default to an empty string). LogRequest { mode, - filename: iter.next().context(error::FilenameMissing { request })?, + filename: iter + .next() + .context(error::FilenameMissingSnafu { request })?, instructions: iter.next().unwrap_or(""), } }; @@ -154,21 +156,22 @@ where P: AsRef, { let settings = get_settings().await?; - let mut settings_map = to_pairs(&settings).context(error::SerializeSettings)?; + let mut settings_map = to_pairs(&settings).context(error::SerializeSettingsSnafu)?; // Filter all settings that match any of the "sensitive" patterns for pattern in SENSITIVE_SETTINGS_PATTERNS { let pattern = - Pattern::new(pattern).context(error::ParseGlobPattern { pattern: *pattern })?; + Pattern::new(pattern).context(error::ParseGlobPatternSnafu { pattern: *pattern })?; settings_map.retain(|k, _| !pattern.matches(k.name().as_str())) } // Serialize the map back to a `Settings` to remove the escaping so it writes nicely to file - let settings: model::Settings = from_map(&settings_map).context(error::DeserializeSettings)?; + let settings: model::Settings = + from_map(&settings_map).context(error::DeserializeSettingsSnafu)?; let outpath = tempdir.as_ref().join(request.filename); - let outfile = File::create(&outpath).context(error::FileCreate { path: &outpath })?; + let outfile = File::create(&outpath).context(error::FileCreateSnafu { path: &outpath })?; serde_json::to_writer_pretty(&outfile, &settings) - .context(error::FileWrite { path: &outpath })?; + .context(error::FileWriteSnafu { path: &outpath })?; Ok(()) } @@ -177,9 +180,9 @@ async fn get_settings() -> Result { let uri = constants::API_SETTINGS_URI; let (_status, response_body) = apiclient::raw_request(constants::API_SOCKET, uri, "GET", None) .await - .context(error::ApiClient { uri })?; + .context(error::ApiClientSnafu { uri })?; - serde_json::from_str(&response_body).context(error::SettingsJson) + serde_json::from_str(&response_body).context(error::SettingsJsonSnafu) } /// Runs an `exec` `LogRequest`'s `instructions` and writes its output to to `tempdir`. @@ -187,27 +190,30 @@ fn handle_exec_request

(request: &LogRequest<'_>, tempdir: P) -> Result<()> where P: AsRef, { - let split = shell_words::split(request.instructions).with_context(|| error::CommandParse { - command: request.to_string(), - })?; - let (command, args) = split.split_first().with_context(|| error::CommandMissing { - request: request.to_string(), - })?; + let split = + shell_words::split(request.instructions).with_context(|_| error::CommandParseSnafu { + command: request.to_string(), + })?; + let (command, args) = split + .split_first() + .with_context(|| error::CommandMissingSnafu { + request: request.to_string(), + })?; let outpath = tempdir.as_ref().join(request.filename); - let ofile = File::create(&outpath).context(error::CommandOutputFile { path: &outpath })?; + let ofile = File::create(&outpath).context(error::CommandOutputFileSnafu { path: &outpath })?; let stderr_file = ofile .try_clone() - .context(error::CommandErrFile { path: &outpath })?; + .context(error::CommandErrFileSnafu { path: &outpath })?; Command::new(command) .args(args) .stdout(Stdio::from(ofile)) .stderr(Stdio::from(stderr_file)) .spawn() - .with_context(|| error::CommandSpawn { + .with_context(|_| error::CommandSpawnSnafu { command: request.to_string(), })? .wait_with_output() - .with_context(|| error::CommandFinish { + .with_context(|_| error::CommandFinishSnafu { command: request.to_string(), })?; Ok(()) @@ -220,16 +226,18 @@ where { ensure!( !request.instructions.is_empty(), - error::HttpMissingUrl { + error::HttpMissingUrlSnafu { request: request.to_string(), } ); let outpath = tempdir.as_ref().join(request.filename); let response = send_get_request(request.instructions)?; - let data = response.bytes().with_context(|| error::HttpResponseBytes { - request: request.to_string(), - })?; - fs::write(&outpath, &data).with_context(|| error::HttpWriteBytes { + let data = response + .bytes() + .with_context(|_| error::HttpResponseBytesSnafu { + request: request.to_string(), + })?; + fs::write(&outpath, &data).with_context(|_| error::HttpWriteBytesSnafu { request: request.to_string(), path: &outpath, })?; @@ -238,17 +246,17 @@ where /// Uses the reqwest library to send a GET request to `URL` and returns the response. fn send_get_request(url: &str) -> Result { - let url = Url::parse(&url).context(error::HttpUrlParse { url })?; + let url = Url::parse(&url).context(error::HttpUrlParseSnafu { url })?; let client = Client::builder() .build() - .with_context(|| error::HttpClient { url: url.clone() })?; + .with_context(|_| error::HttpClientSnafu { url: url.clone() })?; let response = client .get(url.clone()) .send() - .with_context(|| error::HttpSend { url: url.clone() })?; + .with_context(|_| error::HttpSendSnafu { url: url.clone() })?; let response = response .error_for_status() - .context(error::HttpResponse { url })?; + .context(error::HttpResponseSnafu { url })?; Ok(response) } @@ -260,12 +268,12 @@ where { ensure!( !request.instructions.is_empty(), - error::FileFromEmpty { + error::FileFromEmptySnafu { request: request.to_string() } ); let dest = tempdir.as_ref().join(request.filename); - let _ = fs::copy(&request.instructions, &dest).with_context(|| error::FileCopy { + let _ = fs::copy(&request.instructions, &dest).with_context(|_| error::FileCopySnafu { request: request.to_string(), from: request.instructions, to: &dest, @@ -280,7 +288,7 @@ where P: AsRef, { let mut files = HashSet::new(); - let glob_paths = glob(request.instructions).context(error::ParseGlobPattern { + let glob_paths = glob(request.instructions).context(error::ParseGlobPatternSnafu { pattern: request.instructions, })?; for entry in glob_paths { @@ -307,12 +315,12 @@ where .strip_prefix("/") .unwrap_or(src_filepath.as_path()); let dest_filepath = tempdir.as_ref().join(relative_path); - let dest_dir_path = dest_filepath.parent().context(error::RootAsFile)?; + let dest_dir_path = dest_filepath.parent().context(error::RootAsFileSnafu)?; // create directories in dest file path if it does not exist - fs::create_dir_all(dest_dir_path).context(error::CreateOutputDirectory { + fs::create_dir_all(dest_dir_path).context(error::CreateOutputDirectorySnafu { path: dest_dir_path, })?; - let _ = fs::copy(&src_filepath, &dest_filepath).with_context(|| error::FileCopy { + let _ = fs::copy(&src_filepath, &dest_filepath).with_context(|_| error::FileCopySnafu { request: request.to_string(), from: src_filepath.to_str().unwrap_or(""), to: &dest_filepath, diff --git a/sources/logdog/src/main.rs b/sources/logdog/src/main.rs index d537a042fe6..d6a43d874fa 100644 --- a/sources/logdog/src/main.rs +++ b/sources/logdog/src/main.rs @@ -90,7 +90,7 @@ pub(crate) async fn collect_logs>(log_requests: &[&str], outdir: // if a command fails, we will pipe its error here and continue. let outdir = outdir.as_ref(); let error_path = outdir.join(crate::ERROR_FILENAME); - let mut error_file = File::create(&error_path).context(error::ErrorFile { + let mut error_file = File::create(&error_path).context(error::ErrorFileSnafu { path: error_path.clone(), })?; @@ -104,7 +104,7 @@ pub(crate) async fn collect_logs>(log_requests: &[&str], outdir: "Error running command '{}': '{}'\n", log_request, e ) - .context(error::ErrorWrite { + .context(error::ErrorWriteSnafu { path: error_path.clone(), })?; } @@ -114,7 +114,7 @@ pub(crate) async fn collect_logs>(log_requests: &[&str], outdir: /// Runs the bulk of the program's logic, main wraps this. async fn run(outfile: &Path, commands: &[&str]) -> Result<()> { - let temp_dir = TempDir::new().context(error::TempDirCreate)?; + let temp_dir = TempDir::new().context(error::TempDirCreateSnafu)?; collect_logs(&commands, &temp_dir.path().to_path_buf()).await?; create_tarball(&temp_dir.path().to_path_buf(), &outfile)?; println!("logs are at: {}", outfile.display()); diff --git a/sources/metricdog/Cargo.toml b/sources/metricdog/Cargo.toml index 5431eb5f5e4..4e651a135f8 100644 --- a/sources/metricdog/Cargo.toml +++ b/sources/metricdog/Cargo.toml @@ -14,7 +14,7 @@ log = "0.4" reqwest = { version = "0.11.1", default-features = false, features = ["blocking", "rustls-tls"] } serde = { version = "1.0.100", features = ["derive"] } simplelog = "0.10" -snafu = { version = "0.6" } +snafu = { version = "0.7" } structopt = "0.3.17" toml = "0.5.1" url = "2.1.1" diff --git a/sources/metricdog/src/config.rs b/sources/metricdog/src/config.rs index f5f45cb66bc..230cf14e73d 100644 --- a/sources/metricdog/src/config.rs +++ b/sources/metricdog/src/config.rs @@ -24,8 +24,8 @@ impl Config { pub(crate) fn from_file>(path: P) -> Result { let path = path.as_ref(); - let s = fs::read_to_string(path).context(error::ConfigRead { path })?; - let config: Config = toml::from_str(&s).context(error::ConfigParse { path })?; + let s = fs::read_to_string(path).context(error::ConfigReadSnafu { path })?; + let config: Config = toml::from_str(&s).context(error::ConfigParseSnafu { path })?; Ok(config) } } diff --git a/sources/metricdog/src/error.rs b/sources/metricdog/src/error.rs index c5cd3ebd697..fc12ed7b828 100644 --- a/sources/metricdog/src/error.rs +++ b/sources/metricdog/src/error.rs @@ -5,7 +5,7 @@ use std::path::PathBuf; use url::Url; #[derive(Debug, Snafu)] -#[snafu(visibility = "pub(crate)")] +#[snafu(visibility(pub(crate)))] pub(crate) enum Error { #[snafu(display("Unable to load Bottlerocket release info: '{}'", source))] BottlerocketRelease { source: bottlerocket_release::Error }, diff --git a/sources/metricdog/src/main.rs b/sources/metricdog/src/main.rs index 57ac6980cdb..9db8956837b 100644 --- a/sources/metricdog/src/main.rs +++ b/sources/metricdog/src/main.rs @@ -112,7 +112,7 @@ pub(crate) fn main_inner(arguments: Arguments, service_check: Box, ) -> Result { - let metrics_url = Url::from_str(&config.metrics_url).context(error::UrlParse { + let metrics_url = Url::from_str(&config.metrics_url).context(error::UrlParseSnafu { url: &config.metrics_url, })?; Ok(Self { @@ -145,14 +145,14 @@ impl Metricdog { timeout_sec.unwrap_or(DEFAULT_TIMEOUT_SECONDS), )) .build() - .context(error::HttpClient { url: url.clone() })?; + .context(error::HttpClientSnafu { url: url.clone() })?; let response = client .get(url.clone()) .send() - .context(error::HttpSend { url: url.clone() })?; + .context(error::HttpSendSnafu { url: url.clone() })?; response .error_for_status() - .context(error::HttpResponse { url })?; + .context(error::HttpResponseSnafu { url })?; Ok(()) } } diff --git a/sources/metricdog/src/service_check.rs b/sources/metricdog/src/service_check.rs index 5513be6d37e..c95280bcb0a 100644 --- a/sources/metricdog/src/service_check.rs +++ b/sources/metricdog/src/service_check.rs @@ -49,7 +49,7 @@ fn systemctl(args: &[&str]) -> Result { let output = Command::new("systemctl") .args(args) .output() - .with_context(|| error::Command { + .with_context(|_| error::CommandSnafu { command: "systemctl", args: args.iter().map(|&s| s.to_owned()).collect::>(), })?; diff --git a/sources/models/Cargo.toml b/sources/models/Cargo.toml index 30c61b17454..3f7c36937e2 100644 --- a/sources/models/Cargo.toml +++ b/sources/models/Cargo.toml @@ -19,7 +19,7 @@ regex = "1.1" semver = "1.0" serde = { version = "1.0", features = ["derive"] } serde_plain = "1.0" -snafu = "0.6" +snafu = "0.7" toml = "0.5" x509-parser = "0.11.0" url = "2.1" diff --git a/sources/models/src/modeled_types/ecs.rs b/sources/models/src/modeled_types/ecs.rs index 3d457e6c42f..c09df7b900a 100644 --- a/sources/models/src/modeled_types/ecs.rs +++ b/sources/models/src/modeled_types/ecs.rs @@ -36,7 +36,7 @@ impl TryFrom<&str> for ECSAttributeKey { fn try_from(input: &str) -> Result { ensure!( ECS_ATTRIBUTE_KEY.is_match(input), - error::BigPattern { + error::BigPatternSnafu { thing: "ECS attribute key", input } @@ -121,7 +121,7 @@ impl TryFrom<&str> for ECSAttributeValue { fn try_from(input: &str) -> Result { ensure!( ECS_ATTRIBUTE_VALUE.is_match(input), - error::BigPattern { + error::BigPatternSnafu { thing: "ECS attribute value", input } @@ -200,7 +200,7 @@ impl TryFrom<&str> for ECSAgentLogLevel { type Error = error::Error; fn try_from(input: &str) -> Result { - serde_plain::from_str::(&input).context(error::InvalidPlainValue { + serde_plain::from_str::(&input).context(error::InvalidPlainValueSnafu { field: "ecs.loglevel", })?; Ok(ECSAgentLogLevel { diff --git a/sources/models/src/modeled_types/kubernetes.rs b/sources/models/src/modeled_types/kubernetes.rs index cd5d9e5a78d..9446cc6b649 100644 --- a/sources/models/src/modeled_types/kubernetes.rs +++ b/sources/models/src/modeled_types/kubernetes.rs @@ -28,7 +28,7 @@ impl TryFrom<&str> for KubernetesName { fn try_from(input: &str) -> Result { ensure!( KUBERNETES_NAME.is_match(input), - error::Pattern { + error::PatternSnafu { thing: "Kubernetes name", pattern: KUBERNETES_NAME.clone(), input @@ -94,7 +94,7 @@ impl TryFrom<&str> for KubernetesLabelKey { fn try_from(input: &str) -> Result { ensure!( KUBERNETES_LABEL_KEY.is_match(input), - error::BigPattern { + error::BigPatternSnafu { thing: "Kubernetes label key", input } @@ -170,7 +170,7 @@ impl TryFrom<&str> for KubernetesLabelValue { fn try_from(input: &str) -> Result { ensure!( KUBERNETES_LABEL_VALUE.is_match(input), - error::BigPattern { + error::BigPatternSnafu { thing: "Kubernetes label value", input } @@ -243,7 +243,7 @@ impl TryFrom<&str> for KubernetesTaintValue { fn try_from(input: &str) -> Result { ensure!( KUBERNETES_TAINT_VALUE.is_match(input), - error::BigPattern { + error::BigPatternSnafu { thing: "Kubernetes taint value", input } @@ -310,14 +310,14 @@ impl TryFrom<&str> for KubernetesClusterName { fn try_from(input: &str) -> Result { ensure!( !input.is_empty(), - error::InvalidClusterName { + error::InvalidClusterNameSnafu { name: input, msg: "must not be empty" } ); ensure!( KubernetesLabelValue::try_from(input).is_ok(), - error::InvalidClusterName { + error::InvalidClusterNameSnafu { name: input, msg: "cluster names must be valid Kubernetes label values" } @@ -366,7 +366,7 @@ impl TryFrom<&str> for KubernetesAuthenticationMode { fn try_from(input: &str) -> Result { ensure!( matches!(input, "aws" | "tls"), - error::InvalidAuthenticationMode { input } + error::InvalidAuthenticationModeSnafu { input } ); Ok(KubernetesAuthenticationMode { inner: input.to_string(), @@ -417,7 +417,7 @@ impl TryFrom<&str> for KubernetesBootstrapToken { fn try_from(input: &str) -> Result { ensure!( KUBERNETES_BOOTSTRAP_TOKEN.is_match(input), - error::Pattern { + error::PatternSnafu { thing: "Kubernetes bootstrap token", pattern: KUBERNETES_BOOTSTRAP_TOKEN.clone(), input @@ -482,7 +482,7 @@ impl TryFrom<&str> for KubernetesEvictionHardKey { type Error = error::Error; fn try_from(input: &str) -> Result { - serde_plain::from_str::(&input).context(error::InvalidPlainValue { + serde_plain::from_str::(&input).context(error::InvalidPlainValueSnafu { field: "Eviction Hard key", })?; Ok(KubernetesEvictionHardKey { @@ -551,15 +551,15 @@ impl TryFrom<&str> for KubernetesThresholdValue { if input.ends_with("%") { let input_f32 = input[..input.len() - 1] .parse::() - .context(error::InvalidPercentage { input })?; + .context(error::InvalidPercentageSnafu { input })?; ensure!( (0.0..100.0).contains(&input_f32), - error::InvalidThresholdPercentage { input } + error::InvalidThresholdPercentageSnafu { input } ) } else { ensure!( KUBERNETES_QUANTITY.is_match(input), - error::Pattern { + error::PatternSnafu { thing: "Kubernetes quantity", pattern: KUBERNETES_QUANTITY.clone(), input @@ -629,9 +629,11 @@ impl TryFrom<&str> for KubernetesReservedResourceKey { type Error = error::Error; fn try_from(input: &str) -> Result { - serde_plain::from_str::(&input).context(error::InvalidPlainValue { - field: "Reserved sources key", - })?; + serde_plain::from_str::(&input).context( + error::InvalidPlainValueSnafu { + field: "Reserved sources key", + }, + )?; Ok(KubernetesReservedResourceKey { inner: input.to_string(), }) @@ -678,7 +680,7 @@ impl TryFrom<&str> for KubernetesQuantityValue { fn try_from(input: &str) -> Result { ensure!( KUBERNETES_QUANTITY.is_match(input), - error::Pattern { + error::PatternSnafu { thing: "Kubernetes quantity", pattern: KUBERNETES_QUANTITY.clone(), input @@ -739,7 +741,7 @@ impl TryFrom<&str> for KubernetesCloudProvider { fn try_from(input: &str) -> Result { ensure!( matches!(input, "aws" | "external"), - error::InvalidAuthenticationMode { input } + error::InvalidAuthenticationModeSnafu { input } ); Ok(KubernetesCloudProvider { inner: input.to_string(), @@ -790,7 +792,7 @@ impl TryFrom<&str> for CpuManagerPolicy { fn try_from(input: &str) -> Result { serde_plain::from_str::(&input) - .context(error::InvalidCpuManagerPolicy { input })?; + .context(error::InvalidCpuManagerPolicySnafu { input })?; Ok(CpuManagerPolicy { inner: input.to_string(), }) @@ -839,11 +841,11 @@ impl TryFrom<&str> for KubernetesDurationValue { fn try_from(input: &str) -> Result { ensure!( !input.is_empty(), - error::InvalidKubernetesDurationValue { input } + error::InvalidKubernetesDurationValueSnafu { input } ); ensure!( KUBERNETES_DURATION_VALUE.is_match(input), - error::InvalidKubernetesDurationValue { input } + error::InvalidKubernetesDurationValueSnafu { input } ); Ok(KubernetesDurationValue { inner: input.to_string(), @@ -912,7 +914,7 @@ impl TryFrom<&str> for TopologyManagerScope { fn try_from(input: &str) -> Result { serde_plain::from_str::(&input) - .context(error::InvalidTopologyManagerScope { input })?; + .context(error::InvalidTopologyManagerScopeSnafu { input })?; Ok(TopologyManagerScope { inner: input.to_string(), }) @@ -965,7 +967,7 @@ impl TryFrom<&str> for TopologyManagerPolicy { fn try_from(input: &str) -> Result { serde_plain::from_str::(&input) - .context(error::InvalidTopologyManagerPolicy { input })?; + .context(error::InvalidTopologyManagerPolicySnafu { input })?; Ok(TopologyManagerPolicy { inner: input.to_string(), }) diff --git a/sources/models/src/modeled_types/mod.rs b/sources/models/src/modeled_types/mod.rs index a5b536bbdbf..ce88a284389 100644 --- a/sources/models/src/modeled_types/mod.rs +++ b/sources/models/src/modeled_types/mod.rs @@ -15,7 +15,7 @@ pub mod error { type PEMToX509ParseError = x509_parser::nom::Err; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub enum Error { #[snafu(display("Can't create SingleLineString containing line terminator"))] StringContainsLineTerminator, diff --git a/sources/models/src/modeled_types/shared.rs b/sources/models/src/modeled_types/shared.rs index 3e1e7cfdc70..6993526acca 100644 --- a/sources/models/src/modeled_types/shared.rs +++ b/sources/models/src/modeled_types/shared.rs @@ -29,7 +29,7 @@ impl TryFrom<&str> for ValidBase64 { type Error = error::Error; fn try_from(input: &str) -> Result { - base64::decode(&input).context(error::InvalidBase64)?; + base64::decode(&input).context(error::InvalidBase64Snafu)?; Ok(ValidBase64 { inner: input.to_string(), }) @@ -87,7 +87,7 @@ impl TryFrom<&str> for SingleLineString { ensure!( !input.contains(&line_terminators[..]), - error::StringContainsLineTerminator + error::StringContainsLineTerminatorSnafu ); Ok(Self { @@ -151,7 +151,7 @@ impl TryFrom<&str> for ValidLinuxHostname { fn try_from(input: &str) -> Result { ensure!( VALID_LINUX_HOSTNAME.is_match(input), - error::InvalidLinuxHostname { + error::InvalidLinuxHostnameSnafu { input, msg: "must only be [0-9a-z.-], and 1-253 chars long" } @@ -162,7 +162,7 @@ impl TryFrom<&str> for ValidLinuxHostname { // allowed (must be at least one character). ensure!( !input.starts_with("-") && !input.starts_with("."), - error::InvalidLinuxHostname { + error::InvalidLinuxHostnameSnafu { input, msg: "must not start with '-' or '.'" } @@ -173,7 +173,7 @@ impl TryFrom<&str> for ValidLinuxHostname { input .split(".") .all(|x| x.len() >= 1 && x.len() <= 63 && !x.starts_with("-")), - error::InvalidLinuxHostname { + error::InvalidLinuxHostnameSnafu { input, msg: "segment is less than 1 or greater than 63 chars" } @@ -250,7 +250,7 @@ impl TryFrom<&str> for Identifier { .chars() .all(|c| (c.is_ascii() && c.is_alphanumeric()) || c == '-') && input.len() <= CONTAINERD_ID_LENGTH; - ensure!(valid_identifier, error::InvalidIdentifier { input }); + ensure!(valid_identifier, error::InvalidIdentifierSnafu { input }); Ok(Identifier { inner: input.to_string(), }) @@ -317,7 +317,7 @@ impl TryFrom<&str> for Url { }); } } - error::InvalidUrl { input }.fail() + error::InvalidUrlSnafu { input }.fail() } } @@ -390,7 +390,7 @@ impl TryFrom<&str> for FriendlyVersion { inner: input.to_string(), }); } - error::InvalidVersion { input }.fail() + error::InvalidVersionSnafu { input }.fail() } } @@ -481,21 +481,21 @@ impl TryFrom<&str> for DNSDomain { fn try_from(input: &str) -> Result { ensure!( !input.starts_with('.'), - error::InvalidDomainName { + error::InvalidDomainNameSnafu { input: input, msg: "must not start with '.'", } ); let host = Host::parse(input).or_else(|e| { - error::InvalidDomainName { + error::InvalidDomainNameSnafu { input: input, msg: e.to_string(), } .fail() })?; match host { - Host::Ipv4(_) | Host::Ipv6(_) => error::InvalidDomainName { + Host::Ipv4(_) | Host::Ipv6(_) => error::InvalidDomainNameSnafu { input: input, msg: "IP address is not a valid domain name", } @@ -557,21 +557,21 @@ impl TryFrom<&str> for SysctlKey { // Basic directory traversal checks; corndog also checks ensure!( !input.contains(".."), - error::InvalidSysctlKey { + error::InvalidSysctlKeySnafu { input, msg: format!("must not contain '..'"), } ); ensure!( !input.starts_with('.') && !input.starts_with('/'), - error::InvalidSysctlKey { + error::InvalidSysctlKeySnafu { input, msg: format!("must not start with '.' or '/'"), } ); ensure!( SYSCTL_KEY.is_match(input), - error::InvalidSysctlKey { + error::InvalidSysctlKeySnafu { input, msg: format!("must match pattern {}", *SYSCTL_KEY), } @@ -660,7 +660,7 @@ impl TryFrom<&str> for Lockdown { fn try_from(input: &str) -> Result { ensure!( matches!(input, "none" | "integrity" | "confidentiality"), - error::InvalidLockdown { input } + error::InvalidLockdownSnafu { input } ); Ok(Lockdown { inner: input.to_string(), @@ -683,7 +683,7 @@ impl TryFrom<&str> for BootstrapContainerMode { fn try_from(input: &str) -> Result { ensure!( matches!(input, "off" | "once" | "always"), - error::InvalidBootstrapContainerMode { input } + error::InvalidBootstrapContainerModeSnafu { input } ); Ok(BootstrapContainerMode { inner: input.to_string(), @@ -735,20 +735,21 @@ impl TryFrom<&str> for PemCertificateString { inner: input.to_string(), }); } - let decoded_bytes = base64::decode(input).context(error::InvalidBase64)?; + let decoded_bytes = base64::decode(input).context(error::InvalidBase64Snafu)?; // Flag to check if the bundle doesn't contain any valid certificate let mut certs_found = false; // Validate each certificate in the bundle for (_, pem) in x509_parser::pem::Pem::iter_from_buffer(&decoded_bytes).enumerate() { // Parse buffer into a PEM object, then to a x509 certificate - let pem = pem.context(error::InvalidPEM)?; - pem.parse_x509().context(error::InvalidX509Certificate)?; + let pem = pem.context(error::InvalidPEMSnafu)?; + pem.parse_x509() + .context(error::InvalidX509CertificateSnafu)?; certs_found = true; } // No valid certificate found if !certs_found { - return error::NoCertificatesFound {}.fail(); + return error::NoCertificatesFoundSnafu {}.fail(); } Ok(PemCertificateString { diff --git a/sources/parse-datetime/Cargo.toml b/sources/parse-datetime/Cargo.toml index 1780e36521d..15901589292 100644 --- a/sources/parse-datetime/Cargo.toml +++ b/sources/parse-datetime/Cargo.toml @@ -10,7 +10,7 @@ exclude = ["README.md"] [dependencies] chrono = "0.4.11" -snafu = { version = "0.6.3", features = ["backtraces-impl-backtrace-crate"] } +snafu = { version = "0.7", features = ["backtraces-impl-backtrace-crate"] } [build-dependencies] cargo-readme = "3.1" diff --git a/sources/parse-datetime/src/lib.rs b/sources/parse-datetime/src/lib.rs index 63986129567..4449f6a742e 100644 --- a/sources/parse-datetime/src/lib.rs +++ b/sources/parse-datetime/src/lib.rs @@ -27,7 +27,7 @@ mod error { use snafu::Snafu; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub enum Error { #[snafu(display("Date argument '{}' is invalid: {}", input, msg))] DateArgInvalid { input: String, msg: &'static str }, @@ -70,7 +70,7 @@ pub fn parse_offset(input: &str) -> Result { let mut parts: Vec<&str> = input.split_whitespace().collect(); ensure!( parts.len() == 3 || parts.len() == 2, - error::DateArgInvalid { + error::DateArgInvalidSnafu { input, msg: "expected RFC 3339, or something like 'in 7 days' or '7 days'" } @@ -82,21 +82,23 @@ pub fn parse_offset(input: &str) -> Result { if let Some(prefix_str) = parts.pop() { ensure!( prefix_str == "in", - error::DateArgInvalid { + error::DateArgInvalidSnafu { input, msg: "expected prefix 'in', something like 'in 7 days'", } ); } - let count: u32 = count_str.parse().context(error::DateArgCount { input })?; + let count: u32 = count_str + .parse() + .context(error::DateArgCountSnafu { input })?; let duration = match unit_str { "hour" | "hours" => Duration::hours(i64::from(count)), "day" | "days" => Duration::days(i64::from(count)), "week" | "weeks" => Duration::weeks(i64::from(count)), _ => { - return error::DateArgInvalid { + return error::DateArgInvalidSnafu { input, msg: "date argument's unit must be hours/days/weeks", } diff --git a/sources/prairiedog/Cargo.toml b/sources/prairiedog/Cargo.toml index 055af12460b..161c386dc01 100644 --- a/sources/prairiedog/Cargo.toml +++ b/sources/prairiedog/Cargo.toml @@ -14,7 +14,7 @@ log = "0.4" nix = "0.23" signpost = { path = "../updater/signpost", version = "0.1.0" } simplelog = "0.10" -snafu = "0.6" +snafu = "0.7" [build-dependencies] cargo-readme = "3.1" diff --git a/sources/prairiedog/src/main.rs b/sources/prairiedog/src/main.rs index 157dbba6e57..e0d6888376f 100644 --- a/sources/prairiedog/src/main.rs +++ b/sources/prairiedog/src/main.rs @@ -90,14 +90,14 @@ where command.args(args); let output = command .output() - .context(error::ExecutionFailure { command })?; + .context(error::ExecutionFailureSnafu { command })?; trace!("stdout: {}", String::from_utf8_lossy(&output.stdout)); trace!("stderr: {}", String::from_utf8_lossy(&output.stderr)); ensure!( output.status.success(), - error::CommandFailure { bin_path, output } + error::CommandFailureSnafu { bin_path, output } ); Ok(()) @@ -111,14 +111,14 @@ fn capture_dump() -> Result<()> { // Delete previous dumps, if they exist if Path::new(&kdump_file_path).exists() { info!("Deleting existing memory dump"); - fs::remove_file(&kdump_file_path).context(error::RemoveFile { + fs::remove_file(&kdump_file_path).context(error::RemoveFileSnafu { path: &kdump_file_path, })?; } if Path::new(&dmesg_file_path).exists() { info!("Deleting existing dmesg dump"); - fs::remove_file(&dmesg_file_path).context(error::RemoveFile { + fs::remove_file(&dmesg_file_path).context(error::RemoveFileSnafu { path: &dmesg_file_path, })?; } @@ -158,7 +158,7 @@ fn capture_dump() -> Result<()> { // Mounts the active boot partition fn prepare_boot() -> Result<()> { // Get the current partitions state - let state = signpost::State::load().context(error::LoadState)?; + let state = signpost::State::load().context(error::LoadStateSnafu)?; let boot_partition_path = &state.active_set().boot; let flags = nix::mount::MsFlags::MS_RELATIME | nix::mount::MsFlags::MS_NOSUID @@ -178,7 +178,7 @@ fn prepare_boot() -> Result<()> { flags, NONE, ) - .context(error::Mount { + .context(error::MountSnafu { path: BOOT_MOUNT_PATH, })?; @@ -192,7 +192,7 @@ fn prepare_boot() -> Result<()> { nix::mount::MsFlags::MS_PRIVATE, NONE, ) - .context(error::SetupMount { + .context(error::SetupMountSnafu { path: BOOT_MOUNT_PATH, })?; @@ -202,7 +202,7 @@ fn prepare_boot() -> Result<()> { /// Loads the crash kernel using kexec-tools fn load_crash_kernel() -> Result<()> { let kexec_crash_size_path = Path::new(KEXEC_CRASH_SIZE); - let kexec_crash_size = fs::read(kexec_crash_size_path).context(error::ReadFile { + let kexec_crash_size = fs::read(kexec_crash_size_path).context(error::ReadFileSnafu { path: kexec_crash_size_path, })?; let memory_allocated = String::from_utf8_lossy(&kexec_crash_size); @@ -217,14 +217,14 @@ fn load_crash_kernel() -> Result<()> { let kexec_load_disabled_path = Path::new(KEXEC_LOAD_DISABLED); let kexec_load_disabled_value = - fs::read(kexec_load_disabled_path).context(error::ReadFile { + fs::read(kexec_load_disabled_path).context(error::ReadFileSnafu { path: kexec_load_disabled_path, })?; let kexec_load_disabled = String::from_utf8_lossy(&kexec_load_disabled_value).trim() == "1"; // We provide a more useful message when `kexec_load_disabled` is set to 1 if kexec_load_disabled { - return error::KexecLoadDisabled.fail(); + return error::KexecLoadDisabledSnafu.fail(); } // Conditionally add `irqpoll` depending on the architecture @@ -259,14 +259,15 @@ fn setup_logger(args: &Args) -> Result<()> { // Write the logs to a file while capturing dumps, since the journal isn't available Subcommand::CaptureDump(_) => { let log_file_path = Path::new(KDUMP_LOGS_PATH).join(LOG_FILE); - let log_file = File::create(&log_file_path).context(error::WriteFile { + let log_file = File::create(&log_file_path).context(error::WriteFileSnafu { path: log_file_path, })?; - WriteLogger::init(log_level, LogConfig::default(), log_file).context(error::Logger)?; + WriteLogger::init(log_level, LogConfig::default(), log_file) + .context(error::LoggerSnafu)?; } // SimpleLogger will send errors to stderr and anything less to stdout. - _ => SimpleLogger::init(log_level, LogConfig::default()).context(error::Logger)?, + _ => SimpleLogger::init(log_level, LogConfig::default()).context(error::LoggerSnafu)?, } Ok(()) @@ -299,7 +300,7 @@ mod error { use std::process::{Command, Output}; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub(super) enum Error { #[snafu(display("'{}' failed - stderr: {}", bin_path, String::from_utf8_lossy(&output.stderr)))] diff --git a/sources/shimpei/Cargo.toml b/sources/shimpei/Cargo.toml index 93f450ea011..cddc9b8dfc3 100644 --- a/sources/shimpei/Cargo.toml +++ b/sources/shimpei/Cargo.toml @@ -11,7 +11,7 @@ exclude = ["README.md"] [dependencies] log = "0.4" simplelog = "0.10" -snafu = "0.6" +snafu = "0.7" nix = "0.23" [build-dependencies] diff --git a/sources/shimpei/src/main.rs b/sources/shimpei/src/main.rs index 88a18744c5b..2b28ca3517a 100644 --- a/sources/shimpei/src/main.rs +++ b/sources/shimpei/src/main.rs @@ -29,24 +29,26 @@ const OCI_ADD_HOOKS: &str = "/usr/bin/oci-add-hooks"; fn run() -> Result<()> { setup_logger()?; let mut args = env::args(); - let prefix = args.next().context(error::MissingArg { what: "name" })?; + let prefix = args + .next() + .context(error::MissingArgSnafu { what: "name" })?; let hook_path = Path::new(HOOKS_CONFIG_BASE_PATH).join(format!("{}-hooks.json", prefix)); let mut oci_add_hooks_args: Vec = vec![ CString::new("oci-add-hooks").expect("Couldn't create CString from 'oci-add-hooks'"), CString::new("--hook-config-path") .expect("Couldn't create CString from '--hook-config-path'"), - CString::new(hook_path.display().to_string()).context(error::InvalidString { + CString::new(hook_path.display().to_string()).context(error::InvalidStringSnafu { input: hook_path.display().to_string(), })?, CString::new("--runtime-path").expect("Couldn't create CString from '--runtime-path'"), - CString::new(RUNC_BIN_PATH).context(error::InvalidString { + CString::new(RUNC_BIN_PATH).context(error::InvalidStringSnafu { input: RUNC_BIN_PATH.to_string(), })?, ]; for arg in args { oci_add_hooks_args - .push(CString::new(arg.as_bytes()).context(error::InvalidString { input: arg })?); + .push(CString::new(arg.as_bytes()).context(error::InvalidStringSnafu { input: arg })?); } // Use the `execv` syscall instead of `std::process::Command`, since @@ -54,12 +56,12 @@ fn run() -> Result<()> { // replacing the current process nix::unistd::execv( - &CString::new(OCI_ADD_HOOKS).context(error::InvalidString { + &CString::new(OCI_ADD_HOOKS).context(error::InvalidStringSnafu { input: OCI_ADD_HOOKS.to_string(), })?, &oci_add_hooks_args, ) - .context(error::Execv { + .context(error::ExecvSnafu { program: OCI_ADD_HOOKS.to_string(), })?; @@ -67,7 +69,7 @@ fn run() -> Result<()> { } fn setup_logger() -> Result<()> { - SimpleLogger::init(LevelFilter::Info, LogConfig::default()).context(error::Logger) + SimpleLogger::init(LevelFilter::Info, LogConfig::default()).context(error::LoggerSnafu) } fn main() { @@ -82,7 +84,7 @@ mod error { use snafu::Snafu; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub(super) enum Error { #[snafu(display("Failed to setup logger: {}", source))] Logger { source: log::SetLoggerError }, diff --git a/sources/updater/block-party/Cargo.toml b/sources/updater/block-party/Cargo.toml index e0993bc5f23..4f21c177510 100644 --- a/sources/updater/block-party/Cargo.toml +++ b/sources/updater/block-party/Cargo.toml @@ -9,4 +9,4 @@ publish = false exclude = ["README.md"] [dependencies] -snafu = "0.6.0" +snafu = "0.7" diff --git a/sources/updater/block-party/src/lib.rs b/sources/updater/block-party/src/lib.rs index 228f0f20520..0e752b088a1 100644 --- a/sources/updater/block-party/src/lib.rs +++ b/sources/updater/block-party/src/lib.rs @@ -24,7 +24,7 @@ mod error { use std::path::PathBuf; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] /// The error type for this library. pub enum Error { #[snafu(display("Target of {} ends in `..`", path.display()))] @@ -121,10 +121,10 @@ impl BlockDevice { /// Creates a `BlockDevice` for a major/minor number. pub fn from_major_minor(major: u64, minor: u64) -> Result { let path = sys_path(major, minor); - let link_target = fs::read_link(&path).context(error::SysPathLinkRead { path })?; + let link_target = fs::read_link(&path).context(error::SysPathLinkReadSnafu { path })?; let device_name = link_target .file_name() - .context(error::LinkTargetFileName { path: &link_target })? + .context(error::LinkTargetFileNameSnafu { path: &link_target })? .to_owned(); Ok(Self { @@ -137,7 +137,7 @@ impl BlockDevice { /// Creates a `BlockDevice` from a path residing on a block device. pub fn from_device_path>(path: P) -> Result { let path = path.as_ref(); - let metadata = fs::metadata(path).context(error::PathMetadata { path })?; + let metadata = fs::metadata(path).context(error::PathMetadataSnafu { path })?; let major = metadata.st_dev() >> 8; let minor = metadata.st_dev() & 0xff; Ok(Self::from_major_minor(major, minor)?) @@ -146,7 +146,7 @@ impl BlockDevice { /// Creates a `BlockDevice` from a special block device node. pub fn from_device_node>(path: P) -> Result { let path = path.as_ref(); - let metadata = fs::metadata(&path).context(error::PathMetadata { path })?; + let metadata = fs::metadata(&path).context(error::PathMetadataSnafu { path })?; let major = metadata.st_rdev() >> 8; let minor = metadata.st_rdev() & 0xff; Ok(Self::from_major_minor(major, minor)?) @@ -155,15 +155,15 @@ impl BlockDevice { /// Creates a `BlockDevice` from the major:minor string from the file at `path`. fn from_major_minor_in_file>(path: P) -> Result { let path = path.as_ref(); - let s = fs::read_to_string(path).context(error::FileRead { path })?; + let s = fs::read_to_string(path).context(error::FileReadSnafu { path })?; let parts = s .trim() .splitn(2, ':') .map(u64::from_str) .collect::, _>>() - .context(error::MajorMinorParseInt { path })?; + .context(error::MajorMinorParseIntSnafu { path })?; - ensure!(parts.len() == 2, error::MajorMinorLen { path }); + ensure!(parts.len() == 2, error::MajorMinorLenSnafu { path }); Self::from_major_minor(parts[0], parts[1]) } @@ -184,9 +184,9 @@ impl BlockDevice { pub fn disk(&self) -> Result> { // Globbing for /sys/block/*/{self.device_name}/dev for entry in - fs::read_dir("/sys/block").context(error::ListDirectory { path: "/sys/block" })? + fs::read_dir("/sys/block").context(error::ListDirectorySnafu { path: "/sys/block" })? { - let entry = entry.context(error::ReadDirectoryEntry { path: "/sys/block" })?; + let entry = entry.context(error::ReadDirectoryEntrySnafu { path: "/sys/block" })?; if entry.path().join(&self.device_name).exists() { return Self::from_major_minor_in_file(entry.path().join("dev")).map(Some); } @@ -203,8 +203,10 @@ impl BlockDevice { pub fn partition(&self, part_num: u32) -> Result> { let sys_path = self.sys_path(); // Globbing for /sys/dev/block/{major}:{minor}/*/partition - for entry in fs::read_dir(&sys_path).context(error::ListDirectory { path: &sys_path })? { - let entry = entry.context(error::ReadDirectoryEntry { path: &sys_path })?; + for entry in + fs::read_dir(&sys_path).context(error::ListDirectorySnafu { path: &sys_path })? + { + let entry = entry.context(error::ReadDirectoryEntrySnafu { path: &sys_path })?; if entry.path().is_dir() { let partition_path = entry.path().join("partition"); let partition_str = match fs::read_to_string(&partition_path) { @@ -212,7 +214,7 @@ impl BlockDevice { Err(err) => match err.kind() { io::ErrorKind::NotFound => continue, _ => { - return Err(err).context(error::FileRead { + return Err(err).context(error::FileReadSnafu { path: partition_path, }) } @@ -233,7 +235,7 @@ impl BlockDevice { pub fn lower_devices(&self) -> Result { let path = self.sys_path().join("slaves"); fs::read_dir(&path) - .context(error::ListDirectory { path: &path }) + .context(error::ListDirectorySnafu { path: &path }) .map(move |iter| LowerIter { path, iter }) } } @@ -263,7 +265,7 @@ impl Iterator for LowerIter { fn next(&mut self) -> Option> { self.iter.next().map(|entry| { - let entry = entry.context(error::ReadDirectoryEntry { path: &self.path })?; + let entry = entry.context(error::ReadDirectoryEntrySnafu { path: &self.path })?; BlockDevice::from_major_minor_in_file(entry.path().join("dev")) }) } diff --git a/sources/updater/signpost/Cargo.toml b/sources/updater/signpost/Cargo.toml index 9ee1902606a..3f094a0ae7b 100644 --- a/sources/updater/signpost/Cargo.toml +++ b/sources/updater/signpost/Cargo.toml @@ -15,4 +15,4 @@ gptman = { version = "0.8.2", default-features = false } hex-literal = "0.3.0" serde = { version = "1.0.91", features = ["derive"] } serde_plain = "1.0" -snafu = { version = "0.6.0", default-features = false, features = ["std"] } +snafu = { version = "0.7", default-features = false, features = ["std"] } diff --git a/sources/updater/signpost/src/error.rs b/sources/updater/signpost/src/error.rs index bea7436d7a9..7f1f407d5ec 100644 --- a/sources/updater/signpost/src/error.rs +++ b/sources/updater/signpost/src/error.rs @@ -4,7 +4,7 @@ use std::fmt; use std::path::PathBuf; #[derive(Debug, Snafu)] -#[snafu(visibility = "pub(crate)")] +#[snafu(visibility(pub(crate)))] pub enum Error { #[snafu(display( "Active partition {} not in either detected partition set ({:?})", diff --git a/sources/updater/signpost/src/state.rs b/sources/updater/signpost/src/state.rs index fca81b1bc90..e7cd674c213 100644 --- a/sources/updater/signpost/src/state.rs +++ b/sources/updater/signpost/src/state.rs @@ -43,34 +43,34 @@ impl State { // The root filesystem is a dm-verity device. We want to determine what disk and partition // the backing data is part of. Look up the device major and minor via stat(2): let root_fs = BlockDevice::from_device_path("/") - .context(error::BlockDeviceFromPath { device: "/" })?; + .context(error::BlockDeviceFromPathSnafu { device: "/" })?; // Get the first lower device from this one, and determine what disk it belongs to. let active_partition = root_fs .lower_devices() .and_then(|mut iter| iter.next().transpose()) - .context(error::RootLowerDevices { + .context(error::RootLowerDevicesSnafu { root: root_fs.path(), })? - .context(error::RootHasNoLowerDevices { + .context(error::RootHasNoLowerDevicesSnafu { root: root_fs.path(), })?; let os_disk = active_partition .disk() - .context(error::DiskFromPartition { + .context(error::DiskFromPartitionSnafu { device: root_fs.path(), })? - .context(error::RootNotPartition { + .context(error::RootNotPartitionSnafu { device: root_fs.path(), })?; let active_partition = active_partition.path(); // Parse the partition table on the disk. - let table = GPT::find_from(&mut File::open(os_disk.path()).context(error::Open { + let table = GPT::find_from(&mut File::open(os_disk.path()).context(error::OpenSnafu { path: os_disk.path(), what: "reading", })?) .map_err(error::GPTError) - .context(error::GPTFind { + .context(error::GPTFindSnafu { device: os_disk.path(), })?; @@ -80,7 +80,7 @@ impl State { .iter() .filter(|(_, p)| p.partition_type_guid == guid) .nth(n) - .context(error::PartitionMissingFromSet { + .context(error::PartitionMissingFromSetSnafu { part_type: stringify!(guid), set: if n == 0 { "A" } else { "B" }, })? @@ -90,10 +90,10 @@ impl State { let device_from_part_num = |num| -> Result { Ok(os_disk .partition(num) - .context(error::PartitionFromDisk { + .context(error::PartitionFromDiskSnafu { device: os_disk.path(), })? - .context(error::PartitionNotFoundOnDevice { + .context(error::PartitionNotFoundOnDeviceSnafu { num, device: os_disk.path(), })? @@ -124,7 +124,7 @@ impl State { } else if sets[1].contains(&active_partition) { SetSelect::B } else { - return error::ActiveNotInSet { + return error::ActiveNotInSetSnafu { active_partition, sets, } @@ -223,13 +223,13 @@ impl State { let mut inactive_flags = self.gptprio(self.inactive()); ensure!( inactive_flags.priority() == 0 && !inactive_flags.successful(), - error::InactiveAlreadyMarked { + error::InactiveAlreadyMarkedSnafu { inactive: &self.os_disk } ); ensure!( inactive_flags.tries_left() > 0, - error::InactiveNotValid { + error::InactiveNotValidSnafu { inactive: &self.os_disk } ); @@ -265,7 +265,7 @@ impl State { pub fn rollback_to_inactive(&mut self) -> Result<(), Error> { let mut inactive_flags = self.gptprio(self.inactive()); if !inactive_flags.will_boot() { - return error::InactiveInvalidRollback { + return error::InactiveInvalidRollbackSnafu { priority: inactive_flags.priority(), tries_left: inactive_flags.tries_left(), successful: inactive_flags.successful(), @@ -289,13 +289,13 @@ impl State { &mut OpenOptions::new() .write(true) .open(self.os_disk()) - .context(error::Open { + .context(error::OpenSnafu { path: &self.os_disk, what: "writing", })?, ) .map_err(error::GPTError) - .context(error::GPTWrite { + .context(error::GPTWriteSnafu { device: &self.os_disk, })?; Ok(()) diff --git a/sources/updater/update_metadata/Cargo.toml b/sources/updater/update_metadata/Cargo.toml index 13a26dc5c79..27199dfaf10 100644 --- a/sources/updater/update_metadata/Cargo.toml +++ b/sources/updater/update_metadata/Cargo.toml @@ -16,7 +16,7 @@ semver = { version = "1.0", features = ["serde"] } serde = { version = "1.0.100", features = ["derive"] } serde_json = "1.0.40" serde_plain = "1.0" -snafu = "0.6.0" +snafu = "0.7" toml = "0.5" [lib] diff --git a/sources/updater/update_metadata/src/de.rs b/sources/updater/update_metadata/src/de.rs index ef35ff6d475..e8c651a0fc4 100644 --- a/sources/updater/update_metadata/src/de.rs +++ b/sources/updater/update_metadata/src/de.rs @@ -21,10 +21,10 @@ where ) -> Result<(), error::Error> { let bound = key .parse::() - .context(error::BadBound { bound_str: key })?; + .context(error::BadBoundSnafu { bound_str: key })?; ensure!( map.insert(bound, time).is_none(), - error::DuplicateKeyId { keyid: bound } + error::DuplicateKeyIdSnafu { keyid: bound } ); Ok(()) } @@ -74,7 +74,7 @@ where } } } - error::BadDataVersionsFromTo { key }.fail() + error::BadDataVersionsFromToSnafu { key }.fail() } fn parse_tuple_key( @@ -87,10 +87,10 @@ where if let (Ok(from), Ok(to)) = (serde_plain::from_str(from), serde_plain::from_str(to)) { ensure!( map.insert((from, to), list).is_none(), - error::DuplicateVersionKey { key } + error::DuplicateVersionKeySnafu { key } ); } else { - return error::BadDataVersionsFromTo { + return error::BadDataVersionsFromToSnafu { key: format!("{}, {}", from, to), } .fail(); diff --git a/sources/updater/update_metadata/src/error.rs b/sources/updater/update_metadata/src/error.rs index 1d07310e2c1..1c4550a79bb 100644 --- a/sources/updater/update_metadata/src/error.rs +++ b/sources/updater/update_metadata/src/error.rs @@ -7,7 +7,7 @@ use std::path::PathBuf; pub type Result = std::result::Result; #[derive(Debug, Snafu)] -#[snafu(visibility = "pub(crate)")] +#[snafu(visibility(pub(crate)))] pub enum Error { #[snafu(display("Bad bound field: {}", bound_str))] BadBound { diff --git a/sources/updater/update_metadata/src/lib.rs b/sources/updater/update_metadata/src/lib.rs index 33ee5e361e1..2fa13fb04aa 100644 --- a/sources/updater/update_metadata/src/lib.rs +++ b/sources/updater/update_metadata/src/lib.rs @@ -69,8 +69,8 @@ impl UpdateWaves { P: AsRef, { let path = path.as_ref(); - let wave_data = fs::read_to_string(path).context(error::FileRead { path })?; - toml::from_str(&wave_data).context(error::InvalidToml { path }) + let wave_data = fs::read_to_string(path).context(error::FileReadSnafu { path })?; + toml::from_str(&wave_data).context(error::InvalidTomlSnafu { path }) } } @@ -124,26 +124,26 @@ impl Release { P: AsRef, { let path = path.as_ref(); - let release_data = fs::read_to_string(path).context(error::FileRead { path })?; - toml::from_str(&release_data).context(error::InvalidToml { path }) + let release_data = fs::read_to_string(path).context(error::FileReadSnafu { path })?; + toml::from_str(&release_data).context(error::InvalidTomlSnafu { path }) } } pub fn load_file(path: &Path) -> Result { - let file = File::open(path).context(error::FileRead { path })?; - serde_json::from_reader(file).context(error::ManifestParse) + let file = File::open(path).context(error::FileReadSnafu { path })?; + serde_json::from_reader(file).context(error::ManifestParseSnafu) } pub fn write_file(path: &Path, manifest: &Manifest) -> Result<()> { - let manifest = serde_json::to_string_pretty(&manifest).context(error::UpdateSerialize)?; - fs::write(path, &manifest).context(error::FileWrite { path })?; + let manifest = serde_json::to_string_pretty(&manifest).context(error::UpdateSerializeSnafu)?; + fs::write(path, &manifest).context(error::FileWriteSnafu { path })?; Ok(()) } impl Manifest { /// Parses a `Manifest` from JSON, which is presented by a `Read` object. pub fn from_json(r: R) -> Result { - serde_json::from_reader(r).context(error::ManifestParse) + serde_json::from_reader(r).context(error::ManifestParseSnafu) } pub fn add_update( @@ -214,7 +214,7 @@ impl Manifest { let mut waves = update.waves.iter().peekable(); while let Some(wave) = waves.next() { if let Some(next) = waves.peek() { - ensure!(wave.1 < next.1, error::WavesUnordered); + ensure!(wave.1 < next.1, error::WavesUnorderedSnafu); } } } @@ -279,12 +279,12 @@ impl Manifest { for wave in &waves.waves { ensure!( wave.fleet_percentage > 0 && wave.fleet_percentage <= 100, - error::InvalidFleetPercentage { + error::InvalidFleetPercentageSnafu { provided: wave.fleet_percentage } ); - let offset = parse_offset(&wave.start_after).context(error::BadOffset { + let offset = parse_offset(&wave.start_after).context(error::BadOffsetSnafu { offset: &wave.start_after, })?; update.waves.insert(seed, start_at + offset); @@ -440,7 +440,7 @@ fn find_migrations_forward( } version = &transition.1; } else { - return error::MissingMigration { + return error::MissingMigrationSnafu { current: version.clone(), target: to.clone(), } diff --git a/sources/updater/updog/Cargo.toml b/sources/updater/updog/Cargo.toml index 7183afe634f..1b27e323643 100644 --- a/sources/updater/updog/Cargo.toml +++ b/sources/updater/updog/Cargo.toml @@ -21,7 +21,7 @@ serde_json = "1.0.40" serde_plain = "1.0" signpost = { path = "../signpost", version = "0.1.0" } simplelog = "0.10" -snafu = "0.6.0" +snafu = "0.7" toml = "0.5.1" tough = { version = "0.12", features = ["http"] } update_metadata = { path = "../update_metadata", version = "0.1.0" } diff --git a/sources/updater/updog/src/bin/updata.rs b/sources/updater/updog/src/bin/updata.rs index 5eac251542e..a383d2b89c0 100644 --- a/sources/updater/updog/src/bin/updata.rs +++ b/sources/updater/updog/src/bin/updata.rs @@ -159,11 +159,11 @@ impl WaveArgs { fn set(self) -> Result<()> { let mut manifest: Manifest = update_metadata::load_file(&self.file)?; - let wave_file = self.wave_file.context(error::WaveFileArg)?; + let wave_file = self.wave_file.context(error::WaveFileArgSnafu)?; let wave_str = - fs::read_to_string(&wave_file).context(error::ConfigRead { path: &wave_file })?; + fs::read_to_string(&wave_file).context(error::ConfigReadSnafu { path: &wave_file })?; let waves: UpdateWaves = - toml::from_str(&wave_str).context(error::ConfigParse { path: &wave_file })?; + toml::from_str(&wave_str).context(error::ConfigParseSnafu { path: &wave_file })?; let start_at = self.start_at.unwrap_or(Utc::now()); let num_matching = manifest.set_waves( @@ -200,9 +200,9 @@ impl MigrationArgs { // Load the file we will be reading from let release_data = - fs::read_to_string(&self.from).context(error::ConfigRead { path: &self.from })?; + fs::read_to_string(&self.from).context(error::ConfigReadSnafu { path: &self.from })?; let release: Release = - toml::from_str(&release_data).context(error::ReleaseParse { path: &self.from })?; + toml::from_str(&release_data).context(error::ReleaseParseSnafu { path: &self.from })?; // Replace the manifest 'migrations' section with the new data manifest.migrations = release.migrations; @@ -252,7 +252,7 @@ enum Command { fn main_inner() -> Result<()> { // SimpleLogger will send errors to stderr and anything less to stdout. - SimpleLogger::init(LevelFilter::Info, LogConfig::default()).context(error::Logger)?; + SimpleLogger::init(LevelFilter::Info, LogConfig::default()).context(error::LoggerSnafu)?; match Command::from_args() { Command::Init(args) => { @@ -320,7 +320,7 @@ mod tests { // Ensure that we can update a blank manifest fn test_migration_copy() -> Result<()> { let release_path = "tests/data/release.toml"; - let temp_manifest = NamedTempFile::new().context(error::TmpFileCreate)?; + let temp_manifest = NamedTempFile::new().context(error::TmpFileCreateSnafu)?; // Create a new blank manifest update_metadata::write_file(&temp_manifest.path(), &Manifest::default()).unwrap(); @@ -349,7 +349,7 @@ mod tests { // Write example data to temp manifest so we dont' overwrite the file // when we call MigrationsArgs.set() below - let temp_manifest = NamedTempFile::new().context(error::TmpFileCreate)?; + let temp_manifest = NamedTempFile::new().context(error::TmpFileCreateSnafu)?; let example_data = fs::read_to_string(&example_manifest).unwrap(); fs::write(&temp_manifest, &example_data).unwrap(); @@ -372,7 +372,7 @@ mod tests { #[test] fn max_versions() -> Result<()> { - let tmpfd = NamedTempFile::new().context(error::TmpFileCreate)?; + let tmpfd = NamedTempFile::new().context(error::TmpFileCreateSnafu)?; update_metadata::write_file(tmpfd.path(), &Manifest::default()).unwrap(); AddUpdateArgs { file: PathBuf::from(tmpfd.path()), diff --git a/sources/updater/updog/src/error.rs b/sources/updater/updog/src/error.rs index 2025a3aec90..f82afaecdc2 100644 --- a/sources/updater/updog/src/error.rs +++ b/sources/updater/updog/src/error.rs @@ -7,7 +7,7 @@ use update_metadata::error::Error as update_metadata_error; pub(crate) type Result = std::result::Result; #[derive(Debug, Snafu)] -#[snafu(visibility = "pub(crate)")] +#[snafu(visibility(pub(crate)))] pub(crate) enum Error { #[snafu(display( "Failed to convert '{}' from FriendlyVersion to semver::Version: {}", diff --git a/sources/updater/updog/src/main.rs b/sources/updater/updog/src/main.rs index 9fffaeca752..882f2e2ad07 100644 --- a/sources/updater/updog/src/main.rs +++ b/sources/updater/updog/src/main.rs @@ -111,29 +111,29 @@ GLOBAL OPTIONS: fn load_config() -> Result { let path = "/etc/updog.toml"; - let s = fs::read_to_string(path).context(error::ConfigRead { path })?; - let config: Config = toml::from_str(&s).context(error::ConfigParse { path })?; + let s = fs::read_to_string(path).context(error::ConfigReadSnafu { path })?; + let config: Config = toml::from_str(&s).context(error::ConfigParseSnafu { path })?; Ok(config) } fn load_repository(transport: HttpQueryTransport, config: &Config) -> Result { - fs::create_dir_all(METADATA_PATH).context(error::CreateMetadataCache { + fs::create_dir_all(METADATA_PATH).context(error::CreateMetadataCacheSnafu { path: METADATA_PATH, })?; RepositoryLoader::new( - File::open(TRUSTED_ROOT_PATH).context(error::OpenRoot { + File::open(TRUSTED_ROOT_PATH).context(error::OpenRootSnafu { path: TRUSTED_ROOT_PATH, })?, - Url::parse(&config.metadata_base_url).context(error::UrlParse { + Url::parse(&config.metadata_base_url).context(error::UrlParseSnafu { url: &config.metadata_base_url, })?, - Url::parse(&config.targets_base_url).context(error::UrlParse { + Url::parse(&config.targets_base_url).context(error::UrlParseSnafu { url: &config.targets_base_url, })?, ) .transport(transport) .load() - .context(error::Metadata) + .context(error::MetadataSnafu) } fn applicable_updates<'a>( @@ -181,15 +181,16 @@ fn update_required<'a>( if version_lock != "latest" { // Make sure the version string from the config is a valid version string that might be prefixed with 'v' let friendly_version_lock = - FriendlyVersion::try_from(version_lock).context(error::BadVersionConfig { + FriendlyVersion::try_from(version_lock).context(error::BadVersionConfigSnafu { version_str: version_lock, })?; // Convert back to semver::Version - let semver_version_lock = friendly_version_lock - .try_into() - .context(error::BadVersion { - version_str: version_lock, - })?; + let semver_version_lock = + friendly_version_lock + .try_into() + .context(error::BadVersionSnafu { + version_str: version_lock, + })?; // If the configured version-lock matches our current version, we won't update to the same version return if semver_version_lock == *version { Ok(None) @@ -215,26 +216,28 @@ fn write_target_to_disk>( target: &str, disk_path: P, ) -> Result<()> { - let target = target.try_into().context(error::TargetName { target })?; + let target = target + .try_into() + .context(error::TargetNameSnafu { target })?; let reader = repository .read_target(&target) - .context(error::Metadata)? - .context(error::TargetNotFound { + .context(error::MetadataSnafu)? + .context(error::TargetNotFoundSnafu { target: target.raw(), })?; // Note: the file extension for the compression type we're using should be removed in // retrieve_migrations below. - let mut reader = lz4::Decoder::new(reader).context(error::Lz4Decode { + let mut reader = lz4::Decoder::new(reader).context(error::Lz4DecodeSnafu { target: target.raw(), })?; let mut f = OpenOptions::new() .write(true) .create(true) .open(disk_path.as_ref()) - .context(error::OpenPartition { + .context(error::OpenPartitionSnafu { path: disk_path.as_ref(), })?; - io::copy(&mut reader, &mut f).context(error::WriteUpdate)?; + io::copy(&mut reader, &mut f).context(error::WriteUpdateSnafu)?; Ok(()) } @@ -255,7 +258,7 @@ fn retrieve_migrations( let dir = Path::new(MIGRATION_PATH); if !dir.exists() { - fs::create_dir(&dir).context(error::DirCreate { path: &dir })?; + fs::create_dir(&dir).context(error::DirCreateSnafu { path: &dir })?; } // find the list of migrations in the manifest based on our from and to versions. @@ -266,19 +269,19 @@ fn retrieve_migrations( targets.push("manifest.json".to_owned()); repository .cache(METADATA_PATH, MIGRATION_PATH, Some(&targets), true) - .context(error::RepoCacheMigrations)?; + .context(error::RepoCacheMigrationsSnafu)?; // Set a query parameter listing the required migrations query_params.add("migrations", targets.join(",")); Ok(()) } fn update_image(update: &Update, repository: &Repository) -> Result<()> { - let mut gpt_state = State::load().context(error::PartitionTableRead)?; + let mut gpt_state = State::load().context(error::PartitionTableReadSnafu)?; gpt_state.clear_inactive(); // Write out the clearing of the inactive partition immediately, because we're about to // overwrite the partition set with update data and don't want it to be used until we // know we're done with all components. - gpt_state.write().context(error::PartitionTableWrite)?; + gpt_state.write().context(error::PartitionTableWriteSnafu)?; let inactive = gpt_state.inactive_set(); @@ -288,23 +291,23 @@ fn update_image(update: &Update, repository: &Repository) -> Result<()> { write_target_to_disk(repository, &update.images.hash, &inactive.hash)?; gpt_state.mark_inactive_valid(); - gpt_state.write().context(error::PartitionTableWrite)?; + gpt_state.write().context(error::PartitionTableWriteSnafu)?; Ok(()) } fn update_flags() -> Result<()> { - let mut gpt_state = State::load().context(error::PartitionTableRead)?; + let mut gpt_state = State::load().context(error::PartitionTableReadSnafu)?; gpt_state .upgrade_to_inactive() - .context(error::InactivePartitionUpgrade)?; - gpt_state.write().context(error::PartitionTableWrite)?; + .context(error::InactivePartitionUpgradeSnafu)?; + gpt_state.write().context(error::PartitionTableWriteSnafu)?; Ok(()) } fn revert_update_flags() -> Result<()> { - let mut gpt_state = State::load().context(error::PartitionTableRead)?; + let mut gpt_state = State::load().context(error::PartitionTableReadSnafu)?; gpt_state.cancel_upgrade(); - gpt_state.write().context(error::PartitionTableWrite)?; + gpt_state.write().context(error::PartitionTableWriteSnafu)?; Ok(()) } @@ -331,7 +334,7 @@ fn list_updates( if json { println!( "{}", - serde_json::to_string_pretty(&updates).context(error::UpdateSerialize)? + serde_json::to_string_pretty(&updates).context(error::UpdateSerializeSnafu)? ); } else { for u in updates { @@ -431,7 +434,7 @@ fn output(json: bool, object: T, string: &str) -> Result<()> { if json { println!( "{}", - serde_json::to_string_pretty(&object).context(error::UpdateSerialize)? + serde_json::to_string_pretty(&object).context(error::UpdateSerializeSnafu)? ); } else { println!("{}", string); @@ -441,7 +444,7 @@ fn output(json: bool, object: T, string: &str) -> Result<()> { fn initiate_reboot() -> Result<()> { // Set up signal handler for termination signals - let mut signals = Signals::new(&[SIGTERM]).context(error::Signal)?; + let mut signals = Signals::new(&[SIGTERM]).context(error::SignalSnafu)?; let signals_handle = signals.handle(); thread::spawn(move || { for _sig in signals.forever() { @@ -453,7 +456,7 @@ fn initiate_reboot() -> Result<()> { if let Err(err) = process::Command::new("shutdown") .arg("-r") .status() - .context(error::RebootFailure) + .context(error::RebootFailureSnafu) { // Kill the signal handling thread signals_handle.close(); @@ -493,14 +496,14 @@ fn main_inner() -> Result<()> { let arguments = parse_args(std::env::args()); // SimpleLogger will send errors to stderr and anything less to stdout. - SimpleLogger::init(arguments.log_level, LogConfig::default()).context(error::Logger)?; + SimpleLogger::init(arguments.log_level, LogConfig::default()).context(error::LoggerSnafu)?; let command = serde_plain::from_str::(&arguments.subcommand).unwrap_or_else(|_| usage()); let config = load_config()?; set_https_proxy_environment_variables(&config.https_proxy, &config.no_proxy)?; - let current_release = BottlerocketRelease::new().context(error::ReleaseVersion)?; + let current_release = BottlerocketRelease::new().context(error::ReleaseVersionSnafu)?; let variant = arguments.variant.unwrap_or(current_release.variant_id); let transport = HttpQueryTransport::new(); // get a shared pointer to the transport's query_params so we can add metrics information to @@ -531,7 +534,7 @@ fn main_inner() -> Result<()> { &config.version_lock, arguments.force_version, )? - .context(error::UpdateNotAvailable)?; + .context(error::UpdateNotAvailableSnafu)?; output(arguments.json, &update, &fmt_full_version(&update))?; } @@ -589,14 +592,16 @@ fn main_inner() -> Result<()> { fn load_manifest(repository: &tough::Repository) -> Result { let target = "manifest.json"; - let target = target.try_into().context(error::TargetName { target })?; + let target = target + .try_into() + .context(error::TargetNameSnafu { target })?; Manifest::from_json( repository .read_target(&target) - .context(error::ManifestLoad)? - .context(error::ManifestNotFound)?, + .context(error::ManifestLoadSnafu)? + .context(error::ManifestNotFoundSnafu)?, ) - .context(error::ManifestParse) + .context(error::ManifestParseSnafu) } fn main() -> ! { @@ -836,7 +841,7 @@ mod tests { let path = "tests/data/example_2.json"; let manifest: Manifest = serde_json::from_reader(File::open(path).unwrap()).unwrap(); assert!(serde_json::to_string_pretty(&manifest) - .context(error::UpdateSerialize) + .context(error::UpdateSerializeSnafu) .is_ok()); } diff --git a/tools/Cargo.lock b/tools/Cargo.lock index d6f4f0b3539..b9602c4ff3a 100644 --- a/tools/Cargo.lock +++ b/tools/Cargo.lock @@ -161,7 +161,7 @@ dependencies = [ "serde", "serde_plain", "sha2", - "snafu", + "snafu 0.6.10", "toml", "url", "walkdir", @@ -252,7 +252,7 @@ dependencies = [ "rusoto_ec2", "rusoto_signature", "sha2", - "snafu", + "snafu 0.6.10", "tempfile", "tokio", ] @@ -792,7 +792,7 @@ dependencies = [ "sha2", "shell-words", "simplelog", - "snafu", + "snafu 0.6.10", "structopt", "tokio", "toml", @@ -1064,7 +1064,7 @@ version = "0.1.0" dependencies = [ "cargo-readme", "chrono", - "snafu", + "snafu 0.7.0", ] [[package]] @@ -1195,7 +1195,7 @@ dependencies = [ "serde", "serde_json", "simplelog", - "snafu", + "snafu 0.6.10", "structopt", "tempfile", "tinytemplate", @@ -1220,7 +1220,7 @@ dependencies = [ "parse-datetime", "serde", "serde_yaml", - "snafu", + "snafu 0.6.10", "toml", "url", ] @@ -1236,7 +1236,7 @@ dependencies = [ "sha2", "shell-words", "simplelog", - "snafu", + "snafu 0.6.10", "structopt", "tempfile", "toml", @@ -1833,7 +1833,18 @@ checksum = "eab12d3c261b2308b0d80c26fffb58d17eba81a4be97890101f416b478c79ca7" dependencies = [ "backtrace", "doc-comment", - "snafu-derive", + "snafu-derive 0.6.10", +] + +[[package]] +name = "snafu" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2eba135d2c579aa65364522eb78590cdf703176ef71ad4c32b00f58f7afb2df5" +dependencies = [ + "backtrace", + "doc-comment", + "snafu-derive 0.7.0", ] [[package]] @@ -1847,6 +1858,18 @@ dependencies = [ "syn", ] +[[package]] +name = "snafu-derive" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a7fe9b0669ef117c5cabc5549638528f36771f058ff977d7689deb517833a75" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "socket2" version = "0.4.2" @@ -2083,7 +2106,7 @@ dependencies = [ "serde", "serde_json", "serde_plain", - "snafu", + "snafu 0.6.10", "tempfile", "untrusted", "url", @@ -2101,7 +2124,7 @@ dependencies = [ "rusoto_core", "rusoto_credential", "rusoto_kms", - "snafu", + "snafu 0.6.10", "tokio", "tough", ] @@ -2117,7 +2140,7 @@ dependencies = [ "rusoto_ssm", "serde", "serde_json", - "snafu", + "snafu 0.6.10", "tokio", "tough", ] @@ -2210,7 +2233,7 @@ dependencies = [ "serde", "serde_json", "serde_plain", - "snafu", + "snafu 0.7.0", "toml", ] diff --git a/tools/deny.toml b/tools/deny.toml index 3beb27943d9..eca08746114 100644 --- a/tools/deny.toml +++ b/tools/deny.toml @@ -46,7 +46,10 @@ license-files = [ multiple-versions = "deny" wildcards = "deny" -skip = [] +skip-tree = [ + # temporarily using a different version of snafu + { name = "parse-datetime", version = "0.1.0" }, +] [sources] # Deny crates from unknown registries or git repositories. From 01991de9a1d29318462a13422660848dd8330d07 Mon Sep 17 00:00:00 2001 From: Matthew James Briggs Date: Wed, 2 Feb 2022 14:58:38 -0800 Subject: [PATCH 4/8] sources: cargo update minor versions --- sources/Cargo.lock | 685 ++++++++++++++------------- sources/clarify.toml | 12 + sources/deny.toml | 14 +- sources/webpki-roots-shim/Cargo.toml | 2 +- 4 files changed, 373 insertions(+), 340 deletions(-) diff --git a/sources/Cargo.lock b/sources/Cargo.lock index 84c1cae0c75..29ec2c060f3 100644 --- a/sources/Cargo.lock +++ b/sources/Cargo.lock @@ -28,9 +28,9 @@ dependencies = [ [[package]] name = "actix-codec" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13895df506faee81e423febbae3a33b27fca71831b96bb3d60adf16ebcfea952" +checksum = "a36c014a3e811624313b51a227b775ecba55d36ef9462bbaac7d4f13e54c9271" dependencies = [ "bitflags", "bytes", @@ -64,7 +64,7 @@ dependencies = [ "h2", "http", "httparse", - "httpdate 1.0.1", + "httpdate 1.0.2", "itoa 1.0.1", "language-tags", "local-channel", @@ -126,15 +126,15 @@ dependencies = [ "log", "mio 0.8.0", "num_cpus", - "socket2 0.4.2", + "socket2 0.4.4", "tokio", ] [[package]] name = "actix-service" -version = "2.0.1" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d3dc6a618b082974a08d7a4781d24d4691cba51500059bfebe6656a61ebfe1e" +checksum = "3b894941f818cfdc7ccc4b9e60fa7e53b5042a2e8567270f9147d5591893373a" dependencies = [ "futures-core", "paste", @@ -182,8 +182,8 @@ dependencies = [ "serde_json", "serde_urlencoded", "smallvec", - "socket2 0.4.2", - "time 0.3.4", + "socket2 0.4.4", + "time 0.3.7", "url", ] @@ -259,18 +259,18 @@ dependencies = [ [[package]] name = "ansi_term" -version = "0.11.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" dependencies = [ "winapi", ] [[package]] name = "anyhow" -version = "1.0.45" +version = "1.0.53" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee10e43ae4a853c0a3591d4e2ada1719e553be18199d9da9d4a83f5927c2f5c7" +checksum = "94a45b455c14666b85fc40a019e8ab9eb75e3a124e05494f5397122bc9eb06e0" [[package]] name = "apiclient" @@ -288,7 +288,7 @@ dependencies = [ "libc", "log", "models", - "nix 0.23.0", + "nix 0.23.1", "rand", "reqwest", "retry-read", @@ -296,7 +296,7 @@ dependencies = [ "serde_json", "signal-hook", "simplelog", - "snafu 0.7.0", + "snafu", "tokio", "tokio-tungstenite", "toml", @@ -323,15 +323,15 @@ dependencies = [ "log", "maplit", "models", - "nix 0.23.0", + "nix 0.23.1", "num", "percent-encoding", "rand", - "semver 1.0.4", + "semver", "serde", "serde_json", "simplelog", - "snafu 0.7.0", + "snafu", "thar-be-updates", "toml", "walkdir", @@ -339,9 +339,9 @@ dependencies = [ [[package]] name = "argh" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f023c76cd7975f9969f8e29f0e461decbdc7f51048ce43427107a3d192f1c9bf" +checksum = "dbb41d85d92dfab96cb95ab023c265c5e4261bb956c0fb49ca06d90c570f1958" dependencies = [ "argh_derive", "argh_shared", @@ -349,9 +349,9 @@ dependencies = [ [[package]] name = "argh_derive" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48ad219abc0c06ca788aface2e3a1970587e3413ab70acd20e54b6ec524c1f8f" +checksum = "be69f70ef5497dd6ab331a50bd95c6ac6b8f7f17a7967838332743fbd58dc3b5" dependencies = [ "argh_shared", "heck", @@ -362,9 +362,9 @@ dependencies = [ [[package]] name = "argh_shared" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38de00daab4eac7d753e97697066238d67ce9d7e2d823ab4f72fe14af29f3f33" +checksum = "e6f8c380fa28aa1b36107cd97f0196474bb7241bb95a453c5c01a15ac74b2eac" [[package]] name = "arrayvec" @@ -395,9 +395,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.51" +version = "0.1.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44318e776df68115a881de9a8fd1b9e53368d7a4a5ce4cc48517da3393233a5e" +checksum = "061a7acccaa286c011ddc30970520b98fa40e00c9d644633fb26b5fc63a265e3" dependencies = [ "proc-macro2", "quote", @@ -423,9 +423,9 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] name = "backtrace" -version = "0.3.63" +version = "0.3.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "321629d8ba6513061f26707241fa9bc89524ff1cd7a915a97ef0c62c666ce1b6" +checksum = "5e121dee8023ce33ab248d9ce1493df03c3b38a659b240096fcbd7048ff9c31f" dependencies = [ "addr2line", "cc", @@ -493,7 +493,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "generic-array 0.14.4", + "generic-array 0.14.5", ] [[package]] @@ -502,7 +502,7 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1d36a02058e76b040de25a4464ba1c80935655595b661505c8b39b664828b95" dependencies = [ - "generic-array 0.14.4", + "generic-array 0.14.5", ] [[package]] @@ -518,7 +518,7 @@ dependencies = [ name = "block-party" version = "0.1.0" dependencies = [ - "snafu 0.7.0", + "snafu", ] [[package]] @@ -536,7 +536,7 @@ dependencies = [ "serde", "serde_json", "simplelog", - "snafu 0.7.0", + "snafu", "tokio", ] @@ -555,9 +555,9 @@ dependencies = [ "cargo-readme", "envy", "log", - "semver 1.0.4", + "semver", "serde", - "snafu 0.7.0", + "snafu", ] [[package]] @@ -573,9 +573,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.8.0" +version = "3.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f1e260c3a9040a7c19a12468758f4c16f31a81a1fe087482be9570ec864bb6c" +checksum = "a4a45a46ab1f2412e53d3a0ade76ffad2025804294569aae387231a0cd6e0899" [[package]] name = "byte-tools" @@ -621,9 +621,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.71" +version = "1.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79c2681d6594606957bbb8631c4b90a7fcaaa72cdb714743a437b156d6a7eedd" +checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee" [[package]] name = "certdog" @@ -640,7 +640,7 @@ dependencies = [ "serde", "serde_json", "simplelog", - "snafu 0.7.0", + "snafu", "tempfile", "tokio", "x509-parser", @@ -668,9 +668,9 @@ dependencies = [ [[package]] name = "clap" -version = "2.33.3" +version = "2.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" +checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" dependencies = [ "ansi_term", "atty", @@ -744,16 +744,10 @@ dependencies = [ "serde", "serde_json", "simplelog", - "snafu 0.7.0", + "snafu", "tokio", ] -[[package]] -name = "count-zeroes" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c80f87e3dbcccd054a1a06b56548d113a6bce5c1f19b919d0a4dc95e8dd233ca" - [[package]] name = "cpufeatures" version = "0.2.1" @@ -780,18 +774,18 @@ checksum = "ccaeedb56da03b09f598226e25e80088cb4cd25f316e6e4df7d695f0feeb1403" [[package]] name = "crc32fast" -version = "1.2.1" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a" +checksum = "a2209c310e29876f7f0b2721e7e26b84aff178aa3da5d091f9bfbf47669e60e3" dependencies = [ "cfg-if", ] [[package]] name = "crossbeam-channel" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4" +checksum = "e54ea8bc3fb1ee042f5aace6e3c6e025d3874866da222930f70ce62aceba0bfa" dependencies = [ "cfg-if", "crossbeam-utils", @@ -799,9 +793,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db" +checksum = "cfcae03edb34f947e64acdb1c33ec169824e20657e9ecb61cef6c8c74dcb8120" dependencies = [ "cfg-if", "lazy_static", @@ -813,7 +807,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "683d6b536309245c849479fba3da410962a43ed8e51c26b729208ec0ac2798d0" dependencies = [ - "generic-array 0.14.4", + "generic-array 0.14.5", ] [[package]] @@ -822,7 +816,7 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" dependencies = [ - "generic-array 0.14.4", + "generic-array 0.14.5", "subtle", ] @@ -832,14 +826,14 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1a816186fa68d9e426e3cb4ae4dff1fcd8e4a2c34b781bf7a822574a0d0aac8" dependencies = [ - "sct", + "sct 0.6.1", ] [[package]] name = "darling" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "757c0ded2af11d8e739c4daea1ac623dd1624b06c844cf3f5a39f1bdbd99bb12" +checksum = "d0d720b8683f8dd83c65155f0530560cba68cd2bf395f6513a483caee57ff7f4" dependencies = [ "darling_core", "darling_macro", @@ -847,9 +841,9 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c34d8efb62d0c2d7f60ece80f75e5c63c1588ba68032740494b0b9a996466e3" +checksum = "7a340f241d2ceed1deb47ae36c4144b2707ec7dd0b649f894cb39bb595986324" dependencies = [ "fnv", "ident_case", @@ -861,9 +855,9 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ade7bff147130fe5e6d39f089c6bd49ec0250f35d70b2eebf72afdfc919f15cc" +checksum = "72c41b3b7352feb3211a0d743dc5700a4e3b60f51bd2b368892d1e0f9a95f44b" dependencies = [ "darling_core", "quote", @@ -887,7 +881,7 @@ dependencies = [ "percent-encoding", "serde", "serde_json", - "snafu 0.7.0", + "snafu", "toml", "walkdir", ] @@ -919,14 +913,14 @@ dependencies = [ [[package]] name = "derive_more" -version = "0.99.16" +version = "0.99.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40eebddd2156ce1bb37b20bbe5151340a31828b1f2d22ba4141f3531710e38df" +checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" dependencies = [ "convert_case", "proc-macro2", "quote", - "rustc_version 0.3.3", + "rustc_version", "syn", ] @@ -945,7 +939,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" dependencies = [ - "generic-array 0.14.4", + "generic-array 0.14.5", ] [[package]] @@ -956,7 +950,7 @@ checksum = "b697d66081d42af4fba142d56918a3cb21dc8eb63372c6b85d14f44fb9c5979b" dependencies = [ "block-buffer 0.10.0", "crypto-common", - "generic-array 0.14.4", + "generic-array 0.14.5", ] [[package]] @@ -988,7 +982,7 @@ checksum = "53ecafc952c4528d9b51a458d1a8904b81783feff9fde08ab6ed2545ff396872" dependencies = [ "cfg-if", "libc", - "socket2 0.4.2", + "socket2 0.4.4", "winapi", ] @@ -1007,7 +1001,7 @@ dependencies = [ "log", "serde", "simplelog", - "snafu 0.7.0", + "snafu", "tempfile", "toml", ] @@ -1039,7 +1033,7 @@ dependencies = [ "serde_json", "serde_plain", "simplelog", - "snafu 0.7.0", + "snafu", "tokio", "toml", "vmw_backdoor", @@ -1055,7 +1049,7 @@ dependencies = [ "schnauzer", "serde", "serde_json", - "snafu 0.7.0", + "snafu", "tokio", ] @@ -1067,9 +1061,9 @@ checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" [[package]] name = "encoding_rs" -version = "0.8.29" +version = "0.8.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a74ea89a0a1b98f6332de42c95baff457ada66d1cb4030f9ff151b2041a1c746" +checksum = "7896dc8abb250ffdda33912550faa54c88ec8b998dec0b2c55ab224921ce11df" dependencies = [ "cfg-if", ] @@ -1117,6 +1111,15 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" +[[package]] +name = "fastrand" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3fcf0cee53519c866c09b5de1f6c56ff9d647101f81c1964fa632e148896cdf" +dependencies = [ + "instant", +] + [[package]] name = "filetime" version = "0.2.15" @@ -1181,9 +1184,9 @@ checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" [[package]] name = "futures" -version = "0.3.17" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a12aa0eb539080d55c3f2d45a67c3b58b6b0773c1a3ca2dfec66d58c97fd66ca" +checksum = "28560757fe2bb34e79f907794bb6b22ae8b0e5c669b638a1132f2592b19035b4" dependencies = [ "futures-channel", "futures-core", @@ -1196,9 +1199,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.17" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5da6ba8c3bb3c165d3c7319fc1cc8304facf1fb8db99c5de877183c08a273888" +checksum = "ba3dda0b6588335f360afc675d0564c17a77a2bda81ca178a4b6081bd86c7f0b" dependencies = [ "futures-core", "futures-sink", @@ -1206,15 +1209,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.17" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88d1c26957f23603395cd326b0ffe64124b818f4449552f960d815cfba83a53d" +checksum = "d0c8ff0461b82559810cdccfde3215c3f373807f5e5232b71479bff7bb2583d7" [[package]] name = "futures-executor" -version = "0.3.17" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45025be030969d763025784f7f355043dc6bc74093e4ecc5000ca4dc50d8745c" +checksum = "29d6d2ff5bb10fb95c85b8ce46538a2e5f5e7fdc755623a7d4529ab8a4ed9d2a" dependencies = [ "futures-core", "futures-task", @@ -1223,18 +1226,16 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.17" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "522de2a0fe3e380f1bc577ba0474108faf3f6b18321dbf60b3b9c39a75073377" +checksum = "b1f9d34af5a1aac6fb380f735fe510746c38067c5bf16c7fd250280503c971b2" [[package]] name = "futures-macro" -version = "0.3.17" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18e4a4b95cea4b4ccbcf1c5675ca7c4ee4e9e75eb79944d07defde18068f79bb" +checksum = "6dbd947adfffb0efc70599b3ddcf7b5597bb5fa9e245eb99f62b3a5f7bb8bd3c" dependencies = [ - "autocfg", - "proc-macro-hack", "proc-macro2", "quote", "syn", @@ -1242,23 +1243,22 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.17" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36ea153c13024fe480590b3e3d4cad89a0cfacecc24577b68f86c6ced9c2bc11" +checksum = "e3055baccb68d74ff6480350f8d6eb8fcfa3aa11bdc1a1ae3afdd0514617d508" [[package]] name = "futures-task" -version = "0.3.17" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d3d00f4eddb73e498a54394f228cd55853bdf059259e8e7bc6e69d408892e99" +checksum = "6ee7c6485c30167ce4dfb83ac568a849fe53274c831081476ee13e0dce1aad72" [[package]] name = "futures-util" -version = "0.3.17" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36568465210a3a6ee45e1f165136d68671471a501e632e9a98d96872222b5481" +checksum = "d9b5cf40b47a271f77a8b1bec03ca09044d99d2372c0de244e66430761127164" dependencies = [ - "autocfg", "futures-channel", "futures-core", "futures-io", @@ -1268,8 +1268,6 @@ dependencies = [ "memchr", "pin-project-lite", "pin-utils", - "proc-macro-hack", - "proc-macro-nested", "slab", ] @@ -1284,9 +1282,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.4" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" +checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803" dependencies = [ "typenum", "version_check", @@ -1294,9 +1292,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" +checksum = "418d37c8b1d42553c93648be529cb70f920d3baf8ef469b74b9638df426e0b4c" dependencies = [ "cfg-if", "libc", @@ -1313,7 +1311,7 @@ dependencies = [ "hex-literal", "lazy_static", "signpost", - "snafu 0.7.0", + "snafu", ] [[package]] @@ -1343,14 +1341,13 @@ dependencies = [ [[package]] name = "gptman" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f1739cf11514f93ee03192cfcdef9c82ae83592c109f4c8cd5c992509adb68c" +checksum = "f5a6ef4b3fdbdf3d312de4fb312ea65d2e58cc046a7554742dbf8eccc49eb0c5" dependencies = [ "bincode", - "count-zeroes", "crc", - "nix 0.22.0", + "nix 0.22.3", "serde", "thiserror", ] @@ -1364,7 +1361,7 @@ dependencies = [ "gptman", "inotify", "libc", - "snafu 0.7.0", + "snafu", ] [[package]] @@ -1388,9 +1385,9 @@ dependencies = [ [[package]] name = "handlebars" -version = "4.1.4" +version = "4.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1874024f4a29f47d609014caec0b1c866f1c1eb0661a09c9733ecc4757f5f88" +checksum = "25546a65e5cf1f471f3438796fc634650b31d7fcde01d444c309aeb28b92e3a8" dependencies = [ "log", "pest", @@ -1432,9 +1429,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hex-literal" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21e4590e13640f19f249fe3e4eca5113bc4289f2497710378190e7f4bd96f45b" +checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" [[package]] name = "hmac" @@ -1460,7 +1457,7 @@ dependencies = [ "serde", "serde_json", "simplelog", - "snafu 0.7.0", + "snafu", "tokio", ] @@ -1473,13 +1470,13 @@ dependencies = [ [[package]] name = "http" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1323096b05d41827dadeaee54c9981958c0f94e670bc94ed80037d1a7b8b186b" +checksum = "31f4c6746584866f0feabcc69893c5b51beef3831656a968ed7ae254cdc4fd03" dependencies = [ "bytes", "fnv", - "itoa 0.4.8", + "itoa 1.0.1", ] [[package]] @@ -1507,15 +1504,15 @@ checksum = "494b4d60369511e7dea41cf646832512a94e542f68bb9c49e54518e0f468eb47" [[package]] name = "httpdate" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6456b8a6c8f33fee7d958fcd1b60d55b11940a79e63ae87013e6d22e26034440" +checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" [[package]] name = "httptest" -version = "0.15.3" +version = "0.15.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5858cc7b673d0397ffd4cdee93f11eb2fa08a2b0b5e35ae03d6b480a4abe171d" +checksum = "f6f25cfb6def593d43fae1ead24861f217e93bc70768a45cc149a69b5f049df4" dependencies = [ "bstr", "bytes", @@ -1567,11 +1564,24 @@ dependencies = [ "futures-util", "hyper", "log", - "rustls", + "rustls 0.19.1", "rustls-native-certs", "tokio", - "tokio-rustls", - "webpki", + "tokio-rustls 0.22.0", + "webpki 0.21.4", +] + +[[package]] +name = "hyper-rustls" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d87c48c02e0dc5e3b849a2041db3029fd066650f8f717c07bf8ed78ccb895cac" +dependencies = [ + "http", + "hyper", + "rustls 0.20.2", + "tokio", + "tokio-rustls 0.23.2", ] [[package]] @@ -1614,7 +1624,7 @@ dependencies = [ "log", "reqwest", "serde_json", - "snafu 0.7.0", + "snafu", "tokio", "tokio-retry", "tokio-test", @@ -1623,9 +1633,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5" +checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223" dependencies = [ "autocfg", "hashbrown", @@ -1673,9 +1683,9 @@ dependencies = [ [[package]] name = "itertools" -version = "0.10.1" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69ddb889f9d0d08a67338271fa9b62996bc788c7796a5c18cf057420aaed5eaf" +checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" dependencies = [ "either", ] @@ -1694,9 +1704,9 @@ checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" [[package]] name = "js-sys" -version = "0.3.55" +version = "0.3.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cc9ffccd38c451a86bf13657df244e9c3f37493cce8e5e21e940963777acc84" +checksum = "a38fc24e30fd564ce974c02bf1d337caddff65be6cc4735a1f7eab22a7440f04" dependencies = [ "wasm-bindgen", ] @@ -1728,9 +1738,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.107" +version = "0.2.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbe5e23404da5b4f555ef85ebed98fb4083e55a00c317800bc2a50ede9f3d219" +checksum = "e74d72e0f9b65b5b4ca49a346af3976df0f9c61d550727f349ecd559f251a26c" [[package]] name = "local-channel" @@ -1746,15 +1756,15 @@ dependencies = [ [[package]] name = "local-waker" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84f9a2d3e27ce99ce2c3aad0b09b1a7b916293ea9b2bf624c13fe646fadd8da4" +checksum = "902eb695eb0591864543cbfbf6d742510642a605a61fc5e97fe6ceb5a30ac4fb" [[package]] name = "lock_api" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109" +checksum = "88943dd7ef4a2e5a4bfa2753aaab3013e34ce2533d1996fb18ef591e315e2b3b" dependencies = [ "scopeguard", ] @@ -1782,7 +1792,7 @@ dependencies = [ "reqwest", "serde_json", "shell-words", - "snafu 0.7.0", + "snafu", "tar", "tempfile", "tokio", @@ -1841,9 +1851,9 @@ checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" [[package]] name = "memoffset" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" dependencies = [ "autocfg", ] @@ -1852,7 +1862,7 @@ dependencies = [ name = "merge-toml" version = "0.1.0" dependencies = [ - "snafu 0.7.0", + "snafu", "toml", ] @@ -1867,7 +1877,7 @@ dependencies = [ "reqwest", "serde", "simplelog", - "snafu 0.7.0", + "snafu", "structopt", "tempfile", "toml", @@ -1885,7 +1895,7 @@ dependencies = [ "schnauzer", "serde", "serde_json", - "snafu 0.7.0", + "snafu", "toml", ] @@ -1898,13 +1908,13 @@ dependencies = [ "chrono", "log", "lz4", - "nix 0.23.0", + "nix 0.23.1", "pentacle", "rand", "regex", - "semver 1.0.4", + "semver", "simplelog", - "snafu 0.7.0", + "snafu", "storewolf", "tempfile", "tough", @@ -1987,10 +1997,10 @@ dependencies = [ "model-derive", "rand", "regex", - "semver 1.0.4", + "semver", "serde", "serde_plain", - "snafu 0.7.0", + "snafu", "toml", "url", "x509-parser", @@ -2011,14 +2021,14 @@ dependencies = [ "serde", "serde_json", "serde_plain", - "snafu 0.7.0", + "snafu", ] [[package]] name = "nix" -version = "0.22.0" +version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1e25ee6b412c2a1e3fcb6a4499a5c1bfe7f43e014bdce9a6b6666e5aa2d187" +checksum = "e4916f159ed8e5de0082076562152a76b7a1f64a01fd9d1e0fea002c37624faf" dependencies = [ "bitflags", "cc", @@ -2029,9 +2039,9 @@ dependencies = [ [[package]] name = "nix" -version = "0.23.0" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f305c2c2e4c39a82f7bf0bf65fb557f9070ce06781d4f2454295cc34b1c43188" +checksum = "9f866317acbd3a240710c63f065ffb1e4fd466259045ccb504130b7f668f35c6" dependencies = [ "bitflags", "cc", @@ -2046,7 +2056,7 @@ version = "0.1.0" dependencies = [ "migration-helpers", "serde_json", - "snafu 0.7.0", + "snafu", ] [[package]] @@ -2160,14 +2170,23 @@ dependencies = [ [[package]] name = "num_cpus" -version = "1.13.0" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" +checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" dependencies = [ "hermit-abi", "libc", ] +[[package]] +name = "num_threads" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97ba99ba6393e2c3734791401b66902d981cb03bf190af674ca69949b6d5fb15" +dependencies = [ + "libc", +] + [[package]] name = "object" version = "0.27.1" @@ -2213,9 +2232,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" +checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5" [[package]] name = "opaque-debug" @@ -2231,9 +2250,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "openssl-probe" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28988d872ab76095a6e6ac88d99b54fd267702734fd7ffe610ca27f533ddb95a" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "parking_lot" @@ -2266,7 +2285,7 @@ version = "0.1.0" dependencies = [ "cargo-readme", "chrono", - "snafu 0.7.0", + "snafu", ] [[package]] @@ -2306,13 +2325,11 @@ dependencies = [ [[package]] name = "pem" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06673860db84d02a63942fa69cd9543f2624a5df3aea7f33173048fa7ad5cf1a" +checksum = "e9a3b09a20e374558580a4914d3b7d89bd61b954a5a5e1dcbea98753addb1947" dependencies = [ "base64", - "once_cell", - "regex", ] [[package]] @@ -2376,18 +2393,18 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.0.8" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "576bc800220cc65dac09e99e97b08b358cfab6e17078de8dc5fee223bd2d0c08" +checksum = "58ad3879ad3baf4e44784bc6a718a8698867bb991f8ce24d1bcbe2cfb4c3a75e" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.0.8" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e8fe8163d14ce7f0cdac2e040116f22eac817edabff0be91e8aff7e9accf389" +checksum = "744b6f092ba29c3650faf274db506afd39944f48420f6c86b17cfe0ee1cb36bb" dependencies = [ "proc-macro2", "quote", @@ -2396,9 +2413,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" +checksum = "e280fbe77cc62c91527259e9442153f4688736748d24660126286329742b4c6c" [[package]] name = "pin-utils" @@ -2418,15 +2435,15 @@ dependencies = [ "rusoto_core", "rusoto_eks", "serde_json", - "snafu 0.7.0", + "snafu", "tokio", ] [[package]] name = "ppv-lite86" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed0cfbc8191465bed66e1718596ee0b0b35d5ee1f41c5df2189d0fe8bde535ba" +checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" [[package]] name = "prairiedog" @@ -2435,10 +2452,10 @@ dependencies = [ "argh", "cargo-readme", "log", - "nix 0.23.0", + "nix 0.23.1", "signpost", "simplelog", - "snafu 0.7.0", + "snafu", ] [[package]] @@ -2465,23 +2482,11 @@ dependencies = [ "version_check", ] -[[package]] -name = "proc-macro-hack" -version = "0.5.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" - -[[package]] -name = "proc-macro-nested" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" - [[package]] name = "proc-macro2" -version = "1.0.32" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba508cc11742c0dc5c1659771673afbab7a0efab23aa17e854cbab0837ed0b43" +checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029" dependencies = [ "unicode-xid", ] @@ -2494,9 +2499,9 @@ checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" [[package]] name = "quote" -version = "1.0.10" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05" +checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145" dependencies = [ "proc-macro2", ] @@ -2608,9 +2613,9 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.11.6" +version = "0.11.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66d2927ca2f685faf0fc620ac4834690d29e7abb153add10f5812eef20b5e280" +checksum = "7c4e0a76dc12a116108933f6301b95e83634e0c47b0afbed6abbaa0601e99258" dependencies = [ "base64", "bytes", @@ -2620,7 +2625,7 @@ dependencies = [ "http", "http-body", "hyper", - "hyper-rustls", + "hyper-rustls 0.23.0", "ipnet", "js-sys", "lazy_static", @@ -2628,12 +2633,13 @@ dependencies = [ "mime", "percent-encoding", "pin-project-lite", - "rustls", + "rustls 0.20.2", + "rustls-pemfile", "serde", "serde_json", "serde_urlencoded", "tokio", - "tokio-rustls", + "tokio-rustls 0.23.2", "url", "wasm-bindgen", "wasm-bindgen-futures", @@ -2677,12 +2683,12 @@ dependencies = [ "futures", "http", "hyper", - "hyper-rustls", + "hyper-rustls 0.22.1", "lazy_static", "log", "rusoto_credential", "rusoto_signature", - "rustc_version 0.4.0", + "rustc_version", "serde", "serde_json", "tokio", @@ -2742,7 +2748,7 @@ dependencies = [ "percent-encoding", "pin-project-lite", "rusoto_credential", - "rustc_version 0.4.0", + "rustc_version", "serde", "sha2", "tokio", @@ -2754,22 +2760,13 @@ version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" -[[package]] -name = "rustc_version" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" -dependencies = [ - "semver 0.11.0", -] - [[package]] name = "rustc_version" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 1.0.4", + "semver", ] [[package]] @@ -2790,8 +2787,20 @@ dependencies = [ "base64", "log", "ring", - "sct", - "webpki", + "sct 0.6.1", + "webpki 0.21.4", +] + +[[package]] +name = "rustls" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d37e5e2290f3e040b594b1a9e04377c2c671f1a1cfd9bfdef82106ac1c113f84" +dependencies = [ + "log", + "ring", + "sct 0.7.0", + "webpki 0.22.0", ] [[package]] @@ -2801,16 +2810,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a07b7c1885bd8ed3831c289b7870b13ef46fe0e856d288c30d9cc17d75a2092" dependencies = [ "openssl-probe", - "rustls", + "rustls 0.19.1", "schannel", "security-framework", ] +[[package]] +name = "rustls-pemfile" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5eebeaeb360c87bfb72e84abdb3447159c0eaececf1bef2aecd65a8be949d1c9" +dependencies = [ + "base64", +] + [[package]] name = "ryu" -version = "1.0.5" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" +checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" [[package]] name = "same-file" @@ -2850,7 +2868,7 @@ dependencies = [ "percent-encoding", "serde", "serde_json", - "snafu 0.7.0", + "snafu", "tokio", "url", ] @@ -2871,11 +2889,21 @@ dependencies = [ "untrusted", ] +[[package]] +name = "sct" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" +dependencies = [ + "ring", + "untrusted", +] + [[package]] name = "security-framework" -version = "2.4.2" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525bc1abfda2e1998d152c45cf13e696f76d0a4972310b22fac1658b05df7c87" +checksum = "3fed7948b6c68acbb6e20c334f55ad635dc0f75506963de4464289fbd3b051ac" dependencies = [ "bitflags", "core-foundation", @@ -2886,23 +2914,14 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.4.2" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9dd14d83160b528b7bfd66439110573efcfbe281b17fc2ca9f39f550d619c7e" +checksum = "a57321bf8bc2362081b2599912d2961fe899c0efadf1b4b2f8d48b3e253bb96c" dependencies = [ "core-foundation-sys", "libc", ] -[[package]] -name = "semver" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" -dependencies = [ - "semver-parser", -] - [[package]] name = "semver" version = "1.0.4" @@ -2912,20 +2931,11 @@ dependencies = [ "serde", ] -[[package]] -name = "semver-parser" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" -dependencies = [ - "pest", -] - [[package]] name = "serde" -version = "1.0.130" +version = "1.0.136" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913" +checksum = "ce31e24b01e1e524df96f1c2fdd054405f8d7376249a5110886fb4b658484789" dependencies = [ "serde_derive", ] @@ -2944,9 +2954,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.130" +version = "1.0.136" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b" +checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9" dependencies = [ "proc-macro2", "quote", @@ -2955,11 +2965,11 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.69" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e466864e431129c7e0d3476b92f20458e5879919a0596c6472738d9fa2d342f8" +checksum = "d23c1ba4cf0efd44be32017709280b32d1cea5c3f1275c3b6d9e8bc54f758085" dependencies = [ - "itoa 0.4.8", + "itoa 1.0.1", "ryu", "serde", ] @@ -2975,12 +2985,12 @@ dependencies = [ [[package]] name = "serde_urlencoded" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edfa57a7f8d9c1d260a549e7224100f6c43d43f9103e06dd8b4095a9b2b43ce9" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" dependencies = [ "form_urlencoded", - "itoa 0.4.8", + "itoa 1.0.1", "ryu", "serde", ] @@ -2999,7 +3009,7 @@ dependencies = [ "serde", "serde_json", "simplelog", - "snafu 0.7.0", + "snafu", "tokio", ] @@ -3015,7 +3025,7 @@ dependencies = [ "serde", "serde_json", "simplelog", - "snafu 0.7.0", + "snafu", "tokio", ] @@ -3057,9 +3067,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.9.8" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b69f9a4c9740d74c5baa3fd2e547f9525fa8088a8a958e0ca2409a514e33f5fa" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" dependencies = [ "block-buffer 0.9.0", "cfg-if", @@ -3085,7 +3095,7 @@ dependencies = [ "serde", "serde_json", "simplelog", - "snafu 0.7.0", + "snafu", "tokio", ] @@ -3095,9 +3105,9 @@ version = "0.1.0" dependencies = [ "cargo-readme", "log", - "nix 0.23.0", + "nix 0.23.1", "simplelog", - "snafu 0.7.0", + "snafu", ] [[package]] @@ -3108,9 +3118,9 @@ checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" [[package]] name = "signal-hook" -version = "0.3.10" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c98891d737e271a2954825ef19e46bd16bdb98e2746f2eec4f7a4ef7946efd1" +checksum = "647c97df271007dcea485bb74ffdb57f2e683f1306c854f468a0c244badabf2d" dependencies = [ "libc", "signal-hook-registry", @@ -3135,7 +3145,7 @@ dependencies = [ "hex-literal", "serde", "serde_plain", - "snafu 0.7.0", + "snafu", ] [[package]] @@ -3157,19 +3167,9 @@ checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5" [[package]] name = "smallvec" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" - -[[package]] -name = "snafu" -version = "0.6.10" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eab12d3c261b2308b0d80c26fffb58d17eba81a4be97890101f416b478c79ca7" -dependencies = [ - "doc-comment", - "snafu-derive 0.6.10", -] +checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" [[package]] name = "snafu" @@ -3181,18 +3181,7 @@ dependencies = [ "doc-comment", "futures-core", "pin-project", - "snafu-derive 0.7.0", -] - -[[package]] -name = "snafu-derive" -version = "0.6.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1508efa03c362e23817f96cde18abed596a25219a8b2c66e8db33c03543d315b" -dependencies = [ - "proc-macro2", - "quote", - "syn", + "snafu-derive", ] [[package]] @@ -3220,9 +3209,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.4.2" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dc90fe6c7be1a323296982db1836d1ea9e47b6839496dde9a541bc496df3516" +checksum = "66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0" dependencies = [ "libc", "winapi", @@ -3247,7 +3236,7 @@ dependencies = [ "serde", "serde_json", "simplelog", - "snafu 0.7.0", + "snafu", "tempfile", "tokio", ] @@ -3270,9 +3259,9 @@ dependencies = [ "merge-toml", "models", "rand", - "semver 1.0.4", + "semver", "simplelog", - "snafu 0.7.0", + "snafu", "toml", "walkdir", ] @@ -3291,9 +3280,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "structopt" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40b9788f4202aa75c240ecc9c15c65185e6a39ccdeb0fd5d008b98825464c87c" +checksum = "0c6b5c64445ba8094a6ab0c3cd2ad323e07171012d9c98b0b15651daf1787a10" dependencies = [ "clap", "lazy_static", @@ -3333,15 +3322,15 @@ dependencies = [ "serde", "serde_json", "simplelog", - "snafu 0.7.0", + "snafu", "tokio", ] [[package]] name = "syn" -version = "1.0.81" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2afee18b8beb5a596ecb4a2dce128c719b4ba399d34126b9e4396e3f9860966" +checksum = "8a65b3f4ffa0092e9887669db0eae07941f023991ab58ea44da8fe8e2d511c6b" dependencies = [ "proc-macro2", "quote", @@ -3356,9 +3345,9 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tar" -version = "0.4.37" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6f5515d3add52e0bbdcad7b83c388bb36ba7b754dda3b5f5bc2d38640cdba5c" +checksum = "4b55807c0344e1e6c04d7c965f5289c39a8d94ae23ed5c0b57aabac549f871c6" dependencies = [ "filetime", "libc", @@ -3366,13 +3355,13 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.2.0" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" +checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" dependencies = [ "cfg-if", + "fastrand", "libc", - "rand", "redox_syscall", "remove_dir_all", "winapi", @@ -3409,11 +3398,11 @@ dependencies = [ "log", "maplit", "models", - "nix 0.23.0", + "nix 0.23.1", "schnauzer", "serde_json", "simplelog", - "snafu 0.7.0", + "snafu", "tokio", ] @@ -3430,16 +3419,16 @@ dependencies = [ "http", "log", "models", - "nix 0.23.0", + "nix 0.23.1", "num-derive", "num-traits", - "semver 1.0.4", + "semver", "serde", "serde_json", "serde_plain", "signpost", "simplelog", - "snafu 0.7.0", + "snafu", "tempfile", "tokio", "update_metadata", @@ -3477,19 +3466,20 @@ dependencies = [ [[package]] name = "time" -version = "0.3.4" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99beeb0daeac2bd1e86ac2c21caddecb244b39a093594da1a661ec2060c7aedd" +checksum = "004cbc98f30fa233c61a38bc77e96a9106e65c88f2d3bef182ae952027e5753d" dependencies = [ - "itoa 0.4.8", + "itoa 1.0.1", "libc", + "num_threads", ] [[package]] name = "tinyvec" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83b2a3d4d9091d0abd7eba4dc2710b1718583bd4d8992e2190720ea38f391f7" +checksum = "2c1c1d5a42b6245520c249549ec267180beaffcc0615401ac8e31853d4b6d8d2" dependencies = [ "tinyvec_macros", ] @@ -3548,9 +3538,20 @@ version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc6844de72e57df1980054b38be3a9f4702aba4858be64dd700181a8a6d0e1b6" dependencies = [ - "rustls", + "rustls 0.19.1", + "tokio", + "webpki 0.21.4", +] + +[[package]] +name = "tokio-rustls" +version = "0.23.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a27d5f2b839802bd8267fa19b0530f5a08b9c08cd417976be2a65d130fe1c11b" +dependencies = [ + "rustls 0.20.2", "tokio", - "webpki", + "webpki 0.22.0", ] [[package]] @@ -3615,9 +3616,9 @@ dependencies = [ [[package]] name = "tough" -version = "0.12.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99488309ba53ee931b6ccda1cde07feaab95f214d328e3a7244c0f7563b5909f" +checksum = "708125a84e70820bccc5fc11d7196664415be2b02b81ba6946e70e10803aa4da" dependencies = [ "chrono", "dyn-clone", @@ -3626,14 +3627,14 @@ dependencies = [ "log", "olpc-cjson", "path-absolutize", - "pem 1.0.1", + "pem 1.0.2", "percent-encoding", "reqwest", "ring", "serde", "serde_json", "serde_plain", - "snafu 0.6.10", + "snafu", "tempfile", "untrusted", "url", @@ -3693,9 +3694,9 @@ dependencies = [ [[package]] name = "typenum" -version = "1.14.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b63708a265f51345575b27fe43f9500ad611579e764c79edbc2037b1121959ec" +checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" [[package]] name = "ucd-trie" @@ -3755,11 +3756,11 @@ dependencies = [ "chrono", "parse-datetime", "regex", - "semver 1.0.4", + "semver", "serde", "serde_json", "serde_plain", - "snafu 0.7.0", + "snafu", "toml", ] @@ -3774,14 +3775,14 @@ dependencies = [ "models", "rand", "reqwest", - "semver 1.0.4", + "semver", "serde", "serde_json", "serde_plain", "signal-hook", "signpost", "simplelog", - "snafu 0.7.0", + "snafu", "structopt", "tempfile", "toml", @@ -3816,9 +3817,9 @@ checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" [[package]] name = "version_check" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "vmw_backdoor" @@ -3871,9 +3872,9 @@ checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" [[package]] name = "wasm-bindgen" -version = "0.2.78" +version = "0.2.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce" +checksum = "25f1af7423d8588a3d840681122e72e6a24ddbcb3f0ec385cac0d12d24256c06" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -3881,9 +3882,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.78" +version = "0.2.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a317bf8f9fba2476b4b2c85ef4c4af8ff39c3c7f0cdfeed4f82c34a880aa837b" +checksum = "8b21c0df030f5a177f3cba22e9bc4322695ec43e7257d865302900290bcdedca" dependencies = [ "bumpalo", "lazy_static", @@ -3896,9 +3897,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.28" +version = "0.4.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e8d7523cb1f2a4c96c1317ca690031b714a51cc14e05f712446691f413f5d39" +checksum = "2eb6ec270a31b1d3c7e266b999739109abce8b6c87e4b31fcfcd788b65267395" dependencies = [ "cfg-if", "js-sys", @@ -3908,9 +3909,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.78" +version = "0.2.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9" +checksum = "2f4203d69e40a52ee523b2529a773d5ffc1dc0071801c87b3d270b471b80ed01" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3918,9 +3919,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.78" +version = "0.2.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab" +checksum = "bfa8a30d46208db204854cadbb5d4baf5fcf8071ba5bf48190c3e59937962ebc" dependencies = [ "proc-macro2", "quote", @@ -3931,15 +3932,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.78" +version = "0.2.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0237232789cf037d5480773fe568aac745bfe2afbc11a863e97901780a6b47cc" +checksum = "3d958d035c4438e28c70e4321a2911302f10135ce78a9c7834c0cab4123d06a2" [[package]] name = "web-sys" -version = "0.3.55" +version = "0.3.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38eb105f1c59d9eaa6b5cdc92b859d85b926e82cb2e0945cd0c9259faa6fe9fb" +checksum = "c060b319f29dd25724f09a2ba1418f142f539b2be99fbf4d2d5a8f7330afb8eb" dependencies = [ "js-sys", "wasm-bindgen", @@ -3955,14 +3956,24 @@ dependencies = [ "untrusted", ] +[[package]] +name = "webpki" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" +dependencies = [ + "ring", + "untrusted", +] + [[package]] name = "webpki-roots" -version = "0.21.1" +version = "0.22.2" dependencies = [ "lazy_static", "log", "pem 0.8.3", - "webpki", + "webpki 0.21.4", ] [[package]] @@ -4036,6 +4047,6 @@ checksum = "d2d7d3948613f75c98fd9328cfdcc45acc4d360655289d0a7d4ec931392200a3" [[package]] name = "zeroize" -version = "1.4.3" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d68d9dcec5f9b43a30d38c49f91dfedfaac384cb8f085faca366c26207dd1619" +checksum = "7c88870063c39ee00ec285a2f8d6a966e5b6fb2becc4e8dac77ed0d370ed6006" diff --git a/sources/clarify.toml b/sources/clarify.toml index bc759245aa5..9c38affdca5 100644 --- a/sources/clarify.toml +++ b/sources/clarify.toml @@ -53,6 +53,18 @@ license-files = [ { path = "LICENSE-THIRD-PARTY", hash = 0x847bf39 }, ] +# https://github.com/hsivonen/encoding_rs The non-test code that isn't generated from the WHATWG data in this crate is +# under Apache-2.0 OR MIT. Test code is under CC0. +[clarify.encoding_rs] +expression = "(Apache-2.0 OR MIT) AND BSD-3-Clause" +license-files = [ + { path = "COPYRIGHT", hash = 0x39f8ad31 }, + { path = "LICENSE-APACHE", hash = 0x18785531 }, + { path = "LICENSE-MIT", hash = 0xafaec4cb }, + { path = "LICENSE-WHATWG", hash = 0xbcb87a0c }, + { path = "COPYRIGHT", hash = 0x39f8ad31 }, +] + [clarify.lz4-sys] # The lz4-sys crate's license is listed as MIT. # diff --git a/sources/deny.toml b/sources/deny.toml index ceb49ec189a..8d701183a90 100644 --- a/sources/deny.toml +++ b/sources/deny.toml @@ -22,6 +22,16 @@ allow = [ "Zlib" ] +# https://github.com/hsivonen/encoding_rs The non-test code that isn't generated from the WHATWG data in this crate is +# under Apache-2.0 OR MIT. Test code is under CC0. +[[licenses.clarify]] +name = "encoding_rs" +version = "0.8.30" +expression = "(Apache-2.0 OR MIT) AND BSD-3-Clause" +license-files = [ + { path = "COPYRIGHT", hash = 0x39f8ad31 } +] + [[licenses.clarify]] name = "ring" expression = "MIT AND ISC AND OpenSSL" @@ -67,8 +77,8 @@ skip-tree = [ # semver, for build vs. runtime dependencies. { name = "actix-http", version = "3.0.0-rc.1" }, - # snafu uses older versions of some crates, note we will update to snafu 0.7 soon - { name = "snafu", version = "0.6" }, + # rusoto is using a different version of reqwest. + { name = "rusoto_core", version = "0.47.0" }, ] [sources] diff --git a/sources/webpki-roots-shim/Cargo.toml b/sources/webpki-roots-shim/Cargo.toml index dd1477c722a..d9a6efc0cc9 100644 --- a/sources/webpki-roots-shim/Cargo.toml +++ b/sources/webpki-roots-shim/Cargo.toml @@ -9,7 +9,7 @@ name = "webpki-roots" # # You should also double-check sources/Cargo.lock to make sure there aren't two versions of # webpki-roots being used (which would mean that one of them came from crates.io instead of here). -version = "0.21.1" +version = "0.22.2" authors = ["iliana destroyer of worlds "] license = "Apache-2.0 OR MIT" edition = "2018" From f44cdf4205a87f73eb73c9c12ff1594b70cd956c Mon Sep 17 00:00:00 2001 From: Matthew James Briggs Date: Wed, 2 Feb 2022 18:37:30 -0800 Subject: [PATCH 5/8] sources: cargo outdated Update major versions that are outdated. --- sources/Cargo.lock | 113 +++++--------------- sources/api/apiclient/Cargo.toml | 4 +- sources/api/apiserver/Cargo.toml | 2 +- sources/api/bootstrap-containers/Cargo.toml | 2 +- sources/api/certdog/Cargo.toml | 4 +- sources/api/corndog/Cargo.toml | 2 +- sources/api/early-boot-config/Cargo.toml | 2 +- sources/api/host-containers/Cargo.toml | 2 +- sources/api/migration/migrator/Cargo.toml | 2 +- sources/api/servicedog/Cargo.toml | 2 +- sources/api/settings-committer/Cargo.toml | 2 +- sources/api/shibaken/Cargo.toml | 2 +- sources/api/static-pods/Cargo.toml | 2 +- sources/api/storewolf/Cargo.toml | 2 +- sources/api/sundog/Cargo.toml | 2 +- sources/api/thar-be-settings/Cargo.toml | 2 +- sources/api/thar-be-updates/Cargo.toml | 2 +- sources/clarify.toml | 8 ++ sources/driverdog/Cargo.toml | 2 +- sources/growpart/Cargo.toml | 2 +- sources/metricdog/Cargo.toml | 2 +- sources/models/Cargo.toml | 2 +- sources/prairiedog/Cargo.toml | 2 +- sources/shimpei/Cargo.toml | 2 +- sources/updater/updog/Cargo.toml | 2 +- 25 files changed, 60 insertions(+), 111 deletions(-) diff --git a/sources/Cargo.lock b/sources/Cargo.lock index 29ec2c060f3..6ad3f64029a 100644 --- a/sources/Cargo.lock +++ b/sources/Cargo.lock @@ -366,12 +366,6 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6f8c380fa28aa1b36107cd97f0196474bb7241bb95a453c5c01a15ac74b2eac" -[[package]] -name = "arrayvec" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" - [[package]] name = "async-stream" version = "0.3.2" @@ -463,18 +457,6 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" -[[package]] -name = "bitvec" -version = "0.19.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55f93d0ef3363c364d5976646a38f04cf67cfe1d4c8d160cdea02cab2c116b33" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - [[package]] name = "block-buffer" version = "0.7.3" @@ -888,11 +870,10 @@ dependencies = [ [[package]] name = "der-oid-macro" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4cccf60bb98c0fca115a581f894aed0e43fa55bf289fdac5599bec440bb4fd6" +checksum = "c73af209b6a5dc8ca7cbaba720732304792cddc933cfea3d74509c2b1ef2f436" dependencies = [ - "nom", "num-bigint", "num-traits", "syn", @@ -900,9 +881,9 @@ dependencies = [ [[package]] name = "der-parser" -version = "5.1.2" +version = "6.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d7ededb7525bb4114bc209685ce7894edc2965f4914312a1ea578a645a237f0" +checksum = "4cddf120f700b411b2b02ebeb7f04dc0b7c8835909a6c2f52bf72ed0dd3433b2" dependencies = [ "der-oid-macro", "nom", @@ -1176,12 +1157,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "funty" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" - [[package]] name = "futures" version = "0.3.19" @@ -1643,9 +1618,9 @@ dependencies = [ [[package]] name = "inotify" -version = "0.9.6" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8069d3ec154eb856955c1c0fbffefbf5f3c40a104ec912d4797314c1801abff" +checksum = "abf888f9575c290197b2c948dc9e9ff10bd1a39ad1ea8585f734585fa6b9d3f9" dependencies = [ "bitflags", "futures-core", @@ -1723,19 +1698,6 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -[[package]] -name = "lexical-core" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6607c62aa161d23d17a9072cc5da0be67cdfc89d3afb1e8d9c842bebc2525ffe" -dependencies = [ - "arrayvec", - "bitflags", - "cfg-if", - "ryu", - "static_assertions", -] - [[package]] name = "libc" version = "0.2.117" @@ -1928,6 +1890,12 @@ version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + [[package]] name = "miniz_oxide" version = "0.4.4" @@ -2061,14 +2029,12 @@ dependencies = [ [[package]] name = "nom" -version = "6.1.2" +version = "7.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7413f999671bd4745a7b624bd370a569fb6bc574b23c83a3c5ed2e453f3d5e2" +checksum = "1b1d11e1ef389c76fe5b81bcaf2ea32cf88b62bc494e19f493d0b30e7a930109" dependencies = [ - "bitvec", - "funty", - "lexical-core", "memchr", + "minimal-lexical", "version_check", ] @@ -2212,9 +2178,9 @@ dependencies = [ [[package]] name = "oid-registry" -version = "0.1.5" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6aae73e474f83beacd8ae2179e328e03d63d9223949d97e1b7c108059a34715" +checksum = "fe554cb2393bc784fd678c82c84cc0599c31ceadc7f03a594911f822cb8d1815" dependencies = [ "der-parser", ] @@ -2506,12 +2472,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "radium" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "941ba9d78d8e2f7ce474c015eea4d9c6d25b6a3327f9832ee29a4de27f91bbb8" - [[package]] name = "rand" version = "0.8.4" @@ -2771,9 +2731,9 @@ dependencies = [ [[package]] name = "rusticata-macros" -version = "3.2.0" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbbee512c633ecabd4481c40111b6ded03ddd9ab10ba6caa5a74e14c889921ad" +checksum = "65c52377bb2288aa522a0c8208947fada1e0c76397f108cc08f57efe6077b50d" dependencies = [ "nom", ] @@ -3150,9 +3110,9 @@ dependencies = [ [[package]] name = "simplelog" -version = "0.10.2" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85d04ae642154220ef00ee82c36fb07853c10a4f2a0ca6719f9991211d2eb959" +checksum = "c1348164456f72ca0116e4538bdaabb0ddb622c7d9f16387c725af3e96d6001c" dependencies = [ "chrono", "log", @@ -3241,12 +3201,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - [[package]] name = "storewolf" version = "0.1.0" @@ -3337,12 +3291,6 @@ dependencies = [ "unicode-xid", ] -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - [[package]] name = "tar" version = "0.4.38" @@ -3580,13 +3528,12 @@ dependencies = [ [[package]] name = "tokio-tungstenite" -version = "0.15.0" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "511de3f85caf1c98983545490c3d09685fa8eb634e57eec22bb4db271f46cbd8" +checksum = "e80b39df6afcc12cdf752398ade96a6b9e99c903dfdc36e53ad10b9c366bca72" dependencies = [ "futures-util", "log", - "pin-project", "tokio", "tungstenite", ] @@ -3675,9 +3622,9 @@ checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" [[package]] name = "tungstenite" -version = "0.14.0" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0b2d8558abd2e276b0a8df5c05a2ec762609344191e5fd23e292c910e9165b5" +checksum = "6ad3713a14ae247f22a728a0456a545df14acf3867f905adff84be99e23b3ad1" dependencies = [ "base64", "byteorder", @@ -4016,17 +3963,11 @@ dependencies = [ "winapi", ] -[[package]] -name = "wyz" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214" - [[package]] name = "x509-parser" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2ce30cd4a10592affdced3f5c95e03e8f23599d282e727fc44035c21250d552" +checksum = "ffc90836a84cb72e6934137b1504d0cae304ef5d83904beb0c8d773bbfe256ed" dependencies = [ "base64", "chrono", diff --git a/sources/api/apiclient/Cargo.toml b/sources/api/apiclient/Cargo.toml index e4d318c6014..1a33eef134a 100644 --- a/sources/api/apiclient/Cargo.toml +++ b/sources/api/apiclient/Cargo.toml @@ -30,10 +30,10 @@ retry-read = { path = "../../retry-read", version = "0.1.0" } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" signal-hook = "0.3" -simplelog = "0.10" +simplelog = "0.11" snafu = { version = "0.7", features = ["futures"] } tokio = { version = "~1.14", default-features = false, features = ["fs", "io-std", "io-util", "macros", "rt-multi-thread", "time"] } # LTS -tokio-tungstenite = { version = "0.15", default-features = false, features = ["connect"] } +tokio-tungstenite = { version = "0.16", default-features = false, features = ["connect"] } toml = "0.5" unindent = "0.1" url = "2.2.1" diff --git a/sources/api/apiserver/Cargo.toml b/sources/api/apiserver/Cargo.toml index 7261e2d82ca..89c42c5e81a 100644 --- a/sources/api/apiserver/Cargo.toml +++ b/sources/api/apiserver/Cargo.toml @@ -30,7 +30,7 @@ rand = "0.8" semver = "1.0" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -simplelog = "0.10" +simplelog = "0.11" snafu = "0.7" thar-be-updates = { path = "../thar-be-updates", version = "0.1.0" } walkdir = "2.2" diff --git a/sources/api/bootstrap-containers/Cargo.toml b/sources/api/bootstrap-containers/Cargo.toml index d2172d9bc58..2176747ca11 100644 --- a/sources/api/bootstrap-containers/Cargo.toml +++ b/sources/api/bootstrap-containers/Cargo.toml @@ -19,7 +19,7 @@ log = "0.4" models = { path = "../../models", version = "0.1.0" } serde = { version = "1.0", features = ["derive"] } serde_json = "1" -simplelog = "0.10" +simplelog = "0.11" snafu = "0.7" tokio = { version = "~1.14", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS diff --git a/sources/api/certdog/Cargo.toml b/sources/api/certdog/Cargo.toml index 7995fc58702..fd8f9df22b0 100644 --- a/sources/api/certdog/Cargo.toml +++ b/sources/api/certdog/Cargo.toml @@ -19,10 +19,10 @@ log = "0.4" models = { path = "../../models", version = "0.1.0" } serde = { version = "1.0", features = ["derive"] } serde_json = "1" -simplelog = "0.10" +simplelog = "0.11" snafu = "0.7" tokio = { version = "~1.14", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS -x509-parser = "0.11.0" +x509-parser = "0.12" [dev-dependencies] tempfile = "3.2.0" diff --git a/sources/api/corndog/Cargo.toml b/sources/api/corndog/Cargo.toml index 6a15628987e..957e2181c95 100644 --- a/sources/api/corndog/Cargo.toml +++ b/sources/api/corndog/Cargo.toml @@ -17,7 +17,7 @@ log = "0.4" models = { path = "../../models", version = "0.1.0" } serde = { version = "1.0", features = ["derive"] } serde_json = "1" -simplelog = "0.10" +simplelog = "0.11" snafu = "0.7" tokio = { version = "~1.14", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS diff --git a/sources/api/early-boot-config/Cargo.toml b/sources/api/early-boot-config/Cargo.toml index 83b462f46e5..5cd60ff01ea 100644 --- a/sources/api/early-boot-config/Cargo.toml +++ b/sources/api/early-boot-config/Cargo.toml @@ -23,7 +23,7 @@ serde = { version = "1.0", features = ["derive"] } serde_json = "1" serde_plain = "1.0" serde-xml-rs = "0.5" -simplelog = "0.10" +simplelog = "0.11" snafu = "0.7" tokio = { version = "~1.14", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS toml = "0.5" diff --git a/sources/api/host-containers/Cargo.toml b/sources/api/host-containers/Cargo.toml index eb93fe33d1d..08b93bfac66 100644 --- a/sources/api/host-containers/Cargo.toml +++ b/sources/api/host-containers/Cargo.toml @@ -18,7 +18,7 @@ log = "0.4" models = { path = "../../models", version = "0.1.0" } serde = { version = "1.0", features = ["derive"] } serde_json = "1" -simplelog = "0.10" +simplelog = "0.11" snafu = "0.7" tokio = { version = "~1.14", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS diff --git a/sources/api/migration/migrator/Cargo.toml b/sources/api/migration/migrator/Cargo.toml index a7e3f6f4e89..55e9ffc1987 100644 --- a/sources/api/migration/migrator/Cargo.toml +++ b/sources/api/migration/migrator/Cargo.toml @@ -18,7 +18,7 @@ pentacle = "1.0.0" rand = { version = "0.8", default-features = false, features = ["std", "std_rng"] } regex = "1.1" semver = "1.0" -simplelog = "0.10" +simplelog = "0.11" snafu = "0.7" tough = "0.12" update_metadata = { path = "../../../updater/update_metadata", version = "0.1.0" } diff --git a/sources/api/servicedog/Cargo.toml b/sources/api/servicedog/Cargo.toml index 98ac6310c56..d1d853b1a51 100644 --- a/sources/api/servicedog/Cargo.toml +++ b/sources/api/servicedog/Cargo.toml @@ -18,7 +18,7 @@ log = "0.4" models = { path = "../../models", version = "0.1.0" } serde = { version = "1.0", features = ["derive"] } serde_json = "1" -simplelog = "0.10" +simplelog = "0.11" snafu = "0.7" tokio = { version = "~1.14", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS diff --git a/sources/api/settings-committer/Cargo.toml b/sources/api/settings-committer/Cargo.toml index de9bfb009e9..f346075de44 100644 --- a/sources/api/settings-committer/Cargo.toml +++ b/sources/api/settings-committer/Cargo.toml @@ -17,7 +17,7 @@ http = "0.2" log = "0.4" serde = { version = "1.0", features = ["derive"] } serde_json = "1" -simplelog = "0.10" +simplelog = "0.11" tokio = { version = "~1.14", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS [build-dependencies] diff --git a/sources/api/shibaken/Cargo.toml b/sources/api/shibaken/Cargo.toml index 1081f0fb90a..02dd49b0ca1 100644 --- a/sources/api/shibaken/Cargo.toml +++ b/sources/api/shibaken/Cargo.toml @@ -15,7 +15,7 @@ imdsclient = { path = "../../imdsclient", version = "0.1.0" } log = "0.4" serde = { version = "1.0", features = ["derive"] } serde_json = "1" -simplelog = "0.10" +simplelog = "0.11" snafu = "0.7" tokio = { version = "~1.14", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS diff --git a/sources/api/static-pods/Cargo.toml b/sources/api/static-pods/Cargo.toml index e794cdaa578..1587f3ccf28 100644 --- a/sources/api/static-pods/Cargo.toml +++ b/sources/api/static-pods/Cargo.toml @@ -17,7 +17,7 @@ models = { path = "../../models", version = "0.1.0" } schnauzer = { path = "../schnauzer", version = "0.1.0" } serde = { version = "1.0", features = ["derive"] } serde_json = "1" -simplelog = "0.10" +simplelog = "0.11" snafu = "0.7" tokio = { version = "~1.14", default-features = false, features = ["macros", "rt-multi-thread", "time"] } # LTS tempfile = "3.2.0" diff --git a/sources/api/storewolf/Cargo.toml b/sources/api/storewolf/Cargo.toml index 2f5ca12daf5..e830351b031 100644 --- a/sources/api/storewolf/Cargo.toml +++ b/sources/api/storewolf/Cargo.toml @@ -17,7 +17,7 @@ log = "0.4" models = { path = "../../models", version = "0.1.0" } rand = { version = "0.8", default-features = false, features = ["std", "std_rng"] } semver = "1.0" -simplelog = "0.10" +simplelog = "0.11" snafu = "0.7" toml = "0.5" diff --git a/sources/api/sundog/Cargo.toml b/sources/api/sundog/Cargo.toml index 92ae32565fd..48bf4449cb2 100644 --- a/sources/api/sundog/Cargo.toml +++ b/sources/api/sundog/Cargo.toml @@ -18,7 +18,7 @@ log = "0.4" models = { path = "../../models", version = "0.1.0" } serde = { version = "1.0", features = ["derive"] } serde_json = "1" -simplelog = "0.10" +simplelog = "0.11" snafu = "0.7" tokio = { version = "~1.14", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS diff --git a/sources/api/thar-be-settings/Cargo.toml b/sources/api/thar-be-settings/Cargo.toml index 2a843a7731b..d4931a27afd 100644 --- a/sources/api/thar-be-settings/Cargo.toml +++ b/sources/api/thar-be-settings/Cargo.toml @@ -20,7 +20,7 @@ models = { path = "../../models", version = "0.1.0" } nix = "0.23" schnauzer = { path = "../schnauzer", version = "0.1.0" } serde_json = "1" -simplelog = "0.10" +simplelog = "0.11" snafu = "0.7" tokio = { version = "~1.14", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS diff --git a/sources/api/thar-be-updates/Cargo.toml b/sources/api/thar-be-updates/Cargo.toml index 0bf454c05fa..6a39b4fa0ec 100644 --- a/sources/api/thar-be-updates/Cargo.toml +++ b/sources/api/thar-be-updates/Cargo.toml @@ -26,7 +26,7 @@ serde = { version = "1.0.111", features = [ "derive" ] } serde_json = "1.0.53" serde_plain = "1.0" signpost = { path = "../../updater/signpost", version = "0.1.0" } -simplelog = "0.10" +simplelog = "0.11" snafu = "0.7" tempfile = "3.1.0" tokio = { version = "~1.14", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS diff --git a/sources/clarify.toml b/sources/clarify.toml index 9c38affdca5..356d3bf15b9 100644 --- a/sources/clarify.toml +++ b/sources/clarify.toml @@ -90,6 +90,14 @@ skip-files = [ "liblz4/tests/COPYING", ] +[clarify.minimal-lexical] +expression = "MIT OR Apache-2.0" +license-files = [ + { path = "LICENSE.md", hash = 0xfe66d806 }, + { path = "LICENSE-APACHE", hash = 0x4fccb6b7 }, + { path = "LICENSE-MIT", hash = 0x386ca1bc }, +] + [clarify.pulldown-cmark] expression = "MIT" license-files = [ diff --git a/sources/driverdog/Cargo.toml b/sources/driverdog/Cargo.toml index 9c103283439..aaacf668400 100644 --- a/sources/driverdog/Cargo.toml +++ b/sources/driverdog/Cargo.toml @@ -11,7 +11,7 @@ exclude = ["README.md"] [dependencies] argh = "0.1.3" log = "0.4" -simplelog = "0.10" +simplelog = "0.11" snafu = "0.7" serde = { version = "1.0", features = ["derive"] } tempfile = "3.2.0" diff --git a/sources/growpart/Cargo.toml b/sources/growpart/Cargo.toml index 73a7806d43c..c539d7d60de 100644 --- a/sources/growpart/Cargo.toml +++ b/sources/growpart/Cargo.toml @@ -13,7 +13,7 @@ gptman = { version = "0.8.2", default-features = false } snafu = "0.7" libc = "0.2" block-party = { path = "../updater/block-party", version = "0.1.0" } -inotify = "0.9" +inotify = "0.10" [build-dependencies] cargo-readme = "3.1" diff --git a/sources/metricdog/Cargo.toml b/sources/metricdog/Cargo.toml index 4e651a135f8..8a01b1d199c 100644 --- a/sources/metricdog/Cargo.toml +++ b/sources/metricdog/Cargo.toml @@ -13,7 +13,7 @@ bottlerocket-release = { path = "../bottlerocket-release", version = "0.1.0" } log = "0.4" reqwest = { version = "0.11.1", default-features = false, features = ["blocking", "rustls-tls"] } serde = { version = "1.0.100", features = ["derive"] } -simplelog = "0.10" +simplelog = "0.11" snafu = { version = "0.7" } structopt = "0.3.17" toml = "0.5.1" diff --git a/sources/models/Cargo.toml b/sources/models/Cargo.toml index 3f7c36937e2..8b60c592ca2 100644 --- a/sources/models/Cargo.toml +++ b/sources/models/Cargo.toml @@ -21,7 +21,7 @@ serde = { version = "1.0", features = ["derive"] } serde_plain = "1.0" snafu = "0.7" toml = "0.5" -x509-parser = "0.11.0" +x509-parser = "0.12" url = "2.1" [build-dependencies] diff --git a/sources/prairiedog/Cargo.toml b/sources/prairiedog/Cargo.toml index 161c386dc01..2f8073f91f7 100644 --- a/sources/prairiedog/Cargo.toml +++ b/sources/prairiedog/Cargo.toml @@ -13,7 +13,7 @@ argh = "0.1.3" log = "0.4" nix = "0.23" signpost = { path = "../updater/signpost", version = "0.1.0" } -simplelog = "0.10" +simplelog = "0.11" snafu = "0.7" [build-dependencies] diff --git a/sources/shimpei/Cargo.toml b/sources/shimpei/Cargo.toml index cddc9b8dfc3..4fe4c034e6f 100644 --- a/sources/shimpei/Cargo.toml +++ b/sources/shimpei/Cargo.toml @@ -10,7 +10,7 @@ exclude = ["README.md"] [dependencies] log = "0.4" -simplelog = "0.10" +simplelog = "0.11" snafu = "0.7" nix = "0.23" diff --git a/sources/updater/updog/Cargo.toml b/sources/updater/updog/Cargo.toml index 1b27e323643..a4a9facebb2 100644 --- a/sources/updater/updog/Cargo.toml +++ b/sources/updater/updog/Cargo.toml @@ -20,7 +20,7 @@ serde = { version = "1.0.100", features = ["derive"] } serde_json = "1.0.40" serde_plain = "1.0" signpost = { path = "../signpost", version = "0.1.0" } -simplelog = "0.10" +simplelog = "0.11" snafu = "0.7" toml = "0.5.1" tough = { version = "0.12", features = ["http"] } From d23dd20b4b601a90d66d48a291658a1b7a73123a Mon Sep 17 00:00:00 2001 From: Matthew James Briggs Date: Wed, 2 Feb 2022 18:45:27 -0800 Subject: [PATCH 6/8] tools: update snafu to 0.7 --- tools/Cargo.lock | 10 +- tools/buildsys/Cargo.toml | 2 +- tools/buildsys/src/builder.rs | 34 ++++--- tools/buildsys/src/builder/error.rs | 2 +- tools/buildsys/src/cache.rs | 35 ++++--- tools/buildsys/src/cache/error.rs | 2 +- tools/buildsys/src/main.rs | 24 ++--- tools/buildsys/src/manifest.rs | 5 +- tools/buildsys/src/manifest/error.rs | 2 +- tools/buildsys/src/project.rs | 2 +- tools/buildsys/src/project/error.rs | 2 +- tools/buildsys/src/spec.rs | 4 +- tools/buildsys/src/spec/error.rs | 2 +- tools/infrasys/Cargo.toml | 2 +- tools/infrasys/src/error.rs | 2 +- tools/infrasys/src/keys.rs | 37 +++---- tools/infrasys/src/main.rs | 46 ++++----- tools/infrasys/src/root.rs | 20 ++-- tools/infrasys/src/s3.rs | 38 ++++---- tools/infrasys/src/shared.rs | 16 +-- .../test_tomls/toml_yaml_conversion.yml | 40 ++++++++ tools/pubsys-config/Cargo.toml | 2 +- tools/pubsys-config/src/lib.rs | 16 +-- tools/pubsys-config/src/vmware.rs | 10 +- tools/pubsys-setup/Cargo.toml | 2 +- tools/pubsys-setup/src/main.rs | 62 ++++++------ tools/pubsys/Cargo.toml | 2 +- tools/pubsys/src/aws/ami/mod.rs | 64 ++++++------ tools/pubsys/src/aws/ami/register.rs | 22 +++-- tools/pubsys/src/aws/ami/snapshot.rs | 6 +- tools/pubsys/src/aws/ami/wait.rs | 20 ++-- tools/pubsys/src/aws/client.rs | 12 +-- tools/pubsys/src/aws/mod.rs | 6 +- tools/pubsys/src/aws/promote_ssm/mod.rs | 28 +++--- tools/pubsys/src/aws/publish_ami/mod.rs | 58 +++++------ tools/pubsys/src/aws/ssm/mod.rs | 36 +++---- tools/pubsys/src/aws/ssm/ssm.rs | 16 +-- tools/pubsys/src/aws/ssm/template.rs | 20 ++-- tools/pubsys/src/main.rs | 38 +++++--- tools/pubsys/src/repo.rs | 97 ++++++++++--------- .../pubsys/src/repo/check_expirations/mod.rs | 14 +-- tools/pubsys/src/repo/refresh_repo/mod.rs | 30 +++--- tools/pubsys/src/repo/validate_repo/mod.rs | 22 ++--- tools/pubsys/src/vmware/govc.rs | 8 +- tools/pubsys/src/vmware/upload_ova/mod.rs | 26 ++--- 45 files changed, 507 insertions(+), 437 deletions(-) create mode 100644 tools/infrasys/test_tomls/toml_yaml_conversion.yml diff --git a/tools/Cargo.lock b/tools/Cargo.lock index b9602c4ff3a..627d9a1b9a3 100644 --- a/tools/Cargo.lock +++ b/tools/Cargo.lock @@ -161,7 +161,7 @@ dependencies = [ "serde", "serde_plain", "sha2", - "snafu 0.6.10", + "snafu 0.7.0", "toml", "url", "walkdir", @@ -792,7 +792,7 @@ dependencies = [ "sha2", "shell-words", "simplelog", - "snafu 0.6.10", + "snafu 0.7.0", "structopt", "tokio", "toml", @@ -1195,7 +1195,7 @@ dependencies = [ "serde", "serde_json", "simplelog", - "snafu 0.6.10", + "snafu 0.7.0", "structopt", "tempfile", "tinytemplate", @@ -1220,7 +1220,7 @@ dependencies = [ "parse-datetime", "serde", "serde_yaml", - "snafu 0.6.10", + "snafu 0.7.0", "toml", "url", ] @@ -1236,7 +1236,7 @@ dependencies = [ "sha2", "shell-words", "simplelog", - "snafu 0.6.10", + "snafu 0.7.0", "structopt", "tempfile", "toml", diff --git a/tools/buildsys/Cargo.toml b/tools/buildsys/Cargo.toml index bd7ae3d10ec..3fd048ec100 100644 --- a/tools/buildsys/Cargo.toml +++ b/tools/buildsys/Cargo.toml @@ -18,7 +18,7 @@ reqwest = { version = "0.11.1", default-features = false, features = ["rustls-tl serde = { version = "1.0", features = ["derive"] } serde_plain = "1.0" sha2 = "0.9" -snafu = "0.6" +snafu = "0.7" toml = "0.5" url = { version = "2.1.0", features = ["serde"] } walkdir = "2" diff --git a/tools/buildsys/src/builder.rs b/tools/buildsys/src/builder.rs index 293bd561302..28da087a9bc 100644 --- a/tools/buildsys/src/builder.rs +++ b/tools/buildsys/src/builder.rs @@ -77,18 +77,18 @@ impl PackageBuilder { let output_dir: PathBuf = getenv("BUILDSYS_PACKAGES_DIR")?.into(); let arch = getenv("BUILDSYS_ARCH")?; let goarch = serde_plain::from_str::(&arch) - .context(error::UnsupportedArch { arch: &arch })? + .context(error::UnsupportedArchSnafu { arch: &arch })? .goarch(); // We do *not* want to rebuild most packages when the variant changes, because most aren't // affected; packages that care about variant should "echo cargo:rerun-if-env-changed=VAR" // themselves in the package's spec file. let var = "BUILDSYS_VARIANT"; - let variant = env::var(var).context(error::Environment { var })?; + let variant = env::var(var).context(error::EnvironmentSnafu { var })?; // Same for repo, which is used to determine the correct root.json, which is only included // in the os package. let var = "PUBLISH_REPO"; - let repo = env::var(var).context(error::Environment { var })?; + let repo = env::var(var).context(error::EnvironmentSnafu { var })?; let mut args = Vec::new(); args.build_arg("PACKAGE", package); @@ -124,7 +124,7 @@ impl VariantBuilder { let variant = getenv("BUILDSYS_VARIANT")?; let arch = getenv("BUILDSYS_ARCH")?; let goarch = serde_plain::from_str::(&arch) - .context(error::UnsupportedArch { arch: &arch })? + .context(error::UnsupportedArchSnafu { arch: &arch })? .goarch(); let image_layout = image_layout.cloned().unwrap_or_default(); @@ -201,7 +201,7 @@ fn build( ) -> Result<()> { // Our Dockerfile is in the top-level directory. let root = getenv("BUILDSYS_ROOT_DIR")?; - env::set_current_dir(&root).context(error::DirectoryChange { path: &root })?; + env::set_current_dir(&root).context(error::DirectoryChangeSnafu { path: &root })?; // Compute a per-checkout prefix for the tag to avoid collisions. let mut d = Sha512::new(); @@ -304,7 +304,7 @@ fn docker(args: &[String], retry: Retry) -> Result { .stdout_capture() .unchecked() .run() - .context(error::CommandStart)?; + .context(error::CommandStartSnafu)?; let stdout = String::from_utf8_lossy(&output.stdout); println!("{}", &stdout); @@ -314,7 +314,7 @@ fn docker(args: &[String], retry: Retry) -> Result { ensure!( retry_messages.iter().any(|m| m.is_match(&stdout)) && attempt < max_attempts, - error::DockerExecution { + error::DockerExecutionSnafu { args: &args.join(" ") } ); @@ -346,7 +346,7 @@ fn create_build_dir(kind: &BuildType, name: &str, arch: &str) -> Result .iter() .collect(); - fs::create_dir_all(&path).context(error::DirectoryCreate { path: &path })?; + fs::create_dir_all(&path).context(error::DirectoryCreateSnafu { path: &path })?; Ok(path) } @@ -372,16 +372,16 @@ where for artifact_file in find_files(&build_dir, is_artifact) { let mut marker_file = artifact_file.clone().into_os_string(); marker_file.push(MARKER_EXTENSION); - File::create(&marker_file).context(error::FileCreate { path: &marker_file })?; + File::create(&marker_file).context(error::FileCreateSnafu { path: &marker_file })?; let mut output_file: PathBuf = output_dir.as_ref().into(); output_file.push( artifact_file .file_name() - .context(error::BadFilename { path: &output_file })?, + .context(error::BadFilenameSnafu { path: &output_file })?, ); - fs::rename(&artifact_file, &output_file).context(error::FileRename { + fs::rename(&artifact_file, &output_file).context(error::FileRenameSnafu { old_path: &artifact_file, new_path: &output_file, })?; @@ -410,15 +410,17 @@ where output_file.push( marker_file .file_name() - .context(error::BadFilename { path: &marker_file })?, + .context(error::BadFilenameSnafu { path: &marker_file })?, ); output_file.set_extension(""); if output_file.exists() { - std::fs::remove_file(&output_file).context(error::FileRemove { path: &output_file })?; + std::fs::remove_file(&output_file) + .context(error::FileRemoveSnafu { path: &output_file })?; } - std::fs::remove_file(&marker_file).context(error::FileRemove { path: &marker_file })?; + std::fs::remove_file(&marker_file) + .context(error::FileRemoveSnafu { path: &marker_file })?; } Ok(()) @@ -439,7 +441,7 @@ where .max_depth(1) .into_iter() .filter_entry(move |e| filter(e)) - .flat_map(|e| e.context(error::DirectoryWalk)) + .flat_map(|e| e.context(error::DirectoryWalkSnafu)) .map(|e| e.into_path()) } @@ -448,7 +450,7 @@ where /// output. fn getenv(var: &str) -> Result { println!("cargo:rerun-if-env-changed={}", var); - env::var(var).context(error::Environment { var }) + env::var(var).context(error::EnvironmentSnafu { var }) } // =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= diff --git a/tools/buildsys/src/builder/error.rs b/tools/buildsys/src/builder/error.rs index a6476e939f9..6fccfd6272f 100644 --- a/tools/buildsys/src/builder/error.rs +++ b/tools/buildsys/src/builder/error.rs @@ -2,7 +2,7 @@ use snafu::Snafu; use std::path::PathBuf; #[derive(Debug, Snafu)] -#[snafu(visibility = "pub(super)")] +#[snafu(visibility(pub(super)))] pub(crate) enum Error { #[snafu(display("Failed to start command: {}", source))] CommandStart { source: std::io::Error }, diff --git a/tools/buildsys/src/cache.rs b/tools/buildsys/src/cache.rs index 6d3e6a477a8..3e924935641 100644 --- a/tools/buildsys/src/cache.rs +++ b/tools/buildsys/src/cache.rs @@ -32,7 +32,7 @@ impl LookasideCache { let path = &f.path.as_ref().unwrap_or_else(|| &url_file_name); ensure!( path.components().count() == 1, - error::ExternalFileName { path } + error::ExternalFileNameSnafu { path } ); let hash = &f.sha512; @@ -41,7 +41,7 @@ impl LookasideCache { Ok(_) => continue, Err(e) => { eprintln!("{}", e); - fs::remove_file(path).context(error::ExternalFileDelete { path })?; + fs::remove_file(path).context(error::ExternalFileDeleteSnafu { path })?; } } } @@ -53,7 +53,8 @@ impl LookasideCache { let url = format!("{}/{}/{}/{}", LOOKASIDE_CACHE.to_string(), name, hash, name); match Self::fetch_file(&url, &tmp, hash) { Ok(_) => { - fs::rename(&tmp, path).context(error::ExternalFileRename { path: &tmp })?; + fs::rename(&tmp, path) + .context(error::ExternalFileRenameSnafu { path: &tmp })?; continue; } Err(e) => { @@ -65,7 +66,7 @@ impl LookasideCache { if std::env::var("BUILDSYS_UPSTREAM_SOURCE_FALLBACK") == Ok("true".to_string()) { println!("Fetching {:?} from upstream source", url_file_name); Self::fetch_file(&f.url, &tmp, hash)?; - fs::rename(&tmp, path).context(error::ExternalFileRename { path: &tmp })?; + fs::rename(&tmp, path).context(error::ExternalFileRenameSnafu { path: &tmp })?; } } @@ -76,48 +77,52 @@ impl LookasideCache { /// then verifies the contents against the SHA-512 hash provided. fn fetch_file>(url: &str, path: P, hash: &str) -> Result<()> { let path = path.as_ref(); - let mut resp = reqwest::blocking::get(url).context(error::ExternalFileRequest { url })?; + let mut resp = + reqwest::blocking::get(url).context(error::ExternalFileRequestSnafu { url })?; let status = resp.status(); ensure!( status.is_success(), - error::ExternalFileFetch { url, status } + error::ExternalFileFetchSnafu { url, status } ); - let f = File::create(path).context(error::ExternalFileOpen { path })?; + let f = File::create(path).context(error::ExternalFileOpenSnafu { path })?; let mut f = BufWriter::new(f); resp.copy_to(&mut f) - .context(error::ExternalFileSave { path })?; + .context(error::ExternalFileSaveSnafu { path })?; drop(f); match Self::verify_file(path, hash) { Ok(_) => Ok(()), Err(e) => { - fs::remove_file(path).context(error::ExternalFileDelete { path })?; + fs::remove_file(path).context(error::ExternalFileDeleteSnafu { path })?; Err(e) } } } fn extract_file_name(url: &str) -> Result { - let parsed = reqwest::Url::parse(url).context(error::ExternalFileUrl { url })?; + let parsed = reqwest::Url::parse(url).context(error::ExternalFileUrlSnafu { url })?; let name = parsed .path_segments() - .context(error::ExternalFileName { path: url })? + .context(error::ExternalFileNameSnafu { path: url })? .last() - .context(error::ExternalFileName { path: url })?; + .context(error::ExternalFileNameSnafu { path: url })?; Ok(name.into()) } /// Reads a file from disk and compares it to the expected SHA-512 hash. fn verify_file>(path: P, hash: &str) -> Result<()> { let path = path.as_ref(); - let mut f = File::open(path).context(error::ExternalFileOpen { path })?; + let mut f = File::open(path).context(error::ExternalFileOpenSnafu { path })?; let mut d = Sha512::new(); - io::copy(&mut f, &mut d).context(error::ExternalFileLoad { path })?; + io::copy(&mut f, &mut d).context(error::ExternalFileLoadSnafu { path })?; let digest = hex::encode(d.finalize()); - ensure!(digest == hash, error::ExternalFileVerify { path, hash }); + ensure!( + digest == hash, + error::ExternalFileVerifySnafu { path, hash } + ); Ok(()) } } diff --git a/tools/buildsys/src/cache/error.rs b/tools/buildsys/src/cache/error.rs index 55fab980903..4617ad9e2da 100644 --- a/tools/buildsys/src/cache/error.rs +++ b/tools/buildsys/src/cache/error.rs @@ -3,7 +3,7 @@ use std::io; use std::path::PathBuf; #[derive(Debug, Snafu)] -#[snafu(visibility = "pub(super)")] +#[snafu(visibility(pub(super)))] pub(crate) enum Error { #[snafu(display("Bad file name '{}'", path.display()))] ExternalFileName { path: PathBuf }, diff --git a/tools/buildsys/src/main.rs b/tools/buildsys/src/main.rs index b3415b77f1e..e8ab2427079 100644 --- a/tools/buildsys/src/main.rs +++ b/tools/buildsys/src/main.rs @@ -29,7 +29,7 @@ mod error { use snafu::Snafu; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub(super) enum Error { ManifestParse { source: super::manifest::error::Error, @@ -125,12 +125,12 @@ fn build_package() -> Result<()> { let variant = getenv("BUILDSYS_VARIANT")?; let variant_manifest_path = root_dir.join("variants").join(variant).join(manifest_file); let variant_manifest = - ManifestInfo::new(variant_manifest_path).context(error::ManifestParse)?; + ManifestInfo::new(variant_manifest_path).context(error::ManifestParseSnafu)?; supported_arch(&variant_manifest)?; let manifest_dir: PathBuf = getenv("CARGO_MANIFEST_DIR")?.into(); let manifest = - ManifestInfo::new(manifest_dir.join(manifest_file)).context(error::ManifestParse)?; + ManifestInfo::new(manifest_dir.join(manifest_file)).context(error::ManifestParseSnafu)?; // if manifest has package.metadata.build-package.variant-specific = true, then println rerun-if-env-changed if let Some(sensitive) = manifest.variant_sensitive() { @@ -140,7 +140,7 @@ fn build_package() -> Result<()> { } if let Some(files) = manifest.external_files() { - LookasideCache::fetch(&files).context(error::ExternalFileFetch)?; + LookasideCache::fetch(&files).context(error::ExternalFileFetchSnafu)?; } if let Some(groups) = manifest.source_groups() { @@ -149,7 +149,7 @@ fn build_package() -> Result<()> { println!("cargo:rerun-if-env-changed={}", var); let dirs = groups.iter().map(|d| root.join(d)).collect::>(); - let info = ProjectInfo::crawl(&dirs).context(error::ProjectCrawl)?; + let info = ProjectInfo::crawl(&dirs).context(error::ProjectCrawlSnafu)?; for f in info.files { println!("cargo:rerun-if-changed={}", f.display()); } @@ -165,7 +165,7 @@ fn build_package() -> Result<()> { let spec = format!("{}.spec", package); println!("cargo:rerun-if-changed={}", spec); - let info = SpecInfo::new(PathBuf::from(&spec)).context(error::SpecParse)?; + let info = SpecInfo::new(PathBuf::from(&spec)).context(error::SpecParseSnafu)?; for f in info.sources { println!("cargo:rerun-if-changed={}", f.display()); @@ -175,7 +175,7 @@ fn build_package() -> Result<()> { println!("cargo:rerun-if-changed={}", f.display()); } - PackageBuilder::build(&package).context(error::BuildAttempt)?; + PackageBuilder::build(&package).context(error::BuildAttemptSnafu)?; Ok(()) } @@ -186,7 +186,7 @@ fn build_variant() -> Result<()> { println!("cargo:rerun-if-changed={}", manifest_file); let manifest = - ManifestInfo::new(manifest_dir.join(manifest_file)).context(error::ManifestParse)?; + ManifestInfo::new(manifest_dir.join(manifest_file)).context(error::ManifestParseSnafu)?; supported_arch(&manifest)?; @@ -195,7 +195,7 @@ fn build_variant() -> Result<()> { let image_layout = manifest.image_layout(); let kernel_parameters = manifest.kernel_parameters(); VariantBuilder::build(&packages, image_format, image_layout, kernel_parameters) - .context(error::BuildAttempt)?; + .context(error::BuildAttemptSnafu)?; } else { println!("cargo:warning=No included packages in manifest. Skipping variant build."); } @@ -208,11 +208,11 @@ fn supported_arch(manifest: &ManifestInfo) -> Result<()> { if let Some(supported_arches) = manifest.supported_arches() { let arch = getenv("BUILDSYS_ARCH")?; let current_arch: SupportedArch = - serde_plain::from_str(&arch).context(error::UnknownArch { arch: &arch })?; + serde_plain::from_str(&arch).context(error::UnknownArchSnafu { arch: &arch })?; ensure!( supported_arches.contains(¤t_arch), - error::UnsupportedArch { + error::UnsupportedArchSnafu { arch: &arch, supported_arches: supported_arches .into_iter() @@ -226,5 +226,5 @@ fn supported_arch(manifest: &ManifestInfo) -> Result<()> { /// Retrieve a variable that we expect to be set in the environment. fn getenv(var: &str) -> Result { - env::var(var).context(error::Environment { var }) + env::var(var).context(error::EnvironmentSnafu { var }) } diff --git a/tools/buildsys/src/manifest.rs b/tools/buildsys/src/manifest.rs index 028033bbd53..82bb7bae622 100644 --- a/tools/buildsys/src/manifest.rs +++ b/tools/buildsys/src/manifest.rs @@ -137,8 +137,9 @@ impl ManifestInfo { /// Extract the settings we understand from `Cargo.toml`. pub(crate) fn new>(path: P) -> Result { let path = path.as_ref(); - let manifest_data = fs::read_to_string(path).context(error::ManifestFileRead { path })?; - toml::from_str(&manifest_data).context(error::ManifestFileLoad { path }) + let manifest_data = + fs::read_to_string(path).context(error::ManifestFileReadSnafu { path })?; + toml::from_str(&manifest_data).context(error::ManifestFileLoadSnafu { path }) } /// Convenience method to return the list of source groups. diff --git a/tools/buildsys/src/manifest/error.rs b/tools/buildsys/src/manifest/error.rs index c536822d5eb..a2f2056c615 100644 --- a/tools/buildsys/src/manifest/error.rs +++ b/tools/buildsys/src/manifest/error.rs @@ -3,7 +3,7 @@ use std::io; use std::path::PathBuf; #[derive(Debug, Snafu)] -#[snafu(visibility = "pub(super)")] +#[snafu(visibility(pub(super)))] pub(crate) enum Error { #[snafu(display("Failed to read manifest file '{}': {}", path.display(), source))] ManifestFileRead { path: PathBuf, source: io::Error }, diff --git a/tools/buildsys/src/project.rs b/tools/buildsys/src/project.rs index 0ab8df24398..08b5d4ff46d 100644 --- a/tools/buildsys/src/project.rs +++ b/tools/buildsys/src/project.rs @@ -31,7 +31,7 @@ impl ProjectInfo { files.extend( walker .filter_entry(|e| !Self::ignored(e)) - .flat_map(|e| e.context(error::DirectoryWalk)) + .flat_map(|e| e.context(error::DirectoryWalkSnafu)) .map(|e| e.into_path()) .filter(|e| e.is_file()), ); diff --git a/tools/buildsys/src/project/error.rs b/tools/buildsys/src/project/error.rs index d81ec5891d8..03502682426 100644 --- a/tools/buildsys/src/project/error.rs +++ b/tools/buildsys/src/project/error.rs @@ -1,7 +1,7 @@ use snafu::Snafu; #[derive(Debug, Snafu)] -#[snafu(visibility = "pub(super)")] +#[snafu(visibility(pub(super)))] pub(crate) enum Error { #[snafu(display("Failed to walk directory to find project files: {}", source))] DirectoryWalk { source: walkdir::Error }, diff --git a/tools/buildsys/src/spec.rs b/tools/buildsys/src/spec.rs index e50b34ab746..946b97f7a08 100644 --- a/tools/buildsys/src/spec.rs +++ b/tools/buildsys/src/spec.rs @@ -32,14 +32,14 @@ impl SpecInfo { /// "Parse" a spec file, extracting values of potential interest. fn parse>(path: P) -> Result<(Vec, Vec)> { let path = path.as_ref(); - let f = File::open(path).context(error::SpecFileRead { path })?; + let f = File::open(path).context(error::SpecFileReadSnafu { path })?; let f = BufReader::new(f); let mut sources = Vec::new(); let mut patches = Vec::new(); for line in f.lines() { - let line = line.context(error::SpecFileRead { path })?; + let line = line.context(error::SpecFileReadSnafu { path })?; let mut tokens = line.split_whitespace().collect::>(); if let Some(t) = tokens.pop_front() { diff --git a/tools/buildsys/src/spec/error.rs b/tools/buildsys/src/spec/error.rs index 90af879e47e..969ccf32d7e 100644 --- a/tools/buildsys/src/spec/error.rs +++ b/tools/buildsys/src/spec/error.rs @@ -3,7 +3,7 @@ use std::io; use std::path::PathBuf; #[derive(Debug, Snafu)] -#[snafu(visibility = "pub(super)")] +#[snafu(visibility(pub(super)))] pub(crate) enum Error { #[snafu(display("Failed to read spec file '{}': {}", path.display(), source))] SpecFileRead { path: PathBuf, source: io::Error }, diff --git a/tools/infrasys/Cargo.toml b/tools/infrasys/Cargo.toml index 9fa21dcac6d..fc78cc32ba7 100644 --- a/tools/infrasys/Cargo.toml +++ b/tools/infrasys/Cargo.toml @@ -20,7 +20,7 @@ serde_yaml = "0.8.17" sha2 = "0.9" shell-words = "1.0.0" simplelog = "0.10.0" -snafu = "0.6" +snafu = "0.7" structopt = { version = "0.3", default-features = false } tokio = { version = "~1.8", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS toml = "0.5" diff --git a/tools/infrasys/src/error.rs b/tools/infrasys/src/error.rs index 6dd8c3ba883..20bbdc01fc9 100644 --- a/tools/infrasys/src/error.rs +++ b/tools/infrasys/src/error.rs @@ -3,7 +3,7 @@ use std::io; use std::path::PathBuf; #[derive(Debug, Snafu)] -#[snafu(visibility = "pub(super)")] +#[snafu(visibility(pub(super)))] pub enum Error { #[snafu(display( "Failed to create CFN stack '{}' in '{}': {}", diff --git a/tools/infrasys/src/keys.rs b/tools/infrasys/src/keys.rs index 7bd8c0b8d84..15afde39902 100644 --- a/tools/infrasys/src/keys.rs +++ b/tools/infrasys/src/keys.rs @@ -18,7 +18,7 @@ pub async fn create_keys(signing_key_config: &mut SigningKeyConfig) -> Result<() SigningKeyConfig::kms { config, .. } => { config .as_mut() - .context(error::MissingConfig { + .context(error::MissingConfigSnafu { missing: "config field for a kms key", })? .create_kms_keys() @@ -33,7 +33,7 @@ pub fn check_signing_key_config(signing_key_config: &SigningKeyConfig) -> Result match signing_key_config { SigningKeyConfig::file { .. } => (), SigningKeyConfig::kms { config, .. } => { - let config = config.as_ref().context(error::MissingConfig { + let config = config.as_ref().context(error::MissingConfigSnafu { missing: "config field for a kms key", })?; @@ -43,19 +43,19 @@ pub fn check_signing_key_config(signing_key_config: &SigningKeyConfig) -> Result config.key_alias.as_ref(), ) { // everything is unspecified (no way to allocate a key_id) - (true, true, None) => error::KeyConfig { + (true, true, None) => error::KeyConfigSnafu { missing: "an available_key or region/key_alias", } .fail()?, // regions is populated, but no key alias // (it doesn't matter if available keys are listed or not) - (_, false, None) => error::KeyConfig { + (_, false, None) => error::KeyConfigSnafu { missing: "key_alias", } .fail()?, // key alias is populated, but no key regions to create keys in // (it doesn't matter if available keys are listed or not) - (_, true, Some(..)) => error::KeyConfig { missing: "region" }.fail()?, + (_, true, Some(..)) => error::KeyConfigSnafu { missing: "region" }.fail()?, _ => (), }; } @@ -85,19 +85,19 @@ impl KMSKeyConfigExt for KMSKeyConfig { for region in self.regions.iter() { let stack_name = format!( "TUF-KMS-{}", - self.key_alias.as_ref().context(error::KeyConfig { + self.key_alias.as_ref().context(error::KeyConfigSnafu { missing: "key_alias", })? ); let cfn_client = CloudFormationClient::new( - Region::from_str(region).context(error::ParseRegion { what: region })?, + Region::from_str(region).context(error::ParseRegionSnafu { what: region })?, ); let cfn_filepath = format!( "{}/infrasys/cloudformation-templates/kms_key_setup.yml", shared::getenv("BUILDSYS_TOOLS_DIR")? ); let cfn_template = fs::read_to_string(&cfn_filepath) - .context(error::FileRead { path: cfn_filepath })?; + .context(error::FileReadSnafu { path: cfn_filepath })?; let stack_result = cfn_client .create_stack(CreateStackInput { @@ -105,7 +105,7 @@ impl KMSKeyConfigExt for KMSKeyConfig { "Alias".to_string(), self.key_alias .as_ref() - .context(error::KeyConfig { + .context(error::KeyConfigSnafu { missing: "key_alias", })? .to_string(), @@ -115,7 +115,7 @@ impl KMSKeyConfigExt for KMSKeyConfig { ..Default::default() }) .await - .context(error::CreateStack { + .context(error::CreateStackSnafu { stack_name: &stack_name, region, })?; @@ -123,19 +123,20 @@ impl KMSKeyConfigExt for KMSKeyConfig { let stack_arn = stack_result .clone() .stack_id - .context(error::ParseResponse { + .context(error::ParseResponseSnafu { what: "stack_id", resource_name: &stack_name, })?; let output_array = shared::get_stack_outputs(&cfn_client, &stack_name, region).await?; - let key_id = output_array[0] - .output_value - .as_ref() - .context(error::ParseResponse { - what: "outputs[0].output_value (key id)", - resource_name: stack_name, - })?; + let key_id = + output_array[0] + .output_value + .as_ref() + .context(error::ParseResponseSnafu { + what: "outputs[0].output_value (key id)", + resource_name: stack_name, + })?; self.available_keys .insert(key_id.to_string(), region.to_string()); self.key_stack_arns diff --git a/tools/infrasys/src/main.rs b/tools/infrasys/src/main.rs index 6464189f81f..94bd5437071 100644 --- a/tools/infrasys/src/main.rs +++ b/tools/infrasys/src/main.rs @@ -62,11 +62,11 @@ fn run() -> Result<()> { // Parse and store the args passed to the program let args = Args::from_args(); - SimpleLogger::init(args.log_level, LogConfig::default()).context(error::Logger)?; + SimpleLogger::init(args.log_level, LogConfig::default()).context(error::LoggerSnafu)?; match args.subcommand { SubCommand::CreateInfra(ref run_task_args) => { - let rt = Runtime::new().context(error::Runtime)?; + let rt = Runtime::new().context(error::RuntimeSnafu)?; rt.block_on(async { create_infra(&args.infra_config_path, &run_task_args.root_role_path).await }) @@ -75,7 +75,7 @@ fn run() -> Result<()> { } fn check_infra_lock(toml_path: &Path) -> Result<()> { - let lock_path = InfraConfig::compute_lock_path(toml_path).context(error::Config)?; + let lock_path = InfraConfig::compute_lock_path(toml_path).context(error::ConfigSnafu)?; ensure!(!lock_path.is_file(), { error!( @@ -83,7 +83,7 @@ fn check_infra_lock(toml_path: &Path) -> Result<()> { \nPlease clean up your TUF resources in AWS, delete Infra.lock, and run again.", lock_path.display() ); - error::FileExists { path: lock_path } + error::FileExistsSnafu { path: lock_path } }); Ok(()) } @@ -92,18 +92,18 @@ fn check_infra_lock(toml_path: &Path) -> Result<()> { async fn create_infra(toml_path: &Path, root_role_path: &Path) -> Result<()> { check_infra_lock(toml_path)?; info!("Parsing Infra.toml..."); - let mut infra_config = InfraConfig::from_path(toml_path).context(error::Config)?; + let mut infra_config = InfraConfig::from_path(toml_path).context(error::ConfigSnafu)?; let repos = infra_config .repo .as_mut() - .context(error::MissingConfig { missing: "repo" })?; + .context(error::MissingConfigSnafu { missing: "repo" })?; let s3_info_map = infra_config .aws .as_mut() - .context(error::MissingConfig { missing: "aws" })? + .context(error::MissingConfigSnafu { missing: "aws" })? .s3 .as_mut() - .context(error::MissingConfig { missing: "aws.s3" })?; + .context(error::MissingConfigSnafu { missing: "aws.s3" })?; for (repo_name, repo_config) in repos.iter_mut() { // Validate repo_config and unwrap required optional data @@ -135,7 +135,7 @@ async fn create_infra(toml_path: &Path, root_role_path: &Path) -> Result<()> { if repo_info.metadata_base_url.is_none() { *repo_info.metadata_base_url = Some( Url::parse(format!("https://{}{}/", &bucket_rdn, &repo_info.prefix).as_str()) - .context(error::ParseUrl { input: &bucket_rdn })?, + .context(error::ParseUrlSnafu { input: &bucket_rdn })?, ); } if repo_info.targets_url.is_none() { @@ -143,7 +143,7 @@ async fn create_infra(toml_path: &Path, root_role_path: &Path) -> Result<()> { Url::parse( format!("https://{}{}/targets/", &bucket_rdn, &repo_info.prefix).as_str(), ) - .context(error::ParseUrl { input: &bucket_rdn })?, + .context(error::ParseUrlSnafu { input: &bucket_rdn })?, ); } if repo_info.root_role_url.is_none() { @@ -151,10 +151,10 @@ async fn create_infra(toml_path: &Path, root_role_path: &Path) -> Result<()> { Url::parse( format!("https://{}{}/root.json", &bucket_rdn, &repo_info.prefix).as_str(), ) - .context(error::ParseUrl { input: &bucket_rdn })?, + .context(error::ParseUrlSnafu { input: &bucket_rdn })?, ); } - let root_role_data = fs::read_to_string(&root_role_path).context(error::FileRead { + let root_role_data = fs::read_to_string(&root_role_path).context(error::FileReadSnafu { path: root_role_path, })?; let mut d = Sha512::new(); @@ -165,15 +165,15 @@ async fn create_infra(toml_path: &Path, root_role_path: &Path) -> Result<()> { // Generate Infra.lock info!("Writing Infra.lock..."); - let yaml_string = serde_yaml::to_string(&infra_config).context(error::InvalidYaml)?; + let yaml_string = serde_yaml::to_string(&infra_config).context(error::InvalidYamlSnafu)?; fs::write( toml_path .parent() - .context(error::Parent { path: toml_path })? + .context(error::ParentSnafu { path: toml_path })? .join("Infra.lock"), yaml_string, ) - .context(error::FileWrite { path: toml_path })?; + .context(error::FileWriteSnafu { path: toml_path })?; info!("Complete!"); Ok(()) @@ -205,17 +205,17 @@ impl<'a> ValidRepoInfo<'a> { repo_config .file_hosting_config_name .as_ref() - .context(error::MissingConfig { + .context(error::MissingConfigSnafu { missing: "file_hosting_config_name", })?; let s3_info = s3_info_map .get_mut(s3_stack_name) - .context(error::MissingConfig { + .context(error::MissingConfigSnafu { missing: format!("aws.s3 config with name {}", s3_stack_name), })?; Ok(ValidRepoInfo { s3_stack_name: s3_stack_name.to_string(), - s3_region: s3_info.region.as_ref().context(error::MissingConfig { + s3_region: s3_info.region.as_ref().context(error::MissingConfigSnafu { missing: format!("region for '{}' s3 config", s3_stack_name), })?, bucket_name: &mut s3_info.bucket_name, @@ -223,29 +223,29 @@ impl<'a> ValidRepoInfo<'a> { vpce_id: s3_info .vpc_endpoint_id .as_ref() - .context(error::MissingConfig { + .context(error::MissingConfigSnafu { missing: format!("vpc_endpoint_id for '{}' s3 config", s3_stack_name), })?, prefix: s3::format_prefix(&s3_info.s3_prefix), signing_keys: repo_config .signing_keys .as_mut() - .context(error::MissingConfig { + .context(error::MissingConfigSnafu { missing: format!("signing_keys for '{}' repo config", repo_name), })?, root_keys: repo_config .root_keys .as_mut() - .context(error::MissingConfig { + .context(error::MissingConfigSnafu { missing: format!("root_keys for '{}' repo config", repo_name), })?, root_key_threshold: repo_config.root_key_threshold.as_mut().context( - error::MissingConfig { + error::MissingConfigSnafu { missing: format!("root_key_threshold for '{}' repo config", repo_name), }, )?, pub_key_threshold: repo_config.pub_key_threshold.as_ref().context( - error::MissingConfig { + error::MissingConfigSnafu { missing: format!("pub_key_threshold for '{}' repo config", repo_name), }, )?, diff --git a/tools/infrasys/src/root.rs b/tools/infrasys/src/root.rs index 819d92d8410..e447f045965 100644 --- a/tools/infrasys/src/root.rs +++ b/tools/infrasys/src/root.rs @@ -14,16 +14,16 @@ macro_rules! tuftool { ($region:expr, $format_str:expr, $($format_arg:expr),*) => { let arg_str = format!($format_str, $($format_arg),*); trace!("tuftool arg string: {}", arg_str); - let args = shell_words::split(&arg_str).context(error::CommandSplit { command: &arg_str })?; + let args = shell_words::split(&arg_str).context(error::CommandSplitSnafu { command: &arg_str })?; trace!("tuftool split args: {:#?}", args); let status = Command::new("tuftool") .args(args) .env("AWS_REGION", $region) .status() - .context(error::TuftoolSpawn)?; + .context(error::TuftoolSpawnSnafu)?; - ensure!(status.success(), error::TuftoolResult { + ensure!(status.success(), error::TuftoolResultSnafu { command: arg_str, code: status.code().map(|i| i.to_string()).unwrap_or_else(|| "".to_string()) }); @@ -33,7 +33,7 @@ macro_rules! tuftool { pub fn check_root(root_role_path: &Path) -> Result<()> { ensure!(!root_role_path.is_file(), { warn!("Cowardly refusing to overwrite the existing root.json at {}. Please manually delete it and run again.", root_role_path.display()); - error::FileExists { + error::FileExistsSnafu { path: root_role_path, } }); @@ -43,11 +43,11 @@ pub fn check_root(root_role_path: &Path) -> Result<()> { /// Creates the directory where root.json will live and creates root.json itself according to details specified in root-role-path pub fn create_root(root_role_path: &Path) -> Result<()> { // Make /roles and /keys directories, if they don't exist, so we can write generated files. - let role_dir = root_role_path.parent().context(error::InvalidPath { + let role_dir = root_role_path.parent().context(error::InvalidPathSnafu { path: root_role_path, thing: "root role", })?; - fs::create_dir_all(role_dir).context(error::Mkdir { path: role_dir })?; + fs::create_dir_all(role_dir).context(error::MkdirSnafu { path: role_dir })?; // Initialize root tuftool!( Region::default().name(), @@ -75,7 +75,7 @@ pub fn add_keys( SigningKeyConfig::kms { key_id, config, .. } => add_keys_kms( &config .as_ref() - .context(error::MissingConfig { + .context(error::MissingConfigSnafu { missing: "config field for a kms key", })? .available_keys, @@ -103,7 +103,7 @@ fn add_keys_kms( ) -> Result<()> { ensure!( (*available_keys).len() >= (*threshold).get(), - error::InvalidThreshold { + error::InvalidThresholdSnafu { threshold: threshold.to_string(), num_keys: (*available_keys).len(), } @@ -160,7 +160,7 @@ fn add_keys_kms( available_keys .iter() .next() - .context(error::KeyCreation)? + .context(error::KeyCreationSnafu)? .0 .to_string(), ); @@ -178,7 +178,7 @@ pub fn sign_root(signing_key_config: &SigningKeyConfig, filepath: &str) -> Resul SigningKeyConfig::kms { config, .. } => { for (keyid, region) in config .as_ref() - .context(error::MissingConfig { + .context(error::MissingConfigSnafu { missing: "KMS key details", })? .available_keys diff --git a/tools/infrasys/src/s3.rs b/tools/infrasys/src/s3.rs index c91863b9cae..ee998aa3d3a 100644 --- a/tools/infrasys/src/s3.rs +++ b/tools/infrasys/src/s3.rs @@ -39,7 +39,7 @@ pub fn format_prefix(prefix: &str) -> String { pub async fn create_s3_bucket(region: &str, stack_name: &str) -> Result<(String, String, String)> { // TODO: Add support for accommodating pre-existing buckets (skip this creation process) let cfn_client = CloudFormationClient::new( - Region::from_str(region).context(error::ParseRegion { what: region })?, + Region::from_str(region).context(error::ParseRegionSnafu { what: region })?, ); let cfn_filepath: PathBuf = format!( "{}/infrasys/cloudformation-templates/s3_setup.yml", @@ -47,7 +47,7 @@ pub async fn create_s3_bucket(region: &str, stack_name: &str) -> Result<(String, ) .into(); let cfn_template = - fs::read_to_string(&cfn_filepath).context(error::FileRead { path: cfn_filepath })?; + fs::read_to_string(&cfn_filepath).context(error::FileReadSnafu { path: cfn_filepath })?; let stack_result = cfn_client .create_stack(CreateStackInput { stack_name: stack_name.to_string(), @@ -55,12 +55,12 @@ pub async fn create_s3_bucket(region: &str, stack_name: &str) -> Result<(String, ..Default::default() }) .await - .context(error::CreateStack { stack_name, region })?; + .context(error::CreateStackSnafu { stack_name, region })?; // We don't have to wait for successful stack creation to grab the stack ARN let stack_arn = stack_result .clone() .stack_id - .context(error::ParseResponse { + .context(error::ParseResponseSnafu { what: "stack_id", resource_name: stack_name, })?; @@ -70,7 +70,7 @@ pub async fn create_s3_bucket(region: &str, stack_name: &str) -> Result<(String, let bucket_name = output_array[0] .output_value .as_ref() - .context(error::ParseResponse { + .context(error::ParseResponseSnafu { what: "outputs[0].output_value (bucket name)", resource_name: stack_name, })? @@ -78,7 +78,7 @@ pub async fn create_s3_bucket(region: &str, stack_name: &str) -> Result<(String, let bucket_rdn = output_array[1] .output_value .as_ref() - .context(error::ParseResponse { + .context(error::ParseResponseSnafu { what: "outputs[1].output_value (bucket url)", resource_name: stack_name, })? @@ -99,7 +99,7 @@ pub async fn add_bucket_policy( ) -> Result<()> { // Get old policy let s3_client = - S3Client::new(Region::from_str(region).context(error::ParseRegion { what: region })?); + S3Client::new(Region::from_str(region).context(error::ParseRegionSnafu { what: region })?); let mut policy: serde_json::Value = match s3_client .get_bucket_policy(GetBucketPolicyRequest { bucket: bucket_name.to_string(), @@ -107,11 +107,11 @@ pub async fn add_bucket_policy( }) .await { - Ok(output) => serde_json::from_str(&output.policy.context(error::ParseResponse { + Ok(output) => serde_json::from_str(&output.policy.context(error::ParseResponseSnafu { what: "policy", resource_name: bucket_name, })?) - .context(error::InvalidJson { + .context(error::InvalidJsonSnafu { what: format!("retrieved bucket policy for {}", &bucket_name), })?, @@ -119,7 +119,7 @@ pub async fn add_bucket_policy( r#"{"Version": "2008-10-17", "Statement": []}"#, ) - .context(error::InvalidJson { + .context(error::InvalidJsonSnafu { what: format!("new bucket policy for {}", &bucket_name), })?, }; @@ -139,29 +139,29 @@ pub async fn add_bucket_policy( }}"#, bucket_name, prefix, vpcid )) - .context(error::InvalidJson { + .context(error::InvalidJsonSnafu { what: format!("new bucket policy for {}", &bucket_name), })?; // Append new policy onto old one policy .get_mut("Statement") - .context(error::GetPolicyStatement { bucket_name })? + .context(error::GetPolicyStatementSnafu { bucket_name })? .as_array_mut() - .context(error::GetPolicyStatement { bucket_name })? + .context(error::GetPolicyStatementSnafu { bucket_name })? .push(new_bucket_policy); // Push the new policy as a string s3_client .put_bucket_policy(PutBucketPolicyRequest { bucket: bucket_name.to_string(), - policy: serde_json::to_string(&policy).context(error::InvalidJson { + policy: serde_json::to_string(&policy).context(error::InvalidJsonSnafu { what: format!("new bucket policy for {}", &bucket_name), })?, ..Default::default() }) .await - .context(error::PutPolicy { bucket_name })?; + .context(error::PutPolicySnafu { bucket_name })?; Ok(()) } @@ -177,13 +177,13 @@ pub async fn upload_file( file_path: &Path, ) -> Result<()> { let s3_client = - S3Client::new(Region::from_str(region).context(error::ParseRegion { what: region })?); + S3Client::new(Region::from_str(region).context(error::ParseRegionSnafu { what: region })?); // File --> Bytes - let mut file = File::open(file_path).context(error::FileOpen { path: file_path })?; + let mut file = File::open(file_path).context(error::FileOpenSnafu { path: file_path })?; let mut buffer = Vec::new(); file.read_to_end(&mut buffer) - .context(error::FileRead { path: file_path })?; + .context(error::FileReadSnafu { path: file_path })?; s3_client .put_object(PutObjectRequest { @@ -193,7 +193,7 @@ pub async fn upload_file( ..Default::default() }) .await - .context(error::PutObject { bucket_name })?; + .context(error::PutObjectSnafu { bucket_name })?; Ok(()) } diff --git a/tools/infrasys/src/shared.rs b/tools/infrasys/src/shared.rs index addde7e3a2c..0f147f56521 100644 --- a/tools/infrasys/src/shared.rs +++ b/tools/infrasys/src/shared.rs @@ -14,7 +14,7 @@ pub enum KeyRole { /// Retrieve a BUILDSYS_* variable that we expect to be set in the environment pub fn getenv(var: &str) -> Result { - env::var(var).context(error::Environment { var }) + env::var(var).context(error::EnvironmentSnafu { var }) } /// Generates a parameter type object used to specify parameters in CloudFormation templates @@ -39,9 +39,9 @@ pub async fn get_stack_outputs( ..Default::default() }) .await - .context(error::DescribeStack { stack_name, region })? + .context(error::DescribeStackSnafu { stack_name, region })? .stacks - .context(error::ParseResponse { + .context(error::ParseResponseSnafu { what: "stacks", resource_name: stack_name, })?[0] @@ -54,11 +54,11 @@ pub async fn get_stack_outputs( while status != "CREATE_COMPLETE" { ensure!( max_attempts > 0, - error::CreateStackTimeout { stack_name, region } + error::CreateStackTimeoutSnafu { stack_name, region } ); ensure!( status != "CREATE_FAILED", - error::CreateStackFailure { stack_name, region } + error::CreateStackFailureSnafu { stack_name, region } ); info!( "Waiting for stack resources to be ready, current status is '{}'...", @@ -71,9 +71,9 @@ pub async fn get_stack_outputs( ..Default::default() }) .await - .context(error::DescribeStack { stack_name, region })? + .context(error::DescribeStackSnafu { stack_name, region })? .stacks - .context(error::ParseResponse { + .context(error::ParseResponseSnafu { what: "stacks", resource_name: stack_name, })?[0] @@ -82,7 +82,7 @@ pub async fn get_stack_outputs( max_attempts -= 1; } - let output_array = stack_outputs.outputs.context(error::ParseResponse { + let output_array = stack_outputs.outputs.context(error::ParseResponseSnafu { what: "outputs", resource_name: stack_name, })?; diff --git a/tools/infrasys/test_tomls/toml_yaml_conversion.yml b/tools/infrasys/test_tomls/toml_yaml_conversion.yml new file mode 100644 index 00000000000..c9482f65251 --- /dev/null +++ b/tools/infrasys/test_tomls/toml_yaml_conversion.yml @@ -0,0 +1,40 @@ +--- +repo: + default: + root_role_url: ~ + root_role_sha512: ~ + signing_keys: + kms: + key_id: ~ + available_keys: + e4a8f7fe-2272-4e51-bc3e-3f719c77eb31: us-west-1 + key_alias: ~ + regions: [] + key_stack_arns: {} + root_keys: + kms: + key_id: ~ + available_keys: + e4a8f7fe-2272-4e51-bc3e-3f719c77eb31: us-west-1 + key_alias: ~ + regions: [] + key_stack_arns: {} + metadata_base_url: ~ + targets_url: ~ + file_hosting_config_name: TUF-Repo-S3-Buck + root_key_threshold: 1 + pub_key_threshold: 1 +aws: + regions: [] + role: ~ + profile: ~ + region: {} + ssm_prefix: ~ + s3: + TUF-Repo-S3-Buck: + region: us-west-2 + s3_prefix: /my-bottlerocket-remix + vpc_endpoint_id: vpc-12345 + stack_arn: ~ + bucket_name: ~ +vmware: ~ diff --git a/tools/pubsys-config/Cargo.toml b/tools/pubsys-config/Cargo.toml index 5010acd2d40..ae3b5dda235 100644 --- a/tools/pubsys-config/Cargo.toml +++ b/tools/pubsys-config/Cargo.toml @@ -14,6 +14,6 @@ log = "0.4" parse-datetime = { path = "../../sources/parse-datetime", version = "0.1.0" } serde = { version = "1.0", features = ["derive"] } serde_yaml = "0.8.17" -snafu = "0.6" +snafu = "0.7" toml = "0.5" url = { version = "2.1.0", features = ["serde"] } diff --git a/tools/pubsys-config/src/lib.rs b/tools/pubsys-config/src/lib.rs index 59b2f0ce5ef..7c660c7ad59 100644 --- a/tools/pubsys-config/src/lib.rs +++ b/tools/pubsys-config/src/lib.rs @@ -35,8 +35,8 @@ impl InfraConfig { P: AsRef, { let path = path.as_ref(); - let infra_config_str = fs::read_to_string(path).context(error::File { path })?; - toml::from_str(&infra_config_str).context(error::InvalidToml { path }) + let infra_config_str = fs::read_to_string(path).context(error::FileSnafu { path })?; + toml::from_str(&infra_config_str).context(error::InvalidTomlSnafu { path }) } /// Deserializes an InfraConfig from a Infra.lock file at a given path @@ -45,8 +45,8 @@ impl InfraConfig { P: AsRef, { let path = path.as_ref(); - let infra_config_str = fs::read_to_string(path).context(error::File { path })?; - serde_yaml::from_str(&infra_config_str).context(error::InvalidLock { path }) + let infra_config_str = fs::read_to_string(path).context(error::FileSnafu { path })?; + serde_yaml::from_str(&infra_config_str).context(error::InvalidLockSnafu { path }) } /// Deserializes an InfraConfig from a given path, if it exists, otherwise builds a default @@ -97,7 +97,7 @@ impl InfraConfig { Ok(infra_config_path .as_ref() .parent() - .context(error::Parent { + .context(error::ParentSnafu { path: infra_config_path.as_ref(), })? .join("Infra.lock")) @@ -232,8 +232,8 @@ impl RepoExpirationPolicy { P: AsRef, { let path = path.as_ref(); - let expiration_str = fs::read_to_string(path).context(error::File { path })?; - toml::from_str(&expiration_str).context(error::InvalidToml { path }) + let expiration_str = fs::read_to_string(path).context(error::FileSnafu { path })?; + toml::from_str(&expiration_str).context(error::InvalidTomlSnafu { path }) } } @@ -252,7 +252,7 @@ mod error { use std::path::PathBuf; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub enum Error { #[snafu(display("Failed to read '{}': {}", path.display(), source))] File { path: PathBuf, source: io::Error }, diff --git a/tools/pubsys-config/src/vmware.rs b/tools/pubsys-config/src/vmware.rs index a97e8e10d94..e5d43256351 100644 --- a/tools/pubsys-config/src/vmware.rs +++ b/tools/pubsys-config/src/vmware.rs @@ -94,7 +94,7 @@ impl DatacenterBuilder { /// value. pub fn build(self) -> Result { let get_or_err = - |opt: Option, what: &str| opt.context(error::MissingConfig { what }); + |opt: Option, what: &str| opt.context(error::MissingConfigSnafu { what }); Ok(Datacenter { vsphere_url: get_or_err(self.vsphere_url, "vSphere URL")?, @@ -133,8 +133,8 @@ impl DatacenterCredsConfig { P: AsRef, { let path = path.as_ref(); - let creds_config_str = fs::read_to_string(path).context(error::File { path })?; - toml::from_str(&creds_config_str).context(error::InvalidToml { path }) + let creds_config_str = fs::read_to_string(path).context(error::FileSnafu { path })?; + toml::from_str(&creds_config_str).context(error::InvalidTomlSnafu { path }) } } @@ -169,7 +169,7 @@ impl DatacenterCredsBuilder { /// contains a value pub fn build(self) -> Result { let get_or_err = - |opt: Option, what: &str| opt.context(error::MissingConfig { what }); + |opt: Option, what: &str| opt.context(error::MissingConfigSnafu { what }); Ok(DatacenterCreds { username: get_or_err(self.username, "vSphere username")?, @@ -202,7 +202,7 @@ mod error { use std::path::PathBuf; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub enum Error { #[snafu(display("Failed to read '{}': {}", path.display(), source))] File { path: PathBuf, source: io::Error }, diff --git a/tools/pubsys-setup/Cargo.toml b/tools/pubsys-setup/Cargo.toml index bac72852b3f..7b186e6d3e6 100644 --- a/tools/pubsys-setup/Cargo.toml +++ b/tools/pubsys-setup/Cargo.toml @@ -14,7 +14,7 @@ reqwest = { version = "0.11.1", default-features = false, features = ["rustls-tl sha2 = "0.9" shell-words = "1.0" simplelog = "0.10" -snafu = "0.6" +snafu = "0.7" structopt = { version = "0.3", default-features = false } tempfile = "3.1" toml = "0.5" diff --git a/tools/pubsys-setup/src/main.rs b/tools/pubsys-setup/src/main.rs index 838b48b0514..fc7b2babde5 100644 --- a/tools/pubsys-setup/src/main.rs +++ b/tools/pubsys-setup/src/main.rs @@ -55,15 +55,15 @@ macro_rules! tuftool { ($format_str:expr, $($format_arg:expr),*) => { let arg_str = format!($format_str, $($format_arg),*); trace!("tuftool arg string: {}", arg_str); - let args = shell_words::split(&arg_str).context(error::CommandSplit { command: &arg_str })?; + let args = shell_words::split(&arg_str).context(error::CommandSplitSnafu { command: &arg_str })?; trace!("tuftool split args: {:#?}", args); let status = Command::new("tuftool") .args(args) .status() - .context(error::TuftoolSpawn)?; + .context(error::TuftoolSpawnSnafu)?; - ensure!(status.success(), error::TuftoolResult { + ensure!(status.success(), error::TuftoolResultSnafu { command: arg_str, code: status.code().map(|i| i.to_string()).unwrap_or_else(|| "".to_string()) }); @@ -76,19 +76,19 @@ fn run() -> Result<()> { let args = Args::from_args(); // SimpleLogger will send errors to stderr and anything less to stdout. - SimpleLogger::init(args.log_level, LogConfig::default()).context(error::Logger)?; + SimpleLogger::init(args.log_level, LogConfig::default()).context(error::LoggerSnafu)?; // Make /roles and /keys directories, if they don't exist, so we can write generated files. - let role_dir = args.root_role_path.parent().context(error::Path { + let role_dir = args.root_role_path.parent().context(error::PathSnafu { path: &args.root_role_path, thing: "root role", })?; - let key_dir = args.default_key_path.parent().context(error::Path { + let key_dir = args.default_key_path.parent().context(error::PathSnafu { path: &args.default_key_path, thing: "key", })?; - fs::create_dir_all(role_dir).context(error::Mkdir { path: role_dir })?; - fs::create_dir_all(key_dir).context(error::Mkdir { path: key_dir })?; + fs::create_dir_all(role_dir).context(error::MkdirSnafu { path: role_dir })?; + fs::create_dir_all(key_dir).context(error::MkdirSnafu { path: key_dir })?; // Main branching logic for deciding whether to create role/key, use what we have, or error. match find_root_role_and_key(&args)? { @@ -96,7 +96,7 @@ fn run() -> Result<()> { (Some(_root_role_path), None) => { ensure!( args.allow_missing_key, - error::MissingKey { repo: args.repo } + error::MissingKeySnafu { repo: args.repo } ); Ok(()) } @@ -109,7 +109,7 @@ fn run() -> Result<()> { } let temp_root_role = - NamedTempFile::new_in(&role_dir).context(error::TempFileCreate { + NamedTempFile::new_in(&role_dir).context(error::TempFileCreateSnafu { purpose: "root role", })?; let temp_root_role_path = temp_root_role.path().display(); @@ -141,7 +141,7 @@ fn run() -> Result<()> { Url::from_file_path(&args.default_key_path) .ok() - .context(error::FileToUrl { + .context(error::FileToUrlSnafu { path: args.default_key_path, })? }; @@ -151,7 +151,7 @@ fn run() -> Result<()> { temp_root_role .persist_noclobber(&args.root_role_path) - .context(error::TempFilePersist { + .context(error::TempFilePersistSnafu { path: &args.root_role_path, })?; @@ -163,7 +163,7 @@ fn run() -> Result<()> { // Root role files don't need to be secret. fs::set_permissions(&args.root_role_path, fs::Permissions::from_mode(0o644)).context( - error::SetMode { + error::SetModeSnafu { path: &args.root_role_path, }, )?; @@ -177,9 +177,11 @@ fn run() -> Result<()> { fn find_root_role_and_key(args: &Args) -> Result<(Option<&PathBuf>, Option)> { let (mut root_role_path, mut key_url) = (None, None); - if InfraConfig::lock_or_infra_config_exists(&args.infra_config_path).context(error::Config)? { + if InfraConfig::lock_or_infra_config_exists(&args.infra_config_path) + .context(error::ConfigSnafu)? + { let infra_config = InfraConfig::from_path_or_lock(&args.infra_config_path, false) - .context(error::Config)?; + .context(error::ConfigSnafu)?; trace!("Parsed infra config: {:?}", infra_config); // Check whether the user has the relevant repo defined in their Infra.toml. @@ -195,7 +197,7 @@ fn find_root_role_and_key(args: &Args) -> Result<(Option<&PathBuf>, Option) // If it's already been downloaded, just confirm the checksum. if args.root_role_path.exists() { let root_role_data = - fs::read_to_string(&args.root_role_path).context(error::ReadFile { + fs::read_to_string(&args.root_role_path).context(error::ReadFileSnafu { path: &args.root_role_path, })?; let mut d = Sha512::new(); @@ -204,7 +206,7 @@ fn find_root_role_and_key(args: &Args) -> Result<(Option<&PathBuf>, Option) ensure!( &digest == sha512, - error::Hash { + error::HashSnafu { expected: sha512, got: digest, thing: args.root_role_path.to_string_lossy() @@ -221,13 +223,13 @@ fn find_root_role_and_key(args: &Args) -> Result<(Option<&PathBuf>, Option) let path = url .to_file_path() .ok() - .with_context(|| error::UrlToFile { url: url.clone() })?; - fs::read_to_string(&path).context(error::ReadFile { path: &path })? + .with_context(|| error::UrlToFileSnafu { url: url.clone() })?; + fs::read_to_string(&path).context(error::ReadFileSnafu { path: &path })? } else { reqwest::blocking::get(url.clone()) - .with_context(|| error::GetUrl { url: url.clone() })? + .with_context(|_| error::GetUrlSnafu { url: url.clone() })? .text() - .with_context(|| error::GetUrl { url: url.clone() })? + .with_context(|_| error::GetUrlSnafu { url: url.clone() })? }; let mut d = Sha512::new(); @@ -236,7 +238,7 @@ fn find_root_role_and_key(args: &Args) -> Result<(Option<&PathBuf>, Option) ensure!( &digest == sha512, - error::Hash { + error::HashSnafu { expected: sha512, got: digest, thing: url.to_string() @@ -244,9 +246,11 @@ fn find_root_role_and_key(args: &Args) -> Result<(Option<&PathBuf>, Option) ); // Write root role to expected path on disk. - fs::write(&args.root_role_path, &root_role_data).context(error::WriteFile { - path: &args.root_role_path, - })?; + fs::write(&args.root_role_path, &root_role_data).context( + error::WriteFileSnafu { + path: &args.root_role_path, + }, + )?; debug!("Downloaded root role to {}", args.root_role_path.display()); } @@ -254,14 +258,14 @@ fn find_root_role_and_key(args: &Args) -> Result<(Option<&PathBuf>, Option) } else if repo_config.root_role_url.is_some() || repo_config.root_role_sha512.is_some() { // Must specify both URL and checksum. - error::RootRoleConfig.fail()?; + error::RootRoleConfigSnafu.fail()?; } if let Some(key_config) = &repo_config.signing_keys { key_url = Some( Url::try_from(key_config.clone()) .ok() - .context(error::SigningKeyUrl { repo: &args.repo })?, + .context(error::SigningKeyUrlSnafu { repo: &args.repo })?, ); } } else { @@ -284,7 +288,7 @@ fn find_root_role_and_key(args: &Args) -> Result<(Option<&PathBuf>, Option) } if key_url.is_none() && args.default_key_path.exists() { key_url = Some(Url::from_file_path(&args.default_key_path).ok().context( - error::FileToUrl { + error::FileToUrlSnafu { path: &args.default_key_path, }, )?); @@ -310,7 +314,7 @@ mod error { use url::Url; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub(super) enum Error { #[snafu(display("Error splitting shell command - {} - input: {}", source, command))] CommandSplit { diff --git a/tools/pubsys/Cargo.toml b/tools/pubsys/Cargo.toml index c319faa20d4..eafa77cec8c 100644 --- a/tools/pubsys/Cargo.toml +++ b/tools/pubsys/Cargo.toml @@ -31,7 +31,7 @@ rusoto_signature = "0.47.0" rusoto_ssm = { version = "0.47.0", default-features = false, features = ["rustls"] } rusoto_sts = { version = "0.47.0", default-features = false, features = ["rustls"] } simplelog = "0.10.0" -snafu = "0.6" +snafu = "0.7" semver = "1.0" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" diff --git a/tools/pubsys/src/aws/ami/mod.rs b/tools/pubsys/src/aws/ami/mod.rs index fc23716dc2e..e7343abe38e 100644 --- a/tools/pubsys/src/aws/ami/mod.rs +++ b/tools/pubsys/src/aws/ami/mod.rs @@ -78,8 +78,9 @@ pub(crate) async fn run(args: &Args, ami_args: &AmiArgs) -> Result<()> { Ok(amis) => { // Write the AMI IDs to file if requested if let Some(ref path) = ami_args.ami_output { - let file = File::create(path).context(error::FileCreate { path })?; - serde_json::to_writer_pretty(file, &amis).context(error::Serialize { path })?; + let file = File::create(path).context(error::FileCreateSnafu { path })?; + serde_json::to_writer_pretty(file, &amis) + .context(error::SerializeSnafu { path })?; info!("Wrote AMI data to {}", path.display()); } Ok(()) @@ -92,8 +93,8 @@ async fn _run(args: &Args, ami_args: &AmiArgs) -> Result> let mut amis = HashMap::new(); // If a lock file exists, use that, otherwise use Infra.toml or default - let infra_config = - InfraConfig::from_path_or_lock(&args.infra_config_path, true).context(error::Config)?; + let infra_config = InfraConfig::from_path_or_lock(&args.infra_config_path, true) + .context(error::ConfigSnafu)?; trace!("Using infra config: {:?}", infra_config); let aws = infra_config.aws.unwrap_or_else(|| Default::default()); @@ -105,12 +106,12 @@ async fn _run(args: &Args, ami_args: &AmiArgs) -> Result> aws.regions.clone().into() } .into_iter() - .map(|name| region_from_string(&name, &aws).context(error::ParseRegion)) + .map(|name| region_from_string(&name, &aws).context(error::ParseRegionSnafu)) .collect::>>()?; ensure!( !regions.is_empty(), - error::MissingConfig { + error::MissingConfigSnafu { missing: "aws.regions" } ); @@ -119,16 +120,18 @@ async fn _run(args: &Args, ami_args: &AmiArgs) -> Result> let base_region = regions.remove(0); // Build EBS client for snapshot management, and EC2 client for registration - let base_ebs_client = - build_client::(&base_region, &base_region, &aws).context(error::Client { + let base_ebs_client = build_client::(&base_region, &base_region, &aws).context( + error::ClientSnafu { client_type: "EBS", region: base_region.name(), - })?; - let base_ec2_client = - build_client::(&base_region, &base_region, &aws).context(error::Client { + }, + )?; + let base_ec2_client = build_client::(&base_region, &base_region, &aws).context( + error::ClientSnafu { client_type: "EC2", region: base_region.name(), - })?; + }, + )?; // Check if the AMI already exists, in which case we can use the existing ID, otherwise we // register a new one. @@ -139,7 +142,7 @@ async fn _run(args: &Args, ami_args: &AmiArgs) -> Result> &base_ec2_client, ) .await - .context(error::GetAmiId { + .context(error::GetAmiIdSnafu { name: &ami_args.name, arch: &ami_args.arch, region: base_region.name(), @@ -154,7 +157,7 @@ async fn _run(args: &Args, ami_args: &AmiArgs) -> Result> ); let snapshot_ids = get_snapshots(&found_id, &base_region, &base_ec2_client) .await - .context(error::GetSnapshots { + .context(error::GetSnapshotsSnafu { image_id: &found_id, region: base_region.name(), })?; @@ -171,7 +174,7 @@ async fn _run(args: &Args, ami_args: &AmiArgs) -> Result> &base_ec2_client, ) .await - .context(error::RegisterImage { + .context(error::RegisterImageSnafu { name: &ami_args.name, arch: &ami_args.arch, region: base_region.name(), @@ -206,7 +209,7 @@ async fn _run(args: &Args, ami_args: &AmiArgs) -> Result> &aws, ) .await - .context(error::WaitAmi { + .context(error::WaitAmiSnafu { id: &ids_of_image.image_id, region: base_region.name(), })?; @@ -220,18 +223,19 @@ async fn _run(args: &Args, ami_args: &AmiArgs) -> Result> // Get the account ID used in the base region; we don't need to grant to it so we can remove it // from the list. - let base_sts_client = - build_client::(&base_region, &base_region, &aws).context(error::Client { + let base_sts_client = build_client::(&base_region, &base_region, &aws).context( + error::ClientSnafu { client_type: "STS", region: base_region.name(), - })?; + }, + )?; let response = base_sts_client .get_caller_identity(GetCallerIdentityRequest {}) .await - .context(error::GetCallerIdentity { + .context(error::GetCallerIdentitySnafu { region: base_region.name(), })?; - let base_account_id = response.account.context(error::MissingInResponse { + let base_account_id = response.account.context(error::MissingInResponseSnafu { request_type: "GetCallerIdentity", missing: "account", })?; @@ -251,7 +255,7 @@ async fn _run(args: &Args, ami_args: &AmiArgs) -> Result> &base_region, ) .await - .context(error::GrantAccess { + .context(error::GrantAccessSnafu { thing: "snapshots", region: base_region.name(), })?; @@ -265,7 +269,7 @@ async fn _run(args: &Args, ami_args: &AmiArgs) -> Result> &base_region, ) .await - .context(error::GrantAccess { + .context(error::GrantAccessSnafu { thing: "image", region: base_region.name(), })?; @@ -276,7 +280,7 @@ async fn _run(args: &Args, ami_args: &AmiArgs) -> Result> let mut ec2_clients = HashMap::with_capacity(regions.len()); for region in regions.iter() { let ec2_client = - build_client::(®ion, &base_region, &aws).context(error::Client { + build_client::(®ion, &base_region, &aws).context(error::ClientSnafu { client_type: "EC2", region: region.name(), })?; @@ -299,7 +303,7 @@ async fn _run(args: &Args, ami_args: &AmiArgs) -> Result> // If an AMI already existed, just add it to our list, otherwise prepare a copy request. let mut copy_requests = Vec::with_capacity(regions.len()); for (region, get_response) in get_responses { - let get_response = get_response.context(error::GetAmiId { + let get_response = get_response.context(error::GetAmiIdSnafu { name: &ami_args.name, arch: &ami_args.arch, region: region.name(), @@ -389,7 +393,7 @@ async fn _run(args: &Args, ami_args: &AmiArgs) -> Result> } } - ensure!(!saw_error, error::AmiCopy); + ensure!(!saw_error, error::AmiCopySnafu); Ok(amis) } @@ -425,7 +429,7 @@ async fn get_account_ids( let mut sts_clients = HashMap::with_capacity(regions.len()); for region in regions.iter() { let sts_client = - build_client::(®ion, &base_region, &aws).context(error::Client { + build_client::(®ion, &base_region, &aws).context(error::ClientSnafu { client_type: "STS", region: region.name(), })?; @@ -450,10 +454,10 @@ async fn get_account_ids( )> = request_stream.collect().await; for (region, response) in responses { - let response = response.context(error::GetCallerIdentity { + let response = response.context(error::GetCallerIdentitySnafu { region: region.name(), })?; - let account_id = response.account.context(error::MissingInResponse { + let account_id = response.account.context(error::MissingInResponseSnafu { request_type: "GetCallerIdentity", missing: "account", })?; @@ -472,7 +476,7 @@ mod error { use std::path::PathBuf; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub(crate) enum Error { #[snafu(display("Some AMIs failed to copy, see above"))] AmiCopy, diff --git a/tools/pubsys/src/aws/ami/register.rs b/tools/pubsys/src/aws/ami/register.rs index 45dc4b41c4c..50d78f7e2d8 100644 --- a/tools/pubsys/src/aws/ami/register.rs +++ b/tools/pubsys/src/aws/ami/register.rs @@ -37,7 +37,7 @@ async fn _register_image( let root_snapshot = snapshot_from_image(&ami_args.root_image, &uploader, None, ami_args.no_progress) .await - .context(error::Snapshot { + .context(error::SnapshotSnafu { path: &ami_args.root_image, region, })?; @@ -47,7 +47,7 @@ async fn _register_image( if let Some(data_image) = &ami_args.data_image { let snapshot = snapshot_from_image(data_image, &uploader, None, ami_args.no_progress) .await - .context(error::Snapshot { + .context(error::SnapshotSnafu { path: &ami_args.root_image, region, })?; @@ -60,7 +60,7 @@ async fn _register_image( waiter .wait(&root_snapshot, Default::default()) .await - .context(error::WaitSnapshot { + .context(error::WaitSnapshotSnafu { snapshot_type: "root", })?; @@ -68,7 +68,7 @@ async fn _register_image( waiter .wait(&data_snapshot, Default::default()) .await - .context(error::WaitSnapshot { + .context(error::WaitSnapshotSnafu { snapshot_type: "data", })?; } @@ -118,11 +118,11 @@ async fn _register_image( let register_response = ec2_client .register_image(register_request) .await - .context(error::RegisterImage { region })?; + .context(error::RegisterImageSnafu { region })?; let image_id = register_response .image_id - .context(error::MissingImageId { region })?; + .context(error::MissingImageIdSnafu { region })?; let mut snapshot_ids = vec![root_snapshot]; if let Some(data_snapshot) = data_snapshot { @@ -207,14 +207,14 @@ where let describe_response = ec2_client .describe_images(describe_request) .await - .context(error::DescribeImages { region })?; + .context(error::DescribeImagesSnafu { region })?; if let Some(mut images) = describe_response.images { if images.is_empty() { return Ok(None); } ensure!( images.len() == 1, - error::MultipleImages { + error::MultipleImagesSnafu { images: images .into_iter() .map(|i| i.image_id.unwrap_or_else(|| "".to_string())) @@ -224,7 +224,9 @@ where let image = images.remove(0); // If there is an image but we couldn't find the ID of it, fail rather than returning None, // which would indicate no image. - let id = image.image_id.context(error::MissingImageId { region })?; + let id = image + .image_id + .context(error::MissingImageIdSnafu { region })?; Ok(Some(id)) } else { Ok(None) @@ -237,7 +239,7 @@ mod error { use std::path::PathBuf; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub(crate) enum Error { #[snafu(display("Failed to describe images in {}: {}", region, source))] DescribeImages { diff --git a/tools/pubsys/src/aws/ami/snapshot.rs b/tools/pubsys/src/aws/ami/snapshot.rs index ab35805344f..04a9d0d6732 100644 --- a/tools/pubsys/src/aws/ami/snapshot.rs +++ b/tools/pubsys/src/aws/ami/snapshot.rs @@ -31,13 +31,13 @@ where let progress_bar = build_progress_bar(no_progress, "Uploading snapshot"); let filename = path .file_name() - .context(error::InvalidImagePath { path })? + .context(error::InvalidImagePathSnafu { path })? .to_string_lossy(); uploader .upload_from_file(path, desired_size, Some(&filename), progress_bar) .await - .context(error::UploadSnapshot) + .context(error::UploadSnapshotSnafu) } mod error { @@ -45,7 +45,7 @@ mod error { use std::path::PathBuf; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub(crate) enum Error { #[snafu(display("Invalid image path '{}'", path.display()))] InvalidImagePath { path: PathBuf }, diff --git a/tools/pubsys/src/aws/ami/wait.rs b/tools/pubsys/src/aws/ami/wait.rs index 61c9ffb4ac2..77fb23b820d 100644 --- a/tools/pubsys/src/aws/ami/wait.rs +++ b/tools/pubsys/src/aws/ami/wait.rs @@ -27,7 +27,7 @@ pub(crate) async fn wait_for_ami( // Stop if we're over max, unless we're on a success streak, then give it some wiggle room. ensure!( (attempts - successes) <= max_attempts, - error::MaxAttempts { + error::MaxAttemptsSnafu { id, max_attempts, region: region.name() @@ -41,17 +41,15 @@ pub(crate) async fn wait_for_ami( // Use a new client each time so we have more confidence that different endpoints can see // the new AMI. let ec2_client = - build_client::(®ion, &sts_region, &aws).context(error::Client { + build_client::(®ion, &sts_region, &aws).context(error::ClientSnafu { client_type: "EC2", region: region.name(), })?; - let describe_response = - ec2_client - .describe_images(describe_request) - .await - .context(error::DescribeImages { - region: region.name(), - })?; + let describe_response = ec2_client.describe_images(describe_request).await.context( + error::DescribeImagesSnafu { + region: region.name(), + }, + )?; // The response contains an Option>, so we have to check that we got a // list at all, and then that the list contains the ID in question. if let Some(images) = describe_response.images { @@ -76,7 +74,7 @@ pub(crate) async fn wait_for_ami( !["invalid", "deregistered", "failed", "error"] .iter() .any(|e| e == found_state), - error::State { + error::StateSnafu { id, state: found_state, region: region.name() @@ -113,7 +111,7 @@ mod error { use snafu::Snafu; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub(crate) enum Error { #[snafu(display("Error creating {} client in {}: {}", client_type, region, source))] Client { diff --git a/tools/pubsys/src/aws/client.rs b/tools/pubsys/src/aws/client.rs index 588885a5fad..042883e200b 100644 --- a/tools/pubsys/src/aws/client.rs +++ b/tools/pubsys/src/aws/client.rs @@ -72,7 +72,7 @@ pub(crate) fn build_client( base_provider(&aws.profile)?, )?; Ok(T::new_with( - rusoto_core::HttpClient::new().context(error::HttpClient)?, + rusoto_core::HttpClient::new().context(error::HttpClientSnafu)?, provider, region.clone(), )) @@ -106,7 +106,7 @@ where let mut provider = CredentialsProvider(Box::new(base_provider)); for assume_role in assume_roles { let sts = StsClient::new_with( - HttpClient::new().context(error::HttpClient)?, + HttpClient::new().context(error::HttpClientSnafu)?, provider, sts_region.clone(), ); @@ -120,7 +120,7 @@ where None, // MFA serial ); provider = CredentialsProvider(Box::new( - AutoRefreshingProvider::new(expiring_provider).context(error::Provider)?, + AutoRefreshingProvider::new(expiring_provider).context(error::ProviderSnafu)?, )); } Ok(provider) @@ -130,12 +130,12 @@ where /// credentials mechanisms. fn base_provider(maybe_profile: &Option) -> Result { if let Some(profile) = maybe_profile { - let mut p = ProfileProvider::new().context(error::Provider)?; + let mut p = ProfileProvider::new().context(error::ProviderSnafu)?; p.set_profile(profile); Ok(CredentialsProvider(Box::new(p))) } else { Ok(CredentialsProvider(Box::new( - DefaultCredentialsProvider::new().context(error::Provider)?, + DefaultCredentialsProvider::new().context(error::ProviderSnafu)?, ))) } } @@ -144,7 +144,7 @@ pub(crate) mod error { use snafu::Snafu; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub(crate) enum Error { #[snafu(display("Failed to create HTTP client: {}", source))] HttpClient { diff --git a/tools/pubsys/src/aws/mod.rs b/tools/pubsys/src/aws/mod.rs index bb81132cb09..954a3b366d0 100644 --- a/tools/pubsys/src/aws/mod.rs +++ b/tools/pubsys/src/aws/mod.rs @@ -19,7 +19,7 @@ fn region_from_string(name: &str, aws: &AwsConfig) -> Result { name: name.to_string(), endpoint, }, - None => name.parse().context(error::ParseRegion { name })?, + None => name.parse().context(error::ParseRegionSnafu { name })?, }) } @@ -28,7 +28,7 @@ pub(crate) fn parse_arch(input: &str) -> Result { match input { "x86_64" | "amd64" => Ok("x86_64".to_string()), "arm64" | "aarch64" => Ok("arm64".to_string()), - _ => error::ParseArch { + _ => error::ParseArchSnafu { input, msg: "unknown architecture", } @@ -40,7 +40,7 @@ mod error { use snafu::Snafu; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub(crate) enum Error { #[snafu(display("Failed to parse arch '{}': {}", input, msg))] ParseArch { input: String, msg: String }, diff --git a/tools/pubsys/src/aws/promote_ssm/mod.rs b/tools/pubsys/src/aws/promote_ssm/mod.rs index e27f3507169..2b7a2fb1293 100644 --- a/tools/pubsys/src/aws/promote_ssm/mod.rs +++ b/tools/pubsys/src/aws/promote_ssm/mod.rs @@ -53,8 +53,8 @@ pub(crate) async fn run(args: &Args, promote_args: &PromoteArgs) -> Result<()> { // Setup =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= // If a lock file exists, use that, otherwise use Infra.toml - let infra_config = - InfraConfig::from_path_or_lock(&args.infra_config_path, false).context(error::Config)?; + let infra_config = InfraConfig::from_path_or_lock(&args.infra_config_path, false) + .context(error::ConfigSnafu)?; trace!("Parsed infra config: {:#?}", infra_config); let aws = infra_config.aws.unwrap_or_else(Default::default); @@ -67,12 +67,12 @@ pub(crate) async fn run(args: &Args, promote_args: &PromoteArgs) -> Result<()> { aws.regions.clone().into() } .into_iter() - .map(|name| region_from_string(&name, &aws).context(error::ParseRegion)) + .map(|name| region_from_string(&name, &aws).context(error::ParseRegionSnafu)) .collect::>>()?; ensure!( !regions.is_empty(), - error::MissingConfig { + error::MissingConfigSnafu { missing: "aws.regions" } ); @@ -81,7 +81,7 @@ pub(crate) async fn run(args: &Args, promote_args: &PromoteArgs) -> Result<()> { let mut ssm_clients = HashMap::with_capacity(regions.len()); for region in ®ions { let ssm_client = - build_client::(region, &base_region, &aws).context(error::Client { + build_client::(region, &base_region, &aws).context(error::ClientSnafu { client_type: "SSM", region: region.name(), })?; @@ -111,7 +111,7 @@ pub(crate) async fn run(args: &Args, promote_args: &PromoteArgs) -> Result<()> { // in their naming let template_parameters = template::get_parameters(&promote_args.template_path, &source_build_context) - .context(error::FindTemplates)?; + .context(error::FindTemplatesSnafu)?; if template_parameters.parameters.is_empty() { info!( @@ -126,10 +126,10 @@ pub(crate) async fn run(args: &Args, promote_args: &PromoteArgs) -> Result<()> { // from the same template, so we know what to copy. let source_parameter_map = template::render_parameter_names(&template_parameters, ssm_prefix, &source_build_context) - .context(error::RenderTemplates)?; + .context(error::RenderTemplatesSnafu)?; let target_parameter_map = template::render_parameter_names(&template_parameters, ssm_prefix, &target_build_context) - .context(error::RenderTemplates)?; + .context(error::RenderTemplatesSnafu)?; // Parameters are the same in each region, so we need to associate each region with each of // the parameter names so we can fetch them. @@ -155,21 +155,21 @@ pub(crate) async fn run(args: &Args, promote_args: &PromoteArgs) -> Result<()> { info!("Getting current SSM parameters for source and target names"); let current_source_parameters = ssm::get_parameters(&source_keys, &ssm_clients) .await - .context(error::FetchSsm)?; + .context(error::FetchSsmSnafu)?; trace!( "Current source SSM parameters: {:#?}", current_source_parameters ); ensure!( !current_source_parameters.is_empty(), - error::EmptySource { + error::EmptySourceSnafu { version: &promote_args.source } ); let current_target_parameters = ssm::get_parameters(&target_keys, &ssm_clients) .await - .context(error::FetchSsm)?; + .context(error::FetchSsmSnafu)?; trace!( "Current target SSM parameters: {:#?}", current_target_parameters @@ -208,12 +208,12 @@ pub(crate) async fn run(args: &Args, promote_args: &PromoteArgs) -> Result<()> { info!("Setting updated SSM parameters."); ssm::set_parameters(&set_parameters, &ssm_clients) .await - .context(error::SetSsm)?; + .context(error::SetSsmSnafu)?; info!("Validating whether live parameters in SSM reflect changes."); ssm::validate_parameters(&set_parameters, &ssm_clients) .await - .context(error::ValidateSsm)?; + .context(error::ValidateSsmSnafu)?; info!("All parameters match requested values."); Ok(()) @@ -225,7 +225,7 @@ mod error { use snafu::Snafu; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub(crate) enum Error { #[snafu(display("Error creating {} client in {}: {}", client_type, region, source))] Client { diff --git a/tools/pubsys/src/aws/publish_ami/mod.rs b/tools/pubsys/src/aws/publish_ami/mod.rs index 0e692df961a..84b9c25f43d 100644 --- a/tools/pubsys/src/aws/publish_ami/mod.rs +++ b/tools/pubsys/src/aws/publish_ami/mod.rs @@ -66,12 +66,12 @@ pub(crate) async fn run(args: &Args, publish_args: &PublishArgs) -> Result<()> { "Using AMI data from path: {}", publish_args.ami_input.display() ); - let file = File::open(&publish_args.ami_input).context(error::File { + let file = File::open(&publish_args.ami_input).context(error::FileSnafu { op: "open", path: &publish_args.ami_input, })?; let mut ami_input: HashMap = - serde_json::from_reader(file).context(error::Deserialize { + serde_json::from_reader(file).context(error::DeserializeSnafu { path: &publish_args.ami_input, })?; trace!("Parsed AMI input: {:?}", ami_input); @@ -80,14 +80,14 @@ pub(crate) async fn run(args: &Args, publish_args: &PublishArgs) -> Result<()> { // file if a user created one manually, and they shouldn't be creating an empty file. ensure!( !ami_input.is_empty(), - error::Input { + error::InputSnafu { path: &publish_args.ami_input } ); // If a lock file exists, use that, otherwise use Infra.toml or default - let infra_config = - InfraConfig::from_path_or_lock(&args.infra_config_path, true).context(error::Config)?; + let infra_config = InfraConfig::from_path_or_lock(&args.infra_config_path, true) + .context(error::ConfigSnafu)?; trace!("Using infra config: {:?}", infra_config); let aws = infra_config.aws.unwrap_or_else(Default::default); @@ -100,11 +100,11 @@ pub(crate) async fn run(args: &Args, publish_args: &PublishArgs) -> Result<()> { }; ensure!( !regions.is_empty(), - error::MissingConfig { + error::MissingConfigSnafu { missing: "aws.regions" } ); - let base_region = region_from_string(®ions[0], &aws).context(error::ParseRegion)?; + let base_region = region_from_string(®ions[0], &aws).context(error::ParseRegionSnafu)?; // Check that the requested regions are a subset of the regions we *could* publish from the AMI // input JSON. @@ -112,7 +112,7 @@ pub(crate) async fn run(args: &Args, publish_args: &PublishArgs) -> Result<()> { let known_regions = HashSet::<&String>::from_iter(ami_input.keys()); ensure!( requested_regions.is_subset(&known_regions), - error::UnknownRegions { + error::UnknownRegionsSnafu { regions: requested_regions .difference(&known_regions) .map(|s| s.to_string()) @@ -126,10 +126,10 @@ pub(crate) async fn run(args: &Args, publish_args: &PublishArgs) -> Result<()> { let image = ami_input .remove(&name) // This could only happen if someone removes the check above... - .with_context(|| error::UnknownRegions { + .with_context(|| error::UnknownRegionsSnafu { regions: vec![name.clone()], })?; - let region = region_from_string(&name, &aws).context(error::ParseRegion)?; + let region = region_from_string(&name, &aws).context(error::ParseRegionSnafu)?; amis.insert(region, image); } @@ -138,7 +138,7 @@ pub(crate) async fn run(args: &Args, publish_args: &PublishArgs) -> Result<()> { let mut ec2_clients = HashMap::with_capacity(amis.len()); for region in amis.keys() { let ec2_client = - build_client::(®ion, &base_region, &aws).context(error::Client { + build_client::(®ion, &base_region, &aws).context(error::ClientSnafu { client_type: "EC2", region: region.name(), })?; @@ -162,7 +162,7 @@ pub(crate) async fn run(args: &Args, publish_args: &PublishArgs) -> Result<()> { // Make sure waits succeeded and AMIs are available. for ((region, image_id), wait_response) in wait_responses { - wait_response.context(error::WaitAmi { + wait_response.context(error::WaitAmiSnafu { id: &image_id, region: region.name(), })?; @@ -209,25 +209,27 @@ pub(crate) async fn get_snapshots( ..Default::default() }; let describe_response = ec2_client.describe_images(describe_request).await; - let describe_response = describe_response.context(error::DescribeImages { + let describe_response = describe_response.context(error::DescribeImagesSnafu { region: region.name(), })?; // Get the image description, ensuring we only have one. - let mut images = describe_response.images.context(error::MissingInResponse { - request_type: "DescribeImages", - missing: "images", - })?; + let mut images = describe_response + .images + .context(error::MissingInResponseSnafu { + request_type: "DescribeImages", + missing: "images", + })?; ensure!( !images.is_empty(), - error::MissingImage { + error::MissingImageSnafu { region: region.name(), image_id: image_id.to_string(), } ); ensure!( images.len() == 1, - error::MultipleImages { + error::MultipleImagesSnafu { region: region.name(), images: images .into_iter() @@ -240,24 +242,24 @@ pub(crate) async fn get_snapshots( // Look into the block device mappings for snapshots. let bdms = image .block_device_mappings - .context(error::MissingInResponse { + .context(error::MissingInResponseSnafu { request_type: "DescribeImages", missing: "block_device_mappings", })?; ensure!( !bdms.is_empty(), - error::MissingInResponse { + error::MissingInResponseSnafu { request_type: "DescribeImages", missing: "non-empty block_device_mappings" } ); let mut snapshot_ids = Vec::with_capacity(bdms.len()); for bdm in bdms { - let ebs = bdm.ebs.context(error::MissingInResponse { + let ebs = bdm.ebs.context(error::MissingInResponseSnafu { request_type: "DescribeImages", missing: "ebs in block_device_mappings", })?; - let snapshot_id = ebs.snapshot_id.context(error::MissingInResponse { + let snapshot_id = ebs.snapshot_id.context(error::MissingInResponseSnafu { request_type: "DescribeImages", missing: "snapshot_id in block_device_mappings.ebs", })?; @@ -332,7 +334,7 @@ pub(crate) async fn modify_snapshots( )> = request_stream.collect().await; for (snapshot_id, response) in responses { - response.context(error::ModifyImageAttribute { + response.context(error::ModifyImageAttributeSnafu { snapshot_id, region: region.name(), })? @@ -399,7 +401,7 @@ pub(crate) async fn modify_regional_snapshots( ensure!( error_count == 0, - error::ModifySnapshotAttributes { + error::ModifySnapshotAttributesSnafu { error_count, success_count, } @@ -430,7 +432,7 @@ pub(crate) async fn modify_image( ec2_client .modify_image_attribute(modify_image_request) .await - .context(error::ModifyImageAttributes { + .context(error::ModifyImageAttributesSnafu { image_id, region: region.name(), }) @@ -488,7 +490,7 @@ pub(crate) async fn modify_regional_images( ensure!( error_count == 0, - error::ModifyImagesAttributes { + error::ModifyImagesAttributesSnafu { error_count, success_count, } @@ -506,7 +508,7 @@ mod error { use std::path::PathBuf; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub(crate) enum Error { #[snafu(display("Error creating {} client in {}: {}", client_type, region, source))] Client { diff --git a/tools/pubsys/src/aws/ssm/mod.rs b/tools/pubsys/src/aws/ssm/mod.rs index d2245921ecc..7659de30c8a 100644 --- a/tools/pubsys/src/aws/ssm/mod.rs +++ b/tools/pubsys/src/aws/ssm/mod.rs @@ -57,8 +57,8 @@ pub(crate) async fn run(args: &Args, ssm_args: &SsmArgs) -> Result<()> { // Setup =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= // If a lock file exists, use that, otherwise use Infra.toml - let infra_config = - InfraConfig::from_path_or_lock(&args.infra_config_path, false).context(error::Config)?; + let infra_config = InfraConfig::from_path_or_lock(&args.infra_config_path, false) + .context(error::ConfigSnafu)?; trace!("Parsed infra config: {:#?}", infra_config); let aws = infra_config.aws.unwrap_or_else(Default::default); let ssm_prefix = aws.ssm_prefix.as_deref().unwrap_or_else(|| ""); @@ -71,18 +71,18 @@ pub(crate) async fn run(args: &Args, ssm_args: &SsmArgs) -> Result<()> { }; ensure!( !regions.is_empty(), - error::MissingConfig { + error::MissingConfigSnafu { missing: "aws.regions" } ); - let base_region = region_from_string(®ions[0], &aws).context(error::ParseRegion)?; + let base_region = region_from_string(®ions[0], &aws).context(error::ParseRegionSnafu)?; let amis = parse_ami_input(®ions, &ssm_args, &aws)?; let mut ssm_clients = HashMap::with_capacity(amis.len()); for region in amis.keys() { let ssm_client = - build_client::(®ion, &base_region, &aws).context(error::Client { + build_client::(®ion, &base_region, &aws).context(error::ClientSnafu { client_type: "SSM", region: region.name(), })?; @@ -103,7 +103,7 @@ pub(crate) async fn run(args: &Args, ssm_args: &SsmArgs) -> Result<()> { ssm_args.template_path.display() ); let template_parameters = template::get_parameters(&ssm_args.template_path, &build_context) - .context(error::FindTemplates)?; + .context(error::FindTemplatesSnafu)?; if template_parameters.parameters.is_empty() { info!( @@ -115,7 +115,7 @@ pub(crate) async fn run(args: &Args, ssm_args: &SsmArgs) -> Result<()> { let new_parameters = template::render_parameters(template_parameters, amis, ssm_prefix, &build_context) - .context(error::RenderTemplates)?; + .context(error::RenderTemplatesSnafu)?; trace!("Generated templated parameters: {:#?}", new_parameters); // SSM get/compare =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= @@ -124,7 +124,7 @@ pub(crate) async fn run(args: &Args, ssm_args: &SsmArgs) -> Result<()> { let new_parameter_names: Vec<&SsmKey> = new_parameters.keys().collect(); let current_parameters = ssm::get_parameters(&new_parameter_names, &ssm_clients) .await - .context(error::FetchSsm)?; + .context(error::FetchSsmSnafu)?; trace!("Current SSM parameters: {:#?}", current_parameters); // Show the difference between source and target parameters in SSM. @@ -139,7 +139,7 @@ pub(crate) async fn run(args: &Args, ssm_args: &SsmArgs) -> Result<()> { if !ssm_args.allow_clobber { let current_keys: HashSet<&SsmKey> = current_parameters.keys().collect(); let new_keys: HashSet<&SsmKey> = parameters_to_set.keys().collect(); - ensure!(current_keys.is_disjoint(&new_keys), error::NoClobber); + ensure!(current_keys.is_disjoint(&new_keys), error::NoClobberSnafu); } // SSM set =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= @@ -147,12 +147,12 @@ pub(crate) async fn run(args: &Args, ssm_args: &SsmArgs) -> Result<()> { info!("Setting updated SSM parameters."); ssm::set_parameters(¶meters_to_set, &ssm_clients) .await - .context(error::SetSsm)?; + .context(error::SetSsmSnafu)?; info!("Validating whether live parameters in SSM reflect changes."); ssm::validate_parameters(¶meters_to_set, &ssm_clients) .await - .context(error::ValidateSsm)?; + .context(error::ValidateSsmSnafu)?; info!("All parameters match requested values."); Ok(()) @@ -195,12 +195,12 @@ fn parse_ami_input( aws: &AwsConfig, ) -> Result> { info!("Using AMI data from path: {}", ssm_args.ami_input.display()); - let file = File::open(&ssm_args.ami_input).context(error::File { + let file = File::open(&ssm_args.ami_input).context(error::FileSnafu { op: "open", path: &ssm_args.ami_input, })?; let mut ami_input: HashMap = - serde_json::from_reader(file).context(error::Deserialize { + serde_json::from_reader(file).context(error::DeserializeSnafu { path: &ssm_args.ami_input, })?; trace!("Parsed AMI input: {:#?}", ami_input); @@ -209,7 +209,7 @@ fn parse_ami_input( // file if a user created one manually, and they shouldn't be creating an empty file. ensure!( !ami_input.is_empty(), - error::Input { + error::InputSnafu { path: &ssm_args.ami_input } ); @@ -220,7 +220,7 @@ fn parse_ami_input( let known_regions = HashSet::<&String>::from_iter(ami_input.keys()); ensure!( requested_regions.is_subset(&known_regions), - error::UnknownRegions { + error::UnknownRegionsSnafu { regions: requested_regions .difference(&known_regions) .map(|s| s.to_string()) @@ -234,10 +234,10 @@ fn parse_ami_input( let image = ami_input .remove(name) // This could only happen if someone removes the check above... - .with_context(|| error::UnknownRegions { + .with_context(|| error::UnknownRegionsSnafu { regions: vec![name.clone()], })?; - let region = region_from_string(&name, &aws).context(error::ParseRegion)?; + let region = region_from_string(&name, &aws).context(error::ParseRegionSnafu)?; amis.insert(region, image); } @@ -301,7 +301,7 @@ mod error { use std::path::PathBuf; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub(crate) enum Error { #[snafu(display("Error creating {} client in {}: {}", client_type, region, source))] Client { diff --git a/tools/pubsys/src/aws/ssm/ssm.rs b/tools/pubsys/src/aws/ssm/ssm.rs index 3f2dc472a9f..91676e2c59a 100644 --- a/tools/pubsys/src/aws/ssm/ssm.rs +++ b/tools/pubsys/src/aws/ssm/ssm.rs @@ -80,7 +80,7 @@ where new_regions.insert(region.name().to_string()); continue; } else { - return Err(e).context(error::GetParameters { + return Err(e).context(error::GetParametersSnafu { region: region.name(), }); } @@ -95,7 +95,7 @@ where let total_count = valid_count + invalid_count; ensure!( total_count == expected_len, - error::MissingInResponse { + error::MissingInResponseSnafu { region: region.name(), request_type: "GetParameters", missing: format!( @@ -109,12 +109,12 @@ where if let Some(valid_parameters) = response.parameters { if !valid_parameters.is_empty() { for parameter in valid_parameters { - let name = parameter.name.context(error::MissingInResponse { + let name = parameter.name.context(error::MissingInResponseSnafu { region: region.name(), request_type: "GetParameters", missing: "parameter name", })?; - let value = parameter.value.context(error::MissingInResponse { + let value = parameter.value.context(error::MissingInResponseSnafu { region: region.name(), request_type: "GetParameters", missing: format!("value for parameter {}", name), @@ -187,7 +187,7 @@ pub(crate) async fn set_parameters( ensure!( request_interval <= max_interval, - error::Throttled { max_interval } + error::ThrottledSnafu { max_interval } ); // Build requests for parameters. We need to group them by region so we can run each @@ -284,7 +284,7 @@ pub(crate) async fn set_parameters( ); } } - return error::SetParameters { + return error::SetParametersSnafu { failure_count: failed_parameters.len(), total_count, } @@ -330,7 +330,7 @@ pub(crate) async fn validate_parameters( success = false; } } - ensure!(success, error::ValidateParameters); + ensure!(success, error::ValidateParametersSnafu); Ok(()) } @@ -342,7 +342,7 @@ mod error { use std::time::Duration; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub(crate) enum Error { #[snafu(display("Failed to fetch SSM parameters in {}: {}", region, source))] GetParameters { diff --git a/tools/pubsys/src/aws/ssm/template.rs b/tools/pubsys/src/aws/ssm/template.rs index c869567a389..52aec1360d7 100644 --- a/tools/pubsys/src/aws/ssm/template.rs +++ b/tools/pubsys/src/aws/ssm/template.rs @@ -40,12 +40,12 @@ pub(crate) fn get_parameters( template_path: &Path, build_context: &BuildContext<'_>, ) -> Result { - let templates_str = fs::read_to_string(&template_path).context(error::File { + let templates_str = fs::read_to_string(&template_path).context(error::FileSnafu { op: "read", path: &template_path, })?; let mut template_parameters: TemplateParameters = - toml::from_str(&templates_str).context(error::InvalidToml { + toml::from_str(&templates_str).context(error::InvalidTomlSnafu { path: &template_path, })?; trace!("Parsed templates: {:#?}", template_parameters); @@ -54,7 +54,7 @@ pub(crate) fn get_parameters( // conditionals below, we allow that and just don't set any parameters. ensure!( !template_parameters.parameters.is_empty(), - error::NoTemplates { + error::NoTemplatesSnafu { path: template_path } ); @@ -101,17 +101,17 @@ pub(crate) fn render_parameters( for tp in &template_parameters.parameters { let mut tt = TinyTemplate::new(); tt.add_template("name", &tp.name) - .context(error::AddTemplate { template: &tp.name })?; + .context(error::AddTemplateSnafu { template: &tp.name })?; tt.add_template("value", &tp.value) - .context(error::AddTemplate { + .context(error::AddTemplateSnafu { template: &tp.value, })?; let name_suffix = tt .render("name", &context) - .context(error::RenderTemplate { template: &tp.name })?; + .context(error::RenderTemplateSnafu { template: &tp.name })?; let value = tt .render("value", &context) - .context(error::RenderTemplate { + .context(error::RenderTemplateSnafu { template: &tp.value, })?; @@ -137,10 +137,10 @@ pub(crate) fn render_parameter_names( for tp in &template_parameters.parameters { let mut tt = TinyTemplate::new(); tt.add_template("name", &tp.name) - .context(error::AddTemplate { template: &tp.name })?; + .context(error::AddTemplateSnafu { template: &tp.name })?; let name_suffix = tt .render("name", &build_context) - .context(error::RenderTemplate { template: &tp.name })?; + .context(error::RenderTemplateSnafu { template: &tp.name })?; new_parameters.insert(tp.name.clone(), join_name(ssm_prefix, &name_suffix)); } @@ -164,7 +164,7 @@ mod error { use std::path::PathBuf; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub(crate) enum Error { #[snafu(display("Error building template from '{}': {}", template, source))] AddTemplate { diff --git a/tools/pubsys/src/main.rs b/tools/pubsys/src/main.rs index 48cce8c4108..29d5f34f3c1 100644 --- a/tools/pubsys/src/main.rs +++ b/tools/pubsys/src/main.rs @@ -40,46 +40,54 @@ fn run() -> Result<()> { let args = Args::from_args(); // SimpleLogger will send errors to stderr and anything less to stdout. - SimpleLogger::init(args.log_level, LogConfig::default()).context(error::Logger)?; + SimpleLogger::init(args.log_level, LogConfig::default()).context(error::LoggerSnafu)?; match args.subcommand { - SubCommand::Repo(ref repo_args) => repo::run(&args, &repo_args).context(error::Repo), + SubCommand::Repo(ref repo_args) => repo::run(&args, &repo_args).context(error::RepoSnafu), SubCommand::ValidateRepo(ref validate_repo_args) => { - repo::validate_repo::run(&args, &validate_repo_args).context(error::ValidateRepo) + repo::validate_repo::run(&args, &validate_repo_args).context(error::ValidateRepoSnafu) } SubCommand::CheckRepoExpirations(ref check_expirations_args) => { repo::check_expirations::run(&args, &check_expirations_args) - .context(error::CheckExpirations) + .context(error::CheckExpirationsSnafu) } SubCommand::RefreshRepo(ref refresh_repo_args) => { - repo::refresh_repo::run(&args, &refresh_repo_args).context(error::RefreshRepo) + repo::refresh_repo::run(&args, &refresh_repo_args).context(error::RefreshRepoSnafu) } SubCommand::Ami(ref ami_args) => { - let rt = Runtime::new().context(error::Runtime)?; - rt.block_on(async { aws::ami::run(&args, &ami_args).await.context(error::Ami) }) + let rt = Runtime::new().context(error::RuntimeSnafu)?; + rt.block_on(async { + aws::ami::run(&args, &ami_args) + .await + .context(error::AmiSnafu) + }) } SubCommand::PublishAmi(ref publish_args) => { - let rt = Runtime::new().context(error::Runtime)?; + let rt = Runtime::new().context(error::RuntimeSnafu)?; rt.block_on(async { aws::publish_ami::run(&args, &publish_args) .await - .context(error::PublishAmi) + .context(error::PublishAmiSnafu) }) } SubCommand::Ssm(ref ssm_args) => { - let rt = Runtime::new().context(error::Runtime)?; - rt.block_on(async { aws::ssm::run(&args, &ssm_args).await.context(error::Ssm) }) + let rt = Runtime::new().context(error::RuntimeSnafu)?; + rt.block_on(async { + aws::ssm::run(&args, &ssm_args) + .await + .context(error::SsmSnafu) + }) } SubCommand::PromoteSsm(ref promote_args) => { - let rt = Runtime::new().context(error::Runtime)?; + let rt = Runtime::new().context(error::RuntimeSnafu)?; rt.block_on(async { aws::promote_ssm::run(&args, &promote_args) .await - .context(error::PromoteSsm) + .context(error::PromoteSsmSnafu) }) } SubCommand::UploadOva(ref upload_args) => { - vmware::upload_ova::run(&args, &upload_args).context(error::UploadOva) + vmware::upload_ova::run(&args, &upload_args).context(error::UploadOvaSnafu) } } } @@ -138,7 +146,7 @@ mod error { use snafu::Snafu; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub(super) enum Error { #[snafu(display("Failed to build AMI: {}", source))] Ami { source: crate::aws::ami::Error }, diff --git a/tools/pubsys/src/repo.rs b/tools/pubsys/src/repo.rs index b08b1a3b6cd..3892e999cbc 100644 --- a/tools/pubsys/src/repo.rs +++ b/tools/pubsys/src/repo.rs @@ -111,9 +111,9 @@ fn update_manifest(repo_args: &RepoArgs, manifest: &mut Manifest) -> Result<()> let filename = |path: &PathBuf| -> Result { Ok(path .file_name() - .context(error::InvalidImagePath { path })? + .context(error::InvalidImagePathSnafu { path })? .to_str() - .context(error::NonUtf8Path { path })? + .context(error::NonUtf8PathSnafu { path })? .to_string()) }; @@ -135,7 +135,7 @@ fn update_manifest(repo_args: &RepoArgs, manifest: &mut Manifest) -> Result<()> repo_args.variant.clone(), images, ) - .context(error::AddUpdate)?; + .context(error::AddUpdateSnafu)?; // Add migrations =^..^= =^..^= =^..^= =^..^= @@ -143,10 +143,11 @@ fn update_manifest(repo_args: &RepoArgs, manifest: &mut Manifest) -> Result<()> "Using release config from path: {}", repo_args.release_config_path.display() ); - let release = - Release::from_path(&repo_args.release_config_path).context(error::UpdateMetadataRead { + let release = Release::from_path(&repo_args.release_config_path).context( + error::UpdateMetadataReadSnafu { path: &repo_args.release_config_path, - })?; + }, + )?; trace!( "Adding migrations to manifest for versions: {:#?}", release @@ -169,10 +170,11 @@ fn update_manifest(repo_args: &RepoArgs, manifest: &mut Manifest) -> Result<()> "Offsets from that file will be added to the release start time of: {}", wave_start_time ); - let waves = - UpdateWaves::from_path(&repo_args.wave_policy_path).context(error::UpdateMetadataRead { + let waves = UpdateWaves::from_path(&repo_args.wave_policy_path).context( + error::UpdateMetadataReadSnafu { path: &repo_args.wave_policy_path, - })?; + }, + )?; manifest .set_waves( repo_args.variant.clone(), @@ -181,7 +183,7 @@ fn update_manifest(repo_args: &RepoArgs, manifest: &mut Manifest) -> Result<()> wave_start_time, &waves, ) - .context(error::SetWaves { + .context(error::SetWavesSnafu { wave_policy_path: &repo_args.wave_policy_path, })?; @@ -205,7 +207,7 @@ fn set_expirations( editor .snapshot_expires(snapshot_expiration) .targets_expires(targets_expiration) - .context(error::SetTargetsExpiration { + .context(error::SetTargetsExpirationSnafu { expiration: targets_expiration, })? .timestamp_expires(timestamp_expiration); @@ -222,7 +224,7 @@ fn set_versions(editor: &mut RepositoryEditor) -> Result<()> { editor .snapshot_version(version) .targets_version(version) - .context(error::SetTargetsVersion { version })? + .context(error::SetTargetsVersionSnafu { version })? .timestamp_version(version); Ok(()) @@ -244,16 +246,16 @@ where debug!("Adding target from path: {}", target_path.display()); editor .add_target_path(&target_path) - .context(error::AddTarget { path: &target_path })?; + .context(error::AddTargetSnafu { path: &target_path })?; } - let manifest_target = Target::from_path(&manifest_path).context(error::BuildTarget { + let manifest_target = Target::from_path(&manifest_path).context(error::BuildTargetSnafu { path: manifest_path.as_ref(), })?; debug!("Adding target for manifest.json"); editor .add_target("manifest.json", manifest_target) - .context(error::AddTarget { + .context(error::AddTargetSnafu { path: "manifest.json", })?; @@ -264,7 +266,7 @@ where repo_args.repo_expiration_policy_path.display() ); let expiration = RepoExpirationPolicy::from_path(&repo_args.repo_expiration_policy_path) - .context(error::Config)?; + .context(error::ConfigSnafu)?; let expiration_start_time = repo_args.release_start_time.unwrap_or(*DEFAULT_START_TIME); let snapshot_expiration = expiration_start_time + expiration.snapshot_expiration; @@ -277,7 +279,7 @@ where editor .snapshot_expires(snapshot_expiration) .targets_expires(targets_expiration) - .context(error::SetTargetsExpiration { + .context(error::SetTargetsExpirationSnafu { expiration: targets_expiration, })? .timestamp_expires(timestamp_expiration); @@ -291,7 +293,7 @@ where editor .snapshot_version(version) .targets_version(version) - .context(error::SetTargetsVersion { version })? + .context(error::SetTargetsVersionSnafu { version })? .timestamp_version(version); Ok(()) @@ -314,7 +316,7 @@ fn repo_urls<'a>( }; let metadata_url_str = format!("{}{}{}/{}", metadata_base_url, base_slash, variant, arch); - let metadata_url = Url::parse(&metadata_url_str).context(error::ParseUrl { + let metadata_url = Url::parse(&metadata_url_str).context(error::ParseUrlSnafu { input: &metadata_url_str, })?; @@ -341,7 +343,7 @@ where // Try to load the repo... let repo_load_result = RepositoryLoader::new( - File::open(root_role_path).context(error::File { + File::open(root_role_path).context(error::FileSnafu { path: root_role_path, })?, metadata_url.clone(), @@ -355,21 +357,21 @@ where let target = "manifest.json"; let target = target .try_into() - .context(error::ParseTargetName { target })?; + .context(error::ParseTargetNameSnafu { target })?; let reader = repo .read_target(&target) - .context(error::ReadTarget { + .context(error::ReadTargetSnafu { target: target.raw(), })? - .with_context(|| error::NoManifest { + .with_context(|| error::NoManifestSnafu { metadata_url: metadata_url.clone(), })?; - let manifest = serde_json::from_reader(reader).context(error::InvalidJson { + let manifest = serde_json::from_reader(reader).context(error::InvalidJsonSnafu { path: "manifest.json", })?; - let editor = - RepositoryEditor::from_repo(root_role_path, repo).context(error::EditorFromRepo)?; + let editor = RepositoryEditor::from_repo(root_role_path, repo) + .context(error::EditorFromRepoSnafu)?; Ok(Some((editor, manifest))) } @@ -379,7 +381,7 @@ where if is_file_not_found_error(&e) { Ok(None) } else { - Err(e).with_context(|| error::RepoLoad { + Err(e).with_context(|_| error::RepoLoadSnafu { metadata_base_url: metadata_url.clone(), }) } @@ -404,11 +406,11 @@ fn get_signing_key_source(signing_key_config: &SigningKeyConfig) -> Result Result Result> { if let Some(region) = config.available_keys.get(key_id) { Ok(Some(KmsClient::new( - Region::from_str(region).context(error::ParseRegion { what: region })?, + Region::from_str(region).context(error::ParseRegionSnafu { what: region })?, ))) } else { Ok(None) @@ -446,7 +448,7 @@ pub(crate) fn run(args: &Args, repo_args: &RepoArgs) -> Result<()> { // existing repository. (The targets directory is shared, so it's fine if that exists.) ensure!( !Path::exists(&metadata_out_dir), - error::RepoExists { + error::RepoExistsSnafu { path: metadata_out_dir } ); @@ -454,8 +456,8 @@ pub(crate) fn run(args: &Args, repo_args: &RepoArgs) -> Result<()> { // Build repo =^..^= =^..^= =^..^= =^..^= // If a lock file exists, use that, otherwise use Infra.toml or default - let infra_config = - InfraConfig::from_path_or_lock(&args.infra_config_path, true).context(error::Config)?; + let infra_config = InfraConfig::from_path_or_lock(&args.infra_config_path, true) + .context(error::ConfigSnafu)?; trace!("Using infra config: {:?}", infra_config); // If the user has the requested (or "default") repo defined in their Infra.toml, use it, @@ -491,7 +493,8 @@ pub(crate) fn run(args: &Args, repo_args: &RepoArgs) -> Result<()> { metadata_url ); ( - RepositoryEditor::new(&repo_args.root_role_path).context(error::NewEditor)?, + RepositoryEditor::new(&repo_args.root_role_path) + .context(error::NewEditorSnafu)?, Manifest::default(), ) } @@ -499,7 +502,7 @@ pub(crate) fn run(args: &Args, repo_args: &RepoArgs) -> Result<()> { } else { info!("Did not find metadata and target URLs in infra config, creating a new repository"); ( - RepositoryEditor::new(&repo_args.root_role_path).context(error::NewEditor)?, + RepositoryEditor::new(&repo_args.root_role_path).context(error::NewEditorSnafu)?, Manifest::default(), ) }; @@ -508,9 +511,9 @@ pub(crate) fn run(args: &Args, repo_args: &RepoArgs) -> Result<()> { update_manifest(&repo_args, &mut manifest)?; // Write manifest to tempfile so it can be copied in as target later let manifest_path = NamedTempFile::new() - .context(error::TempFile)? + .context(error::TempFileSnafu)? .into_temp_path(); - update_metadata::write_file(&manifest_path, &manifest).context(error::ManifestWrite { + update_metadata::write_file(&manifest_path, &manifest).context(error::ManifestWriteSnafu { path: &manifest_path, })?; @@ -536,7 +539,7 @@ pub(crate) fn run(args: &Args, repo_args: &RepoArgs) -> Result<()> { } else { ensure!( repo_args.default_key_path.exists(), - error::MissingConfig { + error::MissingConfigSnafu { missing: "signing_keys in repo config, and we found no local key", } ); @@ -545,13 +548,13 @@ pub(crate) fn run(args: &Args, repo_args: &RepoArgs) -> Result<()> { }) }; - let signed_repo = editor.sign(&[key_source]).context(error::RepoSign)?; + let signed_repo = editor.sign(&[key_source]).context(error::RepoSignSnafu)?; // Write repo =^..^= =^..^= =^..^= =^..^= // Write targets first so we don't have invalid metadata if targets fail info!("Writing repo targets to: {}", targets_out_dir.display()); - fs::create_dir_all(&targets_out_dir).context(error::CreateDir { + fs::create_dir_all(&targets_out_dir).context(error::CreateDirSnafu { path: &targets_out_dir, })?; @@ -560,7 +563,7 @@ pub(crate) fn run(args: &Args, repo_args: &RepoArgs) -> Result<()> { let target = "manifest.json"; let target = target .try_into() - .context(error::ParseTargetName { target })?; + .context(error::ParseTargetNameSnafu { target })?; signed_repo .copy_target( &manifest_path, @@ -569,7 +572,7 @@ pub(crate) fn run(args: &Args, repo_args: &RepoArgs) -> Result<()> { PathExists::Fail, Some(&target), ) - .context(error::CopyTarget { + .context(error::CopyTargetSnafu { target: &manifest_path, path: &targets_out_dir, })?; @@ -583,7 +586,7 @@ pub(crate) fn run(args: &Args, repo_args: &RepoArgs) -> Result<()> { ); signed_repo .copy_target(copy_target, &targets_out_dir, PathExists::Skip, None) - .context(error::CopyTarget { + .context(error::CopyTargetSnafu { target: copy_target, path: &targets_out_dir, })?; @@ -596,19 +599,19 @@ pub(crate) fn run(args: &Args, repo_args: &RepoArgs) -> Result<()> { ); signed_repo .link_target(link_target, &targets_out_dir, PathExists::Skip, None) - .context(error::LinkTarget { + .context(error::LinkTargetSnafu { target: link_target, path: &targets_out_dir, })?; } info!("Writing repo metadata to: {}", metadata_out_dir.display()); - fs::create_dir_all(&metadata_out_dir).context(error::CreateDir { + fs::create_dir_all(&metadata_out_dir).context(error::CreateDirSnafu { path: &metadata_out_dir, })?; signed_repo .write(&metadata_out_dir) - .context(error::RepoWrite { + .context(error::RepoWriteSnafu { path: &repo_args.outdir, })?; @@ -623,7 +626,7 @@ mod error { use url::Url; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub(crate) enum Error { #[snafu(display("Failed to add new update to manifest: {}", source))] AddUpdate { diff --git a/tools/pubsys/src/repo/check_expirations/mod.rs b/tools/pubsys/src/repo/check_expirations/mod.rs index 11ad4aaf675..8af39b9d271 100644 --- a/tools/pubsys/src/repo/check_expirations/mod.rs +++ b/tools/pubsys/src/repo/check_expirations/mod.rs @@ -82,7 +82,7 @@ fn check_expirations( ) -> Result<()> { // Load the repository let repo = RepositoryLoader::new( - File::open(root_role_path).context(repo_error::File { + File::open(root_role_path).context(repo_error::FileSnafu { path: root_role_path, })?, metadata_url.clone(), @@ -91,7 +91,7 @@ fn check_expirations( // We're gonna check the expiration ourselves .expiration_enforcement(ExpirationEnforcement::Unsafe) .load() - .context(repo_error::RepoLoad { + .context(repo_error::RepoLoadSnafu { metadata_base_url: metadata_url.clone(), })?; info!("Loaded TUF repo:\t{}", metadata_url); @@ -132,16 +132,16 @@ fn check_expirations( pub(crate) fn run(args: &Args, check_expirations_args: &CheckExpirationsArgs) -> Result<()> { // If a lock file exists, use that, otherwise use Infra.toml let infra_config = InfraConfig::from_path_or_lock(&args.infra_config_path, false) - .context(repo_error::Config)?; + .context(repo_error::ConfigSnafu)?; trace!("Parsed infra config: {:?}", infra_config); let repo_config = infra_config .repo .as_ref() - .context(repo_error::MissingConfig { + .context(repo_error::MissingConfigSnafu { missing: "repo section", })? .get(&check_expirations_args.repo) - .with_context(|| repo_error::MissingConfig { + .with_context(|| repo_error::MissingConfigSnafu { missing: format!("definition for repo {}", &check_expirations_args.repo), })?; @@ -150,7 +150,7 @@ pub(crate) fn run(args: &Args, check_expirations_args: &CheckExpirationsArgs) -> &check_expirations_args.variant, &check_expirations_args.arch, )? - .context(repo_error::MissingRepoUrls { + .context(repo_error::MissingRepoUrlsSnafu { repo: &check_expirations_args.repo, })?; check_expirations( @@ -168,7 +168,7 @@ mod error { use url::Url; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub(crate) enum Error { #[snafu(context(false), display("{}", source))] Repo { source: crate::repo::Error }, diff --git a/tools/pubsys/src/repo/refresh_repo/mod.rs b/tools/pubsys/src/repo/refresh_repo/mod.rs index 5bdea815c69..c8d243cb045 100644 --- a/tools/pubsys/src/repo/refresh_repo/mod.rs +++ b/tools/pubsys/src/repo/refresh_repo/mod.rs @@ -73,7 +73,7 @@ fn refresh_repo( // existing repository. ensure!( !Path::exists(&metadata_out_dir), - repo_error::RepoExists { + repo_error::RepoExistsSnafu { path: metadata_out_dir } ); @@ -86,7 +86,7 @@ fn refresh_repo( // Load the repository and get the repo editor for it let repo = RepositoryLoader::new( - File::open(root_role_path).context(repo_error::File { + File::open(root_role_path).context(repo_error::FileSnafu { path: root_role_path, })?, metadata_url.clone(), @@ -94,11 +94,11 @@ fn refresh_repo( ) .expiration_enforcement(expiration_enforcement) .load() - .context(repo_error::RepoLoad { + .context(repo_error::RepoLoadSnafu { metadata_base_url: metadata_url.clone(), })?; - let mut repo_editor = - RepositoryEditor::from_repo(&root_role_path, repo).context(repo_error::EditorFromRepo)?; + let mut repo_editor = RepositoryEditor::from_repo(&root_role_path, repo) + .context(repo_error::EditorFromRepoSnafu)?; info!("Loaded TUF repo: {}", metadata_url); // Refresh the expiration dates of all non-root metadata files @@ -110,16 +110,16 @@ fn refresh_repo( // Sign the repository let signed_repo = repo_editor .sign(&[key_source]) - .context(repo_error::RepoSign)?; + .context(repo_error::RepoSignSnafu)?; // Write out the metadata files for the repository info!("Writing repo metadata to: {}", metadata_out_dir.display()); - fs::create_dir_all(&metadata_out_dir).context(repo_error::CreateDir { + fs::create_dir_all(&metadata_out_dir).context(repo_error::CreateDirSnafu { path: &metadata_out_dir, })?; signed_repo .write(&metadata_out_dir) - .context(repo_error::RepoWrite { + .context(repo_error::RepoWriteSnafu { path: &metadata_out_dir, })?; @@ -130,17 +130,17 @@ fn refresh_repo( pub(crate) fn run(args: &Args, refresh_repo_args: &RefreshRepoArgs) -> Result<(), Error> { // If a lock file exists, use that, otherwise use Infra.toml let infra_config = InfraConfig::from_path_or_lock(&args.infra_config_path, false) - .context(repo_error::Config)?; + .context(repo_error::ConfigSnafu)?; trace!("Parsed infra config: {:?}", infra_config); let repo_config = infra_config .repo .as_ref() - .context(repo_error::MissingConfig { + .context(repo_error::MissingConfigSnafu { missing: "repo section", })? .get(&refresh_repo_args.repo) - .context(repo_error::MissingConfig { + .context(repo_error::MissingConfigSnafu { missing: format!("definition for repo {}", &refresh_repo_args.repo), })?; @@ -153,7 +153,7 @@ pub(crate) fn run(args: &Args, refresh_repo_args: &RefreshRepoArgs) -> Result<() } else { ensure!( refresh_repo_args.default_key_path.exists(), - repo_error::MissingConfig { + repo_error::MissingConfigSnafu { missing: "signing_keys in repo config, and we found no local key", } ); @@ -169,14 +169,14 @@ pub(crate) fn run(args: &Args, refresh_repo_args: &RefreshRepoArgs) -> Result<() ); let expiration = RepoExpirationPolicy::from_path(&refresh_repo_args.repo_expiration_policy_path) - .context(repo_error::Config)?; + .context(repo_error::ConfigSnafu)?; let repo_urls = repo_urls( &repo_config, &refresh_repo_args.variant, &refresh_repo_args.arch, )? - .context(repo_error::MissingRepoUrls { + .context(repo_error::MissingRepoUrlsSnafu { repo: &refresh_repo_args.repo, })?; refresh_repo( @@ -200,7 +200,7 @@ mod error { use url::Url; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub(crate) enum Error { #[snafu(context(false), display("{}", source))] Repo { source: crate::repo::Error }, diff --git a/tools/pubsys/src/repo/validate_repo/mod.rs b/tools/pubsys/src/repo/validate_repo/mod.rs index 9a3ddff47af..1feeea2e576 100644 --- a/tools/pubsys/src/repo/validate_repo/mod.rs +++ b/tools/pubsys/src/repo/validate_repo/mod.rs @@ -51,7 +51,7 @@ fn retrieve_targets(repo: &Repository) -> Result<(), Error> { let thread_pool = rayon::ThreadPoolBuilder::new() .num_threads(min(num_cpus::get(), MAX_DOWNLOAD_THREADS)) .build() - .context(error::ThreadPool)?; + .context(error::ThreadPoolSnafu)?; // create the channels through which our download results will be passed let (tx, rx) = mpsc::channel(); @@ -60,17 +60,17 @@ fn retrieve_targets(repo: &Repository) -> Result<(), Error> { let tx = tx.clone(); let mut reader = repo .read_target(&target) - .with_context(|| repo_error::ReadTarget { + .with_context(|_| repo_error::ReadTargetSnafu { target: target.raw(), })? - .with_context(|| error::TargetMissing { + .with_context(|| error::TargetMissingSnafu { target: target.raw(), })?; info!("Downloading target: {}", target.raw()); thread_pool.spawn(move || { tx.send({ // tough's `Read` implementation validates the target as it's being downloaded - io::copy(&mut reader, &mut io::sink()).context(error::TargetDownload { + io::copy(&mut reader, &mut io::sink()).context(error::TargetDownloadSnafu { target: target.raw(), }) }) @@ -101,14 +101,14 @@ fn validate_repo( ) -> Result<(), Error> { // Load the repository let repo = RepositoryLoader::new( - File::open(root_role_path).context(repo_error::File { + File::open(root_role_path).context(repo_error::FileSnafu { path: root_role_path, })?, metadata_url.clone(), targets_url.clone(), ) .load() - .context(repo_error::RepoLoad { + .context(repo_error::RepoLoadSnafu { metadata_base_url: metadata_url.clone(), })?; info!("Loaded TUF repo: {}", metadata_url); @@ -124,16 +124,16 @@ fn validate_repo( pub(crate) fn run(args: &Args, validate_repo_args: &ValidateRepoArgs) -> Result<(), Error> { // If a lock file exists, use that, otherwise use Infra.toml let infra_config = InfraConfig::from_path_or_lock(&args.infra_config_path, false) - .context(repo_error::Config)?; + .context(repo_error::ConfigSnafu)?; trace!("Parsed infra config: {:?}", infra_config); let repo_config = infra_config .repo .as_ref() - .context(repo_error::MissingConfig { + .context(repo_error::MissingConfigSnafu { missing: "repo section", })? .get(&validate_repo_args.repo) - .context(repo_error::MissingConfig { + .context(repo_error::MissingConfigSnafu { missing: format!("definition for repo {}", &validate_repo_args.repo), })?; @@ -142,7 +142,7 @@ pub(crate) fn run(args: &Args, validate_repo_args: &ValidateRepoArgs) -> Result< &validate_repo_args.variant, &validate_repo_args.arch, )? - .context(repo_error::MissingRepoUrls { + .context(repo_error::MissingRepoUrlsSnafu { repo: &validate_repo_args.repo, })?; validate_repo( @@ -158,7 +158,7 @@ mod error { use std::io; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub(crate) enum Error { #[snafu(display("Invalid percentage specified: {} is greater than 100", percentage))] InvalidPercentage { percentage: u8 }, diff --git a/tools/pubsys/src/vmware/govc.rs b/tools/pubsys/src/vmware/govc.rs index 8248f2c8a3d..f576fd6c8f7 100644 --- a/tools/pubsys/src/vmware/govc.rs +++ b/tools/pubsys/src/vmware/govc.rs @@ -99,7 +99,7 @@ impl Govc { /// to run in the container. // The arguments are `&[&str]` in an attempt to be as flexible as possible for the caller fn docker_run(docker_env: &[&str], mount: Option<&[&str]>, command: &[&str]) -> Result { - let sdk = env::var("BUILDSYS_SDK_IMAGE").context(error::Environment { + let sdk = env::var("BUILDSYS_SDK_IMAGE").context(error::EnvironmentSnafu { var: "BUILDSYS_SDK_IMAGE", })?; trace!("SDK image: {}", sdk); @@ -120,14 +120,14 @@ fn docker_run(docker_env: &[&str], mount: Option<&[&str]>, command: &[&str]) -> .stdout_capture() .unchecked() .run() - .context(error::CommandStart)?; + .context(error::CommandStartSnafu)?; let stdout = String::from_utf8_lossy(&output.stdout); trace!("{}", stdout); if output.status.success() { Ok(output) } else { - error::Docker { output: stdout }.fail() + error::DockerSnafu { output: stdout }.fail() } } @@ -158,7 +158,7 @@ pub(crate) mod error { use snafu::Snafu; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub(crate) enum Error { #[snafu(display("Failed to start command: {}", source))] CommandStart { source: std::io::Error }, diff --git a/tools/pubsys/src/vmware/upload_ova/mod.rs b/tools/pubsys/src/vmware/upload_ova/mod.rs index 3634327e702..4a00b396432 100644 --- a/tools/pubsys/src/vmware/upload_ova/mod.rs +++ b/tools/pubsys/src/vmware/upload_ova/mod.rs @@ -47,12 +47,12 @@ pub(crate) struct UploadArgs { pub(crate) fn run(args: &Args, upload_args: &UploadArgs) -> Result<()> { // If a lock file exists, use that, otherwise use Infra.toml or default let infra_config = InfraConfig::from_path_or_lock(&args.infra_config_path, true) - .context(error::InfraConfig)?; + .context(error::InfraConfigSnafu)?; trace!("Using infra config: {:?}", infra_config); let vmware = infra_config .vmware - .context(error::MissingConfig { missing: "vmware" })?; + .context(error::MissingConfigSnafu { missing: "vmware" })?; // If the user gave an override list of datacenters, use it, otherwise use what's in the config let upload_datacenters = if !upload_args.datacenters.is_empty() { @@ -62,7 +62,7 @@ pub(crate) fn run(args: &Args, upload_args: &UploadArgs) -> Result<()> { }; ensure!( !upload_datacenters.is_empty(), - error::MissingConfig { + error::MissingConfigSnafu { missing: "vmware.datacenters" } ); @@ -74,7 +74,7 @@ pub(crate) fn run(args: &Args, upload_args: &UploadArgs) -> Result<()> { let creds_file = if let Some(ref creds_file) = *VMWARE_CREDS_PATH { if creds_file.exists() { info!("Using vSphere credentials file at {}", creds_file.display()); - DatacenterCredsConfig::from_path(creds_file).context(error::VmwareConfig)? + DatacenterCredsConfig::from_path(creds_file).context(error::VmwareConfigSnafu)? } else { info!("vSphere credentials file not found, will attempt to use environment"); DatacenterCredsConfig::default() @@ -90,13 +90,13 @@ pub(crate) fn run(args: &Args, upload_args: &UploadArgs) -> Result<()> { let dc_common = vmware.common.as_ref(); // Read the import spec as a template - let import_spec_str = fs::read_to_string(&upload_args.spec).context(error::File { + let import_spec_str = fs::read_to_string(&upload_args.spec).context(error::FileSnafu { action: "read", path: &upload_args.spec, })?; let mut tt = TinyTemplate::new(); tt.add_template(SPEC_TEMPLATE_NAME, &import_spec_str) - .context(error::AddTemplate { + .context(error::AddTemplateSnafu { path: &upload_args.spec, })?; @@ -117,7 +117,7 @@ pub(crate) fn run(args: &Args, upload_args: &UploadArgs) -> Result<()> { .take_missing_from(dc_config) .take_missing_from(dc_common) .build() - .context(error::DatacenterBuild)?; + .context(error::DatacenterBuildSnafu)?; // Use a similar pattern here for credentials; start with environment variables and fill in // any missing items with the datacenter-specific credentials from file. @@ -125,12 +125,12 @@ pub(crate) fn run(args: &Args, upload_args: &UploadArgs) -> Result<()> { let creds: DatacenterCreds = creds_env .take_missing_from(dc_creds) .build() - .context(error::CredsBuild)?; + .context(error::CredsBuildSnafu)?; // Render the import spec with this datacenter's details and write to temp file let rendered_spec = render_spec(&tt, &datacenter.network, upload_args.mark_as_template)?; - let import_spec = NamedTempFile::new().context(error::TempFile)?; - fs::write(import_spec.path(), &rendered_spec).context(error::File { + let import_spec = NamedTempFile::new().context(error::TempFileSnafu)?; + fs::write(import_spec.path(), &rendered_spec).context(error::FileSnafu { action: "write", path: import_spec.path(), })?; @@ -150,7 +150,7 @@ pub(crate) fn run(args: &Args, upload_args: &UploadArgs) -> Result<()> { Govc::new(datacenter, creds) .upload_ova(&upload_args.name, &upload_args.ova, import_spec) - .context(error::UploadOva)?; + .context(error::UploadOvaSnafu)?; } Ok(()) @@ -176,7 +176,7 @@ where Ok(tt .render(SPEC_TEMPLATE_NAME, &context) - .context(error::RenderTemplate)?) + .context(error::RenderTemplateSnafu)?) } mod error { @@ -185,7 +185,7 @@ mod error { use std::path::PathBuf; #[derive(Debug, Snafu)] - #[snafu(visibility = "pub(super)")] + #[snafu(visibility(pub(super)))] pub(crate) enum Error { #[snafu(display("Error building template from '{}': {}", path.display(), source))] AddTemplate { From 4cb1deedec4b69d9d14d8850a0dd4f1a0d905304 Mon Sep 17 00:00:00 2001 From: Matthew James Briggs Date: Wed, 2 Feb 2022 19:06:26 -0800 Subject: [PATCH 7/8] tools: update rust dependencies --- tools/Cargo.lock | 516 ++++++++++++++++++++-------------- tools/buildsys/Cargo.toml | 2 +- tools/deny.toml | 13 + tools/infrasys/Cargo.toml | 4 +- tools/pubsys-setup/Cargo.toml | 4 +- tools/pubsys/Cargo.toml | 2 +- 6 files changed, 325 insertions(+), 216 deletions(-) diff --git a/tools/Cargo.lock b/tools/Cargo.lock index 627d9a1b9a3..08734391088 100644 --- a/tools/Cargo.lock +++ b/tools/Cargo.lock @@ -28,18 +28,18 @@ dependencies = [ [[package]] name = "ansi_term" -version = "0.11.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" dependencies = [ "winapi", ] [[package]] name = "argh" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f023c76cd7975f9969f8e29f0e461decbdc7f51048ce43427107a3d192f1c9bf" +checksum = "dbb41d85d92dfab96cb95ab023c265c5e4261bb956c0fb49ca06d90c570f1958" dependencies = [ "argh_derive", "argh_shared", @@ -47,9 +47,9 @@ dependencies = [ [[package]] name = "argh_derive" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48ad219abc0c06ca788aface2e3a1970587e3413ab70acd20e54b6ec524c1f8f" +checksum = "be69f70ef5497dd6ab331a50bd95c6ac6b8f7f17a7967838332743fbd58dc3b5" dependencies = [ "argh_shared", "heck", @@ -60,9 +60,9 @@ dependencies = [ [[package]] name = "argh_shared" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38de00daab4eac7d753e97697066238d67ce9d7e2d823ab4f72fe14af29f3f33" +checksum = "e6f8c380fa28aa1b36107cd97f0196474bb7241bb95a453c5c01a15ac74b2eac" [[package]] name = "assert-json-diff" @@ -76,9 +76,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.51" +version = "0.1.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44318e776df68115a881de9a8fd1b9e53368d7a4a5ce4cc48517da3393233a5e" +checksum = "061a7acccaa286c011ddc30970520b98fa40e00c9d644633fb26b5fc63a265e3" dependencies = [ "proc-macro2", "quote", @@ -104,9 +104,9 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] name = "backtrace" -version = "0.3.63" +version = "0.3.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "321629d8ba6513061f26707241fa9bc89524ff1cd7a915a97ef0c62c666ce1b6" +checksum = "5e121dee8023ce33ab248d9ce1493df03c3b38a659b240096fcbd7048ff9c31f" dependencies = [ "addr2line", "cc", @@ -138,6 +138,15 @@ dependencies = [ "generic-array", ] +[[package]] +name = "block-buffer" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1d36a02058e76b040de25a4464ba1c80935655595b661505c8b39b664828b95" +dependencies = [ + "generic-array", +] + [[package]] name = "bstr" version = "0.2.17" @@ -160,7 +169,7 @@ dependencies = [ "reqwest", "serde", "serde_plain", - "sha2", + "sha2 0.10.1", "snafu 0.7.0", "toml", "url", @@ -169,9 +178,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.8.0" +version = "3.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f1e260c3a9040a7c19a12468758f4c16f31a81a1fe087482be9570ec864bb6c" +checksum = "a4a45a46ab1f2412e53d3a0ade76ffad2025804294569aae387231a0cd6e0899" [[package]] name = "bytes" @@ -196,9 +205,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.71" +version = "1.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79c2681d6594606957bbb8631c4b90a7fcaaa72cdb714743a437b156d6a7eedd" +checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee" [[package]] name = "cfg-if" @@ -222,9 +231,9 @@ dependencies = [ [[package]] name = "clap" -version = "2.33.3" +version = "2.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" +checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" dependencies = [ "ansi_term", "atty", @@ -251,7 +260,7 @@ dependencies = [ "rusoto_ebs", "rusoto_ec2", "rusoto_signature", - "sha2", + "sha2 0.9.9", "snafu 0.6.10", "tempfile", "tokio", @@ -297,18 +306,18 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.2.1" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a" +checksum = "a2209c310e29876f7f0b2721e7e26b84aff178aa3da5d091f9bfbf47669e60e3" dependencies = [ "cfg-if", ] [[package]] name = "crossbeam-channel" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4" +checksum = "e54ea8bc3fb1ee042f5aace6e3c6e025d3874866da222930f70ce62aceba0bfa" dependencies = [ "cfg-if", "crossbeam-utils", @@ -327,9 +336,9 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.5" +version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd" +checksum = "97242a70df9b89a65d0b6df3c4bf5b9ce03c5b7309019777fbde37e7537f8762" dependencies = [ "cfg-if", "crossbeam-utils", @@ -340,14 +349,23 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db" +checksum = "cfcae03edb34f947e64acdb1c33ec169824e20657e9ecb61cef6c8c74dcb8120" dependencies = [ "cfg-if", "lazy_static", ] +[[package]] +name = "crypto-common" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d6b536309245c849479fba3da410962a43ed8e51c26b729208ec0ac2798d0" +dependencies = [ + "generic-array", +] + [[package]] name = "crypto-mac" version = "0.11.1" @@ -364,7 +382,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1a816186fa68d9e426e3cb4ae4dff1fcd8e4a2c34b781bf7a822574a0d0aac8" dependencies = [ - "sct", + "sct 0.6.1", ] [[package]] @@ -376,6 +394,17 @@ dependencies = [ "generic-array", ] +[[package]] +name = "digest" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b697d66081d42af4fba142d56918a3cb21dc8eb63372c6b85d14f44fb9c5979b" +dependencies = [ + "block-buffer 0.10.0", + "crypto-common", + "generic-array", +] + [[package]] name = "dirs-next" version = "2.0.0" @@ -403,12 +432,6 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" -[[package]] -name = "dtoa" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56899898ce76aaf4a0f24d914c97ea6ed976d42fec6ad33fcbb0a1103e07b2b0" - [[package]] name = "duct" version = "0.13.5" @@ -441,13 +464,22 @@ checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" [[package]] name = "encoding_rs" -version = "0.8.29" +version = "0.8.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a74ea89a0a1b98f6332de42c95baff457ada66d1cb4030f9ff151b2041a1c746" +checksum = "7896dc8abb250ffdda33912550faa54c88ec8b998dec0b2c55ab224921ce11df" dependencies = [ "cfg-if", ] +[[package]] +name = "fastrand" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3fcf0cee53519c866c09b5de1f6c56ff9d647101f81c1964fa632e148896cdf" +dependencies = [ + "instant", +] + [[package]] name = "fnv" version = "1.0.7" @@ -466,9 +498,9 @@ dependencies = [ [[package]] name = "futures" -version = "0.3.17" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a12aa0eb539080d55c3f2d45a67c3b58b6b0773c1a3ca2dfec66d58c97fd66ca" +checksum = "28560757fe2bb34e79f907794bb6b22ae8b0e5c669b638a1132f2592b19035b4" dependencies = [ "futures-channel", "futures-core", @@ -481,9 +513,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.17" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5da6ba8c3bb3c165d3c7319fc1cc8304facf1fb8db99c5de877183c08a273888" +checksum = "ba3dda0b6588335f360afc675d0564c17a77a2bda81ca178a4b6081bd86c7f0b" dependencies = [ "futures-core", "futures-sink", @@ -491,15 +523,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.17" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88d1c26957f23603395cd326b0ffe64124b818f4449552f960d815cfba83a53d" +checksum = "d0c8ff0461b82559810cdccfde3215c3f373807f5e5232b71479bff7bb2583d7" [[package]] name = "futures-executor" -version = "0.3.17" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45025be030969d763025784f7f355043dc6bc74093e4ecc5000ca4dc50d8745c" +checksum = "29d6d2ff5bb10fb95c85b8ce46538a2e5f5e7fdc755623a7d4529ab8a4ed9d2a" dependencies = [ "futures-core", "futures-task", @@ -508,18 +540,16 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.17" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "522de2a0fe3e380f1bc577ba0474108faf3f6b18321dbf60b3b9c39a75073377" +checksum = "b1f9d34af5a1aac6fb380f735fe510746c38067c5bf16c7fd250280503c971b2" [[package]] name = "futures-macro" -version = "0.3.17" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18e4a4b95cea4b4ccbcf1c5675ca7c4ee4e9e75eb79944d07defde18068f79bb" +checksum = "6dbd947adfffb0efc70599b3ddcf7b5597bb5fa9e245eb99f62b3a5f7bb8bd3c" dependencies = [ - "autocfg", - "proc-macro-hack", "proc-macro2", "quote", "syn", @@ -527,23 +557,22 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.17" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36ea153c13024fe480590b3e3d4cad89a0cfacecc24577b68f86c6ced9c2bc11" +checksum = "e3055baccb68d74ff6480350f8d6eb8fcfa3aa11bdc1a1ae3afdd0514617d508" [[package]] name = "futures-task" -version = "0.3.17" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d3d00f4eddb73e498a54394f228cd55853bdf059259e8e7bc6e69d408892e99" +checksum = "6ee7c6485c30167ce4dfb83ac568a849fe53274c831081476ee13e0dce1aad72" [[package]] name = "futures-util" -version = "0.3.17" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36568465210a3a6ee45e1f165136d68671471a501e632e9a98d96872222b5481" +checksum = "d9b5cf40b47a271f77a8b1bec03ca09044d99d2372c0de244e66430761127164" dependencies = [ - "autocfg", "futures-channel", "futures-core", "futures-io", @@ -553,16 +582,14 @@ dependencies = [ "memchr", "pin-project-lite", "pin-utils", - "proc-macro-hack", - "proc-macro-nested", "slab", ] [[package]] name = "generic-array" -version = "0.14.4" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" +checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803" dependencies = [ "typenum", "version_check", @@ -570,9 +597,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" +checksum = "418d37c8b1d42553c93648be529cb70f920d3baf8ef469b74b9638df426e0b4c" dependencies = [ "cfg-if", "libc", @@ -600,9 +627,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.7" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fd819562fcebdac5afc5c113c3ec36f902840b70fd4fc458799c8ce4607ae55" +checksum = "d9f1f717ddc7b2ba36df7e871fd88db79326551d3d6f1fc406fbfd28b582ff8e" dependencies = [ "bytes", "fnv", @@ -654,7 +681,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" dependencies = [ "crypto-mac", - "digest", + "digest 0.9.0", ] [[package]] @@ -668,13 +695,13 @@ dependencies = [ [[package]] name = "http" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1323096b05d41827dadeaee54c9981958c0f94e670bc94ed80037d1a7b8b186b" +checksum = "31f4c6746584866f0feabcc69893c5b51beef3831656a968ed7ae254cdc4fd03" dependencies = [ "bytes", "fnv", - "itoa", + "itoa 1.0.1", ] [[package]] @@ -696,15 +723,15 @@ checksum = "acd94fdbe1d4ff688b67b04eee2e17bd50995534a61539e45adfefb45e5e5503" [[package]] name = "httpdate" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6456b8a6c8f33fee7d958fcd1b60d55b11940a79e63ae87013e6d22e26034440" +checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" [[package]] name = "hyper" -version = "0.14.14" +version = "0.14.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b91bb1f221b6ea1f1e4371216b70f40748774c2fb5971b450c07773fb92d26b" +checksum = "b7ec3e62bdc98a2f0393a5048e4c30ef659440ea6e0e572965103e72bd836f55" dependencies = [ "bytes", "futures-channel", @@ -715,7 +742,7 @@ dependencies = [ "http-body", "httparse", "httpdate", - "itoa", + "itoa 0.4.8", "pin-project-lite", "socket2", "tokio", @@ -734,11 +761,24 @@ dependencies = [ "futures-util", "hyper", "log", - "rustls", + "rustls 0.19.1", "rustls-native-certs", "tokio", - "tokio-rustls", - "webpki", + "tokio-rustls 0.22.0", + "webpki 0.21.4", +] + +[[package]] +name = "hyper-rustls" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d87c48c02e0dc5e3b849a2041db3029fd066650f8f717c07bf8ed78ccb895cac" +dependencies = [ + "http", + "hyper", + "rustls 0.20.2", + "tokio", + "tokio-rustls 0.23.2", ] [[package]] @@ -754,9 +794,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5" +checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223" dependencies = [ "autocfg", "hashbrown", @@ -789,7 +829,7 @@ dependencies = [ "rusoto_s3", "serde_json", "serde_yaml", - "sha2", + "sha2 0.10.1", "shell-words", "simplelog", "snafu 0.7.0", @@ -820,11 +860,17 @@ version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" +[[package]] +name = "itoa" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" + [[package]] name = "js-sys" -version = "0.3.55" +version = "0.3.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cc9ffccd38c451a86bf13657df244e9c3f37493cce8e5e21e940963777acc84" +checksum = "a38fc24e30fd564ce974c02bf1d337caddff65be6cc4735a1f7eab22a7440f04" dependencies = [ "wasm-bindgen", ] @@ -837,9 +883,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.107" +version = "0.2.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbe5e23404da5b4f555ef85ebed98fb4083e55a00c317800bc2a50ede9f3d219" +checksum = "e74d72e0f9b65b5b4ca49a346af3976df0f9c61d550727f349ecd559f251a26c" [[package]] name = "linked-hash-map" @@ -849,9 +895,9 @@ checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" [[package]] name = "lock_api" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109" +checksum = "88943dd7ef4a2e5a4bfa2753aaab3013e34ce2533d1996fb18ef591e315e2b3b" dependencies = [ "scopeguard", ] @@ -877,8 +923,8 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b5a279bb9607f9f53c22d496eade00d138d1bdcccd07d74650387cf94942a15" dependencies = [ - "block-buffer", - "digest", + "block-buffer 0.9.0", + "digest 0.9.0", "opaque-debug", ] @@ -890,9 +936,9 @@ checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" [[package]] name = "memoffset" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" dependencies = [ "autocfg", ] @@ -971,9 +1017,9 @@ dependencies = [ [[package]] name = "num_cpus" -version = "1.13.0" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" +checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" dependencies = [ "hermit-abi", "libc", @@ -1007,9 +1053,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" +checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5" [[package]] name = "opaque-debug" @@ -1019,9 +1065,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "openssl-probe" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28988d872ab76095a6e6ac88d99b54fd267702734fd7ffe610ca27f533ddb95a" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "os_pipe" @@ -1087,13 +1133,11 @@ dependencies = [ [[package]] name = "pem" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06673860db84d02a63942fa69cd9543f2624a5df3aea7f33173048fa7ad5cf1a" +checksum = "e9a3b09a20e374558580a4914d3b7d89bd61b954a5a5e1dcbea98753addb1947" dependencies = [ "base64", - "once_cell", - "regex", ] [[package]] @@ -1104,9 +1148,9 @@ checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" [[package]] name = "pin-project-lite" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" +checksum = "e280fbe77cc62c91527259e9442153f4688736748d24660126286329742b4c6c" [[package]] name = "pin-utils" @@ -1116,9 +1160,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "ppv-lite86" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed0cfbc8191465bed66e1718596ee0b0b35d5ee1f41c5df2189d0fe8bde535ba" +checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" [[package]] name = "proc-macro-error" @@ -1144,23 +1188,11 @@ dependencies = [ "version_check", ] -[[package]] -name = "proc-macro-hack" -version = "0.5.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" - -[[package]] -name = "proc-macro-nested" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" - [[package]] name = "proc-macro2" -version = "1.0.32" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba508cc11742c0dc5c1659771673afbab7a0efab23aa17e854cbab0837ed0b43" +checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029" dependencies = [ "unicode-xid", ] @@ -1233,7 +1265,7 @@ dependencies = [ "log", "pubsys-config", "reqwest", - "sha2", + "sha2 0.10.1", "shell-words", "simplelog", "snafu 0.7.0", @@ -1245,9 +1277,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.10" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05" +checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145" dependencies = [ "proc-macro2", ] @@ -1364,19 +1396,20 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.11.6" +version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66d2927ca2f685faf0fc620ac4834690d29e7abb153add10f5812eef20b5e280" +checksum = "87f242f1488a539a79bac6dbe7c8609ae43b7914b7736210f239a37cccb32525" dependencies = [ "base64", "bytes", "encoding_rs", "futures-core", "futures-util", + "h2", "http", "http-body", "hyper", - "hyper-rustls", + "hyper-rustls 0.23.0", "ipnet", "js-sys", "lazy_static", @@ -1384,12 +1417,13 @@ dependencies = [ "mime", "percent-encoding", "pin-project-lite", - "rustls", + "rustls 0.20.2", + "rustls-pemfile", "serde", "serde_json", "serde_urlencoded", "tokio", - "tokio-rustls", + "tokio-rustls 0.23.2", "url", "wasm-bindgen", "wasm-bindgen-futures", @@ -1440,7 +1474,7 @@ dependencies = [ "futures", "http", "hyper", - "hyper-rustls", + "hyper-rustls 0.22.1", "lazy_static", "log", "rusoto_credential", @@ -1535,7 +1569,7 @@ dependencies = [ "base64", "bytes", "chrono", - "digest", + "digest 0.9.0", "futures", "hex", "hmac", @@ -1548,7 +1582,7 @@ dependencies = [ "rusoto_credential", "rustc_version", "serde", - "sha2", + "sha2 0.9.9", "tokio", ] @@ -1605,8 +1639,20 @@ dependencies = [ "base64", "log", "ring", - "sct", - "webpki", + "sct 0.6.1", + "webpki 0.21.4", +] + +[[package]] +name = "rustls" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d37e5e2290f3e040b594b1a9e04377c2c671f1a1cfd9bfdef82106ac1c113f84" +dependencies = [ + "log", + "ring", + "sct 0.7.0", + "webpki 0.22.0", ] [[package]] @@ -1616,16 +1662,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a07b7c1885bd8ed3831c289b7870b13ef46fe0e856d288c30d9cc17d75a2092" dependencies = [ "openssl-probe", - "rustls", + "rustls 0.19.1", "schannel", "security-framework", ] +[[package]] +name = "rustls-pemfile" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5eebeaeb360c87bfb72e84abdb3447159c0eaececf1bef2aecd65a8be949d1c9" +dependencies = [ + "base64", +] + [[package]] name = "ryu" -version = "1.0.5" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" +checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" [[package]] name = "same-file" @@ -1662,11 +1717,21 @@ dependencies = [ "untrusted", ] +[[package]] +name = "sct" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" +dependencies = [ + "ring", + "untrusted", +] + [[package]] name = "security-framework" -version = "2.4.2" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525bc1abfda2e1998d152c45cf13e696f76d0a4972310b22fac1658b05df7c87" +checksum = "3fed7948b6c68acbb6e20c334f55ad635dc0f75506963de4464289fbd3b051ac" dependencies = [ "bitflags", "core-foundation", @@ -1677,9 +1742,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.4.2" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9dd14d83160b528b7bfd66439110573efcfbe281b17fc2ca9f39f550d619c7e" +checksum = "a57321bf8bc2362081b2599912d2961fe899c0efadf1b4b2f8d48b3e253bb96c" dependencies = [ "core-foundation-sys", "libc", @@ -1696,18 +1761,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.130" +version = "1.0.136" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913" +checksum = "ce31e24b01e1e524df96f1c2fdd054405f8d7376249a5110886fb4b658484789" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.130" +version = "1.0.136" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b" +checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9" dependencies = [ "proc-macro2", "quote", @@ -1716,11 +1781,11 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.69" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e466864e431129c7e0d3476b92f20458e5879919a0596c6472738d9fa2d342f8" +checksum = "d23c1ba4cf0efd44be32017709280b32d1cea5c3f1275c3b6d9e8bc54f758085" dependencies = [ - "itoa", + "itoa 1.0.1", "ryu", "serde", ] @@ -1736,41 +1801,52 @@ dependencies = [ [[package]] name = "serde_urlencoded" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edfa57a7f8d9c1d260a549e7224100f6c43d43f9103e06dd8b4095a9b2b43ce9" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" dependencies = [ "form_urlencoded", - "itoa", + "itoa 1.0.1", "ryu", "serde", ] [[package]] name = "serde_yaml" -version = "0.8.21" +version = "0.8.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8c608a35705a5d3cdc9fbe403147647ff34b921f8e833e49306df898f9b20af" +checksum = "a4a521f2940385c165a24ee286aa8599633d162077a54bdcae2a6fd5a7bfa7a0" dependencies = [ - "dtoa", "indexmap", + "ryu", "serde", "yaml-rust", ] [[package]] name = "sha2" -version = "0.9.8" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b69f9a4c9740d74c5baa3fd2e547f9525fa8088a8a958e0ca2409a514e33f5fa" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" dependencies = [ - "block-buffer", + "block-buffer 0.9.0", "cfg-if", "cpufeatures", - "digest", + "digest 0.9.0", "opaque-debug", ] +[[package]] +name = "sha2" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99c3bd8169c58782adad9290a9af5939994036b76187f7b4f0e6de91dbbfc0ec" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.1", +] + [[package]] name = "shared_child" version = "0.3.5" @@ -1804,9 +1880,9 @@ dependencies = [ [[package]] name = "simplelog" -version = "0.10.2" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85d04ae642154220ef00ee82c36fb07853c10a4f2a0ca6719f9991211d2eb959" +checksum = "c1348164456f72ca0116e4538bdaabb0ddb622c7d9f16387c725af3e96d6001c" dependencies = [ "chrono", "log", @@ -1821,9 +1897,9 @@ checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5" [[package]] name = "smallvec" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" +checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" [[package]] name = "snafu" @@ -1831,7 +1907,6 @@ version = "0.6.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eab12d3c261b2308b0d80c26fffb58d17eba81a4be97890101f416b478c79ca7" dependencies = [ - "backtrace", "doc-comment", "snafu-derive 0.6.10", ] @@ -1872,9 +1947,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.4.2" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dc90fe6c7be1a323296982db1836d1ea9e47b6839496dde9a541bc496df3516" +checksum = "66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0" dependencies = [ "libc", "winapi", @@ -1894,9 +1969,9 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" [[package]] name = "structopt" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40b9788f4202aa75c240ecc9c15c65185e6a39ccdeb0fd5d008b98825464c87c" +checksum = "0c6b5c64445ba8094a6ab0c3cd2ad323e07171012d9c98b0b15651daf1787a10" dependencies = [ "clap", "lazy_static", @@ -1924,9 +1999,9 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "syn" -version = "1.0.81" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2afee18b8beb5a596ecb4a2dce128c719b4ba399d34126b9e4396e3f9860966" +checksum = "8a65b3f4ffa0092e9887669db0eae07941f023991ab58ea44da8fe8e2d511c6b" dependencies = [ "proc-macro2", "quote", @@ -1935,13 +2010,13 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.2.0" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" +checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" dependencies = [ "cfg-if", + "fastrand", "libc", - "rand", "redox_syscall", "remove_dir_all", "winapi", @@ -1997,9 +2072,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83b2a3d4d9091d0abd7eba4dc2710b1718583bd4d8992e2190720ea38f391f7" +checksum = "2c1c1d5a42b6245520c249549ec267180beaffcc0615401ac8e31853d4b6d8d2" dependencies = [ "tinyvec_macros", ] @@ -2012,9 +2087,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.8.3" +version = "1.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00a287ce596d527f273dea7638a044739234740dbad141e7ed0c62c7d0c9c55a" +checksum = "cdc46ca74dd45faeaaf96a8fbe2406f425829705ee62100ccaa9b34a2145cff8" dependencies = [ "autocfg", "bytes", @@ -2032,9 +2107,9 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "1.5.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "114383b041aa6212c579467afa0075fbbdd0718de036100bc0ba7961d8cb9095" +checksum = "b557f72f448c511a979e2564e55d74e6c4432fc96ff4f6241bc6bded342643b7" dependencies = [ "proc-macro2", "quote", @@ -2047,9 +2122,20 @@ version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc6844de72e57df1980054b38be3a9f4702aba4858be64dd700181a8a6d0e1b6" dependencies = [ - "rustls", + "rustls 0.19.1", + "tokio", + "webpki 0.21.4", +] + +[[package]] +name = "tokio-rustls" +version = "0.23.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a27d5f2b839802bd8267fa19b0530f5a08b9c08cd417976be2a65d130fe1c11b" +dependencies = [ + "rustls 0.20.2", "tokio", - "webpki", + "webpki 0.22.0", ] [[package]] @@ -2088,9 +2174,9 @@ dependencies = [ [[package]] name = "tough" -version = "0.12.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99488309ba53ee931b6ccda1cde07feaab95f214d328e3a7244c0f7563b5909f" +checksum = "708125a84e70820bccc5fc11d7196664415be2b02b81ba6946e70e10803aa4da" dependencies = [ "chrono", "dyn-clone", @@ -2106,7 +2192,7 @@ dependencies = [ "serde", "serde_json", "serde_plain", - "snafu 0.6.10", + "snafu 0.7.0", "tempfile", "untrusted", "url", @@ -2115,32 +2201,32 @@ dependencies = [ [[package]] name = "tough-kms" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e1ece7cb6917b7d503e85d9285e1a7616d2e5ae96c1362087771401559f47d2" +checksum = "a910dad24be252ff379d79a49c44ed36b3e8b0f5d34b79a8967df24e685bae2d" dependencies = [ "pem", "ring", "rusoto_core", "rusoto_credential", "rusoto_kms", - "snafu 0.6.10", + "snafu 0.7.0", "tokio", "tough", ] [[package]] name = "tough-ssm" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "303c67d70bcf2352668c42984715a71ccbf1558fcbf64064987caadba07fc771" +checksum = "cf1c96981e5a2302abc1ea54f076ac47c2ffe2abcdcc147f7668ee8b3212c094" dependencies = [ "rusoto_core", "rusoto_credential", "rusoto_ssm", "serde", "serde_json", - "snafu 0.6.10", + "snafu 0.7.0", "tokio", "tough", ] @@ -2179,9 +2265,9 @@ checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" [[package]] name = "typenum" -version = "1.14.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b63708a265f51345575b27fe43f9500ad611579e764c79edbc2037b1121959ec" +checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" [[package]] name = "unicode-bidi" @@ -2258,9 +2344,9 @@ checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" [[package]] name = "version_check" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "walkdir" @@ -2291,9 +2377,9 @@ checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" [[package]] name = "wasm-bindgen" -version = "0.2.78" +version = "0.2.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce" +checksum = "25f1af7423d8588a3d840681122e72e6a24ddbcb3f0ec385cac0d12d24256c06" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -2301,9 +2387,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.78" +version = "0.2.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a317bf8f9fba2476b4b2c85ef4c4af8ff39c3c7f0cdfeed4f82c34a880aa837b" +checksum = "8b21c0df030f5a177f3cba22e9bc4322695ec43e7257d865302900290bcdedca" dependencies = [ "bumpalo", "lazy_static", @@ -2316,9 +2402,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.28" +version = "0.4.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e8d7523cb1f2a4c96c1317ca690031b714a51cc14e05f712446691f413f5d39" +checksum = "2eb6ec270a31b1d3c7e266b999739109abce8b6c87e4b31fcfcd788b65267395" dependencies = [ "cfg-if", "js-sys", @@ -2328,9 +2414,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.78" +version = "0.2.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9" +checksum = "2f4203d69e40a52ee523b2529a773d5ffc1dc0071801c87b3d270b471b80ed01" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2338,9 +2424,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.78" +version = "0.2.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab" +checksum = "bfa8a30d46208db204854cadbb5d4baf5fcf8071ba5bf48190c3e59937962ebc" dependencies = [ "proc-macro2", "quote", @@ -2351,15 +2437,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.78" +version = "0.2.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0237232789cf037d5480773fe568aac745bfe2afbc11a863e97901780a6b47cc" +checksum = "3d958d035c4438e28c70e4321a2911302f10135ce78a9c7834c0cab4123d06a2" [[package]] name = "web-sys" -version = "0.3.55" +version = "0.3.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38eb105f1c59d9eaa6b5cdc92b859d85b926e82cb2e0945cd0c9259faa6fe9fb" +checksum = "c060b319f29dd25724f09a2ba1418f142f539b2be99fbf4d2d5a8f7330afb8eb" dependencies = [ "js-sys", "wasm-bindgen", @@ -2375,13 +2461,23 @@ dependencies = [ "untrusted", ] +[[package]] +name = "webpki" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" +dependencies = [ + "ring", + "untrusted", +] + [[package]] name = "webpki-roots" -version = "0.21.1" +version = "0.22.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aabe153544e473b775453675851ecc86863d2a81d786d741f6b76778f2a48940" +checksum = "552ceb903e957524388c4d3475725ff2c8b7960922063af6ce53c9a43da07449" dependencies = [ - "webpki", + "webpki 0.22.0", ] [[package]] @@ -2441,6 +2537,6 @@ dependencies = [ [[package]] name = "zeroize" -version = "1.4.3" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d68d9dcec5f9b43a30d38c49f91dfedfaac384cb8f085faca366c26207dd1619" +checksum = "7c88870063c39ee00ec285a2f8d6a966e5b6fb2becc4e8dac77ed0d370ed6006" diff --git a/tools/buildsys/Cargo.toml b/tools/buildsys/Cargo.toml index 3fd048ec100..d9971fda2d9 100644 --- a/tools/buildsys/Cargo.toml +++ b/tools/buildsys/Cargo.toml @@ -17,7 +17,7 @@ regex = "1" reqwest = { version = "0.11.1", default-features = false, features = ["rustls-tls", "blocking"] } serde = { version = "1.0", features = ["derive"] } serde_plain = "1.0" -sha2 = "0.9" +sha2 = "0.10" snafu = "0.7" toml = "0.5" url = { version = "2.1.0", features = ["serde"] } diff --git a/tools/deny.toml b/tools/deny.toml index eca08746114..7068b6b26f0 100644 --- a/tools/deny.toml +++ b/tools/deny.toml @@ -27,6 +27,16 @@ exceptions = [ { name = "webpki-roots", allow = ["MPL-2.0"], version = "*" }, ] +# https://github.com/hsivonen/encoding_rs The non-test code that isn't generated from the WHATWG data in this crate is +# under Apache-2.0 OR MIT. Test code is under CC0. +[[licenses.clarify]] +name = "encoding_rs" +version = "0.8.30" +expression = "(Apache-2.0 OR MIT) AND BSD-3-Clause" +license-files = [ + { path = "COPYRIGHT", hash = 0x39f8ad31 } +] + [[licenses.clarify]] name = "ring" expression = "MIT AND ISC AND OpenSSL" @@ -49,6 +59,9 @@ wildcards = "deny" skip-tree = [ # temporarily using a different version of snafu { name = "parse-datetime", version = "0.1.0" }, + + # rusoto is using a different version of reqwest. + { name = "rusoto_core", version = "0.47.0" }, ] [sources] diff --git a/tools/infrasys/Cargo.toml b/tools/infrasys/Cargo.toml index fc78cc32ba7..21c56660bfd 100644 --- a/tools/infrasys/Cargo.toml +++ b/tools/infrasys/Cargo.toml @@ -17,9 +17,9 @@ rusoto_core = { version = "0.47", default-features = false, features = ["rustls" rusoto_s3 = { version = "0.47", default-features = false, features = ["rustls"] } serde_json = "1.0.66" serde_yaml = "0.8.17" -sha2 = "0.9" +sha2 = "0.10" shell-words = "1.0.0" -simplelog = "0.10.0" +simplelog = "0.11" snafu = "0.7" structopt = { version = "0.3", default-features = false } tokio = { version = "~1.8", default-features = false, features = ["macros", "rt-multi-thread"] } # LTS diff --git a/tools/pubsys-setup/Cargo.toml b/tools/pubsys-setup/Cargo.toml index 7b186e6d3e6..7bfee00fc72 100644 --- a/tools/pubsys-setup/Cargo.toml +++ b/tools/pubsys-setup/Cargo.toml @@ -11,9 +11,9 @@ hex = "0.4.0" log = "0.4" pubsys-config = { path = "../pubsys-config/", version = "0.1.0" } reqwest = { version = "0.11.1", default-features = false, features = ["rustls-tls", "blocking"] } -sha2 = "0.9" +sha2 = "0.10" shell-words = "1.0" -simplelog = "0.10" +simplelog = "0.11" snafu = "0.7" structopt = { version = "0.3", default-features = false } tempfile = "3.1" diff --git a/tools/pubsys/Cargo.toml b/tools/pubsys/Cargo.toml index eafa77cec8c..dab33feaa3f 100644 --- a/tools/pubsys/Cargo.toml +++ b/tools/pubsys/Cargo.toml @@ -30,7 +30,7 @@ rusoto_kms = { version = "0.47.0", default-features = false, features = ["rustls rusoto_signature = "0.47.0" rusoto_ssm = { version = "0.47.0", default-features = false, features = ["rustls"] } rusoto_sts = { version = "0.47.0", default-features = false, features = ["rustls"] } -simplelog = "0.10.0" +simplelog = "0.11" snafu = "0.7" semver = "1.0" serde = { version = "1.0", features = ["derive"] } From ae4c5344fd7686fd3e89064a85835c5c22df6ab7 Mon Sep 17 00:00:00 2001 From: Matthew James Briggs Date: Wed, 2 Feb 2022 19:25:44 -0800 Subject: [PATCH 8/8] pin tuftool install to known good version --- Makefile.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile.toml b/Makefile.toml index 71af4f3df24..3ebd9af41a8 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -42,6 +42,9 @@ PUBLISH_WAVE_POLICY_PATH = "${BUILDSYS_ROOT_DIR}/sources/updater/waves/default-w PUBLISH_INFRA_CONFIG_PATH = "${BUILDSYS_ROOT_DIR}/Infra.toml" # Default repo to read from PUBLISH_INFRA_CONFIG_PATH PUBLISH_REPO = "default" +# The version of tuftool (without the 'v') that we will install and use for +# publishing-related steps +PUBLISH_TUFTOOL_VERSION="0.7.1" # The size in GiB of the data volume in the block device mapping of registered # AMIs. (You can also specify PUBLISH_ROOT_VOLUME_SIZE to override the root @@ -704,6 +707,7 @@ cargo install \ --jobs ${BUILDSYS_JOBS} \ --root tools \ --quiet \ + --version ${PUBLISH_TUFTOOL_VERSION} \ tuftool ''' ]