Documentation
¶
Index ¶
- Constants
- func GeneratedConfigMap(data map[string]string) *v1.ConfigMap
- func GetAllConfigs(kubeClient k8s.Client) ([]*d8cfg_v1alpha1.ModuleConfig, error)
- func GetConfigMap(klient k8s.Client, ns string, name string) (*v1.ConfigMap, error)
- func GetDeckhouseConfigMap(klient k8s.Client) (*v1.ConfigMap, error)
- func GetGeneratedConfigMap(klient k8s.Client) (*v1.ConfigMap, error)
- func InitService(mm ModuleManager)
- func SetModuleConfigEnabledFlag(kubeClient k8s.Client, name string, enabled bool) error
- type ConfigService
- func (srv *ConfigService) AddExternalModuleName(moduleName, moduleSource string)
- func (srv *ConfigService) ConfigValidator() *ConfigValidator
- func (srv *ConfigService) ExternalNames() map[string]string
- func (srv *ConfigService) PossibleNames() set.Set
- func (srv *ConfigService) SetExternalNames(allExternalNamesToRepos map[string]string)
- func (srv *ConfigService) StatusReporter() *StatusReporter
- func (srv *ConfigService) Transformer() *Transformer
- type ConfigValidator
- type InitialConfigLoader
- func (l *InitialConfigLoader) GetInitialKubeConfig(cmName string) (*kcm.KubeConfig, error)
- func (l *InitialConfigLoader) LegacyConfigMapToInitialConfig(cmData map[string]string) (*kcm.KubeConfig, error)
- func (l *InitialConfigLoader) ModuleConfigListToInitialConfig(allConfigs []*d8cfg_v1alpha1.ModuleConfig, possibleNames set.Set) (*kcm.KubeConfig, error)
- type ModuleManager
- type Status
- type StatusReporter
- type Transformer
- type ValidationResult
- type ValuesValidator
Constants ¶
const (
AnnoMigrationInProgress = "deckhouse.io/migration-in-progress"
)
const DeckhouseConfigMapName = "deckhouse"
const DeckhouseNS = "d8-system"
const GeneratedConfigMapName = "deckhouse-generated-config-do-not-edit"
Variables ¶
This section is empty.
Functions ¶
func GetAllConfigs ¶
func GetAllConfigs(kubeClient k8s.Client) ([]*d8cfg_v1alpha1.ModuleConfig, error)
GetAllConfigs returns all ModuleConfig objects.
func GetConfigMap ¶
func GetDeckhouseConfigMap ¶
GetDeckhouseConfigMap returns default ConfigMap with config values (ConfigMap/deckhouse).
func GetGeneratedConfigMap ¶
GetGeneratedConfigMap returns generated ConfigMap with config values.
func InitService ¶
func InitService(mm ModuleManager)
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 ¶
func (c *ConfigValidator) ConvertToLatest(cfg *d8cfg_v1alpha1.ModuleConfig) ValidationResult
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 ¶
func (c *ConfigValidator) Validate(cfg *d8cfg_v1alpha1.ModuleConfig) ValidationResult
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 ¶
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:
- 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.
- 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 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.