pub struct Spec { /* private fields */ }
Expand description
Base configuration for the container.
Implementations§
source§impl Spec
impl Spec
sourcepub fn version(&self) -> &String
pub fn version(&self) -> &String
MUST be in SemVer v2.0.0 format and specifies the version of the Open Container Initiative Runtime Specification with which the bundle complies. The Open Container Initiative Runtime Specification follows semantic versioning and retains forward and backward compatibility within major versions. For example, if a configuration is compliant with version 1.1 of this specification, it is compatible with all runtimes that support any 1.1 or later release of this specification, but is not compatible with a runtime that supports 1.0 and not 1.1.
sourcepub fn root(&self) -> &Option<Root>
pub fn root(&self) -> &Option<Root>
Specifies the container’s root filesystem. On Windows, for Windows Server Containers, this field is REQUIRED. For Hyper-V Containers, this field MUST NOT be set.
On all other platforms, this field is REQUIRED.
sourcepub fn mounts(&self) -> &Option<Vec<Mount>>
pub fn mounts(&self) -> &Option<Vec<Mount>>
Specifies additional mounts beyond root
. The runtime MUST mount
entries in the listed order.
For Linux, the parameters are as documented in
mount(2)
system call man page. For
Solaris, the mount entry corresponds to the ‘fs’ resource in the
zonecfg(1M)
man page.
sourcepub fn process(&self) -> &Option<Process>
pub fn process(&self) -> &Option<Process>
Specifies the container process. This property is REQUIRED when
start
is
called.
sourcepub fn hostname(&self) -> &Option<String>
pub fn hostname(&self) -> &Option<String>
Specifies the container’s hostname as seen by processes running inside the container. On Linux, for example, this will change the hostname in the container UTS namespace. Depending on your namespace configuration, the container UTS namespace may be the runtime UTS namespace.
sourcepub fn domainname(&self) -> &Option<String>
pub fn domainname(&self) -> &Option<String>
Specifies the container’s domainame as seen by processes running inside the container. On Linux, for example, this will change the domainame in the container UTS namespace. Depending on your namespace configuration, the container UTS namespace may be the runtime UTS namespace.
sourcepub fn hooks(&self) -> &Option<Hooks>
pub fn hooks(&self) -> &Option<Hooks>
Hooks allow users to specify programs to run before or after various lifecycle events. Hooks MUST be called in the listed order. The state of the container MUST be passed to hooks over stdin so that they may do work appropriate to the current state of the container.
sourcepub fn annotations(&self) -> &Option<HashMap<String, String>>
pub fn annotations(&self) -> &Option<HashMap<String, String>>
Annotations contains arbitrary metadata for the container. This information MAY be structured or unstructured. Annotations MUST be a key-value map. If there are no annotations then this property MAY either be absent or an empty map.
Keys MUST be strings. Keys MUST NOT be an empty string. Keys SHOULD be named using a reverse domain notation - e.g. com.example.myKey. Keys using the org.opencontainers namespace are reserved and MUST NOT be used by subsequent specifications. Runtimes MUST handle unknown annotation keys like any other unknown property.
Values MUST be strings. Values MAY be an empty string.
sourcepub fn linux(&self) -> &Option<Linux>
pub fn linux(&self) -> &Option<Linux>
Linux is platform-specific configuration for Linux based containers.
sourcepub fn solaris(&self) -> &Option<Solaris>
pub fn solaris(&self) -> &Option<Solaris>
Solaris is platform-specific configuration for Solaris based containers.
sourcepub fn windows(&self) -> &Option<Windows>
pub fn windows(&self) -> &Option<Windows>
Windows is platform-specific configuration for Windows based containers.
sourcepub fn vm(&self) -> &Option<VM>
pub fn vm(&self) -> &Option<VM>
VM specifies configuration for Virtual Machine based containers.
sourcepub fn uid_mappings(&self) -> &Option<Vec<LinuxIdMapping>>
pub fn uid_mappings(&self) -> &Option<Vec<LinuxIdMapping>>
UID mappings used for changing file owners w/o calling chown, fs should support it. Every mount point could have its own mapping.
sourcepub fn gid_mappings(&self) -> &Option<Vec<LinuxIdMapping>>
pub fn gid_mappings(&self) -> &Option<Vec<LinuxIdMapping>>
GID mappings used for changing file owners w/o calling chown, fs should support it. Every mount point could have its own mapping.
source§impl Spec
impl Spec
sourcepub fn version_mut(&mut self) -> &mut String
pub fn version_mut(&mut self) -> &mut String
MUST be in SemVer v2.0.0 format and specifies the version of the Open Container Initiative Runtime Specification with which the bundle complies. The Open Container Initiative Runtime Specification follows semantic versioning and retains forward and backward compatibility within major versions. For example, if a configuration is compliant with version 1.1 of this specification, it is compatible with all runtimes that support any 1.1 or later release of this specification, but is not compatible with a runtime that supports 1.0 and not 1.1.
sourcepub fn root_mut(&mut self) -> &mut Option<Root>
pub fn root_mut(&mut self) -> &mut Option<Root>
Specifies the container’s root filesystem. On Windows, for Windows Server Containers, this field is REQUIRED. For Hyper-V Containers, this field MUST NOT be set.
On all other platforms, this field is REQUIRED.
sourcepub fn mounts_mut(&mut self) -> &mut Option<Vec<Mount>>
pub fn mounts_mut(&mut self) -> &mut Option<Vec<Mount>>
Specifies additional mounts beyond root
. The runtime MUST mount
entries in the listed order.
For Linux, the parameters are as documented in
mount(2)
system call man page. For
Solaris, the mount entry corresponds to the ‘fs’ resource in the
zonecfg(1M)
man page.
sourcepub fn process_mut(&mut self) -> &mut Option<Process>
pub fn process_mut(&mut self) -> &mut Option<Process>
Specifies the container process. This property is REQUIRED when
start
is
called.
sourcepub fn hostname_mut(&mut self) -> &mut Option<String>
pub fn hostname_mut(&mut self) -> &mut Option<String>
Specifies the container’s hostname as seen by processes running inside the container. On Linux, for example, this will change the hostname in the container UTS namespace. Depending on your namespace configuration, the container UTS namespace may be the runtime UTS namespace.
sourcepub fn domainname_mut(&mut self) -> &mut Option<String>
pub fn domainname_mut(&mut self) -> &mut Option<String>
Specifies the container’s domainame as seen by processes running inside the container. On Linux, for example, this will change the domainame in the container UTS namespace. Depending on your namespace configuration, the container UTS namespace may be the runtime UTS namespace.
sourcepub fn hooks_mut(&mut self) -> &mut Option<Hooks>
pub fn hooks_mut(&mut self) -> &mut Option<Hooks>
Hooks allow users to specify programs to run before or after various lifecycle events. Hooks MUST be called in the listed order. The state of the container MUST be passed to hooks over stdin so that they may do work appropriate to the current state of the container.
sourcepub fn annotations_mut(&mut self) -> &mut Option<HashMap<String, String>>
pub fn annotations_mut(&mut self) -> &mut Option<HashMap<String, String>>
Annotations contains arbitrary metadata for the container. This information MAY be structured or unstructured. Annotations MUST be a key-value map. If there are no annotations then this property MAY either be absent or an empty map.
Keys MUST be strings. Keys MUST NOT be an empty string. Keys SHOULD be named using a reverse domain notation - e.g. com.example.myKey. Keys using the org.opencontainers namespace are reserved and MUST NOT be used by subsequent specifications. Runtimes MUST handle unknown annotation keys like any other unknown property.
Values MUST be strings. Values MAY be an empty string.
sourcepub fn linux_mut(&mut self) -> &mut Option<Linux>
pub fn linux_mut(&mut self) -> &mut Option<Linux>
Linux is platform-specific configuration for Linux based containers.
sourcepub fn solaris_mut(&mut self) -> &mut Option<Solaris>
pub fn solaris_mut(&mut self) -> &mut Option<Solaris>
Solaris is platform-specific configuration for Solaris based containers.
sourcepub fn windows_mut(&mut self) -> &mut Option<Windows>
pub fn windows_mut(&mut self) -> &mut Option<Windows>
Windows is platform-specific configuration for Windows based containers.
sourcepub fn vm_mut(&mut self) -> &mut Option<VM>
pub fn vm_mut(&mut self) -> &mut Option<VM>
VM specifies configuration for Virtual Machine based containers.
sourcepub fn uid_mappings_mut(&mut self) -> &mut Option<Vec<LinuxIdMapping>>
pub fn uid_mappings_mut(&mut self) -> &mut Option<Vec<LinuxIdMapping>>
UID mappings used for changing file owners w/o calling chown, fs should support it. Every mount point could have its own mapping.
sourcepub fn gid_mappings_mut(&mut self) -> &mut Option<Vec<LinuxIdMapping>>
pub fn gid_mappings_mut(&mut self) -> &mut Option<Vec<LinuxIdMapping>>
GID mappings used for changing file owners w/o calling chown, fs should support it. Every mount point could have its own mapping.
source§impl Spec
impl Spec
sourcepub fn set_version(&mut self, val: String) -> &mut Self
pub fn set_version(&mut self, val: String) -> &mut Self
MUST be in SemVer v2.0.0 format and specifies the version of the Open Container Initiative Runtime Specification with which the bundle complies. The Open Container Initiative Runtime Specification follows semantic versioning and retains forward and backward compatibility within major versions. For example, if a configuration is compliant with version 1.1 of this specification, it is compatible with all runtimes that support any 1.1 or later release of this specification, but is not compatible with a runtime that supports 1.0 and not 1.1.
sourcepub fn set_root(&mut self, val: Option<Root>) -> &mut Self
pub fn set_root(&mut self, val: Option<Root>) -> &mut Self
Specifies the container’s root filesystem. On Windows, for Windows Server Containers, this field is REQUIRED. For Hyper-V Containers, this field MUST NOT be set.
On all other platforms, this field is REQUIRED.
sourcepub fn set_mounts(&mut self, val: Option<Vec<Mount>>) -> &mut Self
pub fn set_mounts(&mut self, val: Option<Vec<Mount>>) -> &mut Self
Specifies additional mounts beyond root
. The runtime MUST mount
entries in the listed order.
For Linux, the parameters are as documented in
mount(2)
system call man page. For
Solaris, the mount entry corresponds to the ‘fs’ resource in the
zonecfg(1M)
man page.
sourcepub fn set_process(&mut self, val: Option<Process>) -> &mut Self
pub fn set_process(&mut self, val: Option<Process>) -> &mut Self
Specifies the container process. This property is REQUIRED when
start
is
called.
sourcepub fn set_hostname(&mut self, val: Option<String>) -> &mut Self
pub fn set_hostname(&mut self, val: Option<String>) -> &mut Self
Specifies the container’s hostname as seen by processes running inside the container. On Linux, for example, this will change the hostname in the container UTS namespace. Depending on your namespace configuration, the container UTS namespace may be the runtime UTS namespace.
sourcepub fn set_domainname(&mut self, val: Option<String>) -> &mut Self
pub fn set_domainname(&mut self, val: Option<String>) -> &mut Self
Specifies the container’s domainame as seen by processes running inside the container. On Linux, for example, this will change the domainame in the container UTS namespace. Depending on your namespace configuration, the container UTS namespace may be the runtime UTS namespace.
sourcepub fn set_hooks(&mut self, val: Option<Hooks>) -> &mut Self
pub fn set_hooks(&mut self, val: Option<Hooks>) -> &mut Self
Hooks allow users to specify programs to run before or after various lifecycle events. Hooks MUST be called in the listed order. The state of the container MUST be passed to hooks over stdin so that they may do work appropriate to the current state of the container.
sourcepub fn set_annotations(
&mut self,
val: Option<HashMap<String, String>>,
) -> &mut Self
pub fn set_annotations( &mut self, val: Option<HashMap<String, String>>, ) -> &mut Self
Annotations contains arbitrary metadata for the container. This information MAY be structured or unstructured. Annotations MUST be a key-value map. If there are no annotations then this property MAY either be absent or an empty map.
Keys MUST be strings. Keys MUST NOT be an empty string. Keys SHOULD be named using a reverse domain notation - e.g. com.example.myKey. Keys using the org.opencontainers namespace are reserved and MUST NOT be used by subsequent specifications. Runtimes MUST handle unknown annotation keys like any other unknown property.
Values MUST be strings. Values MAY be an empty string.
sourcepub fn set_linux(&mut self, val: Option<Linux>) -> &mut Self
pub fn set_linux(&mut self, val: Option<Linux>) -> &mut Self
Linux is platform-specific configuration for Linux based containers.
sourcepub fn set_solaris(&mut self, val: Option<Solaris>) -> &mut Self
pub fn set_solaris(&mut self, val: Option<Solaris>) -> &mut Self
Solaris is platform-specific configuration for Solaris based containers.
sourcepub fn set_windows(&mut self, val: Option<Windows>) -> &mut Self
pub fn set_windows(&mut self, val: Option<Windows>) -> &mut Self
Windows is platform-specific configuration for Windows based containers.
sourcepub fn set_vm(&mut self, val: Option<VM>) -> &mut Self
pub fn set_vm(&mut self, val: Option<VM>) -> &mut Self
VM specifies configuration for Virtual Machine based containers.
sourcepub fn set_uid_mappings(
&mut self,
val: Option<Vec<LinuxIdMapping>>,
) -> &mut Self
pub fn set_uid_mappings( &mut self, val: Option<Vec<LinuxIdMapping>>, ) -> &mut Self
UID mappings used for changing file owners w/o calling chown, fs should support it. Every mount point could have its own mapping.
sourcepub fn set_gid_mappings(
&mut self,
val: Option<Vec<LinuxIdMapping>>,
) -> &mut Self
pub fn set_gid_mappings( &mut self, val: Option<Vec<LinuxIdMapping>>, ) -> &mut Self
GID mappings used for changing file owners w/o calling chown, fs should support it. Every mount point could have its own mapping.
source§impl Spec
impl Spec
sourcepub fn load<P: AsRef<Path>>(path: P) -> Result<Self>
pub fn load<P: AsRef<Path>>(path: P) -> Result<Self>
Load a new Spec
from the provided JSON file path
.
§Errors
This function will return an OciSpecError::Io if the spec does not exist or an OciSpecError::SerDe if it is invalid.
§Example
use oci_spec::runtime::Spec;
let spec = Spec::load("config.json").unwrap();
sourcepub fn save<P: AsRef<Path>>(&self, path: P) -> Result<()>
pub fn save<P: AsRef<Path>>(&self, path: P) -> Result<()>
Save a Spec
to the provided JSON file path
.
§Errors
This function will return an OciSpecError::Io if a file cannot be created at the provided path or an OciSpecError::SerDe if the spec cannot be serialized.
§Example
use oci_spec::runtime::Spec;
let mut spec = Spec::load("config.json").unwrap();
spec.save("my_config.json").unwrap();
Trait Implementations§
source§impl<'de> Deserialize<'de> for Spec
impl<'de> Deserialize<'de> for Spec
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl PartialEq for Spec
impl PartialEq for Spec
impl Eq for Spec
impl StructuralPartialEq for Spec
Auto Trait Implementations§
impl Freeze for Spec
impl RefUnwindSafe for Spec
impl Send for Spec
impl Sync for Spec
impl Unpin for Spec
impl UnwindSafe for Spec
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)