Struct oci_spec::image::ImageConfiguration

source ·
pub struct ImageConfiguration { /* private fields */ }
Expand description

The image configuration is associated with an image and describes some basic information about the image such as date created, author, as well as execution/runtime configuration like its entrypoint, default arguments, networking, and volumes.

Implementations§

source§

impl ImageConfiguration

source

pub fn created(&self) -> &Option<String>

An combined date and time at which the image was created, formatted as defined by RFC 3339, section 5.6.

source

pub fn author(&self) -> &Option<String>

Gives the name and/or email address of the person or entity which created and is responsible for maintaining the image.

source

pub fn architecture(&self) -> &Arch

The CPU architecture which the binaries in this image are built to run on. Configurations SHOULD use, and implementations SHOULD understand, values listed in the Go Language document for GOARCH.

source

pub fn os(&self) -> &Os

The name of the operating system which the image is built to run on. Configurations SHOULD use, and implementations SHOULD understand, values listed in the Go Language document for GOOS.

source

pub fn os_version(&self) -> &Option<String>

This OPTIONAL property specifies the version of the operating system targeted by the referenced blob. Implementations MAY refuse to use manifests where os.version is not known to work with the host OS version. Valid values are implementation-defined. e.g. 10.0.14393.1066 on windows.

source

pub fn os_features(&self) -> &Option<Vec<String>>

This OPTIONAL property specifies an array of strings, each specifying a mandatory OS feature. When os is windows, image indexes SHOULD use, and implementations SHOULD understand the following values:

  • win32k: image requires win32k.sys on the host (Note: win32k.sys is missing on Nano Server)
source

pub fn variant(&self) -> &Option<String>

The variant of the specified CPU architecture. Configurations SHOULD use, and implementations SHOULD understand, variant values listed in the Platform Variants table.

source

pub fn config(&self) -> &Option<Config>

The execution parameters which SHOULD be used as a base when running a container using the image. This field can be None, in which case any execution parameters should be specified at creation of the container.

source

pub fn rootfs(&self) -> &RootFs

The rootfs key references the layer content addresses used by the image. This makes the image config hash depend on the filesystem hash.

source

pub fn history(&self) -> &Vec<History>

Describes the history of each layer. The array is ordered from first to last.

source§

impl ImageConfiguration

source

pub fn rootfs_mut(&mut self) -> &mut RootFs

The rootfs key references the layer content addresses used by the image. This makes the image config hash depend on the filesystem hash.

source

pub fn history_mut(&mut self) -> &mut Vec<History>

Describes the history of each layer. The array is ordered from first to last.

source§

impl ImageConfiguration

source

pub fn set_created(&mut self, val: Option<String>) -> &mut Self

An combined date and time at which the image was created, formatted as defined by RFC 3339, section 5.6.

source

pub fn set_author(&mut self, val: Option<String>) -> &mut Self

Gives the name and/or email address of the person or entity which created and is responsible for maintaining the image.

source

pub fn set_architecture(&mut self, val: Arch) -> &mut Self

The CPU architecture which the binaries in this image are built to run on. Configurations SHOULD use, and implementations SHOULD understand, values listed in the Go Language document for GOARCH.

source

pub fn set_os(&mut self, val: Os) -> &mut Self

The name of the operating system which the image is built to run on. Configurations SHOULD use, and implementations SHOULD understand, values listed in the Go Language document for GOOS.

source

pub fn set_os_version(&mut self, val: Option<String>) -> &mut Self

This OPTIONAL property specifies the version of the operating system targeted by the referenced blob. Implementations MAY refuse to use manifests where os.version is not known to work with the host OS version. Valid values are implementation-defined. e.g. 10.0.14393.1066 on windows.

source

pub fn set_os_features(&mut self, val: Option<Vec<String>>) -> &mut Self

This OPTIONAL property specifies an array of strings, each specifying a mandatory OS feature. When os is windows, image indexes SHOULD use, and implementations SHOULD understand the following values:

  • win32k: image requires win32k.sys on the host (Note: win32k.sys is missing on Nano Server)
source

pub fn set_variant(&mut self, val: Option<String>) -> &mut Self

The variant of the specified CPU architecture. Configurations SHOULD use, and implementations SHOULD understand, variant values listed in the Platform Variants table.

source

pub fn set_config(&mut self, val: Option<Config>) -> &mut Self

The execution parameters which SHOULD be used as a base when running a container using the image. This field can be None, in which case any execution parameters should be specified at creation of the container.

source

pub fn set_rootfs(&mut self, val: RootFs) -> &mut Self

The rootfs key references the layer content addresses used by the image. This makes the image config hash depend on the filesystem hash.

source

