Documentation
¶
Index ¶
- Constants
- Variables
- func ApplyConfigPatch(baseCfg []byte, updatedParameters map[string]string, ...) (string, error)
- func CheckConfigTemplateReconfigureKey(configSpec appsv1alpha1.ComponentConfigSpec, key string) bool
- 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 GetClusterVersionResource(cvName string, cv *appsv1alpha1.ClusterVersion, cli client.Client, ...) error
- 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 IsNotUserReconfigureOperation(cm *corev1.ConfigMap) bool
- func IsParametersUpdateFromManager(cm *corev1.ConfigMap) bool
- func IsSchedulableConfigResource(object client.Object) bool
- func IsUpdateDynamicParameters(cc *appsv1alpha1.ConfigConstraintSpec, cfg *ConfigPatchInfo) (bool, 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 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 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
- 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 CheckConfigTemplateReconfigureKey ¶
func CheckConfigTemplateReconfigureKey(configSpec appsv1alpha1.ComponentConfigSpec, key string) bool
func FromCMKeysSelector ¶
func FromCMKeysSelector(keys []string) *set.LinkedHashSetString
func FromStringMap ¶
FromStringMap converts a map[string]string to a map[string]interface{}
func GenerateConstraintsUniqLabelKeyWithConfig ¶
GenerateConstraintsUniqLabelKeyWithConfig generate 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 generate openapi schema from cue type Definitions.
func GenerateTPLUniqLabelKeyWithConfig ¶
GenerateTPLUniqLabelKeyWithConfig generate uniq key for configuration template reference: docs/img/reconfigure-cr-relationship.drawio.png
func GenerateUniqKeyWithConfig ¶
GenerateUniqKeyWithConfig is similar to getInstanceCfgCMName, generate uniq label or annotations for configuration template
func GetClusterVersionResource ¶
func GetClusterVersionResource(cvName string, cv *appsv1alpha1.ClusterVersion, cli client.Client, ctx context.Context) error
func GetComponentCfgName ¶
GetComponentCfgName is similar to getInstanceCfgCMName, 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 get configure parameter ctx: apiserver context cli: apiserver client cluster: appsv1alpha1.Cluster component: component name
func IsNotUserReconfigureOperation ¶
IsNotUserReconfigureOperation is used to check whether the parameters are updated from operation
func IsParametersUpdateFromManager ¶
IsParametersUpdateFromManager is used to check whether the parameters are updated from manager
func IsUpdateDynamicParameters ¶
func IsUpdateDynamicParameters(cc *appsv1alpha1.ConfigConstraintSpec, cfg *ConfigPatchInfo) (bool, error)
IsUpdateDynamicParameters is used to check whether the changed parameters require a restart
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 does merge configuration files and validate
func MergeConfigTemplates ¶
func MergeConfigTemplates(cvConfigSpecs []appsv1alpha1.ComponentConfigSpec, cdConfigSpecs []appsv1alpha1.ComponentConfigSpec) []appsv1alpha1.ComponentConfigSpec
MergeConfigTemplates merge ClusterVersion.ComponentDefs[*].ConfigTemplateRefs and ClusterDefinition.ComponentDefs[*].ConfigTemplateRefs
func NestedPrefixField ¶
func NestedPrefixField(formatConfig *appsv1alpha1.FormatterConfig) string
func NewConfigLoader ¶
func SetParametersUpdateSource ¶
SetParametersUpdateSource is used to set the parameters update source manager: parameter only updated from manager external-template: parameter only updated from template ops: parameter has updated from operation
func TransformConfigFileToKeyValueMap ¶
func TransformConfigFileToKeyValueMap(fileName string, formatterConfig *appsv1alpha1.FormatterConfig, configData []byte) (map[string]string, error)
TransformConfigFileToKeyValueMap transforms a config file which formed by 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 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
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 update parameter by keyvalue
MergeFrom(params map[string]interface{}, option CfgOpOption) error
// Query get 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 difference version.
func CreateMergePatch ¶
func CreateMergePatch(oldVersion, newVersion interface{}, option CfgOption) (*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 define 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