package types
import "github.com/containernetworking/cni/pkg/types"
Index ¶
- Constants
- func GetKeyField(keyString string, v reflect.Value) reflect.Value
- func LoadArgs(args string, container interface{}) error
- func ParseCIDR(s string) (*net.IPNet, error)
- func PrintResult(result Result, version string) error
- type CommonArgs
- type DNS
- type Error
- func NewError(code uint, msg, details string) *Error
- func (e *Error) Error() string
- func (e *Error) Print() error
- type GCAttachment
- type IPAM
- type IPNet
- type NetConf
- type NetConfList
- type PluginConf
- type Result
- type Route
- func (r *Route) Copy() *Route
- func (r Route) MarshalJSON() ([]byte, error)
- func (r *Route) String() string
- func (r *Route) UnmarshalJSON(data []byte) error
- type UnmarshalableArgsError
- type UnmarshallableBool
- type UnmarshallableString
Constants ¶
const ( ErrUnknown uint = iota // 0 ErrIncompatibleCNIVersion // 1 ErrUnsupportedField // 2 ErrUnknownContainer // 3 ErrInvalidEnvironmentVariables // 4 ErrIOFailure // 5 ErrDecodingFailure // 6 ErrInvalidNetworkConfig // 7 ErrInvalidNetNS // 8 ErrTryAgainLater uint = 11 ErrInternal uint = 999 )
Well known error codes see https://github.com/containernetworking/cni/blob/main/SPEC.md#well-known-error-codes
Functions ¶
func GetKeyField ¶
GetKeyField is a helper function to receive Values Values that represent a pointer to a struct
func LoadArgs ¶
LoadArgs parses args from a string in the form "K=V;K2=V2;..."
func ParseCIDR ¶
ParseCIDR takes a string like "10.2.3.1/24" and return IPNet with "10.2.3.1" and /24 mask
func PrintResult ¶
Types ¶
type CommonArgs ¶
type CommonArgs struct { IgnoreUnknown UnmarshallableBool `json:"ignoreunknown,omitempty"` }
CommonArgs contains the IgnoreUnknown argument and must be embedded by all Arg structs
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 contains values interesting for DNS resolvers
func (*DNS) Copy ¶
func (*DNS) IsEmpty ¶
IsEmpty returns true if DNS structure has no value, otherwise return false
type Error ¶
type Error struct { Code uint `json:"code"` Msg string `json:"msg"` Details string `json:"details,omitempty"` }
func NewError ¶
func (*Error) Error ¶
func (*Error) Print ¶
type GCAttachment ¶
GCAttachment is the parameters to a GC call -- namely, the container ID and ifname pair that represents a still-valid attachment.
type IPAM ¶
type IPAM struct { Type string `json:"type,omitempty"` }
func (*IPAM) IsEmpty ¶
IsEmpty returns true if IPAM structure has no value, otherwise return false
type IPNet ¶
like net.IPNet but adds JSON marshalling and unmarshalling
func (IPNet) MarshalJSON ¶
func (*IPNet) UnmarshalJSON ¶
type NetConf ¶
type NetConf = PluginConf
Use PluginConf instead of NetConf, the NetConf backwards-compat alias will be removed in a future release.
type NetConfList ¶
type NetConfList struct { CNIVersion string `json:"cniVersion,omitempty"` Name string `json:"name,omitempty"` DisableCheck bool `json:"disableCheck,omitempty"` DisableGC bool `json:"disableGC,omitempty"` Plugins []*PluginConf `json:"plugins,omitempty"` }
NetConfList describes an ordered list of networks.
type PluginConf ¶
type PluginConf struct { CNIVersion string `json:"cniVersion,omitempty"` Name string `json:"name,omitempty"` Type string `json:"type,omitempty"` Capabilities map[string]bool `json:"capabilities,omitempty"` IPAM IPAM `json:"ipam,omitempty"` DNS DNS `json:"dns,omitempty"` RawPrevResult map[string]interface{} `json:"prevResult,omitempty"` PrevResult Result `json:"-"` // ValidAttachments is only supplied when executing a GC operation ValidAttachments []GCAttachment `json:"cni.dev/valid-attachments,omitempty"` }
PluginConf describes a plugin configuration for a specific network.
func (*PluginConf) MarshalJSON ¶
func (n *PluginConf) MarshalJSON() ([]byte, error)
Note: DNS should be omit if DNS is empty but default Marshal function will output empty structure hence need to write a Marshal function
type Result ¶
type Result interface { // The highest CNI specification result version the result supports // without having to convert Version() string // Returns the result converted into the requested CNI specification // result version, or an error if conversion failed GetAsVersion(version string) (Result, error) // Prints the result in JSON format to stdout Print() error // Prints the result in JSON format to provided writer PrintTo(writer io.Writer) error }
Result is an interface that provides the result of plugin execution
type Route ¶
func (*Route) Copy ¶
func (Route) MarshalJSON ¶
func (*Route) String ¶
func (*Route) UnmarshalJSON ¶
type UnmarshalableArgsError ¶
type UnmarshalableArgsError struct {
// contains filtered or unexported fields
}
UnmarshalableArgsError is used to indicate error unmarshalling args from the args-string in the form "K=V;K2=V2;..."
type UnmarshallableBool ¶
type UnmarshallableBool bool
UnmarshallableBool typedef for builtin bool because builtin type's methods can't be declared
func (*UnmarshallableBool) UnmarshalText ¶
func (b *UnmarshallableBool) UnmarshalText(data []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface. Returns boolean true if the string is "1" or "true" or "True" Returns boolean false if the string is "0" or "false" or "False”
type UnmarshallableString ¶
type UnmarshallableString string
UnmarshallableString typedef for builtin string
func (*UnmarshallableString) UnmarshalText ¶
func (s *UnmarshallableString) UnmarshalText(data []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface. Returns the string
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
pkg/types/020 | |
pkg/types/040 | |
pkg/types/100 | |
pkg/types/create | |
pkg/types/internal |
- Version
- v1.3.0 (latest)
- Published
- Apr 7, 2025
- Platform
- linux/amd64
- Imports
- 8 packages
- Last checked
- 1 day ago –
Tools for package owners.