config

package
v4.0.2 Latest Latest
Warning

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

Go to latest
Published: May 18, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package config is the package that contains the libraries that operates CNI config files

Index

Constants

View Source
const (
	MultusDefaultNetworkName = "multus-cni-network"
	UserRWPermission         = 0600
)

MultusDefaultNetworkName holds the default name of the multus network

Variables

This section is empty.

Functions

func CheckVersionCompatibility

func CheckVersionCompatibility(mc *MultusConf, delegate interface{}) error

CheckVersionCompatibility checks compatibilty of the top level cni version with the delegate cni version. Since version 0.4.0, CHECK was introduced, which causes incompatibility.

Types

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager monitors the configuration of the primary CNI plugin, and regenerates multus configuration whenever it gets updated.

func NewManager

func NewManager(config MultusConf, multusAutoconfigDir string, forceCNIVersion bool) (*Manager, error)

NewManager returns a config manager object, configured to read the primary CNI configuration in `multusAutoconfigDir`. This constructor will auto-discover the primary CNI for which it will delegate.

func NewManagerWithExplicitPrimaryCNIPlugin

func NewManagerWithExplicitPrimaryCNIPlugin(config MultusConf, multusAutoconfigDir, primaryCNIPluginName string, forceCNIVersion bool) (*Manager, error)

NewManagerWithExplicitPrimaryCNIPlugin returns a config manager object, configured to persist the configuration to `multusAutoconfigDir`. This constructor will use the primary CNI plugin indicated by the user, via the primaryCNIPluginName variable.

func (Manager) GenerateConfig

func (m Manager) GenerateConfig() (string, error)

GenerateConfig generates a multus configuration from its current state

func (Manager) MonitorPluginConfiguration

func (m Manager) MonitorPluginConfiguration(shutDown <-chan struct{}, done chan<- struct{}) error

MonitorPluginConfiguration monitors the configuration file pointed to by the primaryCNIPluginName attribute, and re-generates the multus configuration whenever the primary CNI config is updated.

func (*Manager) OverrideNetworkName

func (m *Manager) OverrideNetworkName() error

OverrideNetworkName overrides the name of the multus configuration with the name of the delegated primary CNI.

func (Manager) PersistMultusConfig

func (m Manager) PersistMultusConfig(config string) error

PersistMultusConfig persists the provided configuration to the disc, with Read / Write permissions. The output file path is `<multus auto config dir>/00-multus.conf`

type MultusConf

type MultusConf struct {
	BinDir                   string              `json:"binDir,omitempty"`
	Capabilities             map[string]bool     `json:"capabilities,omitempty"`
	CNIVersion               string              `json:"cniVersion"`
	LogFile                  string              `json:"logFile,omitempty"`
	LogLevel                 string              `json:"logLevel,omitempty"`
	LogToStderr              bool                `json:"logToStderr,omitempty"`
	LogOptions               *logging.LogOptions `json:"logOptions,omitempty"`
	Name                     string              `json:"name"`
	ClusterNetwork           string              `json:"clusterNetwork,omitempty"`
	NamespaceIsolation       bool                `json:"namespaceIsolation,omitempty"`
	RawNonIsolatedNamespaces string              `json:"globalNamespaces,omitempty"`
	ReadinessIndicatorFile   string              `json:"readinessindicatorfile,omitempty"`
	Type                     string              `json:"type"`
	CniDir                   string              `json:"cniDir,omitempty"`
	CniConfigDir             string              `json:"cniConfigDir,omitempty"`
	SocketDir                string              `json:"socketDir,omitempty"`
	MultusConfigFile         string              `json:"multusConfigFile,omitempty"`
	MultusMasterCni          string              `json:"multusMasterCNI,omitempty"`
	MultusAutoconfigDir      string              `json:"multusAutoconfigDir,omitempty"`
	ForceCNIVersion          bool                `json:"forceCNIVersion,omitempty"`
	OverrideNetworkName      bool                `json:"overrideNetworkName,omitempty"`
}

MultusConf holds the multus configuration

func ParseMultusConfig

func ParseMultusConfig(configPath string) (*MultusConf, error)

ParseMultusConfig parses multus config from configPath and create MultusConf.

func (*MultusConf) Generate

func (mc *MultusConf) Generate() (string, error)

Generate generates the multus configuration from whatever state is currently held

type Option

type Option func(conf *MultusConf) error

Option mutates the `conf` object

Jump to

Keyboard shortcuts

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