config

package
v0.0.0-...-94b3a0e Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultBundle   = "Default"
	DefaultLogLevel = "Info"
)
View Source
const (
	ModuleConfigKind     = "ModuleConfig"
	ModuleConfigResource = "moduleconfigs"
	ModuleConfigGroup    = "deckhouse.io"
	ModuleConfigVersion  = "v1alpha1"
)
View Source
const (
	CloudClusterType  = "Cloud"
	StaticClusterType = "Static"
)
View Source
const (

	// don't forget to update the version in release requirements (release.yaml)
	DefaultKubernetesVersion = "1.25"
)

Variables

View Source
var (
	ErrUnsafeFieldChanged   = errors.New("unsafe field has been changed")
	ErrConfigAmountChanged  = errors.New("cannot change amount of cluster configuration yamls")
	ErrSchemaNotFound       = errors.New("schema not found")
	ErrValidationRuleFailed = errors.New("validation rule failed")
)
View Source
var (
	// ModuleConfigGVR GroupVersionResource
	ModuleConfigGVR = schema.GroupVersionResource{
		Group:    ModuleConfigGroup,
		Version:  ModuleConfigVersion,
		Resource: ModuleConfigResource,
	}
)

Functions

func DeleteZonesRule

func DeleteZonesRule(oldRaw, newRaw json.RawMessage) error

func GetIndexFromNodeName

func GetIndexFromNodeName(name string) (int, error)

func ParseBashibleConfig

func ParseBashibleConfig(path, specPath string) (map[string]interface{}, error)

func ReadVersionTagFromInstallerContainer

func ReadVersionTagFromInstallerContainer() (string, bool)

func UpdateReplicasRule

func UpdateReplicasRule(oldRaw, newRaw json.RawMessage) error

func ValidateClusterSettings

func ValidateClusterSettings(configData string) error

ValidateClusterSettings parses and validates cluster configuration and resources. It checks the cluster configuration yamls for compliance with the yaml format and schema. Non-config resources are checked only for compliance with the yaml format and the validity of apiVersion and kind fields. It can be used as an imported functionality in external modules.

func ValidateClusterSettingsChanges

func ValidateClusterSettingsChanges(
	phase phases.OperationPhase,
	oldSettings, newSettings string,
	opts ValidateOptions,
) error

ValidateClusterSettingsChanges validates changes of current cluster configuration with the previous one. It checks the configuration changes for compliance with the current phase and schema extension rule (x-unsafe). It denies any changes for fields with `x-unsafe: true`. It applies all validation rules to fields with not empty `x-unsafe-rules` extension. On the BaseInfra phase changes are allowed. Non-config resources are checked only for compliance with the yaml format and the validity of apiVersion and kind fields: no changes validation for them. It can be used as an imported functionality in external modules.

func ValidateClusterSettingsFormat

func ValidateClusterSettingsFormat(settings string, opts ValidateOptions) error

ValidateClusterSettingsFormat parses and validates cluster configuration and resources. It checks the cluster configuration yamls for compliance with the yaml format and schema. Non-config resources are checked only for compliance with the yaml format and the validity of apiVersion and kind fields. It can be used as an imported functionality in external modules.

func ValidateDiscoveryData

func ValidateDiscoveryData(config *[]byte, paths ...string) (bool, error)

Types

type ClusterConfigCloudSpec

type ClusterConfigCloudSpec struct {
	Provider string `json:"provider"`
	Prefix   string `json:"prefix"`
}

type DeckhouseClusterConfig

type DeckhouseClusterConfig struct {
	ReleaseChannel    string                 `json:"releaseChannel,omitempty"`
	DevBranch         string                 `json:"devBranch,omitempty"`
	Bundle            string                 `json:"bundle,omitempty"`
	LogLevel          string                 `json:"logLevel,omitempty"`
	ImagesRepo        string                 `json:"imagesRepo"`
	RegistryDockerCfg string                 `json:"registryDockerCfg,omitempty"`
	RegistryCA        string                 `json:"registryCA,omitempty"`
	RegistryScheme    string                 `json:"registryScheme,omitempty"`
	ConfigOverrides   map[string]interface{} `json:"configOverrides"`
}

type DeckhouseInstaller

type DeckhouseInstaller struct {
	Registry              RegistryData
	LogLevel              string
	Bundle                string
	DevBranch             string
	UUID                  string
	KubeDNSAddress        string
	ClusterConfig         []byte
	ProviderClusterConfig []byte
	StaticClusterConfig   []byte
	TerraformState        []byte
	NodesTerraformState   map[string][]byte
	CloudDiscovery        []byte
	ModuleConfigs         []*ModuleConfig

	KubeadmBootstrap   bool
	MasterNodeSelector bool

	ReleaseChannel   string
	InstallerVersion string
}

