use alloc::{string::String, vec::Vec};
use crate::Cmd;
use core::fmt::{Display, Formatter};
#[derive(Clone, Debug)]
pub enum HealthCheck {
Some { opts: Vec<HealthCheckOpt>, cmd: Cmd },
None,
}
impl Display for HealthCheck {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
match self {
Self::Some { opts, cmd } => {
write!(f, "HEALTHCHECK ")?;
for opt in opts {
write!(f, "{opt} ")?;
}
write!(f, "{}", cmd)
}
Self::None => write!(f, "HEALTHCHECK NONE"),
}
}
}
#[derive(Clone, Debug)]
pub enum HealthCheckOpt {
Interval(String),
Timeout(String),
StartPeriod(String),
StartInterval(String),
Retries(i32),
}
impl Display for HealthCheckOpt {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
match self {
Self::Interval(d) => write!(f, "--interval={d}"),
Self::Timeout(d) => write!(f, "--timeout={d}"),
Self::StartPeriod(d) => write!(f, "--start-period={d}"),
Self::StartInterval(d) => write!(f, "--start-interval={d}"),
Self::Retries(n) => write!(f, "--retries={n}"),
}
}
}