pub mod builder;
pub mod layer;
pub mod layout;
pub mod manifest;
pub mod registry;
use indexmap::IndexMap;
use serde::{Deserialize, Serialize};
pub use builder::{BuildOptions, BuildOutput, Builder};
pub fn normalize_arch(a: &str) -> &str {
match a {
"x86_64" => "amd64",
"aarch64" => "arm64",
other => other,
}
}
pub fn normalize_os(o: &str) -> &str {
match o {
"macos" | "windows" => "linux",
other => other,
}
}
#[derive(Debug, Default, Clone, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct OciConfig {
#[serde(default)]
pub from: Option<String>,
#[serde(default)]
pub tag: Option<String>,
#[serde(default)]
pub workdir: Option<String>,
#[serde(default)]
pub entrypoint: Option<Vec<String>>,
#[serde(default)]
pub cmd: Option<Vec<String>>,
#[serde(default)]
pub user: Option<String>,
#[serde(default)]
pub mount_point: Option<String>,
#[serde(default)]
pub env: IndexMap<String, String>,
#[serde(default)]
pub labels: IndexMap<String, String>,
}
impl OciConfig {
pub fn fill_defaults_from(&mut self, other: Self) {
if self.from.is_none() {
self.from = other.from;
}
if self.tag.is_none() {
self.tag = other.tag;
}
if self.workdir.is_none() {
self.workdir = other.workdir;
}
if self.entrypoint.is_none() {
self.entrypoint = other.entrypoint;
}
if self.cmd.is_none() {
self.cmd = other.cmd;
}
if self.user.is_none() {
self.user = other.user;
}
if self.mount_point.is_none() {
self.mount_point = other.mount_point;
}
for (k, v) in other.env {
self.env.entry(k).or_insert(v);
}
for (k, v) in other.labels {
self.labels.entry(k).or_insert(v);
}
}
}