Enum cni_plugin::Cni [−][src]
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
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 thenetns
path, or - adjust the configuration of the interface defined by
ifname
inside the namespace at thenetns
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.
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 thenetns
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.
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
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,