diff --git a/src/runtime/hooks.rs b/src/runtime/hooks.rs index c3eafdbb6d..c45cecf22e 100644 --- a/src/runtime/hooks.rs +++ b/src/runtime/hooks.rs @@ -1,11 +1,21 @@ use crate::error::OciSpecError; use derive_builder::Builder; -use getset::{CopyGetters, Getters, Setters}; +use getset::{CopyGetters, Getters, MutGetters, Setters}; use serde::{Deserialize, Serialize}; use std::path::PathBuf; #[derive( - Builder, Clone, Debug, Default, Deserialize, Eq, Getters, Setters, PartialEq, Serialize, + Builder, + Clone, + Debug, + Default, + Deserialize, + Eq, + MutGetters, + Getters, + Setters, + PartialEq, + Serialize, )] #[serde(rename_all = "camelCase")] #[builder( @@ -14,7 +24,7 @@ use std::path::PathBuf; setter(into, strip_option), build_fn(error = "OciSpecError") )] -#[getset(get = "pub", set = "pub")] +#[getset(get_mut = "pub", get = "pub", set = "pub")] /// Hooks specifies a command that is run in the container at a particular /// event in the lifecycle (setup and teardown) of a container. pub struct Hooks { @@ -75,6 +85,7 @@ pub struct Hooks { Deserialize, Eq, Getters, + MutGetters, Setters, PartialEq, Serialize, @@ -88,7 +99,7 @@ pub struct Hooks { /// Hook specifies a command that is run at a particular event in the /// lifecycle of a container. pub struct Hook { - #[getset(get = "pub", set = "pub")] + #[getset(get_mut = "pub", get = "pub", set = "pub")] /// Path to the binary to be executed. Following similar semantics to /// [IEEE Std 1003.1-2008 `execv`'s path](https://pubs.opengroup.org/onlinepubs/9699919799/functions/exec.html). This /// specification extends the IEEE standard in that path MUST be @@ -96,20 +107,20 @@ pub struct Hook { path: PathBuf, #[serde(default, skip_serializing_if = "Option::is_none")] - #[getset(get = "pub", set = "pub")] + #[getset(get_mut = "pub", get = "pub", set = "pub")] /// Arguments used for the binary, including the binary name itself. /// Following the same semantics as [IEEE Std 1003.1-2008 /// `execv`'s argv](https://pubs.opengroup.org/onlinepubs/9699919799/functions/exec.html). args: Option>, #[serde(default, skip_serializing_if = "Option::is_none")] - #[getset(get = "pub", set = "pub")] + #[getset(get_mut = "pub", get = "pub", set = "pub")] /// Additional `key=value` environment variables. Following the same /// semantics as [IEEE Std 1003.1-2008's `environ`](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_01). env: Option>, #[serde(default, skip_serializing_if = "Option::is_none")] - #[getset(get_copy = "pub", set = "pub")] + #[getset(get_mut = "pub", get_copy = "pub", set = "pub")] /// Timeout is the number of seconds before aborting the hook. If set, /// timeout MUST be greater than zero. timeout: Option, diff --git a/src/runtime/linux.rs b/src/runtime/linux.rs index fdb37fc2c3..7ebe27a4dc 100644 --- a/src/runtime/linux.rs +++ b/src/runtime/linux.rs @@ -1,11 +1,13 @@ use crate::error::{oci_error, OciSpecError}; use derive_builder::Builder; -use getset::{CopyGetters, Getters, Setters}; +use getset::{CopyGetters, Getters, MutGetters, Setters}; use serde::{Deserialize, Serialize}; use std::{collections::HashMap, path::PathBuf, vec}; -#[derive(Builder, Clone, Debug, Deserialize, Eq, Getters, Setters, PartialEq, Serialize)] +#[derive( + Builder, Clone, Debug, Deserialize, Eq, Getters, MutGetters, Setters, PartialEq, Serialize, +)] #[serde(rename_all = "camelCase")] #[builder( default, @@ -13,7 +15,7 @@ use std::{collections::HashMap, path::PathBuf, vec}; setter(into, strip_option), build_fn(error = "OciSpecError") )] -#[getset(get = "pub", set = "pub")] +#[getset(get_mut = "pub", get = "pub", set = "pub")] /// Linux contains platform-specific configuration for Linux based /// containers. pub struct Linux { @@ -240,6 +242,7 @@ impl LinuxDeviceType { Deserialize, Eq, Getters, + MutGetters, Setters, PartialEq, Serialize, @@ -254,28 +257,28 @@ impl LinuxDeviceType { /// controller pub struct LinuxDeviceCgroup { #[serde(default)] - #[getset(get_copy = "pub", set = "pub")] + #[getset(get_mut = "pub", get_copy = "pub", set = "pub")] /// Allow or deny allow: bool, #[serde(default, rename = "type", skip_serializing_if = "Option::is_none")] - #[getset(get_copy = "pub", set = "pub")] + #[getset(get_mut = "pub", get_copy = "pub", set = "pub")] /// Device type, block, char, etc. typ: Option, #[serde(default, skip_serializing_if = "Option::is_none")] - #[getset(get_copy = "pub", set = "pub")] + #[getset(get_mut = "pub", get_copy = "pub", set = "pub")] /// Device's major number major: Option, #[serde(default, skip_serializing_if = "Option::is_none")] - #[getset(get_copy = "pub", set = "pub")] + #[getset(get_mut = "pub", get_copy = "pub", set = "pub")] /// Device's minor number minor: Option, /// Cgroup access premissions format, rwm. #[serde(default)] - #[getset(get = "pub", set = "pub")] + #[getset(get_mut = "pub", get = "pub", set = "pub")] access: Option, } @@ -688,6 +691,7 @@ pub struct LinuxNetwork { Deserialize, Eq, Getters, + MutGetters, Setters, PartialEq, Serialize, @@ -702,55 +706,65 @@ pub struct LinuxNetwork { /// Resource constraints for container pub struct LinuxResources { #[serde(default, skip_serializing_if = "Option::is_none")] - #[getset(get = "pub", set = "pub")] + #[getset(get_mut = "pub", get = "pub", set = "pub")] /// Devices configures the device allowlist. devices: Option>, #[serde(default, skip_serializing_if = "Option::is_none")] - #[getset(get = "pub", set = "pub")] + #[getset(get_mut = "pub", get = "pub", set = "pub")] /// Memory restriction configuration. memory: Option, #[serde(default, skip_serializing_if = "Option::is_none")] - #[getset(get = "pub", set = "pub")] + #[getset(get_mut = "pub", get = "pub", set = "pub")] /// CPU resource restriction configuration. cpu: Option, #[serde(default, skip_serializing_if = "Option::is_none")] - #[getset(get = "pub", set = "pub")] + #[getset(get_mut = "pub", get = "pub", set = "pub")] /// Task resource restrictions pids: Option, #[serde(default, skip_serializing_if = "Option::is_none", rename = "blockIO")] - #[getset(get = "pub", set = "pub")] + #[getset(get_mut = "pub", get = "pub", set = "pub")] /// BlockIO restriction configuration. block_io: Option, #[serde(default, skip_serializing_if = "Option::is_none")] - #[getset(get = "pub", set = "pub")] + #[getset(get_mut = "pub", get = "pub", set = "pub")] /// Hugetlb limit (in bytes). hugepage_limits: Option>, #[serde(default, skip_serializing_if = "Option::is_none")] - #[getset(get = "pub", set = "pub")] + #[getset(get_mut = "pub", get = "pub", set = "pub")] /// Network restriction configuration. network: Option, #[serde(default, skip_serializing_if = "Option::is_none")] - #[getset(get = "pub", set = "pub")] + #[getset(get_mut = "pub", get = "pub", set = "pub")] /// Rdma resource restriction configuration. Limits are a set of key /// value pairs that define RDMA resource limits, where the key /// is device name and value is resource limits. rdma: Option>, #[serde(default, skip_serializing_if = "Option::is_none")] - #[getset(get = "pub", set = "pub")] + #[getset(get_mut = "pub", get = "pub", set = "pub")] /// Unified resources. unified: Option>, } #[derive( - Builder, Clone, Copy, CopyGetters, Debug, Default, Deserialize, Eq, PartialEq, Serialize, + Builder, + Clone, + Copy, + CopyGetters, + Debug, + Default, + Deserialize, + Eq, + MutGetters, + PartialEq, + Serialize, )] #[serde(rename_all = "camelCase")] #[builder( @@ -759,7 +773,7 @@ pub struct LinuxResources { setter(into, strip_option), build_fn(error = "OciSpecError") )] -#[getset(get_copy = "pub", set = "pub")] +#[getset(get_mut = "pub", get_copy = "pub", set = "pub")] /// LinuxRdma for Linux cgroup 'rdma' resource management (Linux 4.11). pub struct LinuxRdma { #[serde(skip_serializing_if = "Option::is_none")] @@ -900,6 +914,7 @@ pub fn get_default_namespaces() -> Vec { Deserialize, Eq, Getters, + MutGetters, Setters, PartialEq, Serialize, @@ -915,37 +930,37 @@ pub fn get_default_namespaces() -> Vec { /// file. pub struct LinuxDevice { #[serde(default)] - #[getset(get = "pub", set = "pub")] + #[getset(get_mut = "pub", get = "pub", set = "pub")] /// Path to the device. path: PathBuf, #[serde(rename = "type")] - #[getset(get_copy = "pub", set = "pub")] + #[getset(get_mut = "pub", get_copy = "pub", set = "pub")] /// Device type, block, char, etc.. typ: LinuxDeviceType, #[serde(default)] - #[getset(get_copy = "pub", set = "pub")] + #[getset(get_mut = "pub", get_copy = "pub", set = "pub")] /// Major is the device's major number. major: i64, #[serde(default)] - #[getset(get_copy = "pub", set = "pub")] + #[getset(get_mut = "pub", get_copy = "pub", set = "pub")] /// Minor is the device's minor number. minor: i64, #[serde(default, skip_serializing_if = "Option::is_none")] - #[getset(get_copy = "pub", set = "pub")] + #[getset(get_mut = "pub", get_copy = "pub", set = "pub")] /// FileMode permission bits for the device. file_mode: Option, #[serde(default, skip_serializing_if = "Option::is_none")] - #[getset(get_copy = "pub", set = "pub")] + #[getset(get_mut = "pub", get_copy = "pub", set = "pub")] /// UID of the device. uid: Option, #[serde(default, skip_serializing_if = "Option::is_none")] - #[getset(get_copy = "pub", set = "pub")] + #[getset(get_mut = "pub", get_copy = "pub", set = "pub")] /// Gid of the device. gid: Option, } @@ -1271,7 +1286,17 @@ pub fn get_default_readonly_paths() -> Vec { } #[derive( - Builder, Clone, Debug, Default, Deserialize, Eq, Getters, Setters, PartialEq, Serialize, + Builder, + Clone, + Debug, + Default, + Deserialize, + Eq, + Getters, + MutGetters, + Setters, + PartialEq, + Serialize, )] #[serde(rename_all = "camelCase")] #[builder( @@ -1280,7 +1305,7 @@ pub fn get_default_readonly_paths() -> Vec { setter(into, strip_option), build_fn(error = "OciSpecError") )] -#[getset(get = "pub", set = "pub")] +#[getset(get_mut = "pub", get = "pub", set = "pub")] /// LinuxIntelRdt has container runtime resource constraints for Intel RDT CAT and MBA /// features and flags enabling Intel RDT CMT and MBM features. /// Intel RDT features are available in Linux 4.14 and newer kernel versions. diff --git a/src/runtime/miscellaneous.rs b/src/runtime/miscellaneous.rs index 5c2415ccc1..73a9a7f399 100644 --- a/src/runtime/miscellaneous.rs +++ b/src/runtime/miscellaneous.rs @@ -1,6 +1,6 @@ use crate::error::OciSpecError; use derive_builder::Builder; -use getset::{CopyGetters, Getters, Setters}; +use getset::{CopyGetters, Getters, MutGetters, Setters}; use serde::{Deserialize, Serialize}; use std::path::PathBuf; @@ -40,7 +40,17 @@ impl Default for Root { } #[derive( - Builder, Clone, Debug, Default, Deserialize, Eq, Getters, Setters, PartialEq, Serialize, + Builder, + Clone, + Debug, + Default, + Deserialize, + Eq, + Getters, + MutGetters, + Setters, + PartialEq, + Serialize, )] #[builder( default, @@ -48,7 +58,7 @@ impl Default for Root { setter(into, strip_option), build_fn(error = "OciSpecError") )] -#[getset(get = "pub", set = "pub")] +#[getset(get_mut = "pub", get = "pub", set = "pub")] /// Mount specifies a mount for a container. pub struct Mount { /// Destination is the absolute path where the mount will be placed in diff --git a/src/runtime/mod.rs b/src/runtime/mod.rs index a681c81e80..5dbed9357f 100644 --- a/src/runtime/mod.rs +++ b/src/runtime/mod.rs @@ -1,7 +1,7 @@ //! [OCI runtime spec](https://github.com/opencontainers/runtime-spec) types and definitions. use derive_builder::Builder; -use getset::{Getters, Setters}; +use getset::{Getters, MutGetters, Setters}; use serde::{Deserialize, Serialize}; use std::{ collections::HashMap, @@ -35,7 +35,9 @@ pub use vm::*; pub use windows::*; /// Base configuration for the container. -#[derive(Builder, Clone, Debug, Deserialize, Getters, Setters, PartialEq, Eq, Serialize)] +#[derive( + Builder, Clone, Debug, Deserialize, Getters, MutGetters, Setters, PartialEq, Eq, Serialize, +)] #[serde(rename_all = "camelCase")] #[builder( default, @@ -43,7 +45,7 @@ pub use windows::*; setter(into, strip_option), build_fn(error = "OciSpecError") )] -#[getset(get = "pub", set = "pub")] +#[getset(get_mut = "pub", get = "pub", set = "pub")] pub struct Spec { #[serde(default, rename = "ociVersion")] /// MUST be in SemVer v2.0.0 format and specifies the version of the diff --git a/src/runtime/process.rs b/src/runtime/process.rs index 69a1f02216..b6cc005e95 100644 --- a/src/runtime/process.rs +++ b/src/runtime/process.rs @@ -3,12 +3,22 @@ use crate::{ runtime::{Capabilities, Capability}, }; use derive_builder::Builder; -use getset::{CopyGetters, Getters, Setters}; +use getset::{CopyGetters, Getters, MutGetters, Setters}; use serde::{Deserialize, Serialize}; use std::path::PathBuf; #[derive( - Builder, Clone, CopyGetters, Debug, Deserialize, Getters, Setters, Eq, PartialEq, Serialize, + Builder, + Clone, + CopyGetters, + Debug, + Deserialize, + Getters, + MutGetters, + Setters, + Eq, + PartialEq, + Serialize, )] #[serde(rename_all = "camelCase")] #[builder( @@ -30,7 +40,7 @@ pub struct Process { /// ConsoleSize specifies the size of the console. console_size: Option, - #[getset(get = "pub", set = "pub")] + #[getset(get_mut = "pub", get = "pub", set = "pub")] /// User specifies user information for the process. user: User, @@ -41,13 +51,13 @@ pub struct Process { args: Option>, #[serde(default, skip_serializing_if = "Option::is_none")] - #[getset(get = "pub", set = "pub")] + #[getset(get_mut = "pub", get = "pub", set = "pub")] /// CommandLine specifies the full command line for the application to /// execute on Windows. command_line: Option, #[serde(default, skip_serializing_if = "Option::is_none")] - #[getset(get = "pub", set = "pub")] + #[getset(get_mut = "pub", get = "pub", set = "pub")] /// Env populates the process environment for the process. env: Option>, @@ -265,6 +275,7 @@ pub struct LinuxRlimit { Default, Deserialize, Getters, + MutGetters, Setters, Eq, PartialEq, @@ -280,28 +291,28 @@ pub struct LinuxRlimit { /// User id (uid) and group id (gid) tracks file permssions. pub struct User { #[serde(default)] - #[getset(get_copy = "pub", set = "pub")] + #[getset(get_mut = "pub", get_copy = "pub", set = "pub")] /// UID is the user id. uid: u32, #[serde(default)] - #[getset(get_copy = "pub", set = "pub")] + #[getset(get_mut = "pub", get_copy = "pub", set = "pub")] /// GID is the group id. gid: u32, #[serde(default, skip_serializing_if = "Option::is_none")] - #[getset(get_copy = "pub", set = "pub")] + #[getset(get_mut = "pub", get_copy = "pub", set = "pub")] /// Specifies the umask of the user. umask: Option, #[serde(default, skip_serializing_if = "Option::is_none")] - #[getset(get = "pub", set = "pub")] + #[getset(get_mut = "pub", get = "pub", set = "pub")] /// AdditionalGids are additional group ids set for the container's /// process. additional_gids: Option>, #[serde(default, skip_serializing_if = "Option::is_none")] - #[getset(get = "pub", set = "pub")] + #[getset(get_mut = "pub", get = "pub", set = "pub")] /// Username is the user name. username: Option, }