diff --git a/lib/types/src/entities/deployment.rs b/lib/types/src/entities/deployment.rs index f16695be8..8606022ee 100644 --- a/lib/types/src/entities/deployment.rs +++ b/lib/types/src/entities/deployment.rs @@ -228,6 +228,8 @@ pub struct DockerContainerStats { EnumString, MungosIndexed, )] +#[serde(rename_all = "snake_case")] +#[strum(serialize_all = "snake_case")] pub enum DockerContainerState { #[default] Unknown, diff --git a/periphery/src/guard.rs b/periphery/src/guard.rs index 4cfa62614..3f7c7fab4 100644 --- a/periphery/src/guard.rs +++ b/periphery/src/guard.rs @@ -39,7 +39,7 @@ pub async fn guard_request_by_passkey( format!("failed to get passkey from authorization header as str: {e:?}"), ) })? - .to_string(); + .replace("Bearer ", ""); if state.config.passkeys.contains(&req_passkey) { Ok(next.run(req).await) } else { diff --git a/periphery/src/helpers/docker/client.rs b/periphery/src/helpers/docker/client.rs index 856b95f3c..d00ddb063 100644 --- a/periphery/src/helpers/docker/client.rs +++ b/periphery/src/helpers/docker/client.rs @@ -1,4 +1,4 @@ -use anyhow::anyhow; +use anyhow::{anyhow, Context}; use bollard::{container::ListContainersOptions, Docker}; use monitor_types::entities::{ deployment::BasicContainerInfo, @@ -38,7 +38,11 @@ impl DockerClient { .ok_or(anyhow!("no names on container (empty vec)"))? .replace('/', ""), image: s.image.unwrap_or(String::from("unknown")), - state: s.state.unwrap().parse().unwrap(), + state: s + .state + .context("no container state")? + .parse() + .context("failed to parse container state")?, status: s.status, }; Ok::<_, anyhow::Error>(info) diff --git a/periphery/src/main.rs b/periphery/src/main.rs index da0642f7b..0f6751b4a 100644 --- a/periphery/src/main.rs +++ b/periphery/src/main.rs @@ -43,7 +43,7 @@ async fn app() -> anyhow::Result<()> { .map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, format!("{e:?}"))) }) .await - .map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, format!("{e:?}"))); + .map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, format!("{e:#?}"))); if let Err(e) = &res { debug!("request {req_id} SPAWN ERROR: {e:?}"); }