Enum cni_plugin::Cni[][src]

pub enum Cni {
    Add {
        container_id: String,
        ifname: String,
        netns: PathBuf,
        path: Vec<PathBuf>,
        config: NetworkConfig,
    },
    Del {
        container_id: String,
        ifname: String,
        netns: Option<PathBuf>,
        path: Vec<PathBuf>,
        config: NetworkConfig,
    },
    Check {
        container_id: String,
        ifname: String,
        netns: PathBuf,
        path: Vec<PathBuf>,
        config: NetworkConfig,
    },
    Version(Version),
}

The main entrypoint to this plugin and the enum which contains plugin input.

See the field definitions on Inputs for more details on the command subfields.

Variants

Add

The ADD command: add namespace to network, or apply modifications.

A CNI plugin, upon receiving an ADD command, should either:

  • create the interface defined by ifname inside the namespace at the netns path, or
  • adjust the configuration of the interface defined by ifname inside the namespace at the netns path.

More details in the spec.

Fields of Add

container_id: String

The container ID, as provided by the runtime.

ifname: String

The name of the interface inside the container.

netns: PathBuf

The container’s “isolation domain” or namespace path.

path: Vec<PathBuf>

List of paths to search for CNI plugin executables.

config: NetworkConfig

The input network configuration.

Del

The DEL command: remove namespace from network, or un-apply modifications.

A CNI plugin, upon receiving a DEL command, should either:

  • delete the interface defined by ifname inside the namespace at the netns path, or
  • undo any modifications applied in the plugin’s ADD functionality.

More details in the spec.

Fields of Del

container_id: String

The container ID, as provided by the runtime.

ifname: String

The name of the interface inside the container.

netns: Option<PathBuf>

The container’s “isolation domain” or namespace path.

May not be provided for DEL commands.

path: Vec<PathBuf>

List of paths to search for CNI plugin executables.

config: NetworkConfig

The input network configuration.

Check

The CHECK command: check that a namespace’s networking is as expected.

This was introduced in CNI spec v1.0.0.

More details in the spec.

Fields of Check

container_id: String

The container ID, as provided by the runtime.

ifname: String

The name of the interface inside the container.

netns: PathBuf

The container’s “isolation domain” or namespace path.

path: Vec<PathBuf>

List of paths to search for CNI plugin executables.

config: NetworkConfig

The input network configuration.

Version(Version)

The VERSION command: used to probe plugin version support.

The plugin should reply with a VersionReply.

Note that when using Cni::load(), this command is already handled, and you should mark this unreachable!.

Implementations

impl Cni[src]

pub fn from_env() -> Result<Self, CniError>[src]

Reads the plugin inputs from the environment and STDIN.

This reads and validates the required CNI_* environment variables, and the STDIN for a JSON-encoded input object, but it does not output anything to STDOUT nor exits the process, nor does it panic.

Note that as per convention, the CNI_ARGS variable is deprecated, and this library deliberately chooses to ignore it. You may of course read and parse it yourself.

A number of things are logged in here. If you have used [install_logger][crate::install_logger], this may result in output being sent to STDERR (and/or to file).

In general you should prefer Cni::load().

pub fn load() -> Self[src]

Reads the plugin inputs from the environment and STDIN and reacts to errors and the VERSION command.

This does the same thing as Cni::from_env() but it also immediately replies to the VERSION command, and also immediately replies if errors result from reading the inputs, both of which write to STDOUT and exit.

This version also logs a debug message with the name and version of this library crate.

impl Cni[src]

pub fn into_inputs(self) -> Option<Inputs>[src]

Converts this enum into an alternate representation which holds the Command separately from the inputs.

This is useful to deduplicate prep work between command implementations.

Trait Implementations

impl Clone for Cni[src]

impl Debug for Cni[src]

Auto Trait Implementations

impl RefUnwindSafe for Cni

impl Send for Cni

impl Sync for Cni

impl Unpin for Cni

impl UnwindSafe for Cni

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.