mirror of
https://github.com/moghtech/komodo.git
synced 2026-04-30 14:25:22 -05:00
test periphery api
This commit is contained in:
@@ -228,6 +228,8 @@ pub struct DockerContainerStats {
|
|||||||
EnumString,
|
EnumString,
|
||||||
MungosIndexed,
|
MungosIndexed,
|
||||||
)]
|
)]
|
||||||
|
#[serde(rename_all = "snake_case")]
|
||||||
|
#[strum(serialize_all = "snake_case")]
|
||||||
pub enum DockerContainerState {
|
pub enum DockerContainerState {
|
||||||
#[default]
|
#[default]
|
||||||
Unknown,
|
Unknown,
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ pub async fn guard_request_by_passkey(
|
|||||||
format!("failed to get passkey from authorization header as str: {e:?}"),
|
format!("failed to get passkey from authorization header as str: {e:?}"),
|
||||||
)
|
)
|
||||||
})?
|
})?
|
||||||
.to_string();
|
.replace("Bearer ", "");
|
||||||
if state.config.passkeys.contains(&req_passkey) {
|
if state.config.passkeys.contains(&req_passkey) {
|
||||||
Ok(next.run(req).await)
|
Ok(next.run(req).await)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use anyhow::anyhow;
|
use anyhow::{anyhow, Context};
|
||||||
use bollard::{container::ListContainersOptions, Docker};
|
use bollard::{container::ListContainersOptions, Docker};
|
||||||
use monitor_types::entities::{
|
use monitor_types::entities::{
|
||||||
deployment::BasicContainerInfo,
|
deployment::BasicContainerInfo,
|
||||||
@@ -38,7 +38,11 @@ impl DockerClient {
|
|||||||
.ok_or(anyhow!("no names on container (empty vec)"))?
|
.ok_or(anyhow!("no names on container (empty vec)"))?
|
||||||
.replace('/', ""),
|
.replace('/', ""),
|
||||||
image: s.image.unwrap_or(String::from("unknown")),
|
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,
|
status: s.status,
|
||||||
};
|
};
|
||||||
Ok::<_, anyhow::Error>(info)
|
Ok::<_, anyhow::Error>(info)
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ async fn app() -> anyhow::Result<()> {
|
|||||||
.map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, format!("{e:?}")))
|
.map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, format!("{e:?}")))
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, format!("{e:?}")));
|
.map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, format!("{e:#?}")));
|
||||||
if let Err(e) = &res {
|
if let Err(e) = &res {
|
||||||
debug!("request {req_id} SPAWN ERROR: {e:?}");
|
debug!("request {req_id} SPAWN ERROR: {e:?}");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user