package legacy_examples
import "github.com/containernetworking/cni/pkg/version/legacy_examples"
Package legacy_examples contains sample code from prior versions of the CNI library, for use in verifying backwards compatibility.
Index ¶
Variables ¶
var ExpectedResult = &types020.Result{ CNIVersion: "0.1.0", IP4: &types020.IPConfig{ IP: net.IPNet{ IP: net.ParseIP("10.1.2.3"), Mask: net.CIDRMask(24, 32), }, Gateway: net.ParseIP("10.1.2.1"), Routes: []types.Route{ { Dst: net.IPNet{ IP: net.ParseIP("0.0.0.0"), Mask: net.CIDRMask(0, 32), }, GW: net.ParseIP("10.1.0.1"), }, }, }, DNS: types.DNS{ Nameservers: []string{"8.8.8.8"}, Domain: "example.com", }, }
ExpectedResult is the current representation of the plugin result that is expected from each of the examples.
As we change the CNI spec, the Result type and this value may change. The text of the example plugins should not.
var V010 = Example{ Name: "example_v010", CNIRepoGitRef: "2c482f4", PluginSource: "" /* 677 byte string literal not displayed */, }
V010 acts like a CNI plugin from the v0.1.0 era
var V010_Runtime = ExampleRuntime{ NetConfs: []string{"unversioned", "0.1.0"}, Example: Example{ Name: "example_invoker_v010", CNIRepoGitRef: "c0d34c69", PluginSource: "" /* 1500 byte string literal not displayed */, }, }
V010_Runtime creates a simple noop network configuration, then executes libcni against the noop test plugin.
Types ¶
type Example ¶
An Example is a Git reference to the CNI repo and a Golang CNI plugin that builds against that version of the repo.
By convention, every Example plugin returns an ADD result that is semantically equivalent to the ExpectedResult.
func (Example) Build ¶
Build builds the example, returning the path to the binary
type ExampleNetConf ¶
type ExampleNetConf struct { Config string // contains filtered or unexported fields }
func (*ExampleNetConf) Cleanup ¶
func (c *ExampleNetConf) Cleanup()
type ExampleRuntime ¶
An ExampleRuntime is a small program that uses libcni to invoke a network plugin. It should call ADD and DELETE, verifying all intermediate steps and data structures.
func (*ExampleRuntime) GenerateNetConf ¶
func (e *ExampleRuntime) GenerateNetConf(name string) (*ExampleNetConf, error)
Source Files ¶
example_runtime.go examples.go
- Version
- v1.3.0 (latest)
- Published
- Apr 7, 2025
- Platform
- linux/amd64
- Imports
- 10 packages
- Last checked
- 1 week ago –
Tools for package owners.