core

package
v1.0.0-beta.18 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: AGPL-3.0 Imports: 23 Imported by: 3

Documentation

Index

Constants

View Source
const (
	Unconfirmed int32 = -1
	NotStarted  int32 = 0
)
View Source
const (
	ReconfigureCreatedPhase    = "created"
	ReconfigureNoChangeType    = "noChange"
	ReconfigureAutoReloadPhase = string(appsv1alpha1.AsyncDynamicReloadPolicy)
	ReconfigureSimplePhase     = string(appsv1alpha1.NormalPolicy)
	ReconfigureParallelPhase   = string(appsv1alpha1.RestartPolicy)
	ReconfigureRollingPhase    = string(appsv1alpha1.RollingPolicy)
)
View Source
const ArrayFieldPrefix = "@"

Variables

This section is empty.

Functions

func ApplyConfigPatch

func ApplyConfigPatch(baseCfg []byte, updatedParameters map[string]*string, formatConfig *appsv1beta1.FileFormatConfig) (string, error)

func FromCMKeysSelector

func FromCMKeysSelector(keys []string) *set.LinkedHashSetString

func FromConfigObject

func FromConfigObject(name, config string, formatConfig *appsv1beta1.FileFormatConfig) (unstructured.ConfigObject, error)

func FromStringMap

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

FromStringMap converts a map[string]string to a map[string]interface{}

func FromStringPointerMap

func FromStringPointerMap(m map[string]string) map[string]*string

FromStringPointerMap converts a map[string]string to a map[string]interface{}

func FromValueToString

func FromValueToString(val interface{}) string

func GenerateComponentConfigurationName

func GenerateComponentConfigurationName(clusterName, componentName string) string

GenerateComponentConfigurationName generates configuration name for component

func GenerateConstraintsUniqLabelKeyWithConfig

func GenerateConstraintsUniqLabelKeyWithConfig(configKey string) string

GenerateConstraintsUniqLabelKeyWithConfig generates uniq key for configure template reference: docs/img/reconfigure-cr-relationship.drawio.png

func GenerateEnvFromName

func GenerateEnvFromName(originName string) string

GenerateEnvFromName generates env configmap name

func GenerateRevisionPhaseKey

func GenerateRevisionPhaseKey(revision string) string

func GenerateTPLUniqLabelKeyWithConfig

func GenerateTPLUniqLabelKeyWithConfig(configKey string) string

GenerateTPLUniqLabelKeyWithConfig generates uniq key for configuration template reference: docs/img/reconfigure-cr-relationship.drawio.png

func GenerateUniqKeyWithConfig

func GenerateUniqKeyWithConfig(label string, configKey string) string

GenerateUniqKeyWithConfig is similar to getInstanceCfgCMName, generates uniq label/annotations for configuration template

func GetComponentCfgName

func GetComponentCfgName(clusterName, componentName, tplName string) string

GetComponentCfgName is similar to getInstanceCfgCMName, while without statefulSet object.

func GetInstanceCMName

func GetInstanceCMName(obj client.Object, tpl *appsv1.ComponentTemplateSpec) string

func GetParameterFromConfiguration

func GetParameterFromConfiguration(configMap *corev1.ConfigMap, allFiles bool, fieldPath ...string) ([]string, error)

GetParameterFromConfiguration gets configure parameter ctx: apiserver context cli: apiserver client cluster: appsv1.Cluster component: component name

func GetValidFieldName added in v0.8.2

func GetValidFieldName(key string) string

func IsDynamicParameter added in v0.8.2

func IsDynamicParameter(paramName string, cc *appsv1beta1.ConfigConstraintSpec) bool

IsDynamicParameter checks if the parameter supports hot update

func IsNotUserReconfigureOperation

func IsNotUserReconfigureOperation(cm *corev1.ConfigMap) bool

IsNotUserReconfigureOperation checks if the parameters are updated from operation

func IsParametersUpdateFromManager

func IsParametersUpdateFromManager(cm *corev1.ConfigMap) bool

IsParametersUpdateFromManager checks if the parameters are updated from manager

func IsSchedulableConfigResource

func IsSchedulableConfigResource(object client.Object) bool

func IsUpdateDynamicParameters

func IsUpdateDynamicParameters(cc *appsv1beta1.ConfigConstraintSpec, cfg *ConfigPatchInfo) (bool, error)

IsUpdateDynamicParameters checks if the changed parameters require a restart

func IsValidLabelKeyOrValue added in v0.8.2

func IsValidLabelKeyOrValue(label string) bool

IsValidLabelKeyOrValue checks if the input string is a valid label key or value https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#syntax-and-character-set

func IsWatchModuleForShellTrigger

func IsWatchModuleForShellTrigger(trigger *appsv1beta1.ShellTrigger) bool

func IsWatchModuleForTplTrigger

func IsWatchModuleForTplTrigger(trigger *appsv1beta1.TPLScriptTrigger) bool

func LoadRawConfigObject

func LoadRawConfigObject(data map[string]string, formatConfig *appsv1beta1.FileFormatConfig, keys []string) (map[string]unstructured.ConfigObject, error)

func MakeError

func MakeError(formatMsg string, args ...interface{}) error

func MergeUpdatedConfig

func MergeUpdatedConfig(baseMap, updatedMap map[string]string) map[string]string

MergeUpdatedConfig replaces the file content of the changed key. baseMap is the original configuration file, updatedMap is the updated configuration file

func NeedReloadVolume

func NeedReloadVolume(config appsv1.ComponentConfigSpec) bool

func NestedPrefixField

func NestedPrefixField(formatConfig *appsv1beta1.FileFormatConfig) string

func NewConfigLoader

