config

package
v4.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2025 License: Apache-2.0 Imports: 13 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) (*Manager, error)

NewManager returns a config manager object, configured to read the primary CNI configuration in `config.MultusAutoconfigDir`. If `config.MultusMasterCni` is empty, this constructor will auto-discover the primary CNI for which it will delegate.

func (*Manager) GenerateConfig

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

GenerateConfig generates a multus configuration from its current state

func (*Manager) PersistMultusConfig

func (m *Manager) PersistMultusConfig(config string) (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`

func (*Manager) Start added in v4.1.0

func (m *Manager) Start(ctx context.Context, wg *sync.WaitGroup) error

Start generates an updated Multus config, writes it, and begins watching the config directory and readiness indicator files for changes

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"`
	DaemonSocketDir          string              `json:"daemonSocketDir,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