func PrepareDeckhouseInstallConfig

func PrepareDeckhouseInstallConfig(metaConfig *MetaConfig) (*DeckhouseInstaller, error)

func (*DeckhouseInstaller) GetImage

func (c *DeckhouseInstaller) GetImage(forceVersionTag bool) string

func (*DeckhouseInstaller) IsRegistryAccessRequired

func (c *DeckhouseInstaller) IsRegistryAccessRequired() bool

type MasterNodeGroupSpec

type MasterNodeGroupSpec struct {
	Replicas int `json:"replicas"`
}

type MetaConfig

type MetaConfig struct {
	ClusterType          string                 `json:"-"`
	Layout               string                 `json:"-"`
	ProviderName         string                 `json:"-"`
	OriginalProviderName string                 `json:"-"`
	ClusterPrefix        string                 `json:"-"`
	ClusterDNSAddress    string                 `json:"-"`
	DeckhouseConfig      DeckhouseClusterConfig `json:"-"`
	MasterNodeGroupSpec  MasterNodeGroupSpec    `json:"-"`
	TerraNodeGroupSpecs  []TerraNodeGroupSpec   `json:"-"`

	ClusterConfig     map[string]json.RawMessage `json:"clusterConfiguration"`
	InitClusterConfig map[string]json.RawMessage `json:"-"`
	ModuleConfigs     []*ModuleConfig            `json:"-"`

	ProviderClusterConfig map[string]json.RawMessage `json:"providerClusterConfiguration,omitempty"`
	StaticClusterConfig   map[string]json.RawMessage `json:"staticClusterConfiguration,omitempty"`

	VersionMap       map[string]interface{} `json:"-"`
	Images           imagesDigests          `json:"-"`
	Registry         RegistryData           `json:"-"`
	UUID             string                 `json:"clusterUUID,omitempty"`
	InstallerVersion string                 `json:"-"`
}

func LoadConfigFromFile

func LoadConfigFromFile(path string) (*MetaConfig, error)

func ParseConfig

func ParseConfig(path string) (*MetaConfig, error)

func ParseConfigFromCluster

func ParseConfigFromCluster(kubeCl *client.KubernetesClient) (*MetaConfig, error)

func ParseConfigFromData

func ParseConfigFromData(configData string) (*MetaConfig, error)

func ParseConfigInCluster

func ParseConfigInCluster(kubeCl *client.KubernetesClient) (*MetaConfig, error)

func (*MetaConfig) CachePath

func (m *MetaConfig) CachePath() string

func (*MetaConfig) ClusterConfigYAML

func (m *MetaConfig) ClusterConfigYAML() ([]byte, error)

func (*MetaConfig) ConfigForBashibleBundleTemplate

func (m *MetaConfig) ConfigForBashibleBundleTemplate(bundle, nodeIP string) (map[string]interface{}, error)

func (*MetaConfig) ConfigForKubeadmTemplates

func (m *MetaConfig) ConfigForKubeadmTemplates(nodeIP string) (map[string]interface{}, error)

func (*MetaConfig) DeepCopy

func (m *MetaConfig) DeepCopy() *MetaConfig

func (*MetaConfig) EnrichProxyData

func (m *MetaConfig) EnrichProxyData() (map[string]interface{}, error)

func (*MetaConfig) ExtractMasterNodeGroupStaticSettings

func (m *MetaConfig) ExtractMasterNodeGroupStaticSettings() map[string]interface{}

func (*MetaConfig) FindTerraNodeGroup

func (m *MetaConfig) FindTerraNodeGroup(nodeGroupName string) []byte

func (*MetaConfig) GetTerraNodeGroups

func (m *MetaConfig) GetTerraNodeGroups() []TerraNodeGroupSpec

func (*MetaConfig) LoadImagesDigests

func (m *MetaConfig) LoadImagesDigests(filename string) error

func (*MetaConfig) LoadInstallerVersion

func (m *MetaConfig) LoadInstallerVersion() error

func (*MetaConfig) LoadVersionMap

func (m *MetaConfig) LoadVersionMap(filename string) error

func (*MetaConfig) MarshalConfig

func (m *MetaConfig) MarshalConfig() []byte

func (*MetaConfig) MarshalFullConfig

func (m *MetaConfig) MarshalFullConfig() []byte

func (*MetaConfig) NodeGroupConfig

func (m *MetaConfig) NodeGroupConfig(nodeGroupName string, nodeIndex int, cloudConfig string) []byte

