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),
}Expand description
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
ifnameinside the namespace at thenetnspath, or - adjust the configuration of the interface defined by
ifnameinside the namespace at thenetnspath.
More details in the spec.
Fields
config: NetworkConfigThe 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
ifnameinside the namespace at thenetnspath, or - undo any modifications applied in the plugin’s ADD functionality.
More details in the spec.
Fields
netns: Option<PathBuf>The container’s “isolation domain” or namespace path.
May not be provided for DEL commands.
config: NetworkConfigThe 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
config: NetworkConfigThe 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§
Source§impl Cni
impl Cni
Sourcepub fn from_env() -> Result<Self, CniError>
pub fn from_env() -> Result<Self, CniError>
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().
Sourcepub fn load() -> Self
pub fn load() -> Self
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.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Cni
impl RefUnwindSafe for Cni
impl Send for Cni
impl Sync for Cni
impl Unpin for Cni
impl UnwindSafe for Cni
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§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more