Documentation ¶
Index ¶
- Constants
- Variables
- func ApplyConfigPatch(baseCfg []byte, updatedParameters map[string]string, ...) (string, error)
- func CueValidate(cueTpl string) error
- func FromCMKeysSelector(keys []string) *set.LinkedHashSetString
- func FromStringMap(m map[string]string) map[string]interface{}
- func GenerateConstraintsUniqLabelKeyWithConfig(configKey string) string
- func GenerateOpenAPISchema(cueTpl string, schemaType string) (*apiextv1.JSONSchemaProps, error)
- func GenerateTPLUniqLabelKeyWithConfig(configKey string) string
- func GenerateUniqKeyWithConfig(label string, configKey string) string
- func GetComponentCfgName(clusterName, componentName, tplName string) string
- func GetConfigTemplatesFromComponent(cComponents []appsv1alpha1.ClusterComponentSpec, ...) ([]appsv1alpha1.ComponentConfigSpec, error)
- func GetInstanceCMName(obj client.Object, tpl *appsv1alpha1.ComponentTemplateSpec) string
- func GetParameterFromConfiguration(configMap *corev1.ConfigMap, allFiles bool, fieldPath ...string) ([]string, error)
- func GetReloadOptions(cli client.Client, ctx context.Context, ...) (*appsv1alpha1.ReloadOptions, *appsv1alpha1.FormatterConfig, error)
- func IsNotUserReconfigureOperation(cm *corev1.ConfigMap) bool
- func IsParametersUpdateFromManager(cm *corev1.ConfigMap) bool
- func IsSchedulableConfigResource(object client.Object) bool
- func IsSupportConfigFileReconfigure(configTemplateSpec appsv1alpha1.ComponentConfigSpec, configFileKey string) bool
- func IsUpdateDynamicParameters(cc *appsv1alpha1.ConfigConstraintSpec, cfg *ConfigPatchInfo) (bool, error)
- func IsWatchModuleForShellTrigger(trigger *appsv1alpha1.ShellTrigger) bool
- func IsWatchModuleForTplTrigger(trigger *appsv1alpha1.TPLScriptTrigger) bool
- func LoadConfigObjectFromContent(cfgType appsv1alpha1.CfgFileFormat, rawData string) (map[string]interface{}, error)
- func LoadRawConfigObject(data map[string]string, formatConfig *appsv1alpha1.FormatterConfig, ...) (map[string]unstructured.ConfigObject, error)
- func MakeError(formatMsg string, args ...interface{}) error
- func MergeAndValidateConfigs(configConstraint appsv1alpha1.ConfigConstraintSpec, ...) (map[string]string, error)
- func MergeConfigTemplates(cvConfigSpecs []appsv1alpha1.ComponentConfigSpec, ...) []appsv1alpha1.ComponentConfigSpec
- func MergeUpdatedConfig(baseMap, updatedMap map[string]string) map[string]string
- func NeedReloadVolume(config appsv1alpha1.ComponentConfigSpec) bool
- func NestedPrefixField(formatConfig *appsv1alpha1.FormatterConfig) string
- func NewConfigLoader(option CfgOption) (*dataConfig, error)
- func SetParametersUpdateSource(cm *corev1.ConfigMap, source string)
- func TransformConfigFileToKeyValueMap(fileName string, formatterConfig *appsv1alpha1.FormatterConfig, ...) (map[string]string, error)
- func ValidateConfigPatch(patch *ConfigPatchInfo, formatCfg *appsv1alpha1.FormatterConfig) error
- func ValidateConfigurationWithCue(cueTpl string, cfgType appsv1alpha1.CfgFileFormat, rawData string) error
- func WrapError(err error, formatMsg string, args ...interface{}) error
- type CfgOpOption
- type CfgOption
- type ComponentsType
- type ConfigEventContext
- type ConfigEventHandler
- type ConfigLoaderProvider
- type ConfigOperator
- type ConfigPatchInfo
- func CreateConfigPatch(oldVersion, newVersion map[string]string, format appsv1alpha1.CfgFileFormat, ...) (*ConfigPatchInfo, bool, error)
- func CreateMergePatch(oldVersion, newVersion interface{}, option CfgOption) (*ConfigPatchInfo, error)
- func TransformConfigPatchFromData(data map[string]string, format appsv1alpha1.CfgFileFormat, keys []string) (*ConfigPatchInfo, error)
- type ConfigResource
- type ConfigType
- type ConfigValidator
- type CueType
- type CueWalkVisitor
- type GetResourceFn
- type IniContext
- type Option
- type ParamPairs
- type ParameterPair
- type ParameterUpdateType
- type PolicyExecStatus
- type RawConfig
- type ReconfiguringProgress
- type ValidatorOptions
- type VisualizedParam
- type XMLContext
Constants ¶
const ( Unconfirmed int32 = -1 NotStarted int32 = 0 )
const ( ReconfigureCreatedPhase = "created" ReconfigureNoChangeType = "noChange" ReconfigureAutoReloadPhase = string(appsv1alpha1.AutoReload) ReconfigureSimplePhase = string(appsv1alpha1.NormalPolicy) ReconfigureParallelPhase = string(appsv1alpha1.RestartPolicy) ReconfigureRollingPhase = string(appsv1alpha1.RollingPolicy) )
const ( StoreUnit = 1024 KByte = 1 * StoreUnit MByte = KByte * StoreUnit GByte = MByte * StoreUnit TByte = GByte * StoreUnit PByte = TByte * StoreUnit EByte = PByte * StoreUnit ZByte = EByte * StoreUnit YByte = ZByte * StoreUnit )
const ( Millisecond = time.Duration(1) Second = 1000 * Millisecond Minute = 60 * Second Hour = 60 * Minute Day = 24 * Hour )
Variables ¶
var (
ConfigEventHandlerMap = make(map[string]ConfigEventHandler)
)
Functions ¶
func ApplyConfigPatch ¶
func ApplyConfigPatch(baseCfg []byte, updatedParameters map[string]string, formatConfig *appsv1alpha1.FormatterConfig) (string, error)
func FromCMKeysSelector ¶
func FromCMKeysSelector(keys []string) *set.LinkedHashSetString
func FromStringMap ¶
FromStringMap converts a map[string]string to a map[string]interface{}
func GenerateConstraintsUniqLabelKeyWithConfig ¶
GenerateConstraintsUniqLabelKeyWithConfig generates uniq key for configure template reference: docs/img/reconfigure-cr-relationship.drawio.png
func GenerateOpenAPISchema ¶
func GenerateOpenAPISchema(cueTpl string, schemaType string) (*apiextv1.JSONSchemaProps, error)
GenerateOpenAPISchema generates openapi schema from cue type Definitions.
func GenerateTPLUniqLabelKeyWithConfig ¶
GenerateTPLUniqLabelKeyWithConfig generates uniq key for configuration template reference: docs/img/reconfigure-cr-relationship.drawio.png
func GenerateUniqKeyWithConfig ¶
GenerateUniqKeyWithConfig is similar to getInstanceCfgCMName, generates uniq label/annotations for configuration template
func GetComponentCfgName ¶
GetComponentCfgName is similar to getInstanceCfgCMName, while without statefulSet object.
func GetConfigTemplatesFromComponent ¶
func GetConfigTemplatesFromComponent( cComponents []appsv1alpha1.ClusterComponentSpec, dComponents []appsv1alpha1.ClusterComponentDefinition, aComponents []appsv1alpha1.ClusterComponentVersion, componentName string) ([]appsv1alpha1.ComponentConfigSpec, error)
GetConfigTemplatesFromComponent returns ConfigTemplate list used by the component
func GetInstanceCMName ¶
func GetInstanceCMName(obj client.Object, tpl *appsv1alpha1.ComponentTemplateSpec) string
GetInstanceCMName {{statefull.Name}}-{{clusterVersion.Name}}-{{tpl.Name}}-"config"
func GetParameterFromConfiguration ¶
func GetParameterFromConfiguration(configMap *corev1.ConfigMap, allFiles bool, fieldPath ...string) ([]string, error)
GetParameterFromConfiguration gets configure parameter ctx: apiserver context cli: apiserver client cluster: appsv1alpha1.Cluster component: component name
func GetReloadOptions ¶ added in v0.6.0
func GetReloadOptions(cli client.Client, ctx context.Context, configSpecs []appsv1alpha1.ComponentConfigSpec) (*appsv1alpha1.ReloadOptions, *appsv1alpha1.FormatterConfig, error)
func IsNotUserReconfigureOperation ¶
IsNotUserReconfigureOperation checks if the parameters are updated from operation
func IsParametersUpdateFromManager ¶
IsParametersUpdateFromManager checks if the parameters are updated from manager
func IsSupportConfigFileReconfigure ¶ added in v0.6.0
func IsSupportConfigFileReconfigure(configTemplateSpec appsv1alpha1.ComponentConfigSpec, configFileKey string) bool
func IsUpdateDynamicParameters ¶
func IsUpdateDynamicParameters(cc *appsv1alpha1.ConfigConstraintSpec, cfg *ConfigPatchInfo) (bool, error)
IsUpdateDynamicParameters checks if the changed parameters require a restart
func IsWatchModuleForShellTrigger ¶ added in v0.6.0
func IsWatchModuleForShellTrigger(trigger *appsv1alpha1.ShellTrigger) bool
func IsWatchModuleForTplTrigger ¶ added in v0.6.0
func IsWatchModuleForTplTrigger(trigger *appsv1alpha1.TPLScriptTrigger) bool
func LoadConfigObjectFromContent ¶ added in v0.6.0
func LoadConfigObjectFromContent(cfgType appsv1alpha1.CfgFileFormat, rawData string) (map[string]interface{}, error)
func LoadRawConfigObject ¶
func LoadRawConfigObject(data map[string]string, formatConfig *appsv1alpha1.FormatterConfig, keys []string) (map[string]unstructured.ConfigObject, error)
func MergeAndValidateConfigs ¶
func MergeAndValidateConfigs(configConstraint appsv1alpha1.ConfigConstraintSpec, baseConfigs map[string]string, cmKey []string, updatedParams []ParamPairs) (map[string]string, error)
MergeAndValidateConfigs merges and validates configuration files
func MergeConfigTemplates ¶
func MergeConfigTemplates(cvConfigSpecs []appsv1alpha1.ComponentConfigSpec, cdConfigSpecs []appsv1alpha1.ComponentConfigSpec) []appsv1alpha1.ComponentConfigSpec
MergeConfigTemplates merges ClusterVersion.ComponentDefs[*].ConfigTemplateRefs and ClusterDefinition.ComponentDefs[*].ConfigTemplateRefs
func MergeUpdatedConfig ¶ added in v0.6.0
MergeUpdatedConfig replaces the file content of the changed key. baseMap is the original configuration file, updatedMap is the updated configuration file
func NeedReloadVolume ¶ added in v0.6.0
func NeedReloadVolume(config appsv1alpha1.ComponentConfigSpec) bool
func NestedPrefixField ¶
func NestedPrefixField(formatConfig *appsv1alpha1.FormatterConfig) string
func NewConfigLoader ¶
func SetParametersUpdateSource ¶
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 *appsv1alpha1.FormatterConfig, 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 ¶ added in v0.6.0
func ValidateConfigPatch(patch *ConfigPatchInfo, formatCfg *appsv1alpha1.FormatterConfig) error
ValidateConfigPatch Verifies if the changed parameters have been removed
func ValidateConfigurationWithCue ¶
func ValidateConfigurationWithCue(cueTpl string, cfgType appsv1alpha1.CfgFileFormat, rawData string) 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 appsv1alpha1.CfgFileFormat // Path for CfgLocalType test Path string RawData []byte // ConfigResource for k8s resource ConfigResource *ConfigResource }
type ComponentsType ¶
type ComponentsType interface { appsv1alpha1.ClusterComponentVersion | appsv1alpha1.ClusterComponentDefinition | appsv1alpha1.ClusterComponentSpec }
type ConfigEventContext ¶
type ConfigEventContext struct { Client client.Client ReqCtx intctrlutil.RequestCtx Cluster *appsv1alpha1.Cluster ClusterComponent *appsv1alpha1.ClusterComponentSpec Component *appsv1alpha1.ClusterComponentDefinition ComponentUnits []appv1.StatefulSet DeploymentUnits []appv1.Deployment ConfigSpecName string ConfigPatch *ConfigPatchInfo ConfigMap *corev1.ConfigMap ConfigConstraint *appsv1alpha1.ConfigConstraintSpec PolicyStatus PolicyExecStatus }
type ConfigEventHandler ¶
type ConfigEventHandler interface {
Handle(eventContext ConfigEventContext, lastOpsRequest string, phase appsv1alpha1.OpsPhase, err error) error
}
type ConfigLoaderProvider ¶
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 appsv1alpha1.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 ¶ added in v0.6.0
func TransformConfigPatchFromData(data map[string]string, format appsv1alpha1.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 ConfigValidator ¶
func NewConfigValidator ¶
func NewConfigValidator(configConstraint *appsv1alpha1.ConfigConstraintSpec, options ...ValidatorOptions) ConfigValidator
type CueType ¶
type CueType string
CueType defines cue type +enum
const ( NullableType CueType = "nullable" FloatType CueType = "float" IntType CueType = "integer" BoolType CueType = "boolean" StringType CueType = "string" StructType CueType = "object" ListType CueType = "array" K8SQuantityType CueType = "quantity" ClassicStorageType CueType = "storage" ClassicTimeDurationType CueType = "timeDuration" )
type CueWalkVisitor ¶
type IniContext ¶
type IniContext struct {
SectionName string
}
type Option ¶
type Option func(ctx *CfgOpOption)
Option for operator
func WithFormatterConfig ¶
func WithFormatterConfig(formatConfig *appsv1alpha1.FormatterConfig) Option
type ParamPairs ¶
type ParameterPair ¶
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 RawConfig ¶
type RawConfig struct { // formatter Type appsv1alpha1.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 ValidatorOptions ¶
func WithKeySelector ¶
func WithKeySelector(keys []string) ValidatorOptions
type VisualizedParam ¶
type VisualizedParam struct { Key string UpdateType ParameterUpdateType Parameters []ParameterPair }
func GenerateVisualizedParamsList ¶
func GenerateVisualizedParamsList(configPatch *ConfigPatchInfo, formatConfig *appsv1alpha1.FormatterConfig, sets *set.LinkedHashSetString) []VisualizedParam