func NewConfigLoader(option CfgOption) (*dataConfig, error)

func SetParametersUpdateSource

func SetParametersUpdateSource(cm *corev1.ConfigMap, source string)

SetParametersUpdateSource sets the parameters' update source manager: parameter only updated from manager external-template: parameter only updated from template ops: parameter updated from operation

func TransformConfigFileToKeyValueMap

func TransformConfigFileToKeyValueMap(fileName string, formatterConfig *appsv1beta1.FileFormatConfig, configData []byte) (map[string]string, error)

TransformConfigFileToKeyValueMap transforms a config file in appsv1alpha1.CfgFileFormat format to a map in which the key is config name and the value is config value sectionName means the desired section of config file, such as [mysqld] section. If config file has no section structure, sectionName should be default to get all values in this config file.

func ValidateConfigPatch

func ValidateConfigPatch(patch *ConfigPatchInfo, formatCfg *appsv1beta1.FileFormatConfig) error

ValidateConfigPatch Verifies if the changed parameters have been removed

func WrapError

func WrapError(err error, formatMsg string, args ...interface{}) error

Types

type CfgOpOption

type CfgOpOption struct {
	// optional
	VolumeName string
	// optional
	FileName string

	// option
	// for all configuration
	AllSearch bool

	// optional
	IniContext *IniContext
	// optional
	XMLContext *XMLContext
}

func NewCfgOptions

func NewCfgOptions(filename string, options ...Option) CfgOpOption

type CfgOption

type CfgOption struct {
	Type ConfigType
	Log  logr.Logger

	// formatter
	CfgType appsv1beta1.CfgFileFormat

	// Path for CfgLocalType test
	Path    string
	RawData []byte

	// ConfigResource for k8s resource
	ConfigResource *ConfigResource
}

type ConfigLoaderProvider

type ConfigLoaderProvider func(option CfgOption) (*cfgWrapper, error)

type ConfigOperator

type ConfigOperator interface {
	// MergeFrom updates parameter in key-value
	MergeFrom(params map[string]interface{}, option CfgOpOption) error

	// Query gets parameter
	Query(jsonpath string, option CfgOpOption) ([]byte, error)

	// ToCfgContent to configuration file content
	ToCfgContent() (map[string]string, error)
}

type ConfigPatchInfo

type ConfigPatchInfo struct {
	IsModify bool
	// new config
	AddConfig map[string]interface{}

	// delete config
	DeleteConfig map[string]interface{}

	// update config
	// patch json
	UpdateConfig map[string][]byte

	Target      *cfgWrapper
	LastVersion *cfgWrapper
}

func CreateConfigPatch

func CreateConfigPatch(oldVersion, newVersion map[string]string, format appsv1beta1.CfgFileFormat, keys []string, comparableAllFiles bool) (*ConfigPatchInfo, bool, error)

CreateConfigPatch creates a patch for configuration files with different version.

func CreateMergePatch

func CreateMergePatch(oldVersion, newVersion interface{}, option CfgOption) (*ConfigPatchInfo, error)

func TransformConfigPatchFromData

func TransformConfigPatchFromData(data map[string]string, format appsv1beta1.CfgFileFormat, keys []string) (*ConfigPatchInfo, error)

type ConfigResource

type ConfigResource struct {
	CfgKey         client.ObjectKey
	ResourceReader GetResourceFn

	// configmap data
	ConfigData map[string]string
	CMKeys     *set.LinkedHashSetString
}

func FromConfigData

func FromConfigData(data map[string]string, cmKeys *set.LinkedHashSetString) *ConfigResource

type ConfigType

type ConfigType string
const (
	CfgCmType    ConfigType = "configmap"
	CfgTplType   ConfigType = "configConstraint"
	CfgLocalType ConfigType = "local"
	CfgRawType   ConfigType = "raw"
)

type GetResourceFn

type GetResourceFn func(key client.ObjectKey) (map[string]string, error)

type IniContext

type IniContext struct {
	SectionName string
}

type Option

type Option func(ctx *CfgOpOption)

Option for operator

func WithFormatterConfig

func WithFormatterConfig(formatConfig *appsv1beta1.FileFormatConfig) Option

type ParamPairs

type ParamPairs struct {
	Key           string
	UpdatedParams map[string]interface{}
}

type ParameterPair

type ParameterPair struct {
	Key   string
	Value *string
}

type ParameterUpdateType

type ParameterUpdateType string

ParameterUpdateType describes how to update the parameters. +enum

const (
	AddedType   ParameterUpdateType = "add"
	DeletedType ParameterUpdateType = "delete"
	UpdatedType ParameterUpdateType = "update"
)

type PolicyExecStatus

type PolicyExecStatus struct {
	PolicyName string
	ExecStatus string
	Status     string

	SucceedCount  int32
	ExpectedCount int32
}

type RawConfig

type RawConfig struct {
	// formatter
	Type appsv1beta1.CfgFileFormat

	RawData string
}

type ReconfiguringProgress

type ReconfiguringProgress int32

ReconfiguringProgress defines the progress percentage. range: 0~100 Unconfirmed(-1) describes an uncertain progress, e.g: fsm is failed. +enum

type VisualizedParam

type VisualizedParam struct {
	Key        string
	UpdateType ParameterUpdateType
	Parameters []ParameterPair
}

func GenerateVisualizedParamsList

func GenerateVisualizedParamsList(configPatch *ConfigPatchInfo, formatConfig *appsv1beta1.FileFormatConfig, sets *set.LinkedHashSetString) []VisualizedParam

type XMLContext

type XMLContext struct {
}

XMLContext TODO(zt) Support Xml config

Jump to

Keyboard shortcuts

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