kube_config_manager

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2023 License: Apache-2.0 Imports: 17 Imported by: 2 modules, 1 package

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.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigMapGet added in v1.0.6

func ConfigMapGet(kubeClient klient.Client, namespace string, name string) (*v1.ConfigMap, error)

ConfigMapGet gets the ConfigMap object from the cluster.

func ConfigMapMergeValues added in v1.0.6

func ConfigMapMergeValues(kubeClient klient.Client, namespace string, name string, values utils.Values) error

ConfigMapMergeValues is a helper to use ConfigMapUpdate to save Values object in the ConfigMap.

func ConfigMapUpdate added in v1.0.6

func ConfigMapUpdate(kubeClient klient.Client, namespace string, name string, transformFn func(*v1.ConfigMap) error) error

ConfigMapUpdate gets the ConfigMap object from the cluster, call transformation callback and save modified object.

func GetModulesNamesFromConfigData

func GetModulesNamesFromConfigData(configData map[string]string) (map[string]bool, error)

GetModulesNamesFromConfigData returns all keys in kube config except global modNameEnabled keys are also handled

Types

type Checksums added in v1.0.6

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

Checksums is a non thread-safe storage for KubeConfig sections checksums.

func NewChecksums added in v1.0.6

func NewChecksums() *Checksums

func (*Checksums) Add added in v1.0.6

func (c *Checksums) Add(name string, checksum string)

func (*Checksums) Copy added in v1.0.6

func (c *Checksums) Copy(name string, src *Checksums)

Copy copies all checksums for name from src.

func (*Checksums) HasChecksum added in v1.0.6

func (c *Checksums) HasChecksum(name string) bool

HasChecksum returns true if there is at least one checksum for name.

func (*Checksums) HasEqualChecksum added in v1.0.6

func (c *Checksums) HasEqualChecksum(name string, checksum string) bool

HasEqualChecksum returns true if there is a checksum for name equal to the input checksum.

func (*Checksums) Names added in v1.0.6

func (c *Checksums) Names() map[string]struct{}

func (*Checksums) Remove added in v1.0.6

func (c *Checksums) Remove(name string, checksum string)

func (*Checksums) RemoveAll added in v1.0.6

func (c *Checksums) RemoveAll(name string)

RemoveAll clears all checksums for the name.

func (*Checksums) Set added in v1.0.6

func (c *Checksums) Set(name string, checksum string)

Set saves only one checksum for the name.

type Config

type Config struct {
	Namespace     string
	ConfigMapName string
	KubeClient    klient.Client
	RuntimeConfig *config.Config
}

type GlobalKubeConfig

type GlobalKubeConfig struct {
	Values     utils.Values
	Checksum   string
	ConfigData map[string]string
}

func GetGlobalKubeConfigFromConfigData

func GetGlobalKubeConfigFromConfigData(configData map[string]string) (*GlobalKubeConfig, error)

func GetGlobalKubeConfigFromValues

func GetGlobalKubeConfigFromValues(values utils.Values) (*GlobalKubeConfig, error)

type KubeConfig added in v1.0.6

type KubeConfig struct {
	Global  *GlobalKubeConfig
	Modules map[string]*ModuleKubeConfig
}

func NewConfig

func NewConfig() *KubeConfig

func ParseConfigMapData added in v1.0.6

func ParseConfigMapData(data map[string]string) (cfg *KubeConfig, err error)

type KubeConfigEvent added in v1.0.6

type KubeConfigEvent string
const (
	KubeConfigChanged KubeConfigEvent = "Changed"
	KubeConfigInvalid KubeConfigEvent = "Invalid"
)

type KubeConfigManager

type KubeConfigManager struct {
	KubeClient    klient.Client
	Namespace     string
	ConfigMapName string
	// contains filtered or unexported fields
}

KubeConfigManager watches for changes in ConfigMap/addon-operator and provides methods to change its content. It stores values parsed from ConfigMap data. OpenAPI validation of these config values is not a responsibility of this component.

func NewKubeConfigManager

func NewKubeConfigManager(ctx context.Context, cfg *Config) *KubeConfigManager

func (*KubeConfigManager) Init

func (kcm *KubeConfigManager) Init() error

func (*KubeConfigManager) KubeConfigEventCh added in v1.0.6

func (kcm *KubeConfigManager) KubeConfigEventCh() chan KubeConfigEvent

KubeConfigEventCh return a channel that emits new KubeConfig on ConfigMap changes in global section or enabled modules.

func (*KubeConfigManager) SafeReadConfig added in v1.0.6

func (kcm *KubeConfigManager) SafeReadConfig(handler func(config *KubeConfig))

SafeReadConfig locks currentConfig to safely read from it in external services.

func (*KubeConfigManager) SaveGlobalConfigValues added in v1.0.6

func (kcm *KubeConfigManager) SaveGlobalConfigValues(values utils.Values) error

func (*KubeConfigManager) SaveModuleConfigValues added in v1.0.6

func (kcm *KubeConfigManager) SaveModuleConfigValues(moduleName string, values utils.Values) error

SaveModuleConfigValues updates module section in ConfigMap. It uses knownChecksums to prevent KubeConfigChanged event on self-update.

func (*KubeConfigManager) Start

func (kcm *KubeConfigManager) Start()

func (*KubeConfigManager) Stop

func (kcm *KubeConfigManager) Stop()

type ModuleKubeConfig

type ModuleKubeConfig struct {
	utils.ModuleConfig
	Checksum   string
	ConfigData map[string]string
}

func ExtractModuleKubeConfig

func ExtractModuleKubeConfig(moduleName string, configData map[string]string) (*ModuleKubeConfig, error)

ExtractModuleKubeConfig returns ModuleKubeConfig with values loaded from ConfigMap

func GetModuleKubeConfigFromValues

func GetModuleKubeConfigFromValues(moduleName string, values utils.Values) (*ModuleKubeConfig, error)

func (*ModuleKubeConfig) GetEnabled added in v1.0.6

func (m *ModuleKubeConfig) GetEnabled() string

Jump to

Keyboard shortcuts

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