deckhouse_config

package
v1.46.7 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AnnoMigrationInProgress = "deckhouse.io/migration-in-progress"
)
View Source
const DeckhouseConfigMapName = "deckhouse"
View Source
const DeckhouseNS = "d8-system"
View Source
const GeneratedConfigMapName = "deckhouse-generated-config-do-not-edit"

Variables

This section is empty.

Functions

func GeneratedConfigMap

func GeneratedConfigMap(data map[string]string) *v1.ConfigMap

func GetAllConfigs

func GetAllConfigs(kubeClient k8s.Client) ([]*d8cfg_v1alpha1.ModuleConfig, error)

GetAllConfigs returns all ModuleConfig objects.

func GetConfigMap

func GetConfigMap(klient k8s.Client, ns string, name string) (*v1.ConfigMap, error)

func GetDeckhouseConfigMap

func GetDeckhouseConfigMap(klient k8s.Client) (*v1.ConfigMap, error)

GetDeckhouseConfigMap returns default ConfigMap with config values (ConfigMap/deckhouse).

func GetGeneratedConfigMap

func GetGeneratedConfigMap(klient k8s.Client) (*v1.ConfigMap, error)

GetGeneratedConfigMap returns generated ConfigMap with config values.

func InitService

func InitService(mm ModuleManager)

func SetModuleConfigEnabledFlag added in v1.45.0

func SetModuleConfigEnabledFlag(kubeClient k8s.Client, name string, enabled bool) error

SetModuleConfigEnabledFlag updates spec.enabled flag or creates a new ModuleConfig with spec.enabled flag.

Types

type ConfigService

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

func Service

func Service() *ConfigService

func (*ConfigService) AddExternalModuleName added in v1.44.0

func (srv *ConfigService) AddExternalModuleName(moduleName, moduleSource string)

func (*ConfigService) ConfigValidator

func (srv *ConfigService) ConfigValidator() *ConfigValidator

func (*ConfigService) ExternalNames added in v1.44.0

func (srv *ConfigService) ExternalNames() map[string]string

func (*ConfigService) PossibleNames

func (srv *ConfigService) PossibleNames() set.Set

func (*ConfigService) SetExternalNames added in v1.44.0

func (srv *ConfigService) SetExternalNames(allExternalNamesToRepos map[string]string)

func (*ConfigService) StatusReporter

func (srv *ConfigService) StatusReporter() *StatusReporter

func (*ConfigService) Transformer

func (srv *ConfigService) Transformer() *Transformer

type ConfigValidator

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

ConfigValidator is a validator for values in ModuleConfig.

func NewConfigValidator

func NewConfigValidator(valuesValidator ValuesValidator) *ConfigValidator

func (*ConfigValidator) ConvertToLatest

ConvertToLatest checks if ModuleConfig resource is well-formed and runs conversions for spec.settings is needed. TODO(future) return cfg, error. Put cfg.Spec into result cfg.

func (*ConfigValidator) Validate

Validate checks ModuleConfig resource: - check if resource is well-formed - runs conversions for spec.settings is needed - use OpenAPI schema defined in related config-values.yaml file to validate converted spec.settings. TODO(future) return cfg, error. Put cfg.Spec into result cfg.

type InitialConfigLoader

type InitialConfigLoader struct {
	KubeClient client.Client
}

InitialConfigLoader runs conversions on module sections in the ConfigMap or for settings in all ModuleConfig resources to make a KubeConfig with values conform to the latest OpenAPI schemas. It is used at start to provide a valid config to the AddonOperator instance.

func NewInitialConfigLoader

func NewInitialConfigLoader(kubeClient client.Client) *InitialConfigLoader

func (*InitialConfigLoader) GetInitialKubeConfig

func (l *InitialConfigLoader) GetInitialKubeConfig(cmName string) (*kcm.KubeConfig, error)

GetInitialKubeConfig runs conversions on settings to feed valid 'KubeConfig' to the AddonOperator. Otherwise, Deckhouse will stuck trying to validate old settings with new OpenAPI schemas.

There are 2 cases:

  1. cm/deckhouse is in use or cm/deckhouse-generated-do-no-edit was just copied (it has annotation). There are no ModuleConfig resources, so module sections are treated as settings with version 0.
  2. cm/deckhouse-generated-do-no-edit has no annotation. ConfigMap has no versions, so ModuleConfig resources are used to create initial config. Also, there is no ModuleManager instance, only module names from the ConfigMap are used.

func (*InitialConfigLoader) LegacyConfigMapToInitialConfig

func (l *InitialConfigLoader) LegacyConfigMapToInitialConfig(cmData map[string]string) (*kcm.KubeConfig, error)

LegacyConfigMapToInitialConfig runs registered conversion for each 'module section' in the ConfigMap data. It assumes settings have version 0 (cm/deckhouse case).

func (*InitialConfigLoader) ModuleConfigListToInitialConfig

func (l *InitialConfigLoader) ModuleConfigListToInitialConfig(allConfigs []*d8cfg_v1alpha1.ModuleConfig, possibleNames set.Set) (*kcm.KubeConfig, error)

ModuleConfigListToInitialConfig runs conversion for ModuleConfig resources to transforms settings and enabled flag to the ConfigMap content. Then parse resulting ConfigMap to the KubeConfig.

type ModuleManager

type ModuleManager interface {
	IsModuleEnabled(modName string) bool
	GetModule(modName string) *module_manager.Module
	GetModuleNames() []string
	GetValuesValidator() *validation.ValuesValidator
}

ModuleManager interface is a part of addon-operator's ModuleManager interface with methods needed for deckhouse-config package.

type Status

type Status struct {
	State   string
	Version string
	Status  string
	Type    string
}

type StatusReporter

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

func NewModuleInfo

func NewModuleInfo(mm ModuleManager, possibleNames set.Set) *StatusReporter

func (*StatusReporter) ForConfig

func (s *StatusReporter) ForConfig(cfg *d8cfg_v1alpha1.ModuleConfig, bundleName string, externalModulesToRepo map[string]string) Status

type Transformer

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

func NewTransformer

func NewTransformer(possibleNames set.Set) *Transformer

func (*Transformer) ConfigMapToModuleConfigList

func (t *Transformer) ConfigMapToModuleConfigList(cmData map[string]string) ([]*d8cfg_v1alpha1.ModuleConfig, []string, error)

ConfigMapToModuleConfigList returns a list of ModuleConfig objects. It transforms 'global' section and all modules sections in ConfigMap/deckhouse. Conversion chain is triggered for each section to convert values to the latest version. If module has no conversions, 'version: 1' is used. It ignores sections with unknown names.

func (*Transformer) ModuleConfigListToConfigMap

func (t *Transformer) ModuleConfigListToConfigMap(allConfigs []*d8cfg_v1alpha1.ModuleConfig) (map[string]string, error)

ModuleConfigListToConfigMap creates new Data for ConfigMap from existing ModuleConfig objects. It creates module sections for known modules using a cached set of possible names.

type ValidationResult

type ValidationResult struct {
	Settings map[string]interface{}
	Version  int

	Warning string
	Error   string
}

func (ValidationResult) HasError

func (v ValidationResult) HasError() bool

HasError return true if result has error. TODO(future) use regular error instead.

type ValuesValidator

type ValuesValidator interface {
	GetSchema(schemaType validation.SchemaType, valuesType validation.SchemaType, modName string) *spec.Schema
	ValidateGlobalConfigValues(values utils.Values) error
	ValidateModuleConfigValues(moduleName string, values utils.Values) error
}

ValuesValidator is a part of ValuesValidator from addon-operator with needed methods to validate config values.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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