package version
import "github.com/containernetworking/cni/pkg/version"
Index ¶
- Variables
- func Current() string
- func GreaterThan(version, otherVersion string) (bool, error)
- func GreaterThanOrEqualTo(version, otherVersion string) (bool, error)
- func NewResult(version string, resultBytes []byte) (types.Result, error)
- func ParsePrevResult(conf *types.PluginConf) error
- func ParseVersion(version string) (int, int, int, error)
- type ConfigDecoder
- type ErrorIncompatible
- type PluginDecoder
- type PluginInfo
- func PluginSupports(supportedVersions ...string) PluginInfo
- func VersionsStartingFrom(min string) PluginInfo
- type Reconciler
Variables ¶
var ( Legacy = PluginSupports("0.1.0", "0.2.0") All = PluginSupports("0.1.0", "0.2.0", "0.3.0", "0.3.1", "0.4.0", "1.0.0", "1.1.0") )
Legacy PluginInfo describes a plugin that is backwards compatible with the CNI spec version 0.1.0. In particular, a runtime compiled against the 0.1.0 library ought to work correctly with a plugin that reports support for Legacy versions.
Any future CNI spec versions which meet this definition should be added to this list.
Functions ¶
func Current ¶
func Current() string
Current reports the version of the CNI spec implemented by this library
func GreaterThan ¶
GreaterThan returns true if the first version is greater than the second
func GreaterThanOrEqualTo ¶
GreaterThanOrEqualTo takes two string versions, parses them into major/minor/micro numbers, and compares them to determine whether the first version is greater than or equal to the second
func NewResult ¶
Finds a Result object matching the requested version (if any) and asks that object to parse the plugin result, returning an error if parsing failed.
func ParsePrevResult ¶
func ParsePrevResult(conf *types.PluginConf) error
ParsePrevResult parses a prevResult in a NetConf structure and sets the NetConf's PrevResult member to the parsed Result object.
func ParseVersion ¶
ParseVersion parses a version string like "3.0.1" or "0.4.5" into major, minor, and micro numbers or returns an error
Types ¶
type ConfigDecoder ¶
type ConfigDecoder struct{}
ConfigDecoder can decode the CNI version available in network config data
func (*ConfigDecoder) Decode ¶
func (*ConfigDecoder) Decode(jsonBytes []byte) (string, error)
type ErrorIncompatible ¶
func (*ErrorIncompatible) Details ¶
func (e *ErrorIncompatible) Details() string
func (*ErrorIncompatible) Error ¶
func (e *ErrorIncompatible) Error() string
type PluginDecoder ¶
type PluginDecoder struct{}
PluginDecoder can decode the response returned by a plugin's VERSION command
func (*PluginDecoder) Decode ¶
func (*PluginDecoder) Decode(jsonBytes []byte) (PluginInfo, error)
type PluginInfo ¶
type PluginInfo interface { // SupportedVersions returns one or more CNI spec versions that the plugin // supports. If input is provided in one of these versions, then the plugin // promises to use the same CNI version in its response SupportedVersions() []string // Encode writes this CNI version information as JSON to the given Writer Encode(io.Writer) error }
PluginInfo reports information about CNI versioning
func PluginSupports ¶
func PluginSupports(supportedVersions ...string) PluginInfo
PluginSupports returns a new PluginInfo that will report the given versions as supported
func VersionsStartingFrom ¶
func VersionsStartingFrom(min string) PluginInfo
VersionsFrom returns a list of versions starting from min, inclusive
type Reconciler ¶
type Reconciler struct{}
func (*Reconciler) Check ¶
func (r *Reconciler) Check(configVersion string, pluginInfo PluginInfo) *ErrorIncompatible
func (*Reconciler) CheckRaw ¶
func (*Reconciler) CheckRaw(configVersion string, supportedVersions []string) *ErrorIncompatible
Source Files ¶
conf.go plugin.go reconcile.go version.go
Directories ¶
Path | Synopsis |
---|---|
pkg/version/legacy_examples | Package legacy_examples contains sample code from prior versions of the CNI library, for use in verifying backwards compatibility. |
pkg/version/testhelpers | Package testhelpers supports testing of CNI components of different versions |
- Version
- v1.3.0 (latest)
- Published
- Apr 7, 2025
- Platform
- linux/amd64
- Imports
- 7 packages
- Last checked
- 1 week ago –
Tools for package owners.