use crate::error::OciSpecError;
use derive_builder::Builder;
use getset::{Getters, Setters};
use serde::{Deserialize, Serialize};
use std::path::PathBuf;
#[derive(
Builder, Clone, Debug, Default, Deserialize, Getters, Setters, Eq, PartialEq, Serialize,
)]
#[builder(
default,
pattern = "owned",
setter(into, strip_option),
build_fn(error = "OciSpecError")
)]
#[getset(get = "pub", set = "pub")]
pub struct VM {
#[serde(default, skip_serializing_if = "Option::is_none")]
hypervisor: Option<VMHypervisor>,
kernel: VMKernel,
#[serde(default, skip_serializing_if = "Option::is_none")]
image: Option<VMImage>,
}
#[derive(
Builder, Clone, Debug, Default, Deserialize, Getters, Setters, Eq, PartialEq, Serialize,
)]
#[builder(
default,
pattern = "owned",
setter(into, strip_option),
build_fn(error = "OciSpecError")
)]
#[getset(get = "pub", set = "pub")]
pub struct VMHypervisor {
path: PathBuf,
#[serde(default, skip_serializing_if = "Option::is_none")]
parameters: Option<Vec<String>>,
}
#[derive(
Builder, Clone, Debug, Default, Deserialize, Getters, Setters, Eq, PartialEq, Serialize,
)]
#[builder(
default,
pattern = "owned",
setter(into, strip_option),
build_fn(error = "OciSpecError")
)]
#[getset(get = "pub", set = "pub")]
pub struct VMKernel {
path: PathBuf,
#[serde(default, skip_serializing_if = "Option::is_none")]
parameters: Option<Vec<String>>,
#[serde(default, skip_serializing_if = "Option::is_none")]
initrd: Option<String>,
}
#[derive(
Builder, Clone, Debug, Default, Deserialize, Getters, Setters, Eq, PartialEq, Serialize,
)]
#[builder(
default,
pattern = "owned",
setter(into, strip_option),
build_fn(error = "OciSpecError")
)]
#[getset(get = "pub", set = "pub")]
pub struct VMImage {
path: PathBuf,
format: String,
}