use std::path::PathBuf;
#[derive(Debug, Clone)]
pub struct Config {
pub storage_root: Option<PathBuf>,
pub run_root: Option<PathBuf>,
pub storage_driver: Option<StorageDriver>,
pub storage_opts: Vec<String>,
pub registries_conf: Option<PathBuf>,
pub signature_policy: Option<PathBuf>,
pub auth_file: Option<PathBuf>,
pub insecure: bool,
pub log_level: LogLevel,
}
impl Default for Config {
fn default() -> Self {
Self {
storage_root: None,
run_root: None,
storage_driver: None,
storage_opts: Vec::new(),
registries_conf: None,
signature_policy: None,
auth_file: None,
insecure: false,
log_level: LogLevel::Warn,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum StorageDriver {
Overlay,
Vfs,
}
impl StorageDriver {
pub(crate) fn as_abi(self) -> &'static str {
match self {
Self::Overlay => "overlay",
Self::Vfs => "vfs",
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum LogLevel {
Trace,
Debug,
Info,
#[default]
Warn,
Error,
}
impl LogLevel {
pub(crate) fn as_abi(self) -> &'static str {
match self {
Self::Trace => "trace",
Self::Debug => "debug",
Self::Info => "info",
Self::Warn => "warn",
Self::Error => "error",
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum Isolation {
#[default]
Default,
Oci,
Rootless,
Chroot,
}
impl Isolation {
pub(crate) fn as_abi(self) -> &'static str {
match self {
Self::Default => "",
Self::Oci => "oci",
Self::Rootless => "rootless",
Self::Chroot => "chroot",
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum ImageFormat {
#[default]
Oci,
Docker,
}
impl ImageFormat {
pub(crate) fn as_abi(self) -> &'static str {
match self {
Self::Oci => "oci",
Self::Docker => "docker",
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum PullPolicy {
#[default]
IfMissing,
Always,
IfNewer,
Never,
}
impl PullPolicy {
pub(crate) fn as_abi(self) -> &'static str {
match self {
Self::IfMissing => "missing",
Self::Always => "always",
Self::IfNewer => "ifnewer",
Self::Never => "never",
}
}
}