use indexmap::IndexMap;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use super::{command::Command, healthcheck::Healthcheck, port::PortMapping};
#[non_exhaustive]
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
pub struct ContainerConfig {
pub image: String,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub ports: Vec<PortMapping>,
#[serde(default, skip_serializing_if = "IndexMap::is_empty")]
pub env: IndexMap<String, String>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub volumes: Vec<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub entrypoint: Option<Command>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub command: Option<Command>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub working_dir: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub healthcheck: Option<Healthcheck>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub depends_on: Vec<String>,
}
impl ContainerConfig {
#[must_use]
pub fn new(image: String) -> Self {
Self {
image,
ports: Vec::new(),
env: IndexMap::new(),
volumes: Vec::new(),
entrypoint: None,
command: None,
working_dir: None,
healthcheck: None,
depends_on: Vec::new(),
}
}
}