From a12f21ca7a1ea09b414781d08d1e302f2c9837c1 Mon Sep 17 00:00:00 2001 From: komodo Date: Sat, 8 Mar 2025 16:37:10 -0500 Subject: [PATCH] rust 2024 and fmt --- Cargo.lock | 81 ++++++++------ Cargo.toml | 9 +- bin/core/Cargo.toml | 3 +- bin/core/src/alert/discord.rs | 32 ++++-- bin/core/src/alert/mod.rs | 20 ++-- bin/core/src/alert/slack.rs | 34 ++++-- bin/core/src/api/auth.rs | 2 +- bin/core/src/api/execute/action.rs | 4 +- bin/core/src/api/execute/build.rs | 6 +- bin/core/src/api/execute/deployment.rs | 6 +- bin/core/src/api/execute/mod.rs | 8 +- bin/core/src/api/execute/procedure.rs | 2 +- bin/core/src/api/execute/repo.rs | 6 +- bin/core/src/api/execute/server_template.rs | 2 +- bin/core/src/api/execute/sync.rs | 17 ++- bin/core/src/api/read/build.rs | 2 +- bin/core/src/api/read/deployment.rs | 2 +- bin/core/src/api/read/mod.rs | 12 +-- bin/core/src/api/read/permission.rs | 2 +- bin/core/src/api/read/provider.rs | 4 +- bin/core/src/api/read/server.rs | 6 +- bin/core/src/api/read/toml.rs | 15 +-- bin/core/src/api/read/update.rs | 6 +- bin/core/src/api/read/user.rs | 4 +- bin/core/src/api/read/user_group.rs | 2 +- bin/core/src/api/user.rs | 4 +- bin/core/src/api/write/build.rs | 4 +- bin/core/src/api/write/builder.rs | 5 +- bin/core/src/api/write/deployment.rs | 12 +-- bin/core/src/api/write/description.rs | 10 +- bin/core/src/api/write/mod.rs | 2 +- bin/core/src/api/write/permissions.rs | 6 +- bin/core/src/api/write/provider.rs | 4 +- bin/core/src/api/write/repo.rs | 4 +- bin/core/src/api/write/server.rs | 2 +- bin/core/src/api/write/service_user.rs | 2 +- bin/core/src/api/write/stack.rs | 6 +- bin/core/src/api/write/sync.rs | 17 +-- bin/core/src/api/write/tag.rs | 14 +-- bin/core/src/api/write/user.rs | 4 +- bin/core/src/api/write/user_group.rs | 2 +- bin/core/src/api/write/variable.rs | 4 +- bin/core/src/auth/github/client.rs | 16 ++- bin/core/src/auth/github/mod.rs | 4 +- bin/core/src/auth/google/client.rs | 16 ++- bin/core/src/auth/google/mod.rs | 4 +- bin/core/src/auth/jwt.rs | 4 +- bin/core/src/auth/local.rs | 2 +- bin/core/src/auth/mod.rs | 6 +- bin/core/src/auth/oidc/client.rs | 4 +- bin/core/src/auth/oidc/mod.rs | 10 +- bin/core/src/cloud/aws/ec2.rs | 44 +++++--- bin/core/src/cloud/hetzner/client.rs | 4 +- bin/core/src/cloud/hetzner/mod.rs | 2 +- bin/core/src/db.rs | 4 +- bin/core/src/helpers/builder.rs | 14 +-- bin/core/src/helpers/cache.rs | 12 +-- bin/core/src/helpers/channel.rs | 10 +- bin/core/src/helpers/interpolate.rs | 2 +- bin/core/src/helpers/mod.rs | 22 ++-- bin/core/src/helpers/procedure.rs | 8 +- bin/core/src/helpers/prune.rs | 2 +- bin/core/src/helpers/query.rs | 12 +-- bin/core/src/helpers/update.rs | 24 ++--- bin/core/src/listener/integrations/github.rs | 2 +- bin/core/src/listener/integrations/gitlab.rs | 2 +- bin/core/src/listener/mod.rs | 2 +- bin/core/src/listener/resources.rs | 2 +- bin/core/src/listener/router.rs | 8 +- bin/core/src/monitor/alert/deployment.rs | 2 +- bin/core/src/monitor/alert/mod.rs | 4 +- bin/core/src/monitor/alert/server.rs | 10 +- bin/core/src/monitor/alert/stack.rs | 2 +- bin/core/src/monitor/lists.rs | 2 +- bin/core/src/monitor/mod.rs | 3 +- bin/core/src/monitor/record.rs | 2 +- bin/core/src/monitor/resources.rs | 6 +- bin/core/src/resource/action.rs | 4 +- bin/core/src/resource/alerter.rs | 2 +- bin/core/src/resource/build.rs | 4 +- bin/core/src/resource/builder.rs | 4 +- bin/core/src/resource/deployment.rs | 10 +- bin/core/src/resource/mod.rs | 18 ++-- bin/core/src/resource/procedure.rs | 8 +- bin/core/src/resource/refresh.rs | 22 ++-- bin/core/src/resource/repo.rs | 4 +- bin/core/src/resource/server.rs | 5 +- bin/core/src/resource/server_template.rs | 4 +- bin/core/src/resource/stack.rs | 4 +- bin/core/src/resource/sync.rs | 5 +- bin/core/src/stack/execute.rs | 2 +- bin/core/src/stack/mod.rs | 2 +- bin/core/src/stack/remote.rs | 2 +- bin/core/src/state.rs | 4 +- bin/core/src/sync/deploy.rs | 26 +++-- bin/core/src/sync/execute.rs | 6 +- bin/core/src/sync/file.rs | 4 +- bin/core/src/sync/mod.rs | 2 +- bin/core/src/sync/remote.rs | 4 +- bin/core/src/sync/resources.rs | 10 +- bin/core/src/sync/toml.rs | 2 +- bin/core/src/sync/user_groups.rs | 8 +- bin/core/src/sync/variables.rs | 2 +- bin/core/src/sync/view.rs | 2 +- bin/core/src/ts_client.rs | 4 +- bin/core/src/ws.rs | 6 +- bin/periphery/src/api/build.rs | 100 +++++++++++------- bin/periphery/src/api/compose.rs | 8 +- bin/periphery/src/api/container.rs | 2 +- bin/periphery/src/api/deploy.rs | 10 +- bin/periphery/src/api/git.rs | 14 ++- bin/periphery/src/api/mod.rs | 10 +- bin/periphery/src/compose.rs | 22 ++-- bin/periphery/src/docker.rs | 10 +- bin/periphery/src/helpers.rs | 6 +- bin/periphery/src/router.rs | 4 +- bin/periphery/src/ssl.rs | 4 +- client/core/rs/src/api/execute/deployment.rs | 2 +- client/core/rs/src/api/execute/mod.rs | 2 +- client/core/rs/src/api/execute/server.rs | 2 +- client/core/rs/src/api/execute/sync.rs | 2 +- client/core/rs/src/api/read/alert.rs | 2 +- client/core/rs/src/api/read/build.rs | 2 +- client/core/rs/src/api/read/deployment.rs | 2 +- client/core/rs/src/api/read/mod.rs | 2 +- client/core/rs/src/api/read/permission.rs | 2 +- client/core/rs/src/api/read/server.rs | 2 +- client/core/rs/src/api/read/stack.rs | 2 +- client/core/rs/src/api/read/tag.rs | 2 +- client/core/rs/src/api/read/update.rs | 2 +- client/core/rs/src/api/user.rs | 2 +- client/core/rs/src/api/write/action.rs | 4 +- client/core/rs/src/api/write/alerter.rs | 2 +- client/core/rs/src/api/write/api_key.rs | 2 +- client/core/rs/src/api/write/build.rs | 4 +- client/core/rs/src/api/write/deployment.rs | 2 +- client/core/rs/src/api/write/permissions.rs | 2 +- client/core/rs/src/api/write/procedure.rs | 2 +- client/core/rs/src/api/write/repo.rs | 4 +- client/core/rs/src/api/write/server.rs | 2 +- client/core/rs/src/api/write/stack.rs | 4 +- client/core/rs/src/api/write/sync.rs | 4 +- client/core/rs/src/api/write/tags.rs | 2 +- client/core/rs/src/api/write/user.rs | 2 +- .../core/rs/src/deserializers/conversion.rs | 2 +- .../core/rs/src/deserializers/environment.rs | 2 +- .../rs/src/deserializers/file_contents.rs | 2 +- client/core/rs/src/deserializers/labels.rs | 2 +- .../rs/src/deserializers/maybe_string_i64.rs | 2 +- .../core/rs/src/deserializers/string_list.rs | 2 +- .../src/deserializers/term_signal_labels.rs | 2 +- client/core/rs/src/entities/action.rs | 2 +- client/core/rs/src/entities/alert.rs | 6 +- client/core/rs/src/entities/alerter.rs | 4 +- client/core/rs/src/entities/build.rs | 16 ++- client/core/rs/src/entities/builder.rs | 2 +- client/core/rs/src/entities/config/core.rs | 4 +- .../core/rs/src/entities/config/periphery.rs | 4 +- client/core/rs/src/entities/deployment.rs | 4 +- .../core/rs/src/entities/docker/container.rs | 2 +- client/core/rs/src/entities/mod.rs | 8 +- client/core/rs/src/entities/procedure.rs | 2 +- client/core/rs/src/entities/repo.rs | 5 +- client/core/rs/src/entities/resource.rs | 6 +- client/core/rs/src/entities/server.rs | 2 +- .../rs/src/entities/server_template/mod.rs | 4 +- client/core/rs/src/entities/stack.rs | 5 +- client/core/rs/src/entities/stats.rs | 2 +- client/core/rs/src/entities/sync.rs | 4 +- client/core/rs/src/entities/toml.rs | 3 +- client/core/rs/src/entities/update.rs | 2 +- client/core/rs/src/entities/user.rs | 4 +- client/core/rs/src/entities/user_group.rs | 2 +- client/core/rs/src/request.rs | 6 +- client/core/rs/src/ws.rs | 4 +- client/periphery/rs/src/api/compose.rs | 2 +- client/periphery/rs/src/api/container.rs | 2 +- client/periphery/rs/src/api/git.rs | 2 +- client/periphery/rs/src/api/mod.rs | 2 +- client/periphery/rs/src/lib.rs | 2 +- lib/command/src/lib.rs | 6 +- lib/git/src/clone.rs | 6 +- lib/git/src/commit.rs | 2 +- lib/git/src/environment.rs | 2 +- lib/git/src/init.rs | 2 +- lib/git/src/lib.rs | 14 ++- lib/git/src/pull.rs | 6 +- lib/logger/src/lib.rs | 2 +- lib/logger/src/otel.rs | 4 +- lib/response/src/lib.rs | 2 +- 190 files changed, 714 insertions(+), 555 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 244ebe000..5e4ae71c6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -164,9 +164,9 @@ checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "aws-config" -version = "1.5.17" +version = "1.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "490aa7465ee685b2ced076bb87ef654a47724a7844e2c7d3af4e749ce5b875dd" +checksum = "90aff65e86db5fe300752551c1b015ef72b708ac54bded8ef43d0d53cb7cb0b1" dependencies = [ "aws-credential-types", "aws-runtime", @@ -174,7 +174,7 @@ dependencies = [ "aws-sdk-ssooidc", "aws-sdk-sts", "aws-smithy-async", - "aws-smithy-http", + "aws-smithy-http 0.61.1", "aws-smithy-json", "aws-smithy-runtime", "aws-smithy-runtime-api", @@ -238,7 +238,7 @@ dependencies = [ "aws-credential-types", "aws-sigv4", "aws-smithy-async", - "aws-smithy-http", + "aws-smithy-http 0.60.12", "aws-smithy-runtime", "aws-smithy-runtime-api", "aws-smithy-types", @@ -256,14 +256,14 @@ dependencies = [ [[package]] name = "aws-sdk-ec2" -version = "1.114.0" +version = "1.116.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d96d95163e855b22d8013ddfb219083b9a44d3e5e7ce8dcb14aec73a66dfb09e" +checksum = "17fc79ad005b60bf8fbf1d0c256e8e00b3dcadc0c64ec34382c261ff00476446" dependencies = [ "aws-credential-types", "aws-runtime", "aws-smithy-async", - "aws-smithy-http", + "aws-smithy-http 0.61.1", "aws-smithy-json", "aws-smithy-query", "aws-smithy-runtime", @@ -280,14 +280,14 @@ dependencies = [ [[package]] name = "aws-sdk-sso" -version = "1.60.0" +version = "1.61.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60186fab60b24376d3e33b9ff0a43485f99efd470e3b75a9160c849741d63d56" +checksum = "e65ff295979977039a25f5a0bf067a64bc5e6aa38f3cef4037cf42516265553c" dependencies = [ "aws-credential-types", "aws-runtime", "aws-smithy-async", - "aws-smithy-http", + "aws-smithy-http 0.61.1", "aws-smithy-json", "aws-smithy-runtime", "aws-smithy-runtime-api", @@ -302,14 +302,14 @@ dependencies = [ [[package]] name = "aws-sdk-ssooidc" -version = "1.61.0" +version = "1.62.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7033130ce1ee13e6018905b7b976c915963755aef299c1521897679d6cd4f8ef" +checksum = "91430a60f754f235688387b75ee798ef00cfd09709a582be2b7525ebb5306d4f" dependencies = [ "aws-credential-types", "aws-runtime", "aws-smithy-async", - "aws-smithy-http", + "aws-smithy-http 0.61.1", "aws-smithy-json", "aws-smithy-runtime", "aws-smithy-runtime-api", @@ -324,14 +324,14 @@ dependencies = [ [[package]] name = "aws-sdk-sts" -version = "1.61.0" +version = "1.62.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5c1cac7677179d622b4448b0d31bcb359185295dc6fca891920cfb17e2b5156" +checksum = "9276e139d39fff5a0b0c984fc2d30f970f9a202da67234f948fda02e5bea1dbe" dependencies = [ "aws-credential-types", "aws-runtime", "aws-smithy-async", - "aws-smithy-http", + "aws-smithy-http 0.61.1", "aws-smithy-json", "aws-smithy-query", "aws-smithy-runtime", @@ -352,7 +352,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9bfe75fad52793ce6dec0dc3d4b1f388f038b5eb866c8d4d7f3a8e21b5ea5051" dependencies = [ "aws-credential-types", - "aws-smithy-http", + "aws-smithy-http 0.60.12", "aws-smithy-runtime-api", "aws-smithy-types", "bytes", @@ -399,6 +399,26 @@ dependencies = [ "tracing", ] +[[package]] +name = "aws-smithy-http" +version = "0.61.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6f276f21c7921fe902826618d1423ae5bf74cf8c1b8472aee8434f3dfd31824" +dependencies = [ + "aws-smithy-runtime-api", + "aws-smithy-types", + "bytes", + "bytes-utils", + "futures-core", + "http 0.2.12", + "http-body 0.4.6", + "once_cell", + "percent-encoding", + "pin-project-lite", + "pin-utils", + "tracing", +] + [[package]] name = "aws-smithy-json" version = "0.61.2" @@ -425,7 +445,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d526a12d9ed61fadefda24abe2e682892ba288c2018bcb38b1b4c111d13f6d92" dependencies = [ "aws-smithy-async", - "aws-smithy-http", + "aws-smithy-http 0.60.12", "aws-smithy-runtime-api", "aws-smithy-types", "bytes", @@ -858,7 +878,7 @@ dependencies = [ [[package]] name = "cache" -version = "1.17.0-dev-5" +version = "1.17.0-dev-6" dependencies = [ "anyhow", "tokio", @@ -998,7 +1018,7 @@ dependencies = [ [[package]] name = "command" -version = "1.17.0-dev-5" +version = "1.17.0-dev-6" dependencies = [ "anyhow", "formatting", @@ -1477,7 +1497,7 @@ dependencies = [ [[package]] name = "environment_file" -version = "1.17.0-dev-5" +version = "1.17.0-dev-6" dependencies = [ "thiserror 2.0.12", ] @@ -1546,7 +1566,7 @@ dependencies = [ [[package]] name = "formatting" -version = "1.17.0-dev-5" +version = "1.17.0-dev-6" dependencies = [ "serror", ] @@ -1696,7 +1716,7 @@ checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" [[package]] name = "git" -version = "1.17.0-dev-5" +version = "1.17.0-dev-6" dependencies = [ "anyhow", "cache", @@ -2449,7 +2469,7 @@ dependencies = [ [[package]] name = "komodo_cli" -version = "1.17.0-dev-5" +version = "1.17.0-dev-6" dependencies = [ "anyhow", "clap", @@ -2465,7 +2485,7 @@ dependencies = [ [[package]] name = "komodo_client" -version = "1.17.0-dev-5" +version = "1.17.0-dev-6" dependencies = [ "anyhow", "async_timing_util", @@ -2496,11 +2516,12 @@ dependencies = [ [[package]] name = "komodo_core" -version = "1.17.0-dev-5" +version = "1.17.0-dev-6" dependencies = [ "anyhow", "async_timing_util", "aws-config", + "aws-credential-types", "aws-sdk-ec2", "axum", "axum-extra", @@ -2558,7 +2579,7 @@ dependencies = [ [[package]] name = "komodo_periphery" -version = "1.17.0-dev-5" +version = "1.17.0-dev-6" dependencies = [ "anyhow", "async_timing_util", @@ -2670,7 +2691,7 @@ dependencies = [ [[package]] name = "logger" -version = "1.17.0-dev-5" +version = "1.17.0-dev-6" dependencies = [ "anyhow", "komodo_client", @@ -3399,7 +3420,7 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "periphery_client" -version = "1.17.0-dev-5" +version = "1.17.0-dev-6" dependencies = [ "anyhow", "komodo_client", @@ -3882,7 +3903,7 @@ dependencies = [ [[package]] name = "response" -version = "1.17.0-dev-5" +version = "1.17.0-dev-6" dependencies = [ "anyhow", "axum", diff --git a/Cargo.toml b/Cargo.toml index 1fcfa387e..26f12989c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,8 +8,8 @@ members = [ ] [workspace.package] -version = "1.17.0-dev-5" -edition = "2021" +version = "1.17.0-dev-6" +edition = "2024" authors = ["mbecker20 "] license = "GPL-3.0-or-later" repository = "https://github.com/moghtech/komodo" @@ -102,8 +102,9 @@ bollard = "0.18.1" sysinfo = "0.33.1" # CLOUD -aws-config = "1.5.17" -aws-sdk-ec2 = "1.114.0" +aws-config = "1.5.18" +aws-sdk-ec2 = "1.116.0" +aws-credential-types = "1.2.1" # MISC derive_builder = "0.20.2" diff --git a/bin/core/Cargo.toml b/bin/core/Cargo.toml index 180bd91bc..c3e7660f5 100644 --- a/bin/core/Cargo.toml +++ b/bin/core/Cargo.toml @@ -37,9 +37,10 @@ mungos.workspace = true slack.workspace = true svi.workspace = true # external -axum-server.workspace = true +aws-credential-types.workspace = true ordered_hash_map.workspace = true openidconnect.workspace = true +axum-server.workspace = true urlencoding.workspace = true aws-sdk-ec2.workspace = true aws-config.workspace = true diff --git a/bin/core/src/alert/discord.rs b/bin/core/src/alert/discord.rs index 164371a9b..e925d50ff 100644 --- a/bin/core/src/alert/discord.rs +++ b/bin/core/src/alert/discord.rs @@ -94,7 +94,9 @@ pub async fn send_alert( } => { let link = resource_link(ResourceTargetVariant::Deployment, id); let to = fmt_docker_container_state(to); - format!("📦 Deployment **{name}** is now **{to}**\nserver: **{server_name}**\nprevious: **{from}**\n{link}") + format!( + "📦 Deployment **{name}** is now **{to}**\nserver: **{server_name}**\nprevious: **{from}**\n{link}" + ) } AlertData::DeploymentImageUpdateAvailable { id, @@ -104,7 +106,9 @@ pub async fn send_alert( image, } => { let link = resource_link(ResourceTargetVariant::Deployment, id); - format!("⬆ Deployment **{name}** has an update available\nserver: **{server_name}**\nimage: **{image}**\n{link}") + format!( + "⬆ Deployment **{name}** has an update available\nserver: **{server_name}**\nimage: **{image}**\n{link}" + ) } AlertData::DeploymentAutoUpdated { id, @@ -114,7 +118,9 @@ pub async fn send_alert( image, } => { let link = resource_link(ResourceTargetVariant::Deployment, id); - format!("⬆ Deployment **{name}** was updated automatically ⏫\nserver: **{server_name}**\nimage: **{image}**\n{link}") + format!( + "⬆ Deployment **{name}** was updated automatically ⏫\nserver: **{server_name}**\nimage: **{image}**\n{link}" + ) } AlertData::StackStateChange { id, @@ -126,7 +132,9 @@ pub async fn send_alert( } => { let link = resource_link(ResourceTargetVariant::Stack, id); let to = fmt_stack_state(to); - format!("🥞 Stack **{name}** is now {to}\nserver: **{server_name}**\nprevious: **{from}**\n{link}") + format!( + "🥞 Stack **{name}** is now {to}\nserver: **{server_name}**\nprevious: **{from}**\n{link}" + ) } AlertData::StackImageUpdateAvailable { id, @@ -137,7 +145,9 @@ pub async fn send_alert( image, } => { let link = resource_link(ResourceTargetVariant::Stack, id); - format!("⬆ Stack **{name}** has an update available\nserver: **{server_name}**\nservice: **{service}**\nimage: **{image}**\n{link}") + format!( + "⬆ Stack **{name}** has an update available\nserver: **{server_name}**\nservice: **{service}**\nimage: **{image}**\n{link}" + ) } AlertData::StackAutoUpdated { id, @@ -150,13 +160,17 @@ pub async fn send_alert( let images_label = if images.len() > 1 { "images" } else { "image" }; let images = images.join(", "); - format!("⬆ Stack **{name}** was updated automatically ⏫\nserver: **{server_name}**\n{images_label}: **{images}**\n{link}") + format!( + "⬆ Stack **{name}** was updated automatically ⏫\nserver: **{server_name}**\n{images_label}: **{images}**\n{link}" + ) } AlertData::AwsBuilderTerminationFailed { instance_id, message, } => { - format!("{level} | Failed to terminated AWS builder instance\ninstance id: **{instance_id}**\n{message}") + format!( + "{level} | Failed to terminated AWS builder instance\ninstance id: **{instance_id}**\n{message}" + ) } AlertData::ResourceSyncPendingUpdates { id, name } => { let link = @@ -167,7 +181,9 @@ pub async fn send_alert( } AlertData::BuildFailed { id, name, version } => { let link = resource_link(ResourceTargetVariant::Build, id); - format!("{level} | Build **{name}** failed\nversion: **v{version}**\n{link}") + format!( + "{level} | Build **{name}** failed\nversion: **v{version}**\n{link}" + ) } AlertData::RepoBuildFailed { id, name } => { let link = resource_link(ResourceTargetVariant::Repo, id); diff --git a/bin/core/src/alert/mod.rs b/bin/core/src/alert/mod.rs index 47713f927..127cd6c30 100644 --- a/bin/core/src/alert/mod.rs +++ b/bin/core/src/alert/mod.rs @@ -1,21 +1,21 @@ -use std::collections::HashSet; use ::slack::types::Block; -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use derive_variants::ExtractVariant; use futures::future::join_all; use komodo_client::entities::{ + ResourceTargetVariant, alert::{Alert, AlertData, AlertDataVariant, SeverityLevel}, alerter::*, deployment::DeploymentState, stack::StackState, - ResourceTargetVariant, }; use mungos::{find::find_collect, mongodb::bson::doc}; +use std::collections::HashSet; use tracing::Instrument; -use crate::{config::core_config, state::db_client}; use crate::helpers::interpolate::interpolate_variables_secrets_into_string; use crate::helpers::query::get_variables_and_secrets; +use crate::{config::core_config, state::db_client}; mod discord; mod slack; @@ -136,7 +136,6 @@ async fn send_custom_alert( url: &str, alert: &Alert, ) -> anyhow::Result<()> { - let vars_and_secrets = get_variables_and_secrets().await?; let mut global_replacers = HashSet::new(); let mut secret_replacers = HashSet::new(); @@ -156,9 +155,14 @@ async fn send_custom_alert( .send() .await .map_err(|e| { - let replacers = secret_replacers.into_iter().collect::>(); - let sanitized_error = svi::replace_in_string(&format!("{e:?}"), &replacers); - anyhow::Error::msg(format!("Error with request: {}", sanitized_error)) + let replacers = + secret_replacers.into_iter().collect::>(); + let sanitized_error = + svi::replace_in_string(&format!("{e:?}"), &replacers); + anyhow::Error::msg(format!( + "Error with request: {}", + sanitized_error + )) }) .context("failed at post request to alerter")?; let status = res.status(); diff --git a/bin/core/src/alert/slack.rs b/bin/core/src/alert/slack.rs index ae127526a..4ca91b82a 100644 --- a/bin/core/src/alert/slack.rs +++ b/bin/core/src/alert/slack.rs @@ -73,7 +73,9 @@ pub async fn send_alert( let region = fmt_region(region); match alert.level { SeverityLevel::Ok => { - let text = format!("{level} | *{name}*{region} cpu usage at *{percentage:.1}%*"); + let text = format!( + "{level} | *{name}*{region} cpu usage at *{percentage:.1}%*" + ); let blocks = vec![ Block::header(level), Block::section(format!( @@ -87,7 +89,9 @@ pub async fn send_alert( (text, blocks.into()) } _ => { - let text = format!("{level} | *{name}*{region} cpu usage at *{percentage:.1}%* 📈"); + let text = format!( + "{level} | *{name}*{region} cpu usage at *{percentage:.1}%* 📈" + ); let blocks = vec![ Block::header(level), Block::section(format!( @@ -113,7 +117,9 @@ pub async fn send_alert( let percentage = 100.0 * used_gb / total_gb; match alert.level { SeverityLevel::Ok => { - let text = format!("{level} | *{name}*{region} memory usage at *{percentage:.1}%* 💾"); + let text = format!( + "{level} | *{name}*{region} memory usage at *{percentage:.1}%* 💾" + ); let blocks = vec![ Block::header(level), Block::section(format!( @@ -130,7 +136,9 @@ pub async fn send_alert( (text, blocks.into()) } _ => { - let text = format!("{level} | *{name}*{region} memory usage at *{percentage:.1}%* 💾"); + let text = format!( + "{level} | *{name}*{region} memory usage at *{percentage:.1}%* 💾" + ); let blocks = vec![ Block::header(level), Block::section(format!( @@ -160,7 +168,9 @@ pub async fn send_alert( let percentage = 100.0 * used_gb / total_gb; match alert.level { SeverityLevel::Ok => { - let text = format!("{level} | *{name}*{region} disk usage at *{percentage:.1}%* | mount point: *{path:?}* 💿"); + let text = format!( + "{level} | *{name}*{region} disk usage at *{percentage:.1}%* | mount point: *{path:?}* 💿" + ); let blocks = vec![ Block::header(level), Block::section(format!( @@ -169,12 +179,17 @@ pub async fn send_alert( Block::section(format!( "mount point: {path:?} | using *{used_gb:.1} GiB* / *{total_gb:.1} GiB*" )), - Block::section(resource_link(ResourceTargetVariant::Server, id)), + Block::section(resource_link( + ResourceTargetVariant::Server, + id, + )), ]; (text, blocks.into()) } _ => { - let text = format!("{level} | *{name}*{region} disk usage at *{percentage:.1}%* | mount point: *{path:?}* 💿"); + let text = format!( + "{level} | *{name}*{region} disk usage at *{percentage:.1}%* | mount point: *{path:?}* 💿" + ); let blocks = vec![ Block::header(level), Block::section(format!( @@ -183,7 +198,10 @@ pub async fn send_alert( Block::section(format!( "mount point: {path:?} | using *{used_gb:.1} GiB* / *{total_gb:.1} GiB*" )), - Block::section(resource_link(ResourceTargetVariant::Server, id)), + Block::section(resource_link( + ResourceTargetVariant::Server, + id, + )), ]; (text, blocks.into()) } diff --git a/bin/core/src/api/auth.rs b/bin/core/src/api/auth.rs index 97a03654e..f5757a6a4 100644 --- a/bin/core/src/api/auth.rs +++ b/bin/core/src/api/auth.rs @@ -1,6 +1,6 @@ use std::{sync::OnceLock, time::Instant}; -use axum::{http::HeaderMap, routing::post, Router}; +use axum::{Router, http::HeaderMap, routing::post}; use derive_variants::{EnumVariants, ExtractVariant}; use komodo_client::{api::auth::*, entities::user::User}; use resolver_api::Resolve; diff --git a/bin/core/src/api/execute/action.rs b/bin/core/src/api/execute/action.rs index 52dc6cac7..1be83f62c 100644 --- a/bin/core/src/api/execute/action.rs +++ b/bin/core/src/api/execute/action.rs @@ -317,8 +317,8 @@ fn delete_file( if name == file { if let Err(e) = fs::remove_file(entry.path()).await { warn!( - "Failed to clean up generated file after action execution | {e:#}" - ); + "Failed to clean up generated file after action execution | {e:#}" + ); }; return true; } diff --git a/bin/core/src/api/execute/build.rs b/bin/core/src/api/execute/build.rs index 61a53ece4..3b92607d7 100644 --- a/bin/core/src/api/execute/build.rs +++ b/bin/core/src/api/execute/build.rs @@ -1,6 +1,6 @@ use std::{collections::HashSet, future::IntoFuture, time::Duration}; -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use formatting::format_serror; use futures::future::join_all; use komodo_client::{ @@ -560,7 +560,9 @@ impl Resolve for CancelBuild { ) .await { - warn!("failed to set CancelBuild Update status Complete after timeout | {e:#}") + warn!( + "failed to set CancelBuild Update status Complete after timeout | {e:#}" + ) } }); diff --git a/bin/core/src/api/execute/deployment.rs b/bin/core/src/api/execute/deployment.rs index f8ee64443..e8e7da213 100644 --- a/bin/core/src/api/execute/deployment.rs +++ b/bin/core/src/api/execute/deployment.rs @@ -1,21 +1,21 @@ use std::{collections::HashSet, sync::OnceLock}; -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use cache::TimeoutCache; use formatting::format_serror; use komodo_client::{ api::execute::*, entities::{ + Version, build::{Build, ImageRegistryConfig}, deployment::{ - extract_registry_domain, Deployment, DeploymentImage, + Deployment, DeploymentImage, extract_registry_domain, }, get_image_name, komodo_timestamp, optional_string, permission::PermissionLevel, server::Server, update::{Log, Update}, user::User, - Version, }, }; use periphery_client::api; diff --git a/bin/core/src/api/execute/mod.rs b/bin/core/src/api/execute/mod.rs index 6445bf4e5..89d6ad960 100644 --- a/bin/core/src/api/execute/mod.rs +++ b/bin/core/src/api/execute/mod.rs @@ -1,17 +1,17 @@ use std::{pin::Pin, time::Instant}; use anyhow::Context; -use axum::{middleware, routing::post, Extension, Router}; -use axum_extra::{headers::ContentType, TypedHeader}; +use axum::{Extension, Router, middleware, routing::post}; +use axum_extra::{TypedHeader, headers::ContentType}; use derive_variants::{EnumVariants, ExtractVariant}; use formatting::format_serror; use futures::future::join_all; use komodo_client::{ api::execute::*, entities::{ + Operation, update::{Log, Update}, user::User, - Operation, }, }; use mungos::by_id::find_one_by_id; @@ -25,7 +25,7 @@ use uuid::Uuid; use crate::{ auth::auth_request, helpers::update::{init_execution_update, update_update}, - resource::{list_full_for_user_using_pattern, KomodoResource}, + resource::{KomodoResource, list_full_for_user_using_pattern}, state::db_client, }; diff --git a/bin/core/src/api/execute/procedure.rs b/bin/core/src/api/execute/procedure.rs index a0f5d3478..51c603c15 100644 --- a/bin/core/src/api/execute/procedure.rs +++ b/bin/core/src/api/execute/procedure.rs @@ -1,6 +1,6 @@ use std::pin::Pin; -use formatting::{bold, colored, format_serror, muted, Color}; +use formatting::{Color, bold, colored, format_serror, muted}; use komodo_client::{ api::execute::{ BatchExecutionResponse, BatchRunProcedure, RunProcedure, diff --git a/bin/core/src/api/execute/repo.rs b/bin/core/src/api/execute/repo.rs index 79b3dd72a..fc5dd9bd9 100644 --- a/bin/core/src/api/execute/repo.rs +++ b/bin/core/src/api/execute/repo.rs @@ -1,6 +1,6 @@ use std::{collections::HashSet, future::IntoFuture, time::Duration}; -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use formatting::format_serror; use komodo_client::{ api::{execute::*, write::RefreshRepoCache}, @@ -695,7 +695,9 @@ impl Resolve for CancelRepoBuild { ) .await { - warn!("failed to set CancelRepoBuild Update status Complete after timeout | {e:#}") + warn!( + "failed to set CancelRepoBuild Update status Complete after timeout | {e:#}" + ) } }); diff --git a/bin/core/src/api/execute/server_template.rs b/bin/core/src/api/execute/server_template.rs index b82d047e5..28de0c2fa 100644 --- a/bin/core/src/api/execute/server_template.rs +++ b/bin/core/src/api/execute/server_template.rs @@ -1,4 +1,4 @@ -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use formatting::format_serror; use komodo_client::{ api::{execute::LaunchServer, write::CreateServer}, diff --git a/bin/core/src/api/execute/sync.rs b/bin/core/src/api/execute/sync.rs index b8d303595..2a8c4c8de 100644 --- a/bin/core/src/api/execute/sync.rs +++ b/bin/core/src/api/execute/sync.rs @@ -1,11 +1,11 @@ use std::{collections::HashMap, str::FromStr}; -use anyhow::{anyhow, Context}; -use formatting::{colored, format_serror, Color}; +use anyhow::{Context, anyhow}; +use formatting::{Color, colored, format_serror}; use komodo_client::{ api::{execute::RunSync, write::RefreshResourceSyncPending}, entities::{ - self, + self, ResourceTargetVariant, action::Action, alerter::Alerter, build::Build, @@ -21,7 +21,6 @@ use komodo_client::{ sync::ResourceSync, update::{Log, Update}, user::sync_user, - ResourceTargetVariant, }, }; use mongo_indexed::doc; @@ -34,12 +33,12 @@ use crate::{ resource, state::{action_states, db_client}, sync::{ - deploy::{ - build_deploy_cache, deploy_from_cache, SyncDeployParams, - }, - execute::{get_updates_for_execution, ExecuteResourceSync}, - remote::RemoteResources, AllResourcesById, ResourceSyncTrait, + deploy::{ + SyncDeployParams, build_deploy_cache, deploy_from_cache, + }, + execute::{ExecuteResourceSync, get_updates_for_execution}, + remote::RemoteResources, }, }; diff --git a/bin/core/src/api/read/build.rs b/bin/core/src/api/read/build.rs index 331e5a55c..4fa7ac1f5 100644 --- a/bin/core/src/api/read/build.rs +++ b/bin/core/src/api/read/build.rs @@ -6,11 +6,11 @@ use futures::TryStreamExt; use komodo_client::{ api::read::*, entities::{ + Operation, build::{Build, BuildActionState, BuildListItem, BuildState}, config::core::CoreConfig, permission::PermissionLevel, update::UpdateStatus, - Operation, }, }; use mungos::{ diff --git a/bin/core/src/api/read/deployment.rs b/bin/core/src/api/read/deployment.rs index 1f44c60fe..b5848da4c 100644 --- a/bin/core/src/api/read/deployment.rs +++ b/bin/core/src/api/read/deployment.rs @@ -1,6 +1,6 @@ use std::{cmp, collections::HashSet}; -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use komodo_client::{ api::read::*, entities::{ diff --git a/bin/core/src/api/read/mod.rs b/bin/core/src/api/read/mod.rs index 8a74ec6c2..68f058999 100644 --- a/bin/core/src/api/read/mod.rs +++ b/bin/core/src/api/read/mod.rs @@ -1,10 +1,11 @@ use std::{collections::HashSet, sync::OnceLock, time::Instant}; -use anyhow::{anyhow, Context}; -use axum::{middleware, routing::post, Extension, Router}; +use anyhow::{Context, anyhow}; +use axum::{Extension, Router, middleware, routing::post}; use komodo_client::{ api::read::*, entities::{ + ResourceTarget, build::Build, builder::{Builder, BuilderConfig}, config::{DockerRegistry, GitProvider}, @@ -12,7 +13,6 @@ use komodo_client::{ server::Server, sync::ResourceSync, user::User, - ResourceTarget, }, }; use resolver_api::Resolve; @@ -315,7 +315,7 @@ impl Resolve for ListSecrets { _ => { return Err( anyhow!("target must be `Server` or `Builder`").into(), - ) + ); } }; if let Some(id) = server_id { @@ -373,7 +373,7 @@ impl Resolve for ListGitProvidersFromConfig { _ => { return Err( anyhow!("target must be `Server` or `Builder`").into(), - ) + ); } } } @@ -473,7 +473,7 @@ impl Resolve for ListDockerRegistriesFromConfig { _ => { return Err( anyhow!("target must be `Server` or `Builder`").into(), - ) + ); } } } diff --git a/bin/core/src/api/read/permission.rs b/bin/core/src/api/read/permission.rs index 3a6cfc7c0..eb934b914 100644 --- a/bin/core/src/api/read/permission.rs +++ b/bin/core/src/api/read/permission.rs @@ -1,4 +1,4 @@ -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use komodo_client::{ api::read::{ GetPermissionLevel, GetPermissionLevelResponse, ListPermissions, diff --git a/bin/core/src/api/read/provider.rs b/bin/core/src/api/read/provider.rs index f787e5d29..df416ae3b 100644 --- a/bin/core/src/api/read/provider.rs +++ b/bin/core/src/api/read/provider.rs @@ -1,6 +1,6 @@ -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use komodo_client::api::read::*; -use mongo_indexed::{doc, Document}; +use mongo_indexed::{Document, doc}; use mungos::{ by_id::find_one_by_id, find::find_collect, mongodb::options::FindOptions, diff --git a/bin/core/src/api/read/server.rs b/bin/core/src/api/read/server.rs index f062d7876..c6c5ade25 100644 --- a/bin/core/src/api/read/server.rs +++ b/bin/core/src/api/read/server.rs @@ -4,13 +4,14 @@ use std::{ sync::{Arc, OnceLock}, }; -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use async_timing_util::{ - get_timelength_in_ms, unix_timestamp_ms, FIFTEEN_SECONDS_MS, + FIFTEEN_SECONDS_MS, get_timelength_in_ms, unix_timestamp_ms, }; use komodo_client::{ api::read::*, entities::{ + ResourceTarget, deployment::Deployment, docker::{ container::{Container, ContainerListItem}, @@ -25,7 +26,6 @@ use komodo_client::{ stack::{Stack, StackServiceNames}, stats::{SystemInformation, SystemProcess}, update::Log, - ResourceTarget, }, }; use mungos::{ diff --git a/bin/core/src/api/read/toml.rs b/bin/core/src/api/read/toml.rs index 536204662..c53e60626 100644 --- a/bin/core/src/api/read/toml.rs +++ b/bin/core/src/api/read/toml.rs @@ -6,11 +6,12 @@ use komodo_client::{ ListUserGroups, }, entities::{ - action::Action, alerter::Alerter, build::Build, builder::Builder, - deployment::Deployment, permission::PermissionLevel, - procedure::Procedure, repo::Repo, resource::ResourceQuery, - server::Server, server_template::ServerTemplate, stack::Stack, - sync::ResourceSync, toml::ResourcesToml, ResourceTarget, + ResourceTarget, action::Action, alerter::Alerter, build::Build, + builder::Builder, deployment::Deployment, + permission::PermissionLevel, procedure::Procedure, repo::Repo, + resource::ResourceQuery, server::Server, + server_template::ServerTemplate, stack::Stack, + sync::ResourceSync, toml::ResourcesToml, }, }; use mungos::find::find_collect; @@ -23,9 +24,9 @@ use crate::{ resource, state::db_client, sync::{ - toml::{convert_resource, ToToml, TOML_PRETTY_OPTIONS}, - user_groups::convert_user_groups, AllResourcesById, + toml::{TOML_PRETTY_OPTIONS, ToToml, convert_resource}, + user_groups::convert_user_groups, }, }; diff --git a/bin/core/src/api/read/update.rs b/bin/core/src/api/read/update.rs index b5333d21f..10d9ccca2 100644 --- a/bin/core/src/api/read/update.rs +++ b/bin/core/src/api/read/update.rs @@ -1,9 +1,10 @@ use std::collections::HashMap; -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use komodo_client::{ api::read::{GetUpdate, ListUpdates, ListUpdatesResponse}, entities::{ + ResourceTarget, action::Action, alerter::Alerter, build::Build, @@ -18,7 +19,6 @@ use komodo_client::{ sync::ResourceSync, update::{Update, UpdateListItem}, user::User, - ResourceTarget, }, }; use mungos::{ @@ -242,7 +242,7 @@ impl Resolve for GetUpdate { ResourceTarget::System(_) => { return Err( anyhow!("user must be admin to view system updates").into(), - ) + ); } ResourceTarget::Server(id) => { resource::get_check_permissions::( diff --git a/bin/core/src/api/read/user.rs b/bin/core/src/api/read/user.rs index ad62b6d17..5a9395045 100644 --- a/bin/core/src/api/read/user.rs +++ b/bin/core/src/api/read/user.rs @@ -1,4 +1,4 @@ -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use komodo_client::{ api::read::{ FindUser, FindUserResponse, GetUsername, GetUsernameResponse, @@ -6,7 +6,7 @@ use komodo_client::{ ListApiKeysForServiceUserResponse, ListApiKeysResponse, ListUsers, ListUsersResponse, }, - entities::user::{admin_service_user, UserConfig}, + entities::user::{UserConfig, admin_service_user}, }; use mungos::{ by_id::find_one_by_id, diff --git a/bin/core/src/api/read/user_group.rs b/bin/core/src/api/read/user_group.rs index 2f0eceae0..611bd9de4 100644 --- a/bin/core/src/api/read/user_group.rs +++ b/bin/core/src/api/read/user_group.rs @@ -5,7 +5,7 @@ use komodo_client::api::read::*; use mungos::{ find::find_collect, mongodb::{ - bson::{doc, oid::ObjectId, Document}, + bson::{Document, doc, oid::ObjectId}, options::FindOptions, }, }; diff --git a/bin/core/src/api/user.rs b/bin/core/src/api/user.rs index 959da98e3..95a605b07 100644 --- a/bin/core/src/api/user.rs +++ b/bin/core/src/api/user.rs @@ -1,7 +1,7 @@ use std::{collections::VecDeque, time::Instant}; -use anyhow::{anyhow, Context}; -use axum::{middleware, routing::post, Extension, Json, Router}; +use anyhow::{Context, anyhow}; +use axum::{Extension, Json, Router, middleware, routing::post}; use derive_variants::EnumVariants; use komodo_client::{ api::user::*, diff --git a/bin/core/src/api/write/build.rs b/bin/core/src/api/write/build.rs index 92d5b05ce..b2b22909a 100644 --- a/bin/core/src/api/write/build.rs +++ b/bin/core/src/api/write/build.rs @@ -1,13 +1,13 @@ -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use git::GitRes; use komodo_client::{ api::write::*, entities::{ + CloneArgs, NoData, build::{Build, BuildInfo, PartialBuildConfig}, config::core::CoreConfig, permission::PermissionLevel, update::Update, - CloneArgs, NoData, }, }; use mongo_indexed::doc; diff --git a/bin/core/src/api/write/builder.rs b/bin/core/src/api/write/builder.rs index 0225708f3..337d98506 100644 --- a/bin/core/src/api/write/builder.rs +++ b/bin/core/src/api/write/builder.rs @@ -72,9 +72,6 @@ impl Resolve for RenameBuilder { self, WriteArgs { user }: &WriteArgs, ) -> serror::Result { - Ok( - resource::rename::(&self.id, &self.name, user) - .await?, - ) + Ok(resource::rename::(&self.id, &self.name, user).await?) } } diff --git a/bin/core/src/api/write/deployment.rs b/bin/core/src/api/write/deployment.rs index d3569b8fb..69a02726a 100644 --- a/bin/core/src/api/write/deployment.rs +++ b/bin/core/src/api/write/deployment.rs @@ -1,7 +1,8 @@ -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use komodo_client::{ api::write::*, entities::{ + Operation, deployment::{ Deployment, DeploymentImage, DeploymentState, PartialDeploymentConfig, RestartMode, @@ -12,7 +13,6 @@ use komodo_client::{ server::{Server, ServerState}, to_komodo_name, update::Update, - Operation, }, }; use mungos::{by_id::update_one_by_id, mongodb::bson::doc}; @@ -58,12 +58,8 @@ impl Resolve for CopyDeployment { ) .await?; Ok( - resource::create::( - &self.name, - config.into(), - user, - ) - .await?, + resource::create::(&self.name, config.into(), user) + .await?, ) } } diff --git a/bin/core/src/api/write/description.rs b/bin/core/src/api/write/description.rs index 83d6c53bf..a30709e05 100644 --- a/bin/core/src/api/write/description.rs +++ b/bin/core/src/api/write/description.rs @@ -2,10 +2,10 @@ use anyhow::anyhow; use komodo_client::{ api::write::{UpdateDescription, UpdateDescriptionResponse}, entities::{ - action::Action, alerter::Alerter, build::Build, builder::Builder, - deployment::Deployment, procedure::Procedure, repo::Repo, - server::Server, server_template::ServerTemplate, stack::Stack, - sync::ResourceSync, ResourceTarget, + ResourceTarget, action::Action, alerter::Alerter, build::Build, + builder::Builder, deployment::Deployment, procedure::Procedure, + repo::Repo, server::Server, server_template::ServerTemplate, + stack::Stack, sync::ResourceSync, }, }; use resolver_api::Resolve; @@ -27,7 +27,7 @@ impl Resolve for UpdateDescription { "cannot update description of System resource target" ) .into(), - ) + ); } ResourceTarget::Server(id) => { resource::update_description::( diff --git a/bin/core/src/api/write/mod.rs b/bin/core/src/api/write/mod.rs index 4acb72e1c..8d79727cc 100644 --- a/bin/core/src/api/write/mod.rs +++ b/bin/core/src/api/write/mod.rs @@ -1,7 +1,7 @@ use std::time::Instant; use anyhow::Context; -use axum::{middleware, routing::post, Extension, Router}; +use axum::{Extension, Router, middleware, routing::post}; use derive_variants::{EnumVariants, ExtractVariant}; use komodo_client::{api::write::*, entities::user::User}; use resolver_api::Resolve; diff --git a/bin/core/src/api/write/permissions.rs b/bin/core/src/api/write/permissions.rs index 632e3ab59..d987bbe05 100644 --- a/bin/core/src/api/write/permissions.rs +++ b/bin/core/src/api/write/permissions.rs @@ -1,17 +1,17 @@ use std::str::FromStr; -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use komodo_client::{ api::write::*, entities::{ - permission::{UserTarget, UserTargetVariant}, ResourceTarget, ResourceTargetVariant, + permission::{UserTarget, UserTargetVariant}, }, }; use mungos::{ by_id::{find_one_by_id, update_one_by_id}, mongodb::{ - bson::{doc, oid::ObjectId, Document}, + bson::{Document, doc, oid::ObjectId}, options::UpdateOptions, }, }; diff --git a/bin/core/src/api/write/provider.rs b/bin/core/src/api/write/provider.rs index 22e66efe7..07d7bd0b7 100644 --- a/bin/core/src/api/write/provider.rs +++ b/bin/core/src/api/write/provider.rs @@ -1,9 +1,9 @@ -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use komodo_client::{ api::write::*, entities::{ - provider::{DockerRegistryAccount, GitProviderAccount}, Operation, ResourceTarget, + provider::{DockerRegistryAccount, GitProviderAccount}, }, }; use mungos::{ diff --git a/bin/core/src/api/write/repo.rs b/bin/core/src/api/write/repo.rs index e8dd1de46..99f271848 100644 --- a/bin/core/src/api/write/repo.rs +++ b/bin/core/src/api/write/repo.rs @@ -1,9 +1,10 @@ -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use formatting::format_serror; use git::GitRes; use komodo_client::{ api::write::*, entities::{ + CloneArgs, NoData, Operation, config::core::CoreConfig, komodo_timestamp, permission::PermissionLevel, @@ -11,7 +12,6 @@ use komodo_client::{ server::Server, to_komodo_name, update::{Log, Update}, - CloneArgs, NoData, Operation, }, }; use mongo_indexed::doc; diff --git a/bin/core/src/api/write/server.rs b/bin/core/src/api/write/server.rs index 74f398e15..2e4babee5 100644 --- a/bin/core/src/api/write/server.rs +++ b/bin/core/src/api/write/server.rs @@ -2,10 +2,10 @@ use formatting::format_serror; use komodo_client::{ api::write::*, entities::{ + Operation, permission::PermissionLevel, server::Server, update::{Update, UpdateStatus}, - Operation, }, }; use periphery_client::api; diff --git a/bin/core/src/api/write/service_user.rs b/bin/core/src/api/write/service_user.rs index 964250089..a825254d6 100644 --- a/bin/core/src/api/write/service_user.rs +++ b/bin/core/src/api/write/service_user.rs @@ -1,6 +1,6 @@ use std::str::FromStr; -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use komodo_client::{ api::{user::CreateApiKey, write::*}, entities::{ diff --git a/bin/core/src/api/write/stack.rs b/bin/core/src/api/write/stack.rs index 0c20cb60e..6cf7b2103 100644 --- a/bin/core/src/api/write/stack.rs +++ b/bin/core/src/api/write/stack.rs @@ -1,15 +1,15 @@ -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use formatting::format_serror; use komodo_client::{ api::write::*, entities::{ + FileContents, NoData, Operation, config::core::CoreConfig, permission::PermissionLevel, server::ServerState, stack::{PartialStackConfig, Stack, StackInfo}, update::Update, user::stack_user, - FileContents, NoData, Operation, }, }; use mungos::mongodb::bson::{doc, to_document}; @@ -33,7 +33,7 @@ use crate::{ resource, stack::{ get_stack_and_server, - remote::{get_repo_compose_contents, RemoteComposeContents}, + remote::{RemoteComposeContents, get_repo_compose_contents}, services::extract_services_into_res, }, state::{db_client, github_client}, diff --git a/bin/core/src/api/write/sync.rs b/bin/core/src/api/write/sync.rs index 046a0c224..61234ea84 100644 --- a/bin/core/src/api/write/sync.rs +++ b/bin/core/src/api/write/sync.rs @@ -1,11 +1,11 @@ use std::{collections::HashMap, path::PathBuf}; -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use formatting::format_serror; use komodo_client::{ api::{read::ExportAllResourcesToToml, write::*}, entities::{ - self, + self, CloneArgs, NoData, Operation, ResourceTarget, action::Action, alert::{Alert, AlertData, SeverityLevel}, alerter::Alerter, @@ -27,7 +27,6 @@ use komodo_client::{ to_komodo_name, update::{Log, Update}, user::sync_user, - CloneArgs, NoData, Operation, ResourceTarget, }, }; use mungos::{ @@ -52,8 +51,8 @@ use crate::{ resource, state::{db_client, github_client}, sync::{ - deploy::SyncDeployParams, remote::RemoteResources, - view::push_updates_for_view, AllResourcesById, + AllResourcesById, deploy::SyncDeployParams, + remote::RemoteResources, view::push_updates_for_view, }, }; @@ -165,7 +164,9 @@ async fn write_sync_file_contents_on_host( if let Err(e) = fs::write(&full_path, &contents).await.with_context(|| { - format!("Failed to write resource file contents to {full_path:?}") + format!( + "Failed to write resource file contents to {full_path:?}" + ) }) { update.push_error_log("Write File", format_serror(&e.into())); @@ -261,7 +262,9 @@ async fn write_sync_file_contents_git( if let Err(e) = fs::write(&full_path, &contents).await.with_context(|| { - format!("Failed to write resource file contents to {full_path:?}") + format!( + "Failed to write resource file contents to {full_path:?}" + ) }) { update.push_error_log("Write File", format_serror(&e.into())); diff --git a/bin/core/src/api/write/tag.rs b/bin/core/src/api/write/tag.rs index 0a0e5faa5..2ea1e2b9b 100644 --- a/bin/core/src/api/write/tag.rs +++ b/bin/core/src/api/write/tag.rs @@ -1,17 +1,17 @@ use std::str::FromStr; -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use komodo_client::{ api::write::{ CreateTag, DeleteTag, RenameTag, UpdateTagsOnResource, UpdateTagsOnResourceResponse, }, entities::{ - action::Action, alerter::Alerter, build::Build, builder::Builder, - deployment::Deployment, permission::PermissionLevel, - procedure::Procedure, repo::Repo, server::Server, - server_template::ServerTemplate, stack::Stack, - sync::ResourceSync, tag::Tag, ResourceTarget, + ResourceTarget, action::Action, alerter::Alerter, build::Build, + builder::Builder, deployment::Deployment, + permission::PermissionLevel, procedure::Procedure, repo::Repo, + server::Server, server_template::ServerTemplate, stack::Stack, + sync::ResourceSync, tag::Tag, }, }; use mungos::{ @@ -118,7 +118,7 @@ impl Resolve for UpdateTagsOnResource { let WriteArgs { user } = args; match self.target { ResourceTarget::System(_) => { - return Err(anyhow!("Invalid target type: System").into()) + return Err(anyhow!("Invalid target type: System").into()); } ResourceTarget::Build(id) => { resource::get_check_permissions::( diff --git a/bin/core/src/api/write/user.rs b/bin/core/src/api/write/user.rs index affe88b21..7afdf9744 100644 --- a/bin/core/src/api/write/user.rs +++ b/bin/core/src/api/write/user.rs @@ -1,13 +1,13 @@ use std::str::FromStr; -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use komodo_client::{ api::write::{ DeleteUser, DeleteUserResponse, UpdateUserPassword, UpdateUserPasswordResponse, UpdateUserUsername, UpdateUserUsernameResponse, }, - entities::{user::UserConfig, NoData}, + entities::{NoData, user::UserConfig}, }; use mungos::mongodb::bson::{doc, oid::ObjectId}; use resolver_api::Resolve; diff --git a/bin/core/src/api/write/user_group.rs b/bin/core/src/api/write/user_group.rs index 407c7dc21..7b982a6e4 100644 --- a/bin/core/src/api/write/user_group.rs +++ b/bin/core/src/api/write/user_group.rs @@ -1,6 +1,6 @@ use std::{collections::HashMap, str::FromStr}; -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use komodo_client::{ api::write::{ AddUserToUserGroup, CreateUserGroup, DeleteUserGroup, diff --git a/bin/core/src/api/write/variable.rs b/bin/core/src/api/write/variable.rs index 5a0d2fbec..b3d1ef6b2 100644 --- a/bin/core/src/api/write/variable.rs +++ b/bin/core/src/api/write/variable.rs @@ -1,7 +1,7 @@ -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use komodo_client::{ api::write::*, - entities::{variable::Variable, Operation, ResourceTarget}, + entities::{Operation, ResourceTarget, variable::Variable}, }; use mungos::mongodb::bson::doc; use resolver_api::Resolve; diff --git a/bin/core/src/auth/github/client.rs b/bin/core/src/auth/github/client.rs index 00620e27c..c3e69fb3e 100644 --- a/bin/core/src/auth/github/client.rs +++ b/bin/core/src/auth/github/client.rs @@ -1,11 +1,11 @@ use std::sync::OnceLock; -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use komodo_client::entities::config::core::{ CoreConfig, OauthCredentials, }; use reqwest::StatusCode; -use serde::{de::DeserializeOwned, Deserialize, Serialize}; +use serde::{Deserialize, Serialize, de::DeserializeOwned}; use tokio::sync::Mutex; use crate::{ @@ -47,15 +47,21 @@ impl GithubOauthClient { return None; } if host.is_empty() { - warn!("github oauth is enabled, but 'config.host' is not configured"); + warn!( + "github oauth is enabled, but 'config.host' is not configured" + ); return None; } if id.is_empty() { - warn!("github oauth is enabled, but 'config.github_oauth.id' is not configured"); + warn!( + "github oauth is enabled, but 'config.github_oauth.id' is not configured" + ); return None; } if secret.is_empty() { - warn!("github oauth is enabled, but 'config.github_oauth.secret' is not configured"); + warn!( + "github oauth is enabled, but 'config.github_oauth.secret' is not configured" + ); return None; } GithubOauthClient { diff --git a/bin/core/src/auth/github/mod.rs b/bin/core/src/auth/github/mod.rs index 0fa619c30..1eacaeee0 100644 --- a/bin/core/src/auth/github/mod.rs +++ b/bin/core/src/auth/github/mod.rs @@ -1,6 +1,6 @@ -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use axum::{ - extract::Query, response::Redirect, routing::get, Router, + Router, extract::Query, response::Redirect, routing::get, }; use komodo_client::entities::{ komodo_timestamp, diff --git a/bin/core/src/auth/google/client.rs b/bin/core/src/auth/google/client.rs index 725fed665..38481cbd6 100644 --- a/bin/core/src/auth/google/client.rs +++ b/bin/core/src/auth/google/client.rs @@ -1,12 +1,12 @@ use std::sync::OnceLock; -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use jwt::Token; use komodo_client::entities::config::core::{ CoreConfig, OauthCredentials, }; use reqwest::StatusCode; -use serde::{de::DeserializeOwned, Deserialize}; +use serde::{Deserialize, de::DeserializeOwned}; use serde_json::Value; use tokio::sync::Mutex; @@ -49,15 +49,21 @@ impl GoogleOauthClient { return None; } if host.is_empty() { - warn!("google oauth is enabled, but 'config.host' is not configured"); + warn!( + "google oauth is enabled, but 'config.host' is not configured" + ); return None; } if id.is_empty() { - warn!("google oauth is enabled, but 'config.google_oauth.id' is not configured"); + warn!( + "google oauth is enabled, but 'config.google_oauth.id' is not configured" + ); return None; } if secret.is_empty() { - warn!("google oauth is enabled, but 'config.google_oauth.secret' is not configured"); + warn!( + "google oauth is enabled, but 'config.google_oauth.secret' is not configured" + ); return None; } let scopes = urlencoding::encode( diff --git a/bin/core/src/auth/google/mod.rs b/bin/core/src/auth/google/mod.rs index 45f6f50df..b19a9fd20 100644 --- a/bin/core/src/auth/google/mod.rs +++ b/bin/core/src/auth/google/mod.rs @@ -1,7 +1,7 @@ -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use async_timing_util::unix_timestamp_ms; use axum::{ - extract::Query, response::Redirect, routing::get, Router, + Router, extract::Query, response::Redirect, routing::get, }; use komodo_client::entities::user::{User, UserConfig}; use mongo_indexed::Document; diff --git a/bin/core/src/auth/jwt.rs b/bin/core/src/auth/jwt.rs index 1b4a51db3..aeaf3a23d 100644 --- a/bin/core/src/auth/jwt.rs +++ b/bin/core/src/auth/jwt.rs @@ -1,8 +1,8 @@ use std::collections::HashMap; -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use async_timing_util::{ - get_timelength_in_ms, unix_timestamp_ms, Timelength, + Timelength, get_timelength_in_ms, unix_timestamp_ms, }; use hmac::{Hmac, Mac}; use jwt::SignWithKey; diff --git a/bin/core/src/auth/local.rs b/bin/core/src/auth/local.rs index 402e47da9..9b64383b5 100644 --- a/bin/core/src/auth/local.rs +++ b/bin/core/src/auth/local.rs @@ -1,6 +1,6 @@ use std::str::FromStr; -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use async_timing_util::unix_timestamp_ms; use komodo_client::{ api::auth::{ diff --git a/bin/core/src/auth/mod.rs b/bin/core/src/auth/mod.rs index d7c6d3441..36683ca29 100644 --- a/bin/core/src/auth/mod.rs +++ b/bin/core/src/auth/mod.rs @@ -1,5 +1,5 @@ use ::jwt::VerifyWithKey; -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use async_timing_util::unix_timestamp_ms; use axum::{ extract::Request, http::HeaderMap, middleware::Next, @@ -71,7 +71,9 @@ pub async fn get_user_id_from_headers( } _ => { // AUTH FAIL - Err(anyhow!("must attach either AUTHORIZATION header with jwt OR pass X-API-KEY and X-API-SECRET")) + Err(anyhow!( + "must attach either AUTHORIZATION header with jwt OR pass X-API-KEY and X-API-SECRET" + )) } } } diff --git a/bin/core/src/auth/oidc/client.rs b/bin/core/src/auth/oidc/client.rs index 88a1ff23d..d9935f0c4 100644 --- a/bin/core/src/auth/oidc/client.rs +++ b/bin/core/src/auth/oidc/client.rs @@ -2,9 +2,9 @@ use std::sync::OnceLock; use anyhow::Context; use openidconnect::{ - core::*, Client, ClientId, ClientSecret, EmptyAdditionalClaims, + Client, ClientId, ClientSecret, EmptyAdditionalClaims, EndpointMaybeSet, EndpointNotSet, EndpointSet, IssuerUrl, - RedirectUrl, StandardErrorResponse, + RedirectUrl, StandardErrorResponse, core::*, }; use crate::config::core_config; diff --git a/bin/core/src/auth/oidc/mod.rs b/bin/core/src/auth/oidc/mod.rs index 344b2407f..3043390d4 100644 --- a/bin/core/src/auth/oidc/mod.rs +++ b/bin/core/src/auth/oidc/mod.rs @@ -1,8 +1,8 @@ use std::sync::OnceLock; -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use axum::{ - extract::Query, response::Redirect, routing::get, Router, + Router, extract::Query, response::Redirect, routing::get, }; use client::default_oidc_client; use dashmap::DashMap; @@ -10,10 +10,10 @@ use komodo_client::entities::{ komodo_timestamp, user::{User, UserConfig}, }; -use mungos::mongodb::bson::{doc, Document}; +use mungos::mongodb::bson::{Document, doc}; use openidconnect::{ - core::CoreAuthenticationFlow, AuthorizationCode, CsrfToken, Nonce, - Scope, TokenResponse, + AuthorizationCode, CsrfToken, Nonce, Scope, TokenResponse, + core::CoreAuthenticationFlow, }; use reqwest::StatusCode; use serde::Deserialize; diff --git a/bin/core/src/cloud/aws/ec2.rs b/bin/core/src/cloud/aws/ec2.rs index 4f8ace86d..000e9dfdb 100644 --- a/bin/core/src/cloud/aws/ec2.rs +++ b/bin/core/src/cloud/aws/ec2.rs @@ -1,22 +1,22 @@ use std::{str::FromStr, time::Duration}; -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use aws_config::{BehaviorVersion, Region}; use aws_sdk_ec2::{ + Client, types::{ BlockDeviceMapping, EbsBlockDevice, InstanceNetworkInterfaceSpecification, InstanceStateChange, InstanceStateName, InstanceStatus, InstanceType, ResourceType, Tag, TagSpecification, VolumeType, }, - Client, }; use base64::Engine; use komodo_client::entities::{ + ResourceTarget, alert::{Alert, AlertData, SeverityLevel}, komodo_timestamp, server_template::aws::AwsServerTemplateConfig, - ResourceTarget, }; use crate::{alert::send_alerts, config::core_config}; @@ -29,20 +29,40 @@ pub struct Ec2Instance { pub ip: String, } +/// Provides credentials in the core config file to the AWS client +#[derive(Debug)] +struct CredentialsFromConfig; + +impl aws_credential_types::provider::ProvideCredentials + for CredentialsFromConfig +{ + fn provide_credentials<'a>( + &'a self, + ) -> aws_credential_types::provider::future::ProvideCredentials<'a> + where + Self: 'a, + { + aws_credential_types::provider::future::ProvideCredentials::new( + async { + let config = core_config(); + Ok(aws_credential_types::Credentials::new( + &config.aws.access_key_id, + &config.aws.secret_access_key, + None, + None, + "komodo-config", + )) + }, + ) + } +} + #[instrument] async fn create_ec2_client(region: String) -> Client { - // There may be a better way to pass these keys to client - std::env::set_var( - "AWS_ACCESS_KEY_ID", - &core_config().aws.access_key_id, - ); - std::env::set_var( - "AWS_SECRET_ACCESS_KEY", - &core_config().aws.secret_access_key, - ); let region = Region::new(region); let config = aws_config::defaults(BehaviorVersion::v2024_03_28()) .region(region) + .credentials_provider(CredentialsFromConfig) .load() .await; Client::new(&config) diff --git a/bin/core/src/cloud/hetzner/client.rs b/bin/core/src/cloud/hetzner/client.rs index c4d1712de..79de50ac4 100644 --- a/bin/core/src/cloud/hetzner/client.rs +++ b/bin/core/src/cloud/hetzner/client.rs @@ -1,7 +1,7 @@ -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use axum::http::{HeaderName, HeaderValue}; use reqwest::{RequestBuilder, StatusCode}; -use serde::{de::DeserializeOwned, Serialize}; +use serde::{Serialize, de::DeserializeOwned}; use super::{ common::{ diff --git a/bin/core/src/cloud/hetzner/mod.rs b/bin/core/src/cloud/hetzner/mod.rs index aed19e0b5..e235cd887 100644 --- a/bin/core/src/cloud/hetzner/mod.rs +++ b/bin/core/src/cloud/hetzner/mod.rs @@ -3,7 +3,7 @@ use std::{ time::Duration, }; -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use futures::future::join_all; use komodo_client::entities::server_template::hetzner::{ HetznerDatacenter, HetznerServerTemplateConfig, HetznerServerType, diff --git a/bin/core/src/db.rs b/bin/core/src/db.rs index d372ed3c7..8c138f0f3 100644 --- a/bin/core/src/db.rs +++ b/bin/core/src/db.rs @@ -89,7 +89,9 @@ impl DbClient { client = client.address(address); } _ => { - error!("config.mongo not configured correctly. must pass either config.mongo.uri, or config.mongo.address + config.mongo.username? + config.mongo.password?"); + error!( + "config.mongo not configured correctly. must pass either config.mongo.uri, or config.mongo.address + config.mongo.username? + config.mongo.password?" + ); std::process::exit(1) } } diff --git a/bin/core/src/helpers/builder.rs b/bin/core/src/helpers/builder.rs index 9d6f2467a..fd539f06a 100644 --- a/bin/core/src/helpers/builder.rs +++ b/bin/core/src/helpers/builder.rs @@ -1,27 +1,27 @@ use std::time::Duration; -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use formatting::muted; use komodo_client::entities::{ + Version, builder::{AwsBuilderConfig, Builder, BuilderConfig}, komodo_timestamp, server::Server, server_template::aws::AwsServerTemplateConfig, update::{Log, Update}, - Version, }; use periphery_client::{ - api::{self, GetVersionResponse}, PeripheryClient, + api::{self, GetVersionResponse}, }; use crate::{ cloud::{ - aws::ec2::{ - launch_ec2_instance, terminate_ec2_instance_with_retry, - Ec2Instance, - }, BuildCleanupData, + aws::ec2::{ + Ec2Instance, launch_ec2_instance, + terminate_ec2_instance_with_retry, + }, }, config::core_config, helpers::update::update_update, diff --git a/bin/core/src/helpers/cache.rs b/bin/core/src/helpers/cache.rs index 01416c692..a9ae902d1 100644 --- a/bin/core/src/helpers/cache.rs +++ b/bin/core/src/helpers/cache.rs @@ -9,9 +9,9 @@ pub struct Cache { } impl< - K: PartialEq + Eq + Hash + std::fmt::Debug + Clone, - T: Clone + Default, - > Cache + K: PartialEq + Eq + Hash + std::fmt::Debug + Clone, + T: Clone + Default, +> Cache { #[instrument(level = "debug", skip(self))] pub async fn get(&self, key: &K) -> Option { @@ -70,9 +70,9 @@ impl< } impl< - K: PartialEq + Eq + Hash + std::fmt::Debug + Clone, - T: Clone + Default + Busy, - > Cache + K: PartialEq + Eq + Hash + std::fmt::Debug + Clone, + T: Clone + Default + Busy, +> Cache { #[instrument(level = "debug", skip(self))] pub async fn busy(&self, id: &K) -> bool { diff --git a/bin/core/src/helpers/channel.rs b/bin/core/src/helpers/channel.rs index 3e591bba6..79a5b8914 100644 --- a/bin/core/src/helpers/channel.rs +++ b/bin/core/src/helpers/channel.rs @@ -1,11 +1,11 @@ use std::sync::OnceLock; use komodo_client::entities::update::{Update, UpdateListItem}; -use tokio::sync::{broadcast, Mutex}; +use tokio::sync::{Mutex, broadcast}; /// A channel sending (build_id, update_id) -pub fn build_cancel_channel( -) -> &'static BroadcastChannel<(String, Update)> { +pub fn build_cancel_channel() +-> &'static BroadcastChannel<(String, Update)> { static BUILD_CANCEL_CHANNEL: OnceLock< BroadcastChannel<(String, Update)>, > = OnceLock::new(); @@ -13,8 +13,8 @@ pub fn build_cancel_channel( } /// A channel sending (repo_id, update_id) -pub fn repo_cancel_channel( -) -> &'static BroadcastChannel<(String, Update)> { +pub fn repo_cancel_channel() +-> &'static BroadcastChannel<(String, Update)> { static REPO_CANCEL_CHANNEL: OnceLock< BroadcastChannel<(String, Update)>, > = OnceLock::new(); diff --git a/bin/core/src/helpers/interpolate.rs b/bin/core/src/helpers/interpolate.rs index 7154ad90e..b6e6df4bd 100644 --- a/bin/core/src/helpers/interpolate.rs +++ b/bin/core/src/helpers/interpolate.rs @@ -1,7 +1,7 @@ use std::collections::HashSet; use anyhow::Context; -use komodo_client::entities::{update::Update, SystemCommand}; +use komodo_client::entities::{SystemCommand, update::Update}; use super::query::VariablesAndSecrets; diff --git a/bin/core/src/helpers/mod.rs b/bin/core/src/helpers/mod.rs index 1b57d3b01..8dc907d72 100644 --- a/bin/core/src/helpers/mod.rs +++ b/bin/core/src/helpers/mod.rs @@ -1,24 +1,24 @@ use std::{str::FromStr, time::Duration}; -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use futures::future::join_all; use komodo_client::{ api::write::{CreateBuilder, CreateServer}, entities::{ + ResourceTarget, builder::{PartialBuilderConfig, PartialServerBuilderConfig}, komodo_timestamp, permission::{Permission, PermissionLevel, UserTarget}, server::{PartialServerConfig, Server}, sync::ResourceSync, update::Log, - user::{system_user, User}, - ResourceTarget, + user::{User, system_user}, }, }; use mongo_indexed::Document; use mungos::{ find::find_collect, - mongodb::bson::{doc, oid::ObjectId, to_document, Bson}, + mongodb::bson::{Bson, doc, oid::ObjectId, to_document}, }; use periphery_client::PeripheryClient; use rand::Rng; @@ -208,7 +208,9 @@ pub async fn startup_cleanup() { async fn startup_in_progress_update_cleanup() { let log = Log::error( "Komodo shutdown", - String::from("Komodo shutdown during execution. If this is a build, the builder may not have been terminated.") + String::from( + "Komodo shutdown during execution. If this is a build, the builder may not have been terminated.", + ), ); // This static log won't fail to serialize, unwrap ok. let log = to_document(&log).unwrap(); @@ -319,7 +321,10 @@ pub async fn ensure_first_server_and_builder() { { Ok(server) => server, Err(e) => { - error!("Failed to initialize 'first_server'. Failed to CreateServer. {:#}", e.error); + error!( + "Failed to initialize 'first_server'. Failed to CreateServer. {:#}", + e.error + ); return; } } @@ -342,6 +347,9 @@ pub async fn ensure_first_server_and_builder() { }) .await { - error!("Failed to initialize 'first_builder' | Failed to CreateBuilder | {:#}", e.error); + error!( + "Failed to initialize 'first_builder' | Failed to CreateBuilder | {:#}", + e.error + ); } } diff --git a/bin/core/src/helpers/procedure.rs b/bin/core/src/helpers/procedure.rs index f73356464..071108c95 100644 --- a/bin/core/src/helpers/procedure.rs +++ b/bin/core/src/helpers/procedure.rs @@ -1,7 +1,7 @@ use std::time::{Duration, Instant}; -use anyhow::{anyhow, Context}; -use formatting::{bold, colored, format_serror, muted, Color}; +use anyhow::{Context, anyhow}; +use formatting::{Color, bold, colored, format_serror, muted}; use futures::future::join_all; use komodo_client::{ api::execute::*, @@ -25,7 +25,7 @@ use crate::{ execute::{ExecuteArgs, ExecuteRequest}, write::WriteArgs, }, - resource::{list_full_for_user_using_pattern, KomodoResource}, + resource::{KomodoResource, list_full_for_user_using_pattern}, state::db_client, }; @@ -206,7 +206,7 @@ async fn execute_stage( join_all(futures) .await .into_iter() - .collect::>()?; + .collect::>>()?; Ok(()) } diff --git a/bin/core/src/helpers/prune.rs b/bin/core/src/helpers/prune.rs index 888d5d93a..fce9a7d3a 100644 --- a/bin/core/src/helpers/prune.rs +++ b/bin/core/src/helpers/prune.rs @@ -1,6 +1,6 @@ use anyhow::Context; use async_timing_util::{ - unix_timestamp_ms, wait_until_timelength, Timelength, ONE_DAY_MS, + ONE_DAY_MS, Timelength, unix_timestamp_ms, wait_until_timelength, }; use futures::future::join_all; use mungos::{find::find_collect, mongodb::bson::doc}; diff --git a/bin/core/src/helpers/query.rs b/bin/core/src/helpers/query.rs index 39e637982..62d3ba840 100644 --- a/bin/core/src/helpers/query.rs +++ b/bin/core/src/helpers/query.rs @@ -1,7 +1,8 @@ use std::{collections::HashMap, str::FromStr}; -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use komodo_client::entities::{ + Operation, ResourceTarget, ResourceTargetVariant, action::Action, alerter::Alerter, build::Build, @@ -17,15 +18,14 @@ use komodo_client::entities::{ sync::ResourceSync, tag::Tag, update::Update, - user::{admin_service_user, User}, + user::{User, admin_service_user}, user_group::UserGroup, variable::Variable, - Operation, ResourceTarget, ResourceTargetVariant, }; use mungos::{ find::find_collect, mongodb::{ - bson::{doc, oid::ObjectId, Document}, + bson::{Document, doc, oid::ObjectId}, options::FindOneOptions, }, }; @@ -359,8 +359,8 @@ pub struct VariablesAndSecrets { pub secrets: HashMap, } -pub async fn get_variables_and_secrets( -) -> anyhow::Result { +pub async fn get_variables_and_secrets() +-> anyhow::Result { let variables = find_collect(&db_client().variables, None, None) .await .context("failed to get all variables from db")?; diff --git a/bin/core/src/helpers/update.rs b/bin/core/src/helpers/update.rs index 1de5a27f2..45b6059dd 100644 --- a/bin/core/src/helpers/update.rs +++ b/bin/core/src/helpers/update.rs @@ -1,5 +1,6 @@ use anyhow::Context; use komodo_client::entities::{ + Operation, ResourceTarget, action::Action, alerter::Alerter, build::Build, @@ -13,7 +14,6 @@ use komodo_client::entities::{ sync::ResourceSync, update::{Update, UpdateListItem}, user::User, - Operation, ResourceTarget, }; use mungos::{ by_id::{find_one_by_id, update_one_by_id}, @@ -263,7 +263,7 @@ pub async fn init_execution_update( ), ), ExecuteRequest::BatchDeploy(_data) => { - return Ok(Default::default()) + return Ok(Default::default()); } ExecuteRequest::PullDeployment(data) => ( Operation::PullDeployment, @@ -308,7 +308,7 @@ pub async fn init_execution_update( ), ), ExecuteRequest::BatchDestroyDeployment(_data) => { - return Ok(Default::default()) + return Ok(Default::default()); } // Build @@ -319,7 +319,7 @@ pub async fn init_execution_update( ), ), ExecuteRequest::BatchRunBuild(_data) => { - return Ok(Default::default()) + return Ok(Default::default()); } ExecuteRequest::CancelBuild(data) => ( Operation::CancelBuild, @@ -336,7 +336,7 @@ pub async fn init_execution_update( ), ), ExecuteRequest::BatchCloneRepo(_data) => { - return Ok(Default::default()) + return Ok(Default::default()); } ExecuteRequest::PullRepo(data) => ( Operation::PullRepo, @@ -345,7 +345,7 @@ pub async fn init_execution_update( ), ), ExecuteRequest::BatchPullRepo(_data) => { - return Ok(Default::default()) + return Ok(Default::default()); } ExecuteRequest::BuildRepo(data) => ( Operation::BuildRepo, @@ -354,7 +354,7 @@ pub async fn init_execution_update( ), ), ExecuteRequest::BatchBuildRepo(_data) => { - return Ok(Default::default()) + return Ok(Default::default()); } ExecuteRequest::CancelRepoBuild(data) => ( Operation::CancelRepoBuild, @@ -371,7 +371,7 @@ pub async fn init_execution_update( ), ), ExecuteRequest::BatchRunProcedure(_) => { - return Ok(Default::default()) + return Ok(Default::default()); } // Action @@ -382,7 +382,7 @@ pub async fn init_execution_update( ), ), ExecuteRequest::BatchRunAction(_) => { - return Ok(Default::default()) + return Ok(Default::default()); } // Server template @@ -415,7 +415,7 @@ pub async fn init_execution_update( ), ), ExecuteRequest::BatchDeployStack(_data) => { - return Ok(Default::default()) + return Ok(Default::default()); } ExecuteRequest::DeployStackIfChanged(data) => ( Operation::DeployStack, @@ -424,7 +424,7 @@ pub async fn init_execution_update( ), ), ExecuteRequest::BatchDeployStackIfChanged(_data) => { - return Ok(Default::default()) + return Ok(Default::default()); } ExecuteRequest::StartStack(data) => ( if !data.services.is_empty() { @@ -497,7 +497,7 @@ pub async fn init_execution_update( ), ), ExecuteRequest::BatchDestroyStack(_data) => { - return Ok(Default::default()) + return Ok(Default::default()); } // Alerter diff --git a/bin/core/src/listener/integrations/github.rs b/bin/core/src/listener/integrations/github.rs index 62f2a9f5f..ce155f2d0 100644 --- a/bin/core/src/listener/integrations/github.rs +++ b/bin/core/src/listener/integrations/github.rs @@ -1,4 +1,4 @@ -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use axum::http::HeaderMap; use hex::ToHex; use hmac::{Hmac, Mac}; diff --git a/bin/core/src/listener/integrations/gitlab.rs b/bin/core/src/listener/integrations/gitlab.rs index c5a27df99..b8b3520f5 100644 --- a/bin/core/src/listener/integrations/gitlab.rs +++ b/bin/core/src/listener/integrations/gitlab.rs @@ -1,4 +1,4 @@ -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use serde::Deserialize; use crate::{ diff --git a/bin/core/src/listener/mod.rs b/bin/core/src/listener/mod.rs index 9adbce3f2..97f72d1ad 100644 --- a/bin/core/src/listener/mod.rs +++ b/bin/core/src/listener/mod.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use axum::{http::HeaderMap, Router}; +use axum::{Router, http::HeaderMap}; use komodo_client::entities::resource::Resource; use tokio::sync::Mutex; diff --git a/bin/core/src/listener/resources.rs b/bin/core/src/listener/resources.rs index 67b818ae7..ea767b7ad 100644 --- a/bin/core/src/listener/resources.rs +++ b/bin/core/src/listener/resources.rs @@ -22,7 +22,7 @@ use crate::{ helpers::update::init_execution_update, }; -use super::{ListenerLockCache, ANY_BRANCH}; +use super::{ANY_BRANCH, ListenerLockCache}; // ======= // BUILD diff --git a/bin/core/src/listener/router.rs b/bin/core/src/listener/router.rs index a32ef3dd0..a69124d32 100644 --- a/bin/core/src/listener/router.rs +++ b/bin/core/src/listener/router.rs @@ -1,4 +1,4 @@ -use axum::{extract::Path, http::HeaderMap, routing::post, Router}; +use axum::{Router, extract::Path, http::HeaderMap, routing::post}; use komodo_client::entities::{ action::Action, build::Build, procedure::Procedure, repo::Repo, resource::Resource, stack::Stack, sync::ResourceSync, @@ -11,13 +11,13 @@ use tracing::Instrument; use crate::resource::KomodoResource; use super::{ + CustomSecret, VerifyBranch, VerifySecret, resources::{ + RepoWebhookOption, StackWebhookOption, SyncWebhookOption, handle_action_webhook, handle_build_webhook, handle_procedure_webhook, handle_repo_webhook, - handle_stack_webhook, handle_sync_webhook, RepoWebhookOption, - StackWebhookOption, SyncWebhookOption, + handle_stack_webhook, handle_sync_webhook, }, - CustomSecret, VerifyBranch, VerifySecret, }; #[derive(Deserialize)] diff --git a/bin/core/src/monitor/alert/deployment.rs b/bin/core/src/monitor/alert/deployment.rs index bf296a01d..9b153628d 100644 --- a/bin/core/src/monitor/alert/deployment.rs +++ b/bin/core/src/monitor/alert/deployment.rs @@ -1,9 +1,9 @@ use std::collections::HashMap; use komodo_client::entities::{ + ResourceTarget, alert::{Alert, AlertData, SeverityLevel}, deployment::{Deployment, DeploymentState}, - ResourceTarget, }; use crate::{ diff --git a/bin/core/src/monitor/alert/mod.rs b/bin/core/src/monitor/alert/mod.rs index d370becd2..8a851d6e2 100644 --- a/bin/core/src/monitor/alert/mod.rs +++ b/bin/core/src/monitor/alert/mod.rs @@ -30,8 +30,8 @@ pub async fn check_alerts(ts: i64) { } #[instrument(level = "debug")] -async fn get_all_servers_map( -) -> anyhow::Result<(HashMap, HashMap)> +async fn get_all_servers_map() +-> anyhow::Result<(HashMap, HashMap)> { let servers = resource::list_full_for_user::( ResourceQuery::default(), diff --git a/bin/core/src/monitor/alert/server.rs b/bin/core/src/monitor/alert/server.rs index 7448932eb..2e9305ae6 100644 --- a/bin/core/src/monitor/alert/server.rs +++ b/bin/core/src/monitor/alert/server.rs @@ -3,10 +3,10 @@ use std::{collections::HashMap, path::PathBuf, str::FromStr}; use anyhow::Context; use derive_variants::ExtractVariant; use komodo_client::entities::{ + ResourceTarget, alert::{Alert, AlertData, AlertDataVariant, SeverityLevel}, komodo_timestamp, optional_string, server::{Server, ServerState}, - ResourceTarget, }; use mongo_indexed::Indexed; use mungos::{ @@ -85,7 +85,9 @@ pub async fn alert_servers( id, name, region, .. } => (id, name, region), data => { - error!("got incorrect alert data in ServerStatus handler. got {data:?}"); + error!( + "got incorrect alert data in ServerStatus handler. got {data:?}" + ); continue; } }; @@ -530,8 +532,8 @@ async fn resolve_alerts(alerts: &[(Alert, SendAlerts)]) { } #[instrument(level = "debug")] -async fn get_open_alerts( -) -> anyhow::Result<(OpenAlertMap, OpenDiskAlertMap)> { +async fn get_open_alerts() +-> anyhow::Result<(OpenAlertMap, OpenDiskAlertMap)> { let alerts = find_collect( &db_client().alerts, doc! { "resolved": false }, diff --git a/bin/core/src/monitor/alert/stack.rs b/bin/core/src/monitor/alert/stack.rs index 6fa488e4f..98c73ee68 100644 --- a/bin/core/src/monitor/alert/stack.rs +++ b/bin/core/src/monitor/alert/stack.rs @@ -1,9 +1,9 @@ use std::collections::HashMap; use komodo_client::entities::{ + ResourceTarget, alert::{Alert, AlertData, SeverityLevel}, stack::{Stack, StackState}, - ResourceTarget, }; use crate::{ diff --git a/bin/core/src/monitor/lists.rs b/bin/core/src/monitor/lists.rs index 7eace0ec0..ffd5fe42f 100644 --- a/bin/core/src/monitor/lists.rs +++ b/bin/core/src/monitor/lists.rs @@ -6,8 +6,8 @@ use komodo_client::entities::{ stack::ComposeProject, }; use periphery_client::{ - api::{GetDockerLists, GetDockerListsResponse}, PeripheryClient, + api::{GetDockerLists, GetDockerListsResponse}, }; pub async fn get_docker_lists( diff --git a/bin/core/src/monitor/mod.rs b/bin/core/src/monitor/mod.rs index db9fc8052..77c1966b4 100644 --- a/bin/core/src/monitor/mod.rs +++ b/bin/core/src/monitor/mod.rs @@ -7,8 +7,7 @@ use komodo_client::entities::{ container::ContainerListItem, image::ImageListItem, network::NetworkListItem, volume::VolumeListItem, }, - komodo_timestamp, - optional_string, + komodo_timestamp, optional_string, server::{Server, ServerHealth, ServerState}, stack::{ComposeProject, StackService, StackState}, stats::SystemStats, diff --git a/bin/core/src/monitor/record.rs b/bin/core/src/monitor/record.rs index 0c40f06ee..d4660e4eb 100644 --- a/bin/core/src/monitor/record.rs +++ b/bin/core/src/monitor/record.rs @@ -1,5 +1,5 @@ use komodo_client::entities::stats::{ - sum_disk_usage, SystemStatsRecord, TotalDiskUsage, + SystemStatsRecord, TotalDiskUsage, sum_disk_usage, }; use crate::state::{db_client, server_status_cache}; diff --git a/bin/core/src/monitor/resources.rs b/bin/core/src/monitor/resources.rs index e00758ae9..bd8e5c63f 100644 --- a/bin/core/src/monitor/resources.rs +++ b/bin/core/src/monitor/resources.rs @@ -7,6 +7,7 @@ use anyhow::Context; use komodo_client::{ api::execute::{Deploy, DeployStack}, entities::{ + ResourceTarget, alert::{Alert, AlertData, SeverityLevel}, build::Build, deployment::{Deployment, DeploymentImage, DeploymentState}, @@ -17,7 +18,6 @@ use komodo_client::{ komodo_timestamp, stack::{Stack, StackService, StackServiceNames, StackState}, user::auto_redeploy_user, - ResourceTarget, }, }; @@ -222,8 +222,8 @@ pub async fn update_deployment_cache( } /// (StackId, Service) -fn stack_alert_sent_cache( -) -> &'static Mutex> { +fn stack_alert_sent_cache() +-> &'static Mutex> { static CACHE: OnceLock>> = OnceLock::new(); CACHE.get_or_init(Default::default) diff --git a/bin/core/src/resource/action.rs b/bin/core/src/resource/action.rs index 72688a20a..bd9691e91 100644 --- a/bin/core/src/resource/action.rs +++ b/bin/core/src/resource/action.rs @@ -2,6 +2,7 @@ use std::time::Duration; use anyhow::Context; use komodo_client::entities::{ + Operation, ResourceTargetVariant, action::{ Action, ActionConfig, ActionConfigDiff, ActionInfo, ActionListItem, ActionListItemInfo, ActionQuerySpecifics, @@ -10,11 +11,10 @@ use komodo_client::entities::{ resource::Resource, update::Update, user::User, - Operation, ResourceTargetVariant, }; use mungos::{ find::find_collect, - mongodb::{bson::doc, options::FindOneOptions, Collection}, + mongodb::{Collection, bson::doc, options::FindOneOptions}, }; use crate::state::{action_state_cache, action_states, db_client}; diff --git a/bin/core/src/resource/alerter.rs b/bin/core/src/resource/alerter.rs index c884eb2be..736be84db 100644 --- a/bin/core/src/resource/alerter.rs +++ b/bin/core/src/resource/alerter.rs @@ -1,5 +1,6 @@ use derive_variants::ExtractVariant; use komodo_client::entities::{ + Operation, ResourceTargetVariant, alerter::{ Alerter, AlerterConfig, AlerterConfigDiff, AlerterListItem, AlerterListItemInfo, AlerterQuerySpecifics, PartialAlerterConfig, @@ -7,7 +8,6 @@ use komodo_client::entities::{ resource::Resource, update::Update, user::User, - Operation, ResourceTargetVariant, }; use mungos::mongodb::Collection; diff --git a/bin/core/src/resource/build.rs b/bin/core/src/resource/build.rs index d6c39dc14..1e778e9e0 100644 --- a/bin/core/src/resource/build.rs +++ b/bin/core/src/resource/build.rs @@ -2,6 +2,7 @@ use std::time::Duration; use anyhow::Context; use komodo_client::entities::{ + Operation, ResourceTargetVariant, build::{ Build, BuildConfig, BuildConfigDiff, BuildInfo, BuildListItem, BuildListItemInfo, BuildQuerySpecifics, BuildState, @@ -13,11 +14,10 @@ use komodo_client::entities::{ resource::Resource, update::Update, user::User, - Operation, ResourceTargetVariant, }; use mungos::{ find::find_collect, - mongodb::{bson::doc, options::FindOptions, Collection}, + mongodb::{Collection, bson::doc, options::FindOptions}, }; use crate::{ diff --git a/bin/core/src/resource/builder.rs b/bin/core/src/resource/builder.rs index 0494bd37a..c3135dd89 100644 --- a/bin/core/src/resource/builder.rs +++ b/bin/core/src/resource/builder.rs @@ -1,5 +1,6 @@ use anyhow::Context; use komodo_client::entities::{ + MergePartial, Operation, ResourceTargetVariant, builder::{ Builder, BuilderConfig, BuilderConfigDiff, BuilderConfigVariant, BuilderListItem, BuilderListItemInfo, BuilderQuerySpecifics, @@ -10,11 +11,10 @@ use komodo_client::entities::{ server::Server, update::Update, user::User, - MergePartial, Operation, ResourceTargetVariant, }; use mungos::mongodb::{ - bson::{doc, to_document, Document}, Collection, + bson::{Document, doc, to_document}, }; use crate::state::db_client; diff --git a/bin/core/src/resource/deployment.rs b/bin/core/src/resource/deployment.rs index 19c92ce40..7884cdec9 100644 --- a/bin/core/src/resource/deployment.rs +++ b/bin/core/src/resource/deployment.rs @@ -1,12 +1,13 @@ use anyhow::Context; use formatting::format_serror; use komodo_client::entities::{ + Operation, ResourceTargetVariant, build::Build, deployment::{ - conversions_from_str, Deployment, DeploymentConfig, - DeploymentConfigDiff, DeploymentImage, DeploymentListItem, - DeploymentListItemInfo, DeploymentQuerySpecifics, - DeploymentState, PartialDeploymentConfig, + Deployment, DeploymentConfig, DeploymentConfigDiff, + DeploymentImage, DeploymentListItem, DeploymentListItemInfo, + DeploymentQuerySpecifics, DeploymentState, + PartialDeploymentConfig, conversions_from_str, }, environment_vars_from_str, permission::PermissionLevel, @@ -14,7 +15,6 @@ use komodo_client::entities::{ server::Server, update::Update, user::User, - Operation, ResourceTargetVariant, }; use mungos::mongodb::Collection; use periphery_client::api::container::RemoveContainer; diff --git a/bin/core/src/resource/mod.rs b/bin/core/src/resource/mod.rs index 2c6713fc0..33807f81f 100644 --- a/bin/core/src/resource/mod.rs +++ b/bin/core/src/resource/mod.rs @@ -3,20 +3,20 @@ use std::{ str::FromStr, }; -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use formatting::format_serror; -use futures::{future::join_all, FutureExt}; +use futures::{FutureExt, future::join_all}; use komodo_client::{ api::{read::ExportResourcesToToml, write::CreateTag}, entities::{ + Operation, ResourceTarget, ResourceTargetVariant, komodo_timestamp, permission::PermissionLevel, resource::{AddFilters, Resource, ResourceQuery}, tag::Tag, to_komodo_name, update::Update, - user::{system_user, User}, - Operation, ResourceTarget, ResourceTargetVariant, + user::{User, system_user}, }, parsers::parse_string_list, }; @@ -24,14 +24,14 @@ use mungos::{ by_id::{delete_one_by_id, update_one_by_id}, find::find_collect, mongodb::{ - bson::{doc, oid::ObjectId, to_document, Document}, - options::FindOptions, Collection, + bson::{Document, doc, oid::ObjectId, to_document}, + options::FindOptions, }, }; use partial_derive2::{Diff, FieldDiff, MaybeNone, PartialDiff}; use resolver_api::Resolve; -use serde::{de::DeserializeOwned, Serialize}; +use serde::{Serialize, de::DeserializeOwned}; use crate::{ api::{read::ReadArgs, write::WriteArgs}, @@ -971,7 +971,9 @@ where }) .await { - warn!("failed to delete_many permissions matching target {target:?} | {e:#}"); + warn!( + "failed to delete_many permissions matching target {target:?} | {e:#}" + ); } } diff --git a/bin/core/src/resource/procedure.rs b/bin/core/src/resource/procedure.rs index ad3b3fd2e..5a70dbd5f 100644 --- a/bin/core/src/resource/procedure.rs +++ b/bin/core/src/resource/procedure.rs @@ -1,9 +1,10 @@ use std::time::Duration; -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use komodo_client::{ api::execute::Execution, entities::{ + Operation, ResourceTargetVariant, action::Action, alerter::Alerter, build::Build, @@ -21,12 +22,11 @@ use komodo_client::{ sync::ResourceSync, update::Update, user::User, - Operation, ResourceTargetVariant, }, }; use mungos::{ find::find_collect, - mongodb::{bson::doc, options::FindOneOptions, Collection}, + mongodb::{Collection, bson::doc, options::FindOneOptions}, }; use crate::{ @@ -173,7 +173,7 @@ async fn validate_config( Some(id) if procedure.id == id => { return Err(anyhow!( "Cannot have self-referential procedure" - )) + )); } _ => {} } diff --git a/bin/core/src/resource/refresh.rs b/bin/core/src/resource/refresh.rs index 5740d6afd..ef4421128 100644 --- a/bin/core/src/resource/refresh.rs +++ b/bin/core/src/resource/refresh.rs @@ -1,6 +1,6 @@ use std::time::Duration; -use async_timing_util::{get_timelength_in_ms, Timelength}; +use async_timing_util::{Timelength, get_timelength_in_ms}; use komodo_client::{ api::write::{ RefreshBuildCache, RefreshRepoCache, RefreshResourceSyncPending, @@ -95,7 +95,9 @@ async fn refresh_deployments() { if let Err(e) = pull_deployment_inner(deployment, server).await { - warn!("Failed to pull latest image for Deployment {name} | {e:#}"); + warn!( + "Failed to pull latest image for Deployment {name} | {e:#}" + ); } } } @@ -151,15 +153,17 @@ async fn refresh_repos() { } async fn refresh_syncs() { - let Ok(syncs) = - find_collect(&db_client().resource_syncs, None, None) - .await - .inspect_err(|e| { - warn!( + let Ok(syncs) = find_collect( + &db_client().resource_syncs, + None, + None, + ) + .await + .inspect_err(|e| { + warn!( "failed to get resource syncs from db in refresh task | {e:#}" ) - }) - else { + }) else { return; }; for sync in syncs { diff --git a/bin/core/src/resource/repo.rs b/bin/core/src/resource/repo.rs index 69b910eb2..4c589f5ac 100644 --- a/bin/core/src/resource/repo.rs +++ b/bin/core/src/resource/repo.rs @@ -3,6 +3,7 @@ use std::time::Duration; use anyhow::Context; use formatting::format_serror; use komodo_client::entities::{ + Operation, ResourceTargetVariant, builder::Builder, permission::PermissionLevel, repo::{ @@ -14,11 +15,10 @@ use komodo_client::entities::{ to_komodo_name, update::Update, user::User, - Operation, ResourceTargetVariant, }; use mungos::{ find::find_collect, - mongodb::{bson::doc, options::FindOneOptions, Collection}, + mongodb::{Collection, bson::doc, options::FindOneOptions}, }; use periphery_client::api::git::DeleteRepo; diff --git a/bin/core/src/resource/server.rs b/bin/core/src/resource/server.rs index 68170bd81..457ce077a 100644 --- a/bin/core/src/resource/server.rs +++ b/bin/core/src/resource/server.rs @@ -1,6 +1,6 @@ use anyhow::Context; use komodo_client::entities::{ - komodo_timestamp, + Operation, ResourceTargetVariant, komodo_timestamp, resource::Resource, server::{ PartialServerConfig, Server, ServerConfig, ServerConfigDiff, @@ -8,9 +8,8 @@ use komodo_client::entities::{ }, update::Update, user::User, - Operation, ResourceTargetVariant, }; -use mungos::mongodb::{bson::doc, Collection}; +use mungos::mongodb::{Collection, bson::doc}; use crate::{ config::core_config, diff --git a/bin/core/src/resource/server_template.rs b/bin/core/src/resource/server_template.rs index c54bfef69..bb98ee418 100644 --- a/bin/core/src/resource/server_template.rs +++ b/bin/core/src/resource/server_template.rs @@ -1,4 +1,5 @@ use komodo_client::entities::{ + MergePartial, Operation, ResourceTargetVariant, resource::Resource, server_template::{ PartialServerTemplateConfig, ServerTemplate, @@ -8,11 +9,10 @@ use komodo_client::entities::{ }, update::Update, user::User, - MergePartial, Operation, ResourceTargetVariant, }; use mungos::mongodb::{ - bson::{to_document, Document}, Collection, + bson::{Document, to_document}, }; use crate::state::db_client; diff --git a/bin/core/src/resource/stack.rs b/bin/core/src/resource/stack.rs index c51406377..a54c18f3f 100644 --- a/bin/core/src/resource/stack.rs +++ b/bin/core/src/resource/stack.rs @@ -3,6 +3,7 @@ use formatting::format_serror; use komodo_client::{ api::write::RefreshStackCache, entities::{ + Operation, ResourceTargetVariant, permission::PermissionLevel, resource::Resource, server::Server, @@ -12,8 +13,7 @@ use komodo_client::{ StackQuerySpecifics, StackServiceWithUpdate, StackState, }, update::Update, - user::{stack_user, User}, - Operation, ResourceTargetVariant, + user::{User, stack_user}, }, }; use mungos::mongodb::Collection; diff --git a/bin/core/src/resource/sync.rs b/bin/core/src/resource/sync.rs index 9f1ad5ab0..b0edfb14b 100644 --- a/bin/core/src/resource/sync.rs +++ b/bin/core/src/resource/sync.rs @@ -3,7 +3,7 @@ use formatting::format_serror; use komodo_client::{ api::write::RefreshResourceSyncPending, entities::{ - komodo_timestamp, + Operation, ResourceTargetVariant, komodo_timestamp, resource::Resource, sync::{ PartialResourceSyncConfig, ResourceSync, ResourceSyncConfig, @@ -12,8 +12,7 @@ use komodo_client::{ ResourceSyncState, }, update::Update, - user::{sync_user, User}, - Operation, ResourceTargetVariant, + user::{User, sync_user}, }, }; use mongo_indexed::doc; diff --git a/bin/core/src/stack/execute.rs b/bin/core/src/stack/execute.rs index 0f30745f9..2b16e3c09 100644 --- a/bin/core/src/stack/execute.rs +++ b/bin/core/src/stack/execute.rs @@ -7,7 +7,7 @@ use komodo_client::{ user::User, }, }; -use periphery_client::{api::compose::*, PeripheryClient}; +use periphery_client::{PeripheryClient, api::compose::*}; use crate::{ helpers::{periphery_client, update::update_update}, diff --git a/bin/core/src/stack/mod.rs b/bin/core/src/stack/mod.rs index 71d526f0a..c7c73bf0d 100644 --- a/bin/core/src/stack/mod.rs +++ b/bin/core/src/stack/mod.rs @@ -1,4 +1,4 @@ -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use komodo_client::entities::{ permission::PermissionLevel, server::{Server, ServerState}, diff --git a/bin/core/src/stack/remote.rs b/bin/core/src/stack/remote.rs index 3500c0832..593b93468 100644 --- a/bin/core/src/stack/remote.rs +++ b/bin/core/src/stack/remote.rs @@ -3,7 +3,7 @@ use std::{fs, path::PathBuf}; use anyhow::Context; use formatting::format_serror; use komodo_client::entities::{ - stack::Stack, update::Log, CloneArgs, FileContents, + CloneArgs, FileContents, stack::Stack, update::Log, }; use crate::{config::core_config, helpers::git_token}; diff --git a/bin/core/src/state.rs b/bin/core/src/state.rs index b67690378..304abe076 100644 --- a/bin/core/src/state.rs +++ b/bin/core/src/state.rs @@ -55,8 +55,8 @@ pub fn jwt_client() -> &'static JwtClient { }) } -pub fn github_client( -) -> Option<&'static HashMap> { +pub fn github_client() +-> Option<&'static HashMap> { static GITHUB_CLIENT: OnceLock< Option>, > = OnceLock::new(); diff --git a/bin/core/src/sync/deploy.rs b/bin/core/src/sync/deploy.rs index 673ff6953..9fa8cd16c 100644 --- a/bin/core/src/sync/deploy.rs +++ b/bin/core/src/sync/deploy.rs @@ -1,7 +1,7 @@ use std::{collections::HashMap, time::Duration}; -use anyhow::{anyhow, Context}; -use formatting::{bold, colored, format_serror, muted, Color}; +use anyhow::{Context, anyhow}; +use formatting::{Color, bold, colored, format_serror, muted}; use futures::future::join_all; use komodo_client::{ api::{ @@ -9,6 +9,7 @@ use komodo_client::{ read::ListBuildVersions, }, entities::{ + FileContents, ResourceTarget, deployment::{ Deployment, DeploymentConfig, DeploymentImage, DeploymentState, PartialDeploymentConfig, @@ -18,7 +19,6 @@ use komodo_client::{ toml::ResourceToml, update::Log, user::sync_user, - FileContents, ResourceTarget, }, }; use resolver_api::Resolve; @@ -729,10 +729,14 @@ async fn insert_target_using_after_list<'a>( )), ); return Ok(()); - }, + } // The parent will not deploy, do nothing here. - Some(None) => {}, - None => return Err(anyhow!("Did not find parent in cache after build recursion. This should not happen.")) + Some(None) => {} + None => { + return Err(anyhow!( + "Did not find parent in cache after build recursion. This should not happen." + )); + } } } ResourceTarget::Stack(name) => { @@ -772,10 +776,14 @@ async fn insert_target_using_after_list<'a>( )), ); return Ok(()); - }, + } // The parent will not deploy, do nothing here. - Some(None) => {}, - None => return Err(anyhow!("Did not find parent in cache after build recursion. This should not happen.")) + Some(None) => {} + None => { + return Err(anyhow!( + "Did not find parent in cache after build recursion. This should not happen." + )); + } } } _ => unreachable!(), diff --git a/bin/core/src/sync/execute.rs b/bin/core/src/sync/execute.rs index 78a1bc898..deee26384 100644 --- a/bin/core/src/sync/execute.rs +++ b/bin/core/src/sync/execute.rs @@ -1,12 +1,12 @@ use std::collections::HashMap; use anyhow::Context; -use formatting::{bold, colored, muted, Color}; +use formatting::{Color, bold, colored, muted}; use komodo_client::{ api::write::{UpdateDescription, UpdateTagsOnResource}, entities::{ - tag::Tag, toml::ResourceToml, update::Log, user::sync_user, - ResourceTargetVariant, + ResourceTargetVariant, tag::Tag, toml::ResourceToml, update::Log, + user::sync_user, }, }; use mungos::find::find_collect; diff --git a/bin/core/src/sync/file.rs b/bin/core/src/sync/file.rs index 4dd70b1d7..227c465b9 100644 --- a/bin/core/src/sync/file.rs +++ b/bin/core/src/sync/file.rs @@ -3,8 +3,8 @@ use std::{ path::{Path, PathBuf}, }; -use anyhow::{anyhow, Context}; -use formatting::{bold, colored, format_serror, muted, Color}; +use anyhow::{Context, anyhow}; +use formatting::{Color, bold, colored, format_serror, muted}; use komodo_client::entities::{ sync::SyncFileContents, toml::{ResourceToml, ResourcesToml}, diff --git a/bin/core/src/sync/mod.rs b/bin/core/src/sync/mod.rs index 6635f7557..54fe23bf2 100644 --- a/bin/core/src/sync/mod.rs +++ b/bin/core/src/sync/mod.rs @@ -2,6 +2,7 @@ use std::{collections::HashMap, str::FromStr}; use anyhow::anyhow; use komodo_client::entities::{ + ResourceTarget, ResourceTargetVariant, action::Action, alerter::Alerter, build::Build, @@ -15,7 +16,6 @@ use komodo_client::entities::{ sync::ResourceSync, tag::Tag, toml::{ResourceToml, ResourcesToml}, - ResourceTarget, ResourceTargetVariant, }; use mungos::mongodb::bson::oid::ObjectId; use toml::ToToml; diff --git a/bin/core/src/sync/remote.rs b/bin/core/src/sync/remote.rs index 743dce8a0..b581ff904 100644 --- a/bin/core/src/sync/remote.rs +++ b/bin/core/src/sync/remote.rs @@ -1,11 +1,11 @@ -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use git::GitRes; use komodo_client::entities::{ + CloneArgs, sync::{ResourceSync, SyncFileContents}, to_komodo_name, toml::ResourcesToml, update::Log, - CloneArgs, }; use crate::{config::core_config, helpers::git_token}; diff --git a/bin/core/src/sync/resources.rs b/bin/core/src/sync/resources.rs index eb30c55af..e15e84630 100644 --- a/bin/core/src/sync/resources.rs +++ b/bin/core/src/sync/resources.rs @@ -1,9 +1,10 @@ use std::collections::HashMap; -use formatting::{bold, colored, muted, Color}; +use formatting::{Color, bold, colored, muted}; use komodo_client::{ api::execute::Execution, entities::{ + ResourceTarget, ResourceTargetVariant, action::Action, alerter::Alerter, build::Build, @@ -18,7 +19,6 @@ use komodo_client::{ tag::Tag, update::Log, user::sync_user, - ResourceTarget, ResourceTargetVariant, }, }; use partial_derive2::{MaybeNone, PartialDiff}; @@ -27,16 +27,16 @@ use crate::{ api::write::WriteArgs, resource::KomodoResource, sync::{ - execute::{run_update_description, run_update_tags}, ToUpdateItem, + execute::{run_update_description, run_update_tags}, }, }; use super::{ + AllResourcesById, ResourceSyncTrait, ToCreate, ToDelete, ToUpdate, execute::ExecuteResourceSync, include_resource_by_resource_type_and_name, - include_resource_by_tags, AllResourcesById, ResourceSyncTrait, - ToCreate, ToDelete, ToUpdate, + include_resource_by_tags, }; impl ResourceSyncTrait for Server { diff --git a/bin/core/src/sync/toml.rs b/bin/core/src/sync/toml.rs index 48cf6f28a..48dc03f65 100644 --- a/bin/core/src/sync/toml.rs +++ b/bin/core/src/sync/toml.rs @@ -339,7 +339,7 @@ impl ToToml for Repo { match key.as_str() { "server_id" => return Ok((String::from("server"), value)), "builder_id" => { - return Ok((String::from("builder"), value)) + return Ok((String::from("builder"), value)); } _ => {} } diff --git a/bin/core/src/sync/user_groups.rs b/bin/core/src/sync/user_groups.rs index 6ca7a65b5..bab309f30 100644 --- a/bin/core/src/sync/user_groups.rs +++ b/bin/core/src/sync/user_groups.rs @@ -1,7 +1,7 @@ use std::{cmp::Ordering, collections::HashMap}; use anyhow::Context; -use formatting::{bold, colored, muted, Color}; +use formatting::{Color, bold, colored, muted}; use komodo_client::{ api::{ read::ListUserTargetPermissions, @@ -11,13 +11,13 @@ use komodo_client::{ }, }, entities::{ + ResourceTarget, ResourceTargetVariant, permission::{PermissionLevel, UserTarget}, sync::DiffData, toml::{PermissionToml, UserGroupToml}, update::Log, - user::{sync_user, User}, + user::{User, sync_user}, user_group::UserGroup, - ResourceTarget, ResourceTargetVariant, }, }; use mungos::find::find_collect; @@ -29,7 +29,7 @@ use crate::{ state::db_client, }; -use super::{toml::TOML_PRETTY_OPTIONS, AllResourcesById}; +use super::{AllResourcesById, toml::TOML_PRETTY_OPTIONS}; pub struct UpdateItem { user_group: UserGroupToml, diff --git a/bin/core/src/sync/variables.rs b/bin/core/src/sync/variables.rs index b447dc49d..b45922b73 100644 --- a/bin/core/src/sync/variables.rs +++ b/bin/core/src/sync/variables.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use anyhow::Context; -use formatting::{bold, colored, muted, Color}; +use formatting::{Color, bold, colored, muted}; use komodo_client::{ api::write::*, entities::{ diff --git a/bin/core/src/sync/view.rs b/bin/core/src/sync/view.rs index cef6b8f42..a362aa5a2 100644 --- a/bin/core/src/sync/view.rs +++ b/bin/core/src/sync/view.rs @@ -2,10 +2,10 @@ use std::collections::HashMap; use anyhow::Context; use komodo_client::entities::{ + ResourceTargetVariant, sync::{DiffData, ResourceDiff}, tag::Tag, toml::ResourceToml, - ResourceTargetVariant, }; use mungos::find::find_collect; use partial_derive2::MaybeNone; diff --git a/bin/core/src/ts_client.rs b/bin/core/src/ts_client.rs index 187d1c74f..1caf6322d 100644 --- a/bin/core/src/ts_client.rs +++ b/bin/core/src/ts_client.rs @@ -1,9 +1,9 @@ -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use axum::{ + Router, extract::Path, http::{HeaderMap, HeaderValue}, routing::get, - Router, }; use reqwest::StatusCode; use serde::Deserialize; diff --git a/bin/core/src/ws.rs b/bin/core/src/ws.rs index 8d48ecf96..65c2a41be 100644 --- a/bin/core/src/ws.rs +++ b/bin/core/src/ws.rs @@ -1,17 +1,17 @@ use anyhow::anyhow; use axum::{ + Router, extract::{ - ws::{Message, WebSocket}, WebSocketUpgrade, + ws::{Message, WebSocket}, }, response::IntoResponse, routing::get, - Router, }; use futures::{SinkExt, StreamExt}; use komodo_client::{ entities::{ - permission::PermissionLevel, user::User, ResourceTarget, + ResourceTarget, permission::PermissionLevel, user::User, }, ws::WsLoginMessage, }; diff --git a/bin/periphery/src/api/build.rs b/bin/periphery/src/api/build.rs index ec61a804e..b684d3fef 100644 --- a/bin/periphery/src/api/build.rs +++ b/bin/periphery/src/api/build.rs @@ -1,15 +1,17 @@ -use anyhow::{anyhow, Context}; +use std::{fmt::Write, path::Path}; + +use anyhow::{Context, anyhow}; use command::{ run_komodo_command, run_komodo_command_with_interpolation, }; use formatting::format_serror; use komodo_client::{ entities::{ + EnvironmentVar, Version, build::{Build, BuildConfig}, environment_vars_from_str, get_image_name, optional_string, to_komodo_name, update::Log, - EnvironmentVar, Version, }, parsers::QUOTE_PATTERN, }; @@ -105,8 +107,12 @@ impl Resolve for build::Build { let secret_args = environment_vars_from_str(secret_args) .context("Invalid secret_args")?; - let command_secret_args = - parse_secret_args(&secret_args, *skip_secret_interp)?; + let command_secret_args = parse_secret_args( + &secret_args, + &build_dir, + *skip_secret_interp, + ) + .await?; let labels = parse_labels( &environment_vars_from_str(labels).context("Invalid labels")?, @@ -143,8 +149,6 @@ impl Resolve for build::Build { logs.push(log) } - cleanup_secret_env_vars(&secret_args); - Ok(logs) } } @@ -188,45 +192,59 @@ fn parse_build_args(build_args: &[EnvironmentVar]) -> String { .join("") } -fn parse_secret_args( +/// https://docs.docker.com/build/building/secrets/#using-build-secrets +async fn parse_secret_args( secret_args: &[EnvironmentVar], + build_dir: &Path, skip_secret_interp: bool, ) -> anyhow::Result { let periphery_config = periphery_config(); - Ok( - secret_args - .iter() - .map(|EnvironmentVar { variable, value }| { - if variable.is_empty() { - return Err(anyhow!("secret variable cannot be empty string")) - } else if variable.contains('=') { - return Err(anyhow!("invalid variable {variable}. variable cannot contain '='")) - } - let value = if skip_secret_interp { - value.to_string() - } else { - svi::interpolate_variables( - value, - &periphery_config.secrets, - svi::Interpolator::DoubleBrackets, - true, - ) - .context( - "failed to interpolate periphery secrets into build secrets", - )?.0 - }; - std::env::set_var(variable, value); - anyhow::Ok(format!(" --secret id={variable}")) - }) - .collect::>>()? - .join(""), - ) -} - -fn cleanup_secret_env_vars(secret_args: &[EnvironmentVar]) { - secret_args.iter().for_each( - |EnvironmentVar { variable, .. }| std::env::remove_var(variable), - ) + let mut res = String::new(); + for EnvironmentVar { variable, value } in secret_args { + // Check edge cases + if variable.is_empty() { + return Err(anyhow!("secret variable cannot be empty string")); + } else if variable.contains('=') { + return Err(anyhow!( + "invalid variable {variable}. variable cannot contain '='" + )); + } + // Interpolate in value + let value = if skip_secret_interp { + value.to_string() + } else { + svi::interpolate_variables( + value, + &periphery_config.secrets, + svi::Interpolator::DoubleBrackets, + true, + ) + .context( + "Failed to interpolate periphery secrets into build secrets", + )? + .0 + }; + // Write the value to file to mount + let path = build_dir.join(variable); + tokio::fs::write(&path, value).await.with_context(|| { + format!( + "Failed to write build secret {variable} to {}", + path.display() + ) + })?; + // Extend the command + write!( + &mut res, + " --secret id={variable},src={}", + path.display() + ) + .with_context(|| { + format!( + "Failed to format build secret arguments for {variable}" + ) + })?; + } + Ok(res) } // diff --git a/bin/periphery/src/api/compose.rs b/bin/periphery/src/api/compose.rs index 3630bd65b..8443a88c4 100644 --- a/bin/periphery/src/api/compose.rs +++ b/bin/periphery/src/api/compose.rs @@ -1,11 +1,11 @@ use std::{fmt::Write, path::PathBuf}; -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use command::run_komodo_command; use formatting::format_serror; -use git::{write_commit_file, GitRes}; +use git::{GitRes, write_commit_file}; use komodo_client::entities::{ - stack::ComposeProject, to_komodo_name, update::Log, FileContents, + FileContents, stack::ComposeProject, to_komodo_name, update::Log, }; use periphery_client::api::{compose::*, git::RepoActionResponse}; use resolver_api::Resolve; @@ -13,7 +13,7 @@ use serde::{Deserialize, Serialize}; use tokio::fs; use crate::{ - compose::{compose_up, docker_compose, write_stack, WriteStackRes}, + compose::{WriteStackRes, compose_up, docker_compose, write_stack}, config::periphery_config, docker::docker_login, helpers::{log_grep, pull_or_clone_stack}, diff --git a/bin/periphery/src/api/container.rs b/bin/periphery/src/api/container.rs index 8ab421871..c6440ac56 100644 --- a/bin/periphery/src/api/container.rs +++ b/bin/periphery/src/api/container.rs @@ -1,4 +1,4 @@ -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use command::run_komodo_command; use futures::future::join_all; use komodo_client::entities::{ diff --git a/bin/periphery/src/api/deploy.rs b/bin/periphery/src/api/deploy.rs index b847cc2d2..f123f4c85 100644 --- a/bin/periphery/src/api/deploy.rs +++ b/bin/periphery/src/api/deploy.rs @@ -5,13 +5,13 @@ use command::{ use formatting::format_serror; use komodo_client::{ entities::{ + EnvironmentVar, deployment::{ - conversions_from_str, extract_registry_domain, Conversion, - Deployment, DeploymentConfig, DeploymentImage, RestartMode, + Conversion, Deployment, DeploymentConfig, DeploymentImage, + RestartMode, conversions_from_str, extract_registry_domain, }, environment_vars_from_str, to_komodo_name, update::Log, - EnvironmentVar, }, parsers::QUOTE_PATTERN, }; @@ -149,7 +149,9 @@ fn docker_run_command( ); let command = parse_command(command); let extra_args = parse_extra_args(extra_args); - let command = format!("docker run -d --name {name}{ports}{volumes}{network}{restart}{environment}{labels}{extra_args} {image}{command}"); + let command = format!( + "docker run -d --name {name}{ports}{volumes}{network}{restart}{environment}{labels}{extra_args} {image}{command}" + ); Ok(command) } diff --git a/bin/periphery/src/api/git.rs b/bin/periphery/src/api/git.rs index 023a2d45a..0b7ea42d3 100644 --- a/bin/periphery/src/api/git.rs +++ b/bin/periphery/src/api/git.rs @@ -1,12 +1,12 @@ -use std::path::PathBuf; -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use git::GitRes; -use komodo_client::entities::{update::Log, CloneArgs, LatestCommit}; +use komodo_client::entities::{CloneArgs, LatestCommit, update::Log}; use periphery_client::api::git::{ CloneRepo, DeleteRepo, GetLatestCommit, PullOrCloneRepo, PullRepo, RenameRepo, RepoActionResponse, }; use resolver_api::Resolve; +use std::path::PathBuf; use tokio::fs; use crate::config::periphery_config; @@ -19,11 +19,15 @@ impl Resolve for GetLatestCommit { ) -> serror::Result { let repo_path = match self.path { Some(p) => PathBuf::from(p), - None => periphery_config().repo_dir.join(self.name) + None => periphery_config().repo_dir.join(self.name), }; if !repo_path.is_dir() { return Err( - anyhow!("Repo path {} is not directory. is it cloned?", repo_path.display()).into(), + anyhow!( + "Repo path {} is not directory. is it cloned?", + repo_path.display() + ) + .into(), ); } Ok(git::get_commit_hash_info(&repo_path).await?) diff --git a/bin/periphery/src/api/mod.rs b/bin/periphery/src/api/mod.rs index e9e3d876a..b8a090200 100644 --- a/bin/periphery/src/api/mod.rs +++ b/bin/periphery/src/api/mod.rs @@ -3,16 +3,16 @@ use command::run_komodo_command; use derive_variants::EnumVariants; use futures::TryFutureExt; use komodo_client::entities::{ + SystemCommand, config::{DockerRegistry, GitProvider}, update::Log, - SystemCommand, }; use periphery_client::api::{ - build::*, compose::*, container::*, git::*, image::*, network::*, - stats::*, volume::*, GetDockerLists, GetDockerListsResponse, - GetHealth, GetHealthResponse, GetVersion, GetVersionResponse, + GetDockerLists, GetDockerListsResponse, GetHealth, + GetHealthResponse, GetVersion, GetVersionResponse, ListDockerRegistries, ListGitProviders, ListSecrets, PruneSystem, - RunCommand, + RunCommand, build::*, compose::*, container::*, git::*, image::*, + network::*, stats::*, volume::*, }; use resolver_api::Resolve; use response::Response; diff --git a/bin/periphery/src/compose.rs b/bin/periphery/src/compose.rs index 3b7051180..2ddd24c17 100644 --- a/bin/periphery/src/compose.rs +++ b/bin/periphery/src/compose.rs @@ -1,6 +1,6 @@ use std::{fmt::Write, path::PathBuf}; -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use command::{ run_komodo_command, run_komodo_command_multiline, run_komodo_command_with_interpolation, @@ -8,14 +8,14 @@ use command::{ use formatting::format_serror; use git::environment; use komodo_client::entities::{ - all_logs_success, environment_vars_from_str, + CloneArgs, FileContents, all_logs_success, + environment_vars_from_str, stack::{ ComposeFile, ComposeService, ComposeServiceDeploy, Stack, StackServiceNames, }, to_komodo_name, update::Log, - CloneArgs, FileContents, }; use periphery_client::api::{ compose::ComposeUpResponse, @@ -87,7 +87,9 @@ pub async fn compose_up( } } if !res.missing_files.is_empty() { - return Err(anyhow!("A compose file doesn't exist after writing stack. Ensure the run_directory and file_paths are correct.")); + return Err(anyhow!( + "A compose file doesn't exist after writing stack. Ensure the run_directory and file_paths are correct." + )); } for (path, full_path) in &file_paths { @@ -110,8 +112,8 @@ pub async fn compose_up( contents: error, }); return Err(anyhow!( - "failed to read compose file at {full_path:?}, stopping run" - )); + "failed to read compose file at {full_path:?}, stopping run" + )); } }; res.file_contents.push(FileContents { @@ -489,7 +491,9 @@ pub async fn write_stack( )) } else if stack.config.repo.is_empty() { if stack.config.file_contents.trim().is_empty() { - return Err(anyhow!("Must either input compose file contents directly, or use files on host / git repo options.")); + return Err(anyhow!( + "Must either input compose file contents directly, or use files on host / git repo options." + )); } // ============== // UI BASED FILES @@ -698,7 +702,9 @@ async fn compose_down( let success = log.success; res.logs.push(log); if !success { - return Err(anyhow!("Failed to bring down existing container(s) with docker compose down. Stopping run.")); + return Err(anyhow!( + "Failed to bring down existing container(s) with docker compose down. Stopping run." + )); } Ok(()) diff --git a/bin/periphery/src/docker.rs b/bin/periphery/src/docker.rs index 3f32f85b3..0e4fc49d6 100644 --- a/bin/periphery/src/docker.rs +++ b/bin/periphery/src/docker.rs @@ -1,20 +1,20 @@ use std::{collections::HashMap, sync::OnceLock}; -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use bollard::{ + Docker, container::{InspectContainerOptions, ListContainersOptions}, network::InspectNetworkOptions, - Docker, }; use command::run_komodo_command; use komodo_client::entities::{ + TerminationSignal, docker::{ - container::*, image::*, network::*, volume::*, ContainerConfig, - GraphDriverData, HealthConfig, PortBinding, + ContainerConfig, GraphDriverData, HealthConfig, PortBinding, + container::*, image::*, network::*, volume::*, }, to_komodo_name, update::Log, - TerminationSignal, }; use run_command::async_run_command; diff --git a/bin/periphery/src/helpers.rs b/bin/periphery/src/helpers.rs index 6a15a1263..6a24f29c8 100644 --- a/bin/periphery/src/helpers.rs +++ b/bin/periphery/src/helpers.rs @@ -1,10 +1,10 @@ use std::path::PathBuf; -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use komodo_client::{ entities::{ - stack::Stack, to_komodo_name, CloneArgs, EnvironmentVar, - SearchCombinator, + CloneArgs, EnvironmentVar, SearchCombinator, stack::Stack, + to_komodo_name, }, parsers::QUOTE_PATTERN, }; diff --git a/bin/periphery/src/router.rs b/bin/periphery/src/router.rs index 366fa29a9..b4901afad 100644 --- a/bin/periphery/src/router.rs +++ b/bin/periphery/src/router.rs @@ -1,14 +1,14 @@ use std::net::SocketAddr; -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use axum::{ + Router, body::Body, extract::ConnectInfo, http::{Request, StatusCode}, middleware::{self, Next}, response::Response, routing::post, - Router, }; use derive_variants::ExtractVariant; use resolver_api::Resolve; diff --git a/bin/periphery/src/ssl.rs b/bin/periphery/src/ssl.rs index 4e959ef9f..96435490e 100644 --- a/bin/periphery/src/ssl.rs +++ b/bin/periphery/src/ssl.rs @@ -25,7 +25,9 @@ async fn generate_self_signed_ssl_certs() { let key_path = &config.ssl_key_file.display(); let cert_path = &config.ssl_cert_file.display(); - let command = format!("openssl req -x509 -newkey rsa:4096 -keyout {key_path} -out {cert_path} -sha256 -days 3650 -nodes -subj \"/C=XX/CN=periphery\""); + let command = format!( + "openssl req -x509 -newkey rsa:4096 -keyout {key_path} -out {cert_path} -sha256 -days 3650 -nodes -subj \"/C=XX/CN=periphery\"" + ); let log = run_command::async_run_command(&command).await; if log.success() { diff --git a/client/core/rs/src/api/execute/deployment.rs b/client/core/rs/src/api/execute/deployment.rs index a37833a40..67ea89215 100644 --- a/client/core/rs/src/api/execute/deployment.rs +++ b/client/core/rs/src/api/execute/deployment.rs @@ -4,7 +4,7 @@ use resolver_api::Resolve; use serde::{Deserialize, Serialize}; use typeshare::typeshare; -use crate::entities::{update::Update, TerminationSignal}; +use crate::entities::{TerminationSignal, update::Update}; use super::{BatchExecutionResponse, KomodoExecuteRequest}; diff --git a/client/core/rs/src/api/execute/mod.rs b/client/core/rs/src/api/execute/mod.rs index 32ea25a63..33b2abb11 100644 --- a/client/core/rs/src/api/execute/mod.rs +++ b/client/core/rs/src/api/execute/mod.rs @@ -29,7 +29,7 @@ pub use sync::*; use crate::{ api::write::CommitSync, - entities::{update::Update, NoData, _Serror, I64}, + entities::{_Serror, I64, NoData, update::Update}, }; pub trait KomodoExecuteRequest: HasResponse {} diff --git a/client/core/rs/src/api/execute/server.rs b/client/core/rs/src/api/execute/server.rs index 76f76e038..4b6c3b122 100644 --- a/client/core/rs/src/api/execute/server.rs +++ b/client/core/rs/src/api/execute/server.rs @@ -4,7 +4,7 @@ use resolver_api::Resolve; use serde::{Deserialize, Serialize}; use typeshare::typeshare; -use crate::entities::{update::Update, TerminationSignal}; +use crate::entities::{TerminationSignal, update::Update}; use super::KomodoExecuteRequest; diff --git a/client/core/rs/src/api/execute/sync.rs b/client/core/rs/src/api/execute/sync.rs index 076c5d842..b5fd9bebc 100644 --- a/client/core/rs/src/api/execute/sync.rs +++ b/client/core/rs/src/api/execute/sync.rs @@ -4,7 +4,7 @@ use resolver_api::Resolve; use serde::{Deserialize, Serialize}; use typeshare::typeshare; -use crate::entities::{update::Update, ResourceTargetVariant}; +use crate::entities::{ResourceTargetVariant, update::Update}; use super::KomodoExecuteRequest; diff --git a/client/core/rs/src/api/read/alert.rs b/client/core/rs/src/api/read/alert.rs index 534845ca9..3a679b966 100644 --- a/client/core/rs/src/api/read/alert.rs +++ b/client/core/rs/src/api/read/alert.rs @@ -3,7 +3,7 @@ use resolver_api::Resolve; use serde::{Deserialize, Serialize}; use typeshare::typeshare; -use crate::entities::{alert::Alert, MongoDocument, I64, U64}; +use crate::entities::{I64, MongoDocument, U64, alert::Alert}; use super::KomodoReadRequest; diff --git a/client/core/rs/src/api/read/build.rs b/client/core/rs/src/api/read/build.rs index e45c9a21f..ac886f751 100644 --- a/client/core/rs/src/api/read/build.rs +++ b/client/core/rs/src/api/read/build.rs @@ -6,8 +6,8 @@ use serde::{Deserialize, Serialize}; use typeshare::typeshare; use crate::entities::{ + I64, Version, build::{Build, BuildActionState, BuildListItem, BuildQuery}, - Version, I64, }; use super::KomodoReadRequest; diff --git a/client/core/rs/src/api/read/deployment.rs b/client/core/rs/src/api/read/deployment.rs index 7194a1d3d..aabaf58b5 100644 --- a/client/core/rs/src/api/read/deployment.rs +++ b/client/core/rs/src/api/read/deployment.rs @@ -4,13 +4,13 @@ use serde::{Deserialize, Serialize}; use typeshare::typeshare; use crate::entities::{ + I64, SearchCombinator, U64, deployment::{ Deployment, DeploymentActionState, DeploymentListItem, DeploymentQuery, DeploymentState, }, docker::container::{ContainerListItem, ContainerStats}, update::Log, - SearchCombinator, I64, U64, }; use super::KomodoReadRequest; diff --git a/client/core/rs/src/api/read/mod.rs b/client/core/rs/src/api/read/mod.rs index 76e931d7a..dec204a0e 100644 --- a/client/core/rs/src/api/read/mod.rs +++ b/client/core/rs/src/api/read/mod.rs @@ -46,8 +46,8 @@ pub use user_group::*; pub use variable::*; use crate::entities::{ - config::{DockerRegistry, GitProvider}, ResourceTarget, Timelength, + config::{DockerRegistry, GitProvider}, }; pub trait KomodoReadRequest: HasResponse {} diff --git a/client/core/rs/src/api/read/permission.rs b/client/core/rs/src/api/read/permission.rs index c812abc03..6adeed507 100644 --- a/client/core/rs/src/api/read/permission.rs +++ b/client/core/rs/src/api/read/permission.rs @@ -4,8 +4,8 @@ use serde::{Deserialize, Serialize}; use typeshare::typeshare; use crate::entities::{ - permission::{Permission, PermissionLevel, UserTarget}, ResourceTarget, + permission::{Permission, PermissionLevel, UserTarget}, }; use super::KomodoReadRequest; diff --git a/client/core/rs/src/api/read/server.rs b/client/core/rs/src/api/read/server.rs index 3ab08fbf9..7d7ce9b17 100644 --- a/client/core/rs/src/api/read/server.rs +++ b/client/core/rs/src/api/read/server.rs @@ -4,6 +4,7 @@ use serde::{Deserialize, Serialize}; use typeshare::typeshare; use crate::entities::{ + I64, ResourceTarget, SearchCombinator, Timelength, U64, docker::{ container::{Container, ContainerListItem}, image::{Image, ImageHistoryResponseItem, ImageListItem}, @@ -19,7 +20,6 @@ use crate::entities::{ SystemInformation, SystemProcess, SystemStats, SystemStatsRecord, }, update::Log, - ResourceTarget, SearchCombinator, Timelength, I64, U64, }; use super::KomodoReadRequest; diff --git a/client/core/rs/src/api/read/stack.rs b/client/core/rs/src/api/read/stack.rs index 868a7ed7b..39557d408 100644 --- a/client/core/rs/src/api/read/stack.rs +++ b/client/core/rs/src/api/read/stack.rs @@ -4,11 +4,11 @@ use serde::{Deserialize, Serialize}; use typeshare::typeshare; use crate::entities::{ + SearchCombinator, U64, stack::{ Stack, StackActionState, StackListItem, StackQuery, StackService, }, update::Log, - SearchCombinator, U64, }; use super::KomodoReadRequest; diff --git a/client/core/rs/src/api/read/tag.rs b/client/core/rs/src/api/read/tag.rs index f90a101a4..9eff08446 100644 --- a/client/core/rs/src/api/read/tag.rs +++ b/client/core/rs/src/api/read/tag.rs @@ -3,7 +3,7 @@ use resolver_api::Resolve; use serde::{Deserialize, Serialize}; use typeshare::typeshare; -use crate::entities::{tag::Tag, MongoDocument}; +use crate::entities::{MongoDocument, tag::Tag}; use super::KomodoReadRequest; diff --git a/client/core/rs/src/api/read/update.rs b/client/core/rs/src/api/read/update.rs index e1f9a0e05..200cc1b6d 100644 --- a/client/core/rs/src/api/read/update.rs +++ b/client/core/rs/src/api/read/update.rs @@ -4,8 +4,8 @@ use serde::{Deserialize, Serialize}; use typeshare::typeshare; use crate::entities::{ - update::{Update, UpdateListItem}, MongoDocument, + update::{Update, UpdateListItem}, }; use super::KomodoReadRequest; diff --git a/client/core/rs/src/api/user.rs b/client/core/rs/src/api/user.rs index d130275a3..d0bbc0868 100644 --- a/client/core/rs/src/api/user.rs +++ b/client/core/rs/src/api/user.rs @@ -3,7 +3,7 @@ use resolver_api::{HasResponse, Resolve}; use serde::{Deserialize, Serialize}; use typeshare::typeshare; -use crate::entities::{NoData, ResourceTarget, I64}; +use crate::entities::{I64, NoData, ResourceTarget}; pub trait KomodoUserRequest: HasResponse {} diff --git a/client/core/rs/src/api/write/action.rs b/client/core/rs/src/api/write/action.rs index f10fdba38..72b24d3ee 100644 --- a/client/core/rs/src/api/write/action.rs +++ b/client/core/rs/src/api/write/action.rs @@ -4,9 +4,9 @@ use serde::{Deserialize, Serialize}; use typeshare::typeshare; use crate::entities::{ - action::{Action, _PartialActionConfig}, - update::Update, NoData, + action::{_PartialActionConfig, Action}, + update::Update, }; use super::KomodoWriteRequest; diff --git a/client/core/rs/src/api/write/alerter.rs b/client/core/rs/src/api/write/alerter.rs index e983c2754..dad9aa4cf 100644 --- a/client/core/rs/src/api/write/alerter.rs +++ b/client/core/rs/src/api/write/alerter.rs @@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize}; use typeshare::typeshare; use crate::entities::{ - alerter::{Alerter, _PartialAlerterConfig}, + alerter::{_PartialAlerterConfig, Alerter}, update::Update, }; diff --git a/client/core/rs/src/api/write/api_key.rs b/client/core/rs/src/api/write/api_key.rs index 0317a622f..a1dcc8b38 100644 --- a/client/core/rs/src/api/write/api_key.rs +++ b/client/core/rs/src/api/write/api_key.rs @@ -5,7 +5,7 @@ use typeshare::typeshare; use crate::{ api::user::CreateApiKeyResponse, - entities::{NoData, I64}, + entities::{I64, NoData}, }; use super::KomodoWriteRequest; diff --git a/client/core/rs/src/api/write/build.rs b/client/core/rs/src/api/write/build.rs index c81c08d7c..6d4dbc84f 100644 --- a/client/core/rs/src/api/write/build.rs +++ b/client/core/rs/src/api/write/build.rs @@ -4,9 +4,9 @@ use serde::{Deserialize, Serialize}; use typeshare::typeshare; use crate::entities::{ - build::{Build, _PartialBuildConfig}, - update::Update, NoData, + build::{_PartialBuildConfig, Build}, + update::Update, }; use super::KomodoWriteRequest; diff --git a/client/core/rs/src/api/write/deployment.rs b/client/core/rs/src/api/write/deployment.rs index a62a1e3b6..e9adb8eef 100644 --- a/client/core/rs/src/api/write/deployment.rs +++ b/client/core/rs/src/api/write/deployment.rs @@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize}; use typeshare::typeshare; use crate::entities::{ - deployment::{Deployment, _PartialDeploymentConfig}, + deployment::{_PartialDeploymentConfig, Deployment}, update::Update, }; diff --git a/client/core/rs/src/api/write/permissions.rs b/client/core/rs/src/api/write/permissions.rs index 5c710eda5..2b1738d4b 100644 --- a/client/core/rs/src/api/write/permissions.rs +++ b/client/core/rs/src/api/write/permissions.rs @@ -4,8 +4,8 @@ use serde::{Deserialize, Serialize}; use typeshare::typeshare; use crate::entities::{ - permission::{PermissionLevel, UserTarget}, NoData, ResourceTarget, ResourceTargetVariant, + permission::{PermissionLevel, UserTarget}, }; use super::KomodoWriteRequest; diff --git a/client/core/rs/src/api/write/procedure.rs b/client/core/rs/src/api/write/procedure.rs index 7fe423eb9..653fac095 100644 --- a/client/core/rs/src/api/write/procedure.rs +++ b/client/core/rs/src/api/write/procedure.rs @@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize}; use typeshare::typeshare; use crate::entities::{ - procedure::{Procedure, _PartialProcedureConfig}, + procedure::{_PartialProcedureConfig, Procedure}, update::Update, }; diff --git a/client/core/rs/src/api/write/repo.rs b/client/core/rs/src/api/write/repo.rs index ec08c43a0..7b4467cbb 100644 --- a/client/core/rs/src/api/write/repo.rs +++ b/client/core/rs/src/api/write/repo.rs @@ -4,9 +4,9 @@ use serde::{Deserialize, Serialize}; use typeshare::typeshare; use crate::entities::{ - repo::{Repo, _PartialRepoConfig}, - update::Update, NoData, + repo::{_PartialRepoConfig, Repo}, + update::Update, }; use super::KomodoWriteRequest; diff --git a/client/core/rs/src/api/write/server.rs b/client/core/rs/src/api/write/server.rs index d36727be2..148349483 100644 --- a/client/core/rs/src/api/write/server.rs +++ b/client/core/rs/src/api/write/server.rs @@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize}; use typeshare::typeshare; use crate::entities::{ - server::{Server, _PartialServerConfig}, + server::{_PartialServerConfig, Server}, update::Update, }; diff --git a/client/core/rs/src/api/write/stack.rs b/client/core/rs/src/api/write/stack.rs index 587c3b36e..26de59515 100644 --- a/client/core/rs/src/api/write/stack.rs +++ b/client/core/rs/src/api/write/stack.rs @@ -4,9 +4,9 @@ use serde::{Deserialize, Serialize}; use typeshare::typeshare; use crate::entities::{ - stack::{Stack, _PartialStackConfig}, - update::Update, NoData, + stack::{_PartialStackConfig, Stack}, + update::Update, }; use super::KomodoWriteRequest; diff --git a/client/core/rs/src/api/write/sync.rs b/client/core/rs/src/api/write/sync.rs index 2389f1b64..3b5d76e66 100644 --- a/client/core/rs/src/api/write/sync.rs +++ b/client/core/rs/src/api/write/sync.rs @@ -5,9 +5,9 @@ use serde::{Deserialize, Serialize}; use typeshare::typeshare; use crate::entities::{ - sync::{ResourceSync, _PartialResourceSyncConfig}, - update::Update, NoData, + sync::{_PartialResourceSyncConfig, ResourceSync}, + update::Update, }; use super::KomodoWriteRequest; diff --git a/client/core/rs/src/api/write/tags.rs b/client/core/rs/src/api/write/tags.rs index fcefd57cc..5791a3fc9 100644 --- a/client/core/rs/src/api/write/tags.rs +++ b/client/core/rs/src/api/write/tags.rs @@ -3,7 +3,7 @@ use resolver_api::Resolve; use serde::{Deserialize, Serialize}; use typeshare::typeshare; -use crate::entities::{tag::Tag, NoData, ResourceTarget}; +use crate::entities::{NoData, ResourceTarget, tag::Tag}; use super::KomodoWriteRequest; diff --git a/client/core/rs/src/api/write/user.rs b/client/core/rs/src/api/write/user.rs index 442e25960..991db9aad 100644 --- a/client/core/rs/src/api/write/user.rs +++ b/client/core/rs/src/api/write/user.rs @@ -3,7 +3,7 @@ use resolver_api::Resolve; use serde::{Deserialize, Serialize}; use typeshare::typeshare; -use crate::entities::{user::User, NoData}; +use crate::entities::{NoData, user::User}; use super::KomodoWriteRequest; diff --git a/client/core/rs/src/deserializers/conversion.rs b/client/core/rs/src/deserializers/conversion.rs index b5629a809..9e7665cbc 100644 --- a/client/core/rs/src/deserializers/conversion.rs +++ b/client/core/rs/src/deserializers/conversion.rs @@ -1,6 +1,6 @@ use serde::{ - de::{value::SeqAccessDeserializer, Visitor}, Deserialize, Deserializer, + de::{Visitor, value::SeqAccessDeserializer}, }; use crate::entities::deployment::Conversion; diff --git a/client/core/rs/src/deserializers/environment.rs b/client/core/rs/src/deserializers/environment.rs index 606c7009d..6c279874c 100644 --- a/client/core/rs/src/deserializers/environment.rs +++ b/client/core/rs/src/deserializers/environment.rs @@ -1,6 +1,6 @@ use serde::{ - de::{value::SeqAccessDeserializer, Visitor}, Deserialize, Deserializer, + de::{Visitor, value::SeqAccessDeserializer}, }; use crate::entities::EnvironmentVar; diff --git a/client/core/rs/src/deserializers/file_contents.rs b/client/core/rs/src/deserializers/file_contents.rs index 6e2f529d4..e36844f65 100644 --- a/client/core/rs/src/deserializers/file_contents.rs +++ b/client/core/rs/src/deserializers/file_contents.rs @@ -1,4 +1,4 @@ -use serde::{de::Visitor, Deserializer}; +use serde::{Deserializer, de::Visitor}; /// Using this ensures the file contents end with trailing '\n' pub fn file_contents_deserializer<'de, D>( diff --git a/client/core/rs/src/deserializers/labels.rs b/client/core/rs/src/deserializers/labels.rs index f8620d12b..f161c86d3 100644 --- a/client/core/rs/src/deserializers/labels.rs +++ b/client/core/rs/src/deserializers/labels.rs @@ -1,6 +1,6 @@ use serde::{ - de::{value::SeqAccessDeserializer, Visitor}, Deserialize, Deserializer, + de::{Visitor, value::SeqAccessDeserializer}, }; use crate::entities::EnvironmentVar; diff --git a/client/core/rs/src/deserializers/maybe_string_i64.rs b/client/core/rs/src/deserializers/maybe_string_i64.rs index db5e5d673..af35c4682 100644 --- a/client/core/rs/src/deserializers/maybe_string_i64.rs +++ b/client/core/rs/src/deserializers/maybe_string_i64.rs @@ -1,4 +1,4 @@ -use serde::{de::Visitor, Deserializer}; +use serde::{Deserializer, de::Visitor}; pub fn maybe_string_i64_deserializer<'de, D>( deserializer: D, diff --git a/client/core/rs/src/deserializers/string_list.rs b/client/core/rs/src/deserializers/string_list.rs index 9611fa393..44dcfec5d 100644 --- a/client/core/rs/src/deserializers/string_list.rs +++ b/client/core/rs/src/deserializers/string_list.rs @@ -1,6 +1,6 @@ use serde::{ - de::{value::SeqAccessDeserializer, SeqAccess, Visitor}, Deserialize, Deserializer, + de::{SeqAccess, Visitor, value::SeqAccessDeserializer}, }; use crate::parsers::parse_string_list; diff --git a/client/core/rs/src/deserializers/term_signal_labels.rs b/client/core/rs/src/deserializers/term_signal_labels.rs index 8c5d8936b..cc884d04b 100644 --- a/client/core/rs/src/deserializers/term_signal_labels.rs +++ b/client/core/rs/src/deserializers/term_signal_labels.rs @@ -1,6 +1,6 @@ use serde::{ - de::{value::SeqAccessDeserializer, Visitor}, Deserialize, Deserializer, + de::{Visitor, value::SeqAccessDeserializer}, }; use crate::entities::deployment::TerminationSignalLabel; diff --git a/client/core/rs/src/entities/action.rs b/client/core/rs/src/entities/action.rs index aad0c1897..265552af8 100644 --- a/client/core/rs/src/entities/action.rs +++ b/client/core/rs/src/entities/action.rs @@ -1,4 +1,4 @@ -use bson::{doc, Document}; +use bson::{Document, doc}; use derive_builder::Builder; use derive_default_builder::DefaultBuilder; use partial_derive2::Partial; diff --git a/client/core/rs/src/entities/alert.rs b/client/core/rs/src/entities/alert.rs index 25024db59..c13b636a1 100644 --- a/client/core/rs/src/entities/alert.rs +++ b/client/core/rs/src/entities/alert.rs @@ -5,11 +5,11 @@ use serde::{Deserialize, Serialize}; use strum::{Display, EnumString}; use typeshare::typeshare; -use crate::entities::{MongoId, I64}; +use crate::entities::{I64, MongoId}; use super::{ - _Serror, deployment::DeploymentState, stack::StackState, - ResourceTarget, Version, + _Serror, ResourceTarget, Version, deployment::DeploymentState, + stack::StackState, }; /// Representation of an alert in the system. diff --git a/client/core/rs/src/entities/alerter.rs b/client/core/rs/src/entities/alerter.rs index 636e4b9db..838496abb 100644 --- a/client/core/rs/src/entities/alerter.rs +++ b/client/core/rs/src/entities/alerter.rs @@ -1,4 +1,4 @@ -use bson::{doc, Document}; +use bson::{Document, doc}; use derive_builder::Builder; use derive_default_builder::DefaultBuilder; use derive_variants::EnumVariants; @@ -8,9 +8,9 @@ use strum::{AsRefStr, Display, EnumString}; use typeshare::typeshare; use super::{ + ResourceTarget, alert::AlertDataVariant, resource::{Resource, ResourceListItem, ResourceQuery}, - ResourceTarget, }; #[typeshare] diff --git a/client/core/rs/src/entities/build.rs b/client/core/rs/src/entities/build.rs index 9621feab2..22209c1e4 100644 --- a/client/core/rs/src/entities/build.rs +++ b/client/core/rs/src/entities/build.rs @@ -1,10 +1,10 @@ -use bson::{doc, Document}; +use bson::{Document, doc}; use derive_builder::Builder; use derive_default_builder::DefaultBuilder; use partial_derive2::Partial; use serde::{ - de::{value::MapAccessDeserializer, Visitor}, Deserialize, Deserializer, Serialize, + de::{Visitor, value::MapAccessDeserializer}, }; use strum::Display; use typeshare::typeshare; @@ -19,8 +19,8 @@ use crate::{ }; use super::{ - resource::{Resource, ResourceListItem, ResourceQuery}, NoData, SystemCommand, Version, + resource::{Resource, ResourceListItem, ResourceQuery}, }; #[typeshare] @@ -390,7 +390,10 @@ impl<'de> Visitor<'de> for ImageRegistryVisitor { &self, formatter: &mut std::fmt::Formatter, ) -> std::fmt::Result { - write!(formatter, "{{ \"domain\": string, \"account\": string, \"organization\": string }}") + write!( + formatter, + "{{ \"domain\": string, \"account\": string, \"organization\": string }}" + ) } fn visit_map(self, map: A) -> Result @@ -420,7 +423,10 @@ impl<'de> Visitor<'de> for OptionImageRegistryVisitor { &self, formatter: &mut std::fmt::Formatter, ) -> std::fmt::Result { - write!(formatter, "null or {{ \"domain\": string, \"account\": string, \"organization\": string }}") + write!( + formatter, + "null or {{ \"domain\": string, \"account\": string, \"organization\": string }}" + ) } fn visit_map(self, map: A) -> Result diff --git a/client/core/rs/src/entities/builder.rs b/client/core/rs/src/entities/builder.rs index e66961c73..3597416b2 100644 --- a/client/core/rs/src/entities/builder.rs +++ b/client/core/rs/src/entities/builder.rs @@ -10,9 +10,9 @@ use crate::deserializers::{ }; use super::{ + MergePartial, config::{DockerRegistry, GitProvider}, resource::{AddFilters, Resource, ResourceListItem, ResourceQuery}, - MergePartial, }; #[typeshare] diff --git a/client/core/rs/src/entities/config/core.rs b/client/core/rs/src/entities/config/core.rs index 4dcf1adfd..0880c039b 100644 --- a/client/core/rs/src/entities/config/core.rs +++ b/client/core/rs/src/entities/config/core.rs @@ -14,11 +14,11 @@ use std::{collections::HashMap, path::PathBuf, str::FromStr}; use serde::{Deserialize, Serialize}; use crate::entities::{ - logger::{LogConfig, LogLevel, StdioLogMode}, Timelength, + logger::{LogConfig, LogLevel, StdioLogMode}, }; -use super::{empty_or_redacted, DockerRegistry, GitProvider}; +use super::{DockerRegistry, GitProvider, empty_or_redacted}; /// # Komodo Core Environment Variables /// diff --git a/client/core/rs/src/entities/config/periphery.rs b/client/core/rs/src/entities/config/periphery.rs index a94f4f2ab..ed01d0d4a 100644 --- a/client/core/rs/src/entities/config/periphery.rs +++ b/client/core/rs/src/entities/config/periphery.rs @@ -18,12 +18,12 @@ use clap::Parser; use serde::Deserialize; use crate::entities::{ - logger::{LogConfig, LogLevel, StdioLogMode}, Timelength, + logger::{LogConfig, LogLevel, StdioLogMode}, }; use super::{ - empty_or_redacted, DockerRegistry, GitProvider, ProviderAccount, + DockerRegistry, GitProvider, ProviderAccount, empty_or_redacted, }; /// # Periphery Command Line Arguments. diff --git a/client/core/rs/src/entities/deployment.rs b/client/core/rs/src/entities/deployment.rs index 4b579b752..e6d1760f6 100644 --- a/client/core/rs/src/entities/deployment.rs +++ b/client/core/rs/src/entities/deployment.rs @@ -1,5 +1,5 @@ use anyhow::Context; -use bson::{doc, Document}; +use bson::{Document, doc}; use derive_builder::Builder; use derive_default_builder::DefaultBuilder; use derive_variants::EnumVariants; @@ -20,9 +20,9 @@ use crate::{ }; use super::{ + TerminationSignal, Version, docker::container::ContainerStateStatusEnum, resource::{Resource, ResourceListItem, ResourceQuery}, - TerminationSignal, Version, }; #[typeshare] diff --git a/client/core/rs/src/entities/docker/container.rs b/client/core/rs/src/entities/docker/container.rs index 0e7e09a0d..c948ba16e 100644 --- a/client/core/rs/src/entities/docker/container.rs +++ b/client/core/rs/src/entities/docker/container.rs @@ -4,7 +4,7 @@ use anyhow::anyhow; use serde::{Deserialize, Serialize}; use typeshare::typeshare; -use crate::entities::{Usize, I64}; +use crate::entities::{I64, Usize}; use super::{ContainerConfig, GraphDriverData, PortBinding}; diff --git a/client/core/rs/src/entities/mod.rs b/client/core/rs/src/entities/mod.rs index b6344495e..852c4533c 100644 --- a/client/core/rs/src/entities/mod.rs +++ b/client/core/rs/src/entities/mod.rs @@ -10,8 +10,8 @@ use clap::Parser; use derive_empty_traits::EmptyTraits; use derive_variants::{EnumVariants, ExtractVariant}; use serde::{ - de::{value::MapAccessDeserializer, Visitor}, Deserialize, Serialize, + de::{Visitor, value::MapAccessDeserializer}, }; use serror::Serror; use strum::{AsRefStr, Display, EnumString}; @@ -213,11 +213,7 @@ impl SystemCommand { } pub fn into_option(self) -> Option { - if self.is_none() { - None - } else { - Some(self) - } + if self.is_none() { None } else { Some(self) } } pub fn is_none(&self) -> bool { diff --git a/client/core/rs/src/entities/procedure.rs b/client/core/rs/src/entities/procedure.rs index fe8eaccc8..316451623 100644 --- a/client/core/rs/src/entities/procedure.rs +++ b/client/core/rs/src/entities/procedure.rs @@ -9,8 +9,8 @@ use typeshare::typeshare; use crate::api::execute::Execution; use super::{ - resource::{Resource, ResourceListItem, ResourceQuery}, I64, + resource::{Resource, ResourceListItem, ResourceQuery}, }; #[typeshare] diff --git a/client/core/rs/src/entities/repo.rs b/client/core/rs/src/entities/repo.rs index 872e220f8..d00067282 100644 --- a/client/core/rs/src/entities/repo.rs +++ b/client/core/rs/src/entities/repo.rs @@ -1,5 +1,5 @@ use anyhow::Context; -use bson::{doc, Document}; +use bson::{Document, doc}; use derive_builder::Builder; use derive_default_builder::DefaultBuilder; use partial_derive2::Partial; @@ -16,9 +16,8 @@ use crate::{ }; use super::{ - environment_vars_from_str, + EnvironmentVar, SystemCommand, environment_vars_from_str, resource::{Resource, ResourceListItem, ResourceQuery}, - EnvironmentVar, SystemCommand, }; #[typeshare] diff --git a/client/core/rs/src/entities/resource.rs b/client/core/rs/src/entities/resource.rs index 5c1c4bc92..21c4b564b 100644 --- a/client/core/rs/src/entities/resource.rs +++ b/client/core/rs/src/entities/resource.rs @@ -1,4 +1,4 @@ -use bson::{doc, Document}; +use bson::{Document, doc}; use derive_builder::Builder; use derive_default_builder::DefaultBuilder; use serde::{Deserialize, Serialize}; @@ -6,10 +6,10 @@ use typeshare::typeshare; use crate::{ deserializers::string_list_deserializer, - entities::{MongoId, I64}, + entities::{I64, MongoId}, }; -use super::{permission::PermissionLevel, ResourceTargetVariant}; +use super::{ResourceTargetVariant, permission::PermissionLevel}; #[typeshare] #[derive(Debug, Clone, Serialize, Deserialize, Builder)] diff --git a/client/core/rs/src/entities/server.rs b/client/core/rs/src/entities/server.rs index aa448a78b..a4c4c36df 100644 --- a/client/core/rs/src/entities/server.rs +++ b/client/core/rs/src/entities/server.rs @@ -10,9 +10,9 @@ use crate::deserializers::{ }; use super::{ + I64, alert::SeverityLevel, resource::{AddFilters, Resource, ResourceListItem, ResourceQuery}, - I64, }; #[typeshare] diff --git a/client/core/rs/src/entities/server_template/mod.rs b/client/core/rs/src/entities/server_template/mod.rs index a26c11d8d..0744811c8 100644 --- a/client/core/rs/src/entities/server_template/mod.rs +++ b/client/core/rs/src/entities/server_template/mod.rs @@ -1,4 +1,4 @@ -use bson::{doc, Document}; +use bson::{Document, doc}; use derive_default_builder::DefaultBuilder; use derive_variants::EnumVariants; use partial_derive2::{Diff, MaybeNone, PartialDiff}; @@ -11,8 +11,8 @@ use self::{ }; use super::{ - resource::{AddFilters, Resource, ResourceListItem, ResourceQuery}, MergePartial, + resource::{AddFilters, Resource, ResourceListItem, ResourceQuery}, }; pub mod aws; diff --git a/client/core/rs/src/entities/stack.rs b/client/core/rs/src/entities/stack.rs index c23dc05d7..14f655029 100644 --- a/client/core/rs/src/entities/stack.rs +++ b/client/core/rs/src/entities/stack.rs @@ -1,6 +1,6 @@ use std::{collections::HashMap, sync::OnceLock}; -use bson::{doc, Document}; +use bson::{Document, doc}; use derive_builder::Builder; use derive_default_builder::DefaultBuilder; use partial_derive2::Partial; @@ -16,9 +16,10 @@ use crate::deserializers::{ }; use super::{ + FileContents, SystemCommand, docker::container::ContainerListItem, resource::{Resource, ResourceListItem, ResourceQuery}, - to_komodo_name, FileContents, SystemCommand, + to_komodo_name, }; #[typeshare] diff --git a/client/core/rs/src/entities/stats.rs b/client/core/rs/src/entities/stats.rs index 4b501b235..3170ceb9d 100644 --- a/client/core/rs/src/entities/stats.rs +++ b/client/core/rs/src/entities/stats.rs @@ -3,7 +3,7 @@ use std::path::PathBuf; use serde::{Deserialize, Serialize}; use typeshare::typeshare; -use crate::entities::{Timelength, I64}; +use crate::entities::{I64, Timelength}; /// System information of a server #[typeshare] diff --git a/client/core/rs/src/entities/sync.rs b/client/core/rs/src/entities/sync.rs index b766f446f..c63ace485 100644 --- a/client/core/rs/src/entities/sync.rs +++ b/client/core/rs/src/entities/sync.rs @@ -1,4 +1,4 @@ -use bson::{doc, Document}; +use bson::{Document, doc}; use derive_builder::Builder; use derive_default_builder::DefaultBuilder; use partial_derive2::Partial; @@ -12,8 +12,8 @@ use crate::deserializers::{ }; use super::{ + I64, ResourceTarget, resource::{Resource, ResourceListItem, ResourceQuery}, - ResourceTarget, I64, }; #[typeshare] diff --git a/client/core/rs/src/entities/toml.rs b/client/core/rs/src/entities/toml.rs index 744a21c88..cebb3922d 100644 --- a/client/core/rs/src/entities/toml.rs +++ b/client/core/rs/src/entities/toml.rs @@ -4,6 +4,7 @@ use serde::{Deserialize, Serialize}; use typeshare::typeshare; use super::{ + ResourceTarget, ResourceTargetVariant, action::_PartialActionConfig, alerter::_PartialAlerterConfig, build::_PartialBuildConfig, builder::_PartialBuilderConfig, deployment::_PartialDeploymentConfig, permission::PermissionLevel, @@ -11,7 +12,7 @@ use super::{ server::_PartialServerConfig, server_template::PartialServerTemplateConfig, stack::_PartialStackConfig, sync::_PartialResourceSyncConfig, - variable::Variable, ResourceTarget, ResourceTargetVariant, + variable::Variable, }; /// Specifies resources to sync on Komodo diff --git a/client/core/rs/src/entities/update.rs b/client/core/rs/src/entities/update.rs index 896c51da4..2ba030dde 100644 --- a/client/core/rs/src/entities/update.rs +++ b/client/core/rs/src/entities/update.rs @@ -4,7 +4,7 @@ use strum::{Display, EnumString}; use typeshare::typeshare; use crate::entities::{ - all_logs_success, komodo_timestamp, MongoId, Operation, I64, + I64, MongoId, Operation, all_logs_success, komodo_timestamp, }; use super::{ResourceTarget, Version}; diff --git a/client/core/rs/src/entities/user.rs b/client/core/rs/src/entities/user.rs index 2cf539496..ed207500c 100644 --- a/client/core/rs/src/entities/user.rs +++ b/client/core/rs/src/entities/user.rs @@ -3,9 +3,9 @@ use std::{collections::HashMap, sync::OnceLock}; use serde::{Deserialize, Serialize}; use typeshare::typeshare; -use crate::entities::{MongoId, I64}; +use crate::entities::{I64, MongoId}; -use super::{permission::PermissionLevel, ResourceTargetVariant}; +use super::{ResourceTargetVariant, permission::PermissionLevel}; #[typeshare] #[derive(Serialize, Deserialize, Debug, Clone, Default)] diff --git a/client/core/rs/src/entities/user_group.rs b/client/core/rs/src/entities/user_group.rs index 3c01a80d5..3668643d2 100644 --- a/client/core/rs/src/entities/user_group.rs +++ b/client/core/rs/src/entities/user_group.rs @@ -6,7 +6,7 @@ use typeshare::typeshare; use crate::deserializers::string_list_deserializer; use super::{ - permission::PermissionLevel, MongoId, ResourceTargetVariant, I64, + I64, MongoId, ResourceTargetVariant, permission::PermissionLevel, }; /// Permission users at the group level. diff --git a/client/core/rs/src/request.rs b/client/core/rs/src/request.rs index 5cf752255..973e9ba3e 100644 --- a/client/core/rs/src/request.rs +++ b/client/core/rs/src/request.rs @@ -1,16 +1,16 @@ -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use reqwest::StatusCode; -use serde::{de::DeserializeOwned, Serialize}; +use serde::{Serialize, de::DeserializeOwned}; use serde_json::json; use serror::deserialize_error; use crate::{ + KomodoClient, api::{ auth::KomodoAuthRequest, execute::KomodoExecuteRequest, read::KomodoReadRequest, user::KomodoUserRequest, write::KomodoWriteRequest, }, - KomodoClient, }; impl KomodoClient { diff --git a/client/core/rs/src/ws.rs b/client/core/rs/src/ws.rs index f8684be6e..78b6527c8 100644 --- a/client/core/rs/src/ws.rs +++ b/client/core/rs/src/ws.rs @@ -8,11 +8,11 @@ use thiserror::Error; use tokio::sync::broadcast; use tokio_tungstenite::{connect_async, tungstenite::Message}; use tokio_util::sync::CancellationToken; -use tracing::{debug, info, info_span, warn, Instrument}; +use tracing::{Instrument, debug, info, info_span, warn}; use typeshare::typeshare; use uuid::Uuid; -use crate::{entities::update::UpdateListItem, KomodoClient}; +use crate::{KomodoClient, entities::update::UpdateListItem}; #[typeshare] #[derive(Debug, Clone, Serialize, Deserialize)] diff --git a/client/periphery/rs/src/api/compose.rs b/client/periphery/rs/src/api/compose.rs index 5eac9a794..2e561be67 100644 --- a/client/periphery/rs/src/api/compose.rs +++ b/client/periphery/rs/src/api/compose.rs @@ -1,7 +1,7 @@ use komodo_client::entities::{ + FileContents, SearchCombinator, stack::{ComposeProject, Stack, StackServiceNames}, update::Log, - FileContents, SearchCombinator, }; use resolver_api::Resolve; use serde::{Deserialize, Serialize}; diff --git a/client/periphery/rs/src/api/container.rs b/client/periphery/rs/src/api/container.rs index 658e3ccfe..3be1910c8 100644 --- a/client/periphery/rs/src/api/container.rs +++ b/client/periphery/rs/src/api/container.rs @@ -1,8 +1,8 @@ use komodo_client::entities::{ + SearchCombinator, TerminationSignal, deployment::Deployment, docker::container::{Container, ContainerStats}, update::Log, - SearchCombinator, TerminationSignal, }; use resolver_api::Resolve; use serde::{Deserialize, Serialize}; diff --git a/client/periphery/rs/src/api/git.rs b/client/periphery/rs/src/api/git.rs index 5edccf31b..9c53dabeb 100644 --- a/client/periphery/rs/src/api/git.rs +++ b/client/periphery/rs/src/api/git.rs @@ -1,7 +1,7 @@ use std::path::PathBuf; use komodo_client::entities::{ - update::Log, CloneArgs, EnvironmentVar, LatestCommit, + CloneArgs, EnvironmentVar, LatestCommit, update::Log, }; use resolver_api::Resolve; use serde::{Deserialize, Serialize}; diff --git a/client/periphery/rs/src/api/mod.rs b/client/periphery/rs/src/api/mod.rs index ed9616ab3..bad9699ca 100644 --- a/client/periphery/rs/src/api/mod.rs +++ b/client/periphery/rs/src/api/mod.rs @@ -1,4 +1,5 @@ use komodo_client::entities::{ + SystemCommand, config::{DockerRegistry, GitProvider}, docker::{ container::ContainerListItem, image::ImageListItem, @@ -6,7 +7,6 @@ use komodo_client::entities::{ }, stack::ComposeProject, update::Log, - SystemCommand, }; use resolver_api::Resolve; use serde::{Deserialize, Serialize}; diff --git a/client/periphery/rs/src/lib.rs b/client/periphery/rs/src/lib.rs index 8fc127771..685529182 100644 --- a/client/periphery/rs/src/lib.rs +++ b/client/periphery/rs/src/lib.rs @@ -3,7 +3,7 @@ use std::{sync::OnceLock, time::Duration}; use anyhow::Context; use reqwest::StatusCode; use resolver_api::HasResponse; -use serde::{de::DeserializeOwned, Serialize}; +use serde::{Serialize, de::DeserializeOwned}; use serde_json::json; pub mod api; diff --git a/lib/command/src/lib.rs b/lib/command/src/lib.rs index 3c2df0ae9..0079df1ed 100644 --- a/lib/command/src/lib.rs +++ b/lib/command/src/lib.rs @@ -6,7 +6,7 @@ use komodo_client::{ entities::{komodo_timestamp, update::Log}, parsers::parse_multiline_command, }; -use run_command::{async_run_command, CommandOutput}; +use run_command::{CommandOutput, async_run_command}; use svi::Interpolator; pub async fn run_komodo_command( @@ -45,7 +45,7 @@ pub async fn run_komodo_command_multiline( /// Interpolates provided secrets into (potentially multiline) command, /// executes the command, and sanitizes the output to avoid exposing the secrets. -/// +/// /// Checks to make sure the command is non-empty after being multiline-parsed. /// /// If `parse_multiline: true`, parses commands out of multiline string @@ -73,7 +73,7 @@ pub async fn run_komodo_command_with_interpolation( return Some(Log::error( &format!("{stage} - Interpolate Secrets"), format_serror(&e.into()), - )) + )); } }; let mut log = if parse_multiline { diff --git a/lib/git/src/clone.rs b/lib/git/src/clone.rs index d1aedf8b7..344c26169 100644 --- a/lib/git/src/clone.rs +++ b/lib/git/src/clone.rs @@ -6,12 +6,12 @@ use command::{ }; use formatting::format_serror; use komodo_client::entities::{ - all_logs_success, komodo_timestamp, update::Log, CloneArgs, - EnvironmentVar, + CloneArgs, EnvironmentVar, all_logs_success, komodo_timestamp, + update::Log, }; use run_command::async_run_command; -use crate::{get_commit_hash_log, GitRes}; +use crate::{GitRes, get_commit_hash_log}; /// Will delete the existing repo folder, /// clone the repo, get the latest hash / message, diff --git a/lib/git/src/commit.rs b/lib/git/src/commit.rs index 3e3bf7808..5d275c828 100644 --- a/lib/git/src/commit.rs +++ b/lib/git/src/commit.rs @@ -7,7 +7,7 @@ use komodo_client::entities::{all_logs_success, update::Log}; use run_command::async_run_command; use tokio::fs; -use crate::{get_commit_hash_log, GitRes}; +use crate::{GitRes, get_commit_hash_log}; /// Write file, add, commit, force push. /// Repo must be cloned. diff --git a/lib/git/src/environment.rs b/lib/git/src/environment.rs index c0a9134a6..bf3c01912 100644 --- a/lib/git/src/environment.rs +++ b/lib/git/src/environment.rs @@ -5,7 +5,7 @@ use std::{ use anyhow::Context; use formatting::format_serror; -use komodo_client::entities::{update::Log, EnvironmentVar}; +use komodo_client::entities::{EnvironmentVar, update::Log}; /// If the environment was written and needs to be passed to the compose command, /// will return the env file PathBuf. diff --git a/lib/git/src/init.rs b/lib/git/src/init.rs index 78f9e6fa9..c6c71d672 100644 --- a/lib/git/src/init.rs +++ b/lib/git/src/init.rs @@ -3,7 +3,7 @@ use std::path::Path; use command::run_komodo_command; use formatting::format_serror; use komodo_client::entities::{ - all_logs_success, update::Log, CloneArgs, + CloneArgs, all_logs_success, update::Log, }; pub async fn init_folder_as_repo( diff --git a/lib/git/src/lib.rs b/lib/git/src/lib.rs index 5094ec169..248d57a2d 100644 --- a/lib/git/src/lib.rs +++ b/lib/git/src/lib.rs @@ -1,9 +1,9 @@ use std::path::{Path, PathBuf}; -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use formatting::{bold, muted}; use komodo_client::entities::{ - komodo_timestamp, update::Log, LatestCommit, + LatestCommit, komodo_timestamp, update::Log, }; use run_command::async_run_command; use tracing::instrument; @@ -36,7 +36,10 @@ pub struct GitRes { pub async fn get_commit_hash_info( repo_dir: &Path, ) -> anyhow::Result { - let command = format!("cd {} && git rev-parse --short HEAD && git rev-parse HEAD && git log -1 --pretty=%B", repo_dir.display()); + let command = format!( + "cd {} && git rev-parse --short HEAD && git rev-parse HEAD && git log -1 --pretty=%B", + repo_dir.display() + ); let output = async_run_command(&command).await; let mut split = output.stdout.split('\n'); let (hash, _, message) = ( @@ -58,7 +61,10 @@ pub async fn get_commit_hash_log( repo_dir: &Path, ) -> anyhow::Result<(Log, String, String)> { let start_ts = komodo_timestamp(); - let command = format!("cd {} && git rev-parse --short HEAD && git rev-parse HEAD && git log -1 --pretty=%B", repo_dir.display()); + let command = format!( + "cd {} && git rev-parse --short HEAD && git rev-parse HEAD && git log -1 --pretty=%B", + repo_dir.display() + ); let output = async_run_command(&command).await; let mut split = output.stdout.split('\n'); let (short_hash, _, msg) = ( diff --git a/lib/git/src/pull.rs b/lib/git/src/pull.rs index ba230e78c..ee22853de 100644 --- a/lib/git/src/pull.rs +++ b/lib/git/src/pull.rs @@ -11,11 +11,11 @@ use command::{ }; use formatting::format_serror; use komodo_client::entities::{ - all_logs_success, komodo_timestamp, update::Log, CloneArgs, - EnvironmentVar, + CloneArgs, EnvironmentVar, all_logs_success, komodo_timestamp, + update::Log, }; -use crate::{get_commit_hash_log, GitRes}; +use crate::{GitRes, get_commit_hash_log}; /// Wait this long after a pull to allow another pull through const PULL_TIMEOUT: i64 = 5_000; diff --git a/lib/logger/src/lib.rs b/lib/logger/src/lib.rs index 48cbd8b27..341531a64 100644 --- a/lib/logger/src/lib.rs +++ b/lib/logger/src/lib.rs @@ -3,7 +3,7 @@ use komodo_client::entities::logger::{LogConfig, StdioLogMode}; use tracing::level_filters::LevelFilter; use tracing_opentelemetry::OpenTelemetryLayer; use tracing_subscriber::{ - layer::SubscriberExt, util::SubscriberInitExt, Registry, + Registry, layer::SubscriberExt, util::SubscriberInitExt, }; mod otel; diff --git a/lib/logger/src/otel.rs b/lib/logger/src/otel.rs index 10e67e9f7..c92ef8c15 100644 --- a/lib/logger/src/otel.rs +++ b/lib/logger/src/otel.rs @@ -1,10 +1,10 @@ use std::time::Duration; -use opentelemetry::{global, trace::TracerProvider, KeyValue}; +use opentelemetry::{KeyValue, global, trace::TracerProvider}; use opentelemetry_otlp::WithExportConfig; use opentelemetry_sdk::{ - trace::{Sampler, Tracer}, Resource, + trace::{Sampler, Tracer}, }; use opentelemetry_semantic_conventions::resource::SERVICE_VERSION; diff --git a/lib/response/src/lib.rs b/lib/response/src/lib.rs index a2fb05fd7..db3513b3b 100644 --- a/lib/response/src/lib.rs +++ b/lib/response/src/lib.rs @@ -1,5 +1,5 @@ use anyhow::Context; -use axum::http::{header::CONTENT_TYPE, HeaderValue, StatusCode}; +use axum::http::{HeaderValue, StatusCode, header::CONTENT_TYPE}; use serde::Serialize; use serror::serialize_error;