oci_spec::image

Struct 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>,