package convert

import "github.com/containernetworking/cni/pkg/types/internal"

Index

Functions

func Convert

func Convert(from types.Result, toVersion string) (types.Result, error)

Convert converts a CNI Result to the requested CNI specification version, or returns an error if the conversion could not be performed or failed

func Create

func Create(version string, bytes []byte) (types.Result, error)

Create creates a CNI Result using the given JSON, or an error if the creation could not be performed

func RegisterConverter

func RegisterConverter(fromVersion string, toVersions []string, convertFn ConvertFn)

RegisterConverter registers a CNI Result converter. SHOULD NOT BE CALLED EXCEPT FROM CNI ITSELF.

func RegisterCreator

func RegisterCreator(versions []string, createFn ResultFactoryFunc)

RegisterCreator registers a CNI Result creator. SHOULD NOT BE CALLED EXCEPT FROM CNI ITSELF.

Types

type ConvertFn

type ConvertFn func(from types.Result, toVersion string) (types.Result, error)

ConvertFn should convert from the given arbitrary Result type into a Result implementing CNI specification version passed in toVersion. The function is guaranteed to be passed a Result type matching the fromVersion it was registered with, and is guaranteed to be passed a toVersion matching one of the toVersions it was registered with.

type ResultFactoryFunc

type ResultFactoryFunc func([]byte) (types.Result, error)

Source Files

convert.go create.go

Version
v1.3.0 (latest)
Published
Apr 7, 2025
Platform
linux/amd64
Imports
2 packages
Last checked
5 days ago

Tools for package owners.