From c8c5e552e21714ec2ffd3c2d29eb6494bf6afa8d Mon Sep 17 00:00:00 2001 From: Everett Pompeii Date: Wed, 20 Sep 2023 09:10:24 -0400 Subject: [PATCH] rm_old_config_keys --- changelog.md | 4 ++ lib/bencher_json/src/system/config/mod.rs | 14 ++----- services/api/src/config/config_tx.rs | 45 +---------------------- services/api/src/config/mod.rs | 10 ++--- services/api/src/error.rs | 2 - 5 files changed, 13 insertions(+), 62 deletions(-) diff --git a/changelog.md b/changelog.md index 6511b1fa1..3f7e8f517 100644 --- a/changelog.md +++ b/changelog.md @@ -4,6 +4,10 @@ heading: "Bencher Changelog" sortOrder: 4 --- +## Pending `v0.3.11` +- Add strongly typed IDs for database entities +- Remove deprecated configuration keys (`endpoint` => `console.url` and `secret_key` => `security.secret_key`) + ## `v0.3.10` - Add optional error monitoring with [Sentry](https://sentry.io) - Start API error message improvement diff --git a/lib/bencher_json/src/system/config/mod.rs b/lib/bencher_json/src/system/config/mod.rs index ec7e92ce3..37689ff0d 100644 --- a/lib/bencher_json/src/system/config/mod.rs +++ b/lib/bencher_json/src/system/config/mod.rs @@ -1,4 +1,4 @@ -use bencher_valid::{Sanitize, Secret, Url}; +use bencher_valid::Sanitize; #[cfg(feature = "schema")] use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -33,14 +33,8 @@ pub struct JsonUpdateConfig { #[derive(Debug, Clone, Serialize, Deserialize)] #[cfg_attr(feature = "schema", derive(JsonSchema))] pub struct JsonConfig { - // TODO Remove deprecated endpoint - pub endpoint: Option, - // TODO Remove deprecated secret_key - pub secret_key: Option, - // TODO Make mandatory - pub console: Option, - // TODO Make mandatory - pub security: Option, + pub console: JsonConsole, + pub security: JsonSecurity, pub server: JsonServer, pub logging: JsonLogging, pub database: JsonDatabase, @@ -52,7 +46,7 @@ pub struct JsonConfig { impl Sanitize for JsonConfig { fn sanitize(&mut self) { - self.secret_key.sanitize(); + self.security.sanitize(); self.database.sanitize(); self.smtp.sanitize(); #[cfg(feature = "plus")] diff --git a/services/api/src/config/config_tx.rs b/services/api/src/config/config_tx.rs index 8722294bf..72d910672 100644 --- a/services/api/src/config/config_tx.rs +++ b/services/api/src/config/config_tx.rs @@ -16,7 +16,7 @@ use dropshot::{ ApiDescription, ConfigDropshot, ConfigLogging, ConfigLoggingIfExists, ConfigLoggingLevel, ConfigTls, HttpServer, }; -use slog::{debug, error, info, warn, Logger}; +use slog::{debug, error, info, Logger}; use tokio::sync::mpsc::Sender; use crate::{ @@ -54,8 +54,6 @@ fn into_inner(log: &Logger, config_tx: ConfigTx) -> Result Result Self { Self(JsonConfig { - endpoint: None, - secret_key: None, - console: Some(JsonConsole { + console: JsonConsole { url: DEFAULT_CONSOLE_URL.clone().into(), - }), - security: Some(JsonSecurity { + }, + security: JsonSecurity { issuer: Some(BENCHER_DOT_DEV.into()), secret_key: DEFAULT_SECRET_KEY.clone(), - }), + }, server: JsonServer { bind_address: *DEFAULT_BIND_ADDRESS, request_body_max_bytes: DEFAULT_MAX_BODY_SIZE, diff --git a/services/api/src/error.rs b/services/api/src/error.rs index 329dd253c..09b1320e9 100644 --- a/services/api/src/error.rs +++ b/services/api/src/error.rs @@ -185,8 +185,6 @@ pub enum ApiError { #[error("Failed to cast integer: {0}")] IntError(#[from] std::num::TryFromIntError), - #[error("Missing configuration key: {0}")] - MissingConfigKey(String), #[error("Failed to parse integer: {0}")] BadInt(i64), #[error("Failed to parse URL encoding: {0}")]