cni

package module
v0.0.0-...-ef98665 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 24, 2020 License: Apache-2.0 Imports: 5 Imported by: 2 modules, 4 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

This repository holds some common structs and functions to use when working with CNI in Go.

Documentation

Index

Constants

View Source
const (
	//CNIVersion is the cniVersion
	CNIVersion = "0.4.0"
)

Variables

This section is empty.

Functions

func PrepareExit

func PrepareExit(err error, code int, message string) (int, []byte)

PrepareExit returns the error code and json bytes to be printed to stdout by the calling program

Types

type Args

type Args struct {
	Annotations map[string]string `json:"annotations"`
}

Args are additional arguments provided by the container runtime

type Config

type Config struct {
	CNIVersion     string      `json:"cniVersion"`
	Name           string      `json:"name"`
	Type           string      `json:"type"`
	PreviousResult *Result     `json:"prevResult,omitempty"`
	Ipam           *IpamConfig `json:"ipam"`
	Args           *Args       `json:"args"`
}

Config represents the cni network config file

func NewConfig

func NewConfig(confBytes []byte) (*Config, error)

NewConfig returns a new standard cni config object

type DNS

type DNS struct {
	Nameservers []string `json:"nameservers,omitempty"`
	Domain      string   `json:"domain,omitempty"`
	Search      []string `json:"search,omitempty"`
	Options     []string `json:"options,omitempty"`
}

DNS represents the DNS structure in the Result

type Error

type Error struct {
	Version string `json:"cniVersion"`
	Code    int    `json:"code"`
	Message string `json:"msg"`
	Details string `json:"details,omitempty"`
}

Error represents the object we return to runtime in the case of a failure

func NewDetailedError

func NewDetailedError(code int, message, details string) *Error

NewDetailedError generates a new CNIError with details

func NewError

func NewError(code int, message string) *Error

NewError generates a new CNIError

func (*Error) Marshal

func (e *Error) Marshal() []byte

Marshal marshals the error into a json string

type IP

type IP struct {
	Version   string `json:"version"`
	Address   string `json:"address"`
	Gateway   string `json:"gateway,omitempty"`
	Interface *int   `json:"interface,omitempty"`
}

IP represents the ip address in the Result

type Interface

type Interface struct {
	Name    string `json:"name"`
	MAC     string `json:"mac,omitempty"`
	Sandbox string `json:"sandbox,omitempty"`
}

Interface represents the interface in the Result

type IpamConfig

type IpamConfig struct {
	Type string `json:"type"`
}

IpamConfig represents the cni ipam config

type Result

type Result struct {
	CNIVersion string       `json:"cniVersion"`
	Interfaces []*Interface `json:"interfaces,omitempty"`
	IPs        []*IP        `json:"ips"`
	Routes     []*Route     `json:"route,omitempty"`
	DNS        *DNS         `json:"dns,omitempty"`
}

Result represents the cni result given back to the caller

func (*Result) Marshal

func (r *Result) Marshal() []byte

Marshal marshals the error into a json string

type Route

type Route struct {
	Destination string `json:"dst"`
	Gateway     string `json:"gw,omitempty"`
}

Route represents any route in the Result

type Vars

type Vars struct {
	Command            string
	NetworkNamespace   string
	ContainerInterface string
	ContainerID        string
	Arguments          string
	Path               string
	// contains filtered or unexported fields
}

Vars represents the environment variables that the runtime should have populated

func NewVars

func NewVars() *Vars

NewVars returns an object populated with the standard CNI environment variables

func (*Vars) GetArg

func (v *Vars) GetArg(key string) (string, bool)

GetArg gets a specific argument passed in by the CNI_ARGS variable

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址