nanite_docker/instruction/
healthcheck.rs1use alloc::{string::String, vec::Vec};
2
3use crate::Cmd;
4use core::fmt::{Display, Formatter};
5
6#[derive(Clone, Debug)]
22pub enum HealthCheck {
23 Some { opts: Vec<HealthCheckOpt>, cmd: Cmd },
24 None,
25}
26
27impl Display for HealthCheck {
28 fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
29 match self {
30 Self::Some { opts, cmd } => {
31 write!(f, "HEALTHCHECK ")?;
32
33 for opt in opts {
34 write!(f, "{opt} ")?;
35 }
36
37 write!(f, "{}", cmd)
38 }
39 Self::None => write!(f, "HEALTHCHECK NONE"),
40 }
41 }
42}
43
44#[derive(Clone, Debug)]
45pub enum HealthCheckOpt {
46 Interval(String),
47 Timeout(String),
48 StartPeriod(String),
49 StartInterval(String),
50 Retries(i32),
51}
52
53impl Display for HealthCheckOpt {
54 fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
55 match self {
56 Self::Interval(d) => write!(f, "--interval={d}"),
57 Self::Timeout(d) => write!(f, "--timeout={d}"),
58 Self::StartPeriod(d) => write!(f, "--start-period={d}"),
59 Self::StartInterval(d) => write!(f, "--start-interval={d}"),
60 Self::Retries(n) => write!(f, "--retries={n}"),
61 }
62 }
63}