package skel
import "github.com/containernetworking/cni/pkg/skel"
Package skel provides skeleton code for a CNI plugin. In particular, it implements argument parsing and validation.
Index ¶
- func PluginMain(cmdAdd, cmdCheck, cmdDel func(_ *CmdArgs) error, versionInfo version.PluginInfo, about string)
- func PluginMainFuncs(funcs CNIFuncs, versionInfo version.PluginInfo, about string)
- func PluginMainFuncsWithError(funcs CNIFuncs, versionInfo version.PluginInfo, about string) *types.Error
- func PluginMainWithError(cmdAdd, cmdCheck, cmdDel func(_ *CmdArgs) error, versionInfo version.PluginInfo, about string) *types.Error
- type CNIFuncs
- type CmdArgs
Functions ¶
func PluginMain ¶
func PluginMain(cmdAdd, cmdCheck, cmdDel func(_ *CmdArgs) error, versionInfo version.PluginInfo, about string)
PluginMain is the core "main" for a plugin which includes automatic error handling.
The caller must also specify what CNI spec versions the plugin supports.
The caller can specify an "about" string, which is printed on stderr when no CNI_COMMAND is specified. The recommended output is "CNI plugin <foo> v<version>"
When an error occurs in either cmdAdd, cmdCheck, or cmdDel, PluginMain will print the error as JSON to stdout and call os.Exit(1).
To have more control over error handling, use PluginMainWithError() instead.
Deprecated: Use github.com/containernetworking/cni/pkg/skel.PluginMainFuncs instead.
func PluginMainFuncs ¶
func PluginMainFuncs(funcs CNIFuncs, versionInfo version.PluginInfo, about string)
PluginMainFuncs is the core "main" for a plugin which includes automatic error handling. This is a newer alternative func to PluginMain which abstracts CNI commands within a CNIFuncs interface.
The caller must also specify what CNI spec versions the plugin supports.
The caller can specify an "about" string, which is printed on stderr when no CNI_COMMAND is specified. The recommended output is "CNI plugin <foo> v<version>"
When an error occurs in any func in CNIFuncs, PluginMainFuncs will print the error as JSON to stdout and call os.Exit(1).
To have more control over error handling, use PluginMainFuncsWithError() instead.
func PluginMainFuncsWithError ¶
func PluginMainFuncsWithError(funcs CNIFuncs, versionInfo version.PluginInfo, about string) *types.Error
PluginMainFuncsWithError is the core "main" for a plugin. It accepts callback functions defined within CNIFuncs and returns an error.
The caller must also specify what CNI spec versions the plugin supports.
It is the responsibility of the caller to check for non-nil error return.
For a plugin to comply with the CNI spec, it must print any error to stdout as JSON and then exit with nonzero status code.
To let this package automatically handle errors and call os.Exit(1) for you, use PluginMainFuncs() instead.
func PluginMainWithError ¶
func PluginMainWithError(cmdAdd, cmdCheck, cmdDel func(_ *CmdArgs) error, versionInfo version.PluginInfo, about string) *types.Error
PluginMainWithError is the core "main" for a plugin. It accepts callback functions for add, check, and del CNI commands and returns an error.
The caller must also specify what CNI spec versions the plugin supports.
It is the responsibility of the caller to check for non-nil error return.
For a plugin to comply with the CNI spec, it must print any error to stdout as JSON and then exit with nonzero status code.
To let this package automatically handle errors and call os.Exit(1) for you, use PluginMain() instead.
Deprecated: Use github.com/containernetworking/cni/pkg/skel.PluginMainFuncsWithError instead.
Types ¶
type CNIFuncs ¶
type CNIFuncs struct { Add func(_ *CmdArgs) error Del func(_ *CmdArgs) error Check func(_ *CmdArgs) error GC func(_ *CmdArgs) error Status func(_ *CmdArgs) error }
CNIFuncs contains a group of callback command funcs to be passed in as parameters to the core "main" for a plugin.
type CmdArgs ¶
type CmdArgs struct { ContainerID string Netns string IfName string Args string Path string NetnsOverride string StdinData []byte }
CmdArgs captures all the arguments passed in to the plugin via both env vars and stdin
Source Files ¶
- Version
- v1.3.0 (latest)
- Published
- Apr 7, 2025
- Platform
- linux/amd64
- Imports
- 12 packages
- Last checked
- 1 week ago –
Tools for package owners.