NodeGroupConfig returns values for terraform to order master node or static node

func (*MetaConfig) NodeGroupManifest

func (m *MetaConfig) NodeGroupManifest(terraNodeGroup TerraNodeGroupSpec) map[string]interface{}

NodeGroupManifest prepares NodeGroup custom resource for static nodes, which were ordered by Terraform

func (*MetaConfig) ParseRegistryData

func (m *MetaConfig) ParseRegistryData() (map[string]interface{}, error)

func (*MetaConfig) Prepare

func (m *MetaConfig) Prepare() (*MetaConfig, error)

Prepare extracts all necessary information from raw json messages to the root structure

func (*MetaConfig) ProviderClusterConfigYAML

func (m *MetaConfig) ProviderClusterConfigYAML() ([]byte, error)

func (*MetaConfig) StaticClusterConfigYAML

func (m *MetaConfig) StaticClusterConfigYAML() ([]byte, error)

type ModuleConfig

type ModuleConfig struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec ModuleConfigSpec `json:"spec"`
}

ModuleConfig is a configuration for module or for global config values.

func ConvertInitConfigurationToModuleConfigs

func ConvertInitConfigurationToModuleConfigs(metaConfig *MetaConfig, schemasStore *SchemaStore, bundle string, level string) ([]*ModuleConfig, error)

ConvertInitConfigurationToModuleConfigs turns InitConfiguration into a set of ModuleConfig's. At first, it creates a mandatory "deckhouse" ModuleConfig, then it checks for any module configuration overrides within InitConfiguration.configOverrides. If it detects such overrides, it converts them into ModuleConfig resources as well. Finally, it unlocks further bootstrap by allowing modules hooks to run with created ModuleConfig's.

type ModuleConfigSpec

type ModuleConfigSpec struct {
	Version  int            `json:"version,omitempty"`
	Settings SettingsValues `json:"settings,omitempty"`
	Enabled  *bool          `json:"enabled,omitempty"`
}

type OpenAPISchema

type OpenAPISchema struct {
	Kind     string                 `json:"kind"`
	Versions []OpenAPISchemaVersion `json:"apiVersions"`
}

type OpenAPISchemaVersion

type OpenAPISchemaVersion struct {
	Version string      `json:"apiVersion"`
	Schema  interface{} `json:"openAPISpec"`
}

type RegistryData

type RegistryData struct {
	Address   string `json:"address"`
	Path      string `json:"path"`
	Scheme    string `json:"scheme"`
	CA        string `json:"ca"`
	DockerCfg string `json:"dockerCfg"`
}

func (*RegistryData) Auth

func (r *RegistryData) Auth() (string, error)

func (*RegistryData) ConvertToMap

func (r *RegistryData) ConvertToMap() map[string]interface{}

type SchemaIndex

type SchemaIndex struct {
	Kind    string `json:"kind"`
	Version string `json:"apiVersion"`
}

func (*SchemaIndex) IsValid

func (i *SchemaIndex) IsValid() bool

func (*SchemaIndex) String

func (i *SchemaIndex) String() string

type SchemaStore

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

func NewSchemaStore

func NewSchemaStore(paths ...string) *SchemaStore

func (*SchemaStore) Get

func (s *SchemaStore) Get(index *SchemaIndex) *spec.Schema

func (*SchemaStore) GetModuleConfigVersion

func (s *SchemaStore) GetModuleConfigVersion(name string) int

func (*SchemaStore) HasSchemaForModuleConfig

func (s *SchemaStore) HasSchemaForModuleConfig(name string) bool

func (*SchemaStore) UploadByPath

func (s *SchemaStore) UploadByPath(path string) error

func (*SchemaStore) Validate

func (s *SchemaStore) Validate(doc *[]byte) (*SchemaIndex, error)

func (*SchemaStore) ValidateWithIndex

func (s *SchemaStore) ValidateWithIndex(index *SchemaIndex, doc *[]byte) error

type SettingsValues

type SettingsValues map[string]interface{}

SettingsValues empty interface in needed to handle DeepCopy generation. DeepCopy does not work with unnamed empty interfaces

type TerraNodeGroupSpec

type TerraNodeGroupSpec struct {
	Replicas     int                    `json:"replicas"`
	Name         string                 `json:"name"`
	NodeTemplate map[string]interface{} `json:"nodeTemplate"`
}

type ValidateOptions

type ValidateOptions struct {
	CommanderMode bool
}

type ValidationRule

type ValidationRule func(oldValue, newValue json.RawMessage) error

Jump to

Keyboard shortcuts

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