pub fn set_history(&mut self, val: Vec<History>) -> &mut Self

Describes the history of each layer. The array is ordered from first to last.

source§

impl ImageConfiguration

source

pub fn from_file<P: AsRef<Path>>(path: P) -> Result<ImageConfiguration>

Attempts to load an image configuration from a file.

§Errors

This function will return an OciSpecError::Io if the file does not exist or an OciSpecError::SerDe if the image configuration cannot be deserialized.

§Example
use oci_spec::image::ImageConfiguration;

let image_index = ImageConfiguration::from_file("config.json").unwrap();
source

pub fn from_reader<R: Read>(reader: R) -> Result<ImageConfiguration>

Attempts to load an image configuration from a stream.

§Errors

This function will return an OciSpecError::SerDe if the image configuration cannot be deserialized.

§Example
use oci_spec::image::ImageConfiguration;
use std::fs::File;

let reader = File::open("config.json").unwrap();
let image_index = ImageConfiguration::from_reader(reader).unwrap();
source

pub fn to_file<P: AsRef<Path>>(&self, path: P) -> Result<()>

Attempts to write an image configuration to a file as JSON. If the file already exists, it will be overwritten.

§Errors

This function will return an OciSpecError::SerDe if the image configuration cannot be serialized.

§Example
use oci_spec::image::ImageConfiguration;

let image_index = ImageConfiguration::from_file("config.json").unwrap();
image_index.to_file("my-config.json").unwrap();
source

pub fn to_file_pretty<P: AsRef<Path>>(&self, path: P) -> Result<()>

Attempts to write an image configuration to a file as pretty printed JSON. If the file already exists, it will be overwritten.

§Errors

This function will return an OciSpecError::SerDe if the image configuration cannot be serialized.

§Example
use oci_spec::image::ImageConfiguration;

let image_index = ImageConfiguration::from_file("config.json").unwrap();
image_index.to_file_pretty("my-config.json").unwrap();
source

pub fn to_writer<W: Write>(&self, writer: &mut W) -> Result<()>

Attempts to write an image configuration to a stream as JSON.

§Errors

This function will return an OciSpecError::SerDe if the image configuration cannot be serialized.

§Example
use oci_spec::image::ImageConfiguration;

let image_index = ImageConfiguration::from_file("config.json").unwrap();
let mut writer = Vec::new();
image_index.to_writer(&mut writer);
source

pub fn to_writer_pretty<W: Write>(&self, writer: &mut W) -> Result<()>

Attempts to write an image configuration to a stream as pretty printed JSON.

§Errors

This function will return an OciSpecError::SerDe if the image configuration cannot be serialized.

§Example
use oci_spec::image::ImageConfiguration;

let image_index = ImageConfiguration::from_file("config.json").unwrap();
let mut writer = Vec::new();
image_index.to_writer_pretty(&mut writer);
source

pub fn to_string(&self) -> Result<String>

Attempts to write an image configuration to a string as JSON.

§Errors

This function will return an OciSpecError::SerDe if the image configuration cannot be serialized.

§Example
use oci_spec::image::ImageConfiguration;

let image_configuration = ImageConfiguration::from_file("config.json").unwrap();
let json_str = image_configuration.to_string().unwrap();
source

pub fn to_string_pretty(&self) -> Result<String>

Attempts to write an image configuration to a string as pretty printed JSON.

§Errors

This function will return an OciSpecError::SerDe if the image configuration cannot be serialized.

§Example
use oci_spec::image::ImageConfiguration;

let image_configuration = ImageConfiguration::from_file("config.json").unwrap();
let json_str = image_configuration.to_string_pretty().unwrap();
source

pub fn labels_of_config(&self) -> Option<&HashMap<String, String>>

Extract the labels of the configuration, if present.

source

pub fn version(&self) -> Option<&str>

Retrieve the version number associated with this configuration. This will try to use several well-known label keys.

source

pub fn get_config_annotation(&self, key: &str) -> Option<&str>

Extract the value of a given annotation on the configuration, if present.

Trait Implementations§

source§

impl Clone for ImageConfiguration

source§

fn clone(&self) -> ImageConfiguration

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ImageConfiguration

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for ImageConfiguration

source§

fn default() -> ImageConfiguration

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for ImageConfiguration

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for ImageConfiguration

This ToString trait is automatically implemented for any type which implements the Display trait. As such, ToString shouldn’t be implemented directly: Display should be implemented instead, and you get the ToString implementation for free.

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq for ImageConfiguration

source§

fn eq(&self, other: &ImageConfiguration) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for ImageConfiguration

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Eq for ImageConfiguration

source§

impl StructuralPartialEq for ImageConfiguration

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,