From e1531b85e5fdad3b7a503196cbf5f15a0286c5f8 Mon Sep 17 00:00:00 2001
From: zhangtao <111836083+sophon-zt@users.noreply.github.com>
Date: Fri, 29 Mar 2024 19:12:31 +0800
Subject: [PATCH] chore: refactor configconstraint api and support
multi-version (#6919)
---
PROJECT | 11 +
apis/apps/v1/configconstraint_conversion.go | 23 +
apis/apps/v1/configconstraint_types.go | 438 ++++
apis/apps/v1/configconstraint_types_test.go | 67 +
apis/apps/v1/configconstraint_webhook.go | 95 +
apis/apps/v1/doc.go | 23 +
apis/apps/v1/groupversion_info.go | 39 +
apis/apps/v1/meta.go | 48 +
apis/apps/v1/register.go | 29 +
apis/apps/v1/type.go | 112 +
apis/apps/v1/webhook_suite_test.go | 135 ++
apis/apps/v1/zz_generated.deepcopy.go | 452 ++++
apis/apps/v1alpha1/config_meta.go | 18 +-
.../v1alpha1/configconstraint_conversion.go | 136 ++
apis/apps/v1alpha1/configconstraint_types.go | 271 +--
.../v1alpha1/configconstraint_types_test.go | 12 +-
apis/apps/v1alpha1/type.go | 92 -
apis/apps/v1alpha1/webhook_suite_test.go | 6 +-
apis/apps/v1alpha1/zz_generated.deepcopy.go | 235 +-
cmd/manager/main.go | 7 +
cmd/reloader/app/flags.go | 10 +-
cmd/reloader/template/main.go | 4 +-
.../apps.kubeblocks.io_configconstraints.yaml | 512 +++-
config/samples/apps_v1_configconstraint.yaml | 12 +
config/webhook/manifests.yaml | 20 +
controllers/apps/cluster_plan_builder.go | 2 +
.../apps/clusterdefinition_controller_test.go | 5 +-
controllers/apps/configuration/config_util.go | 37 +-
.../apps/configuration/config_util_test.go | 11 +-
.../configconstraint_controller.go | 13 +-
.../configconstraint_controller_test.go | 17 +-
.../apps/configuration/configuration_test.go | 9 +-
.../apps/configuration/policy_util_test.go | 5 +-
.../configuration/reconfigure_controller.go | 2 +-
.../apps/configuration/reconfigure_policy.go | 13 +-
.../apps/configuration/relatedresource.go | 5 +-
controllers/apps/configuration/suite_test.go | 3 +
.../apps/configuration/sync_upgrade_policy.go | 11 +-
.../configuration/sync_upgrade_policy_test.go | 7 +-
.../apps/operations/reconfigure_pipeline.go | 5 +-
.../operations/reconfigure_pipeline_test.go | 5 +-
.../apps/operations/reconfigure_test.go | 5 +-
.../apps/operations/reconfigure_util.go | 5 +-
controllers/apps/operations/suite_test.go | 3 +
.../apps/operations/util/suite_test.go | 3 +
controllers/apps/suite_test.go | 5 +
controllers/apps/transform_types.go | 2 +
.../apps/transformer_component_tls_test.go | 3 +-
controllers/k8score/suite_test.go | 4 +
.../apps.kubeblocks.io_configconstraints.yaml | 512 +++-
deploy/helm/templates/dataprotection.yaml | 10 +-
docs/developer_docs/api-reference/cluster.md | 2144 +++++++++++------
hack/client-sdk-gen.sh | 2 +-
pkg/client/clientset/versioned/clientset.go | 13 +
.../versioned/fake/clientset_generated.go | 7 +
.../clientset/versioned/fake/register.go | 2 +
.../clientset/versioned/scheme/register.go | 2 +
.../versioned/typed/apps/v1/apps_client.go | 107 +
.../typed/apps/v1/configconstraint.go | 184 ++
.../clientset/versioned/typed/apps/v1/doc.go | 20 +
.../versioned/typed/apps/v1/fake/doc.go | 20 +
.../typed/apps/v1/fake/fake_apps_client.go | 40 +
.../apps/v1/fake/fake_configconstraint.go | 132 +
.../typed/apps/v1/generated_expansion.go | 21 +
.../externalversions/apps/interface.go | 8 +
.../apps/v1/configconstraint.go | 89 +
.../externalversions/apps/v1/interface.go | 45 +
.../informers/externalversions/generic.go | 7 +-
.../listers/apps/v1/configconstraint.go | 68 +
.../listers/apps/v1/expansion_generated.go | 23 +
pkg/configuration/config_manager/builder.go | 17 +-
.../config_manager/builder_test.go | 77 +-
.../config_manager/config_handler.go | 153 +-
.../config_manager/config_handler_test.go | 79 +-
.../config_manager/handler_util.go | 43 +-
.../config_manager/handler_util_test.go | 177 +-
pkg/configuration/config_manager/proc_util.go | 4 +-
.../config_manager/reload_util.go | 12 +-
.../config_manager/reload_util_test.go | 33 +-
.../config_manager/signal_darwin.go | 66 +-
.../config_manager/signal_linux.go | 66 +-
.../config_manager/signal_windows.go | 30 +-
pkg/configuration/config_manager/type.go | 19 +-
pkg/configuration/core/config.go | 12 +-
pkg/configuration/core/config_patch.go | 4 +-
pkg/configuration/core/config_patch_test.go | 8 +-
pkg/configuration/core/config_patch_util.go | 10 +-
.../core/config_patch_util_test.go | 54 +-
pkg/configuration/core/config_query.go | 4 +-
pkg/configuration/core/config_test.go | 24 +-
pkg/configuration/core/config_util.go | 15 +-
pkg/configuration/core/config_util_test.go | 31 +-
pkg/configuration/core/reconfigure_util.go | 8 +-
.../core/reconfigure_util_test.go | 44 +-
pkg/configuration/core/type.go | 5 +-
pkg/configuration/validate/config_validate.go | 16 +-
.../validate/config_validate_test.go | 38 +-
pkg/configuration/validate/cue_util.go | 8 +-
pkg/controller/component/suite_test.go | 5 +
pkg/controller/configuration/envfrom_utils.go | 11 +-
.../configuration/envfrom_utils_test.go | 5 +-
pkg/controller/configuration/operator_test.go | 19 +-
pkg/controller/configuration/patch_merger.go | 5 +-
pkg/controller/configuration/pipeline_test.go | 11 +-
.../configuration/resource_wrapper.go | 5 +-
.../configuration/resource_wrapper_test.go | 3 +-
pkg/controller/configuration/suite_test.go | 4 +
.../configuration/template_merger.go | 7 +-
.../configuration/template_merger_test.go | 5 +-
.../configuration/template_wrapper.go | 9 +-
.../configuration/template_wrapper_test.go | 9 +-
.../configuration/tool_image_builder.go | 12 +-
.../configuration/tool_image_builder_test.go | 9 +-
pkg/controller/factory/builder.go | 3 +-
pkg/controller/factory/builder_test.go | 3 +-
pkg/controller/factory/suite_test.go | 4 +
pkg/controller/plan/prepare_test.go | 3 +-
pkg/controller/plan/suite_test.go | 4 +
.../rsm2/reconciler_revision_update_test.go | 3 +-
pkg/controller/rsm2/reconciler_status_test.go | 7 +-
pkg/controllerutil/config_util.go | 3 +-
pkg/controllerutil/config_util_test.go | 11 +-
pkg/controllerutil/suite_test.go | 4 +
pkg/generics/type.go | 3 +-
pkg/lorry/cronjobs/manager.go | 3 +-
pkg/lorry/engines/dbmanager_mock.go | 5 +-
pkg/unstructured/config_object.go | 12 +-
pkg/unstructured/properties.go | 4 +-
pkg/unstructured/properties_test.go | 8 +-
pkg/unstructured/redis_config.go | 4 +-
pkg/unstructured/redis_config_test.go | 10 +-
pkg/unstructured/viper_wrap.go | 24 +-
pkg/unstructured/viper_wrap_test.go | 8 +-
pkg/unstructured/xml_config.go | 4 +-
pkg/unstructured/xml_config_test.go | 6 +-
pkg/unstructured/yaml_config.go | 4 +-
pkg/unstructured/yaml_config_test.go | 6 +-
test/integration/controller_suite_test.go | 6 +-
test/testdata/config/config-constraint.yaml | 11 +-
test/testdata/config/envfrom-constraint.yaml | 2 +-
.../operations_config/config-constraint.yaml | 4 +-
.../mysql-config-constraint-not-validate.yaml | 15 +-
.../resources/mysql-config-constraint.yaml | 8 +-
.../mysql-consensus-config-constraint.yaml | 11 +-
144 files changed, 5694 insertions(+), 2128 deletions(-)
create mode 100644 apis/apps/v1/configconstraint_conversion.go
create mode 100644 apis/apps/v1/configconstraint_types.go
create mode 100644 apis/apps/v1/configconstraint_types_test.go
create mode 100644 apis/apps/v1/configconstraint_webhook.go
create mode 100644 apis/apps/v1/doc.go
create mode 100644 apis/apps/v1/groupversion_info.go
create mode 100644 apis/apps/v1/meta.go
create mode 100644 apis/apps/v1/register.go
create mode 100644 apis/apps/v1/type.go
create mode 100644 apis/apps/v1/webhook_suite_test.go
create mode 100644 apis/apps/v1/zz_generated.deepcopy.go
create mode 100644 apis/apps/v1alpha1/configconstraint_conversion.go
create mode 100644 config/samples/apps_v1_configconstraint.yaml
create mode 100644 pkg/client/clientset/versioned/typed/apps/v1/apps_client.go
create mode 100644 pkg/client/clientset/versioned/typed/apps/v1/configconstraint.go
create mode 100644 pkg/client/clientset/versioned/typed/apps/v1/doc.go
create mode 100644 pkg/client/clientset/versioned/typed/apps/v1/fake/doc.go
create mode 100644 pkg/client/clientset/versioned/typed/apps/v1/fake/fake_apps_client.go
create mode 100644 pkg/client/clientset/versioned/typed/apps/v1/fake/fake_configconstraint.go
create mode 100644 pkg/client/clientset/versioned/typed/apps/v1/generated_expansion.go
create mode 100644 pkg/client/informers/externalversions/apps/v1/configconstraint.go
create mode 100644 pkg/client/informers/externalversions/apps/v1/interface.go
create mode 100644 pkg/client/listers/apps/v1/configconstraint.go
create mode 100644 pkg/client/listers/apps/v1/expansion_generated.go
diff --git a/PROJECT b/PROJECT
index 36332bb35e7..3a9c3e19575 100644
--- a/PROJECT
+++ b/PROJECT
@@ -243,4 +243,15 @@ resources:
defaulting: true
validation: true
webhookVersion: v1
+- api:
+ crdVersion: v1
+ domain: kubeblocks.io
+ group: apps
+ kind: ConfigConstraint
+ path: github.com/apecloud/kubeblocks/apis/apps/v1
+ version: v1
+ webhooks:
+ conversion: true
+ validation: true
+ webhookVersion: v1
version: "3"
diff --git a/apis/apps/v1/configconstraint_conversion.go b/apis/apps/v1/configconstraint_conversion.go
new file mode 100644
index 00000000000..ca736596e45
--- /dev/null
+++ b/apis/apps/v1/configconstraint_conversion.go
@@ -0,0 +1,23 @@
+/*
+Copyright (C) 2022-2023 ApeCloud Co., Ltd
+
+This file is part of KubeBlocks project
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with this program. If not, see .
+*/
+
+package v1
+
+func (r *ConfigConstraint) Hub() {
+}
diff --git a/apis/apps/v1/configconstraint_types.go b/apis/apps/v1/configconstraint_types.go
new file mode 100644
index 00000000000..8e825df6c9d
--- /dev/null
+++ b/apis/apps/v1/configconstraint_types.go
@@ -0,0 +1,438 @@
+/*
+Copyright (C) 2022-2024 ApeCloud Co., Ltd
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package v1
+
+import (
+ corev1 "k8s.io/api/core/v1"
+ apiext "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+)
+
+// ConfigConstraintSpec defines the desired state of ConfigConstraint
+type ConfigConstraintSpec struct {
+ // Specifies the dynamic reload actions supported by the engine. If set, the controller call the scripts defined in the actions for a dynamic parameter upgrade.
+ // The actions are called only when the modified parameter is defined in dynamicParameters part && DynamicReloadAction != nil
+ //
+ // +optional
+ DynamicReloadAction *DynamicReloadAction `json:"dynamicReloadAction,omitempty"`
+
+ // Indicates the dynamic reload action and restart action can be merged to a restart action.
+ //
+ // When a batch of parameters updates incur both restart & dynamic reload, it works as:
+ // - set to true, the two actions merged to only one restart action
+ // - set to false, the two actions cannot be merged, the actions executed in order [dynamic reload, restart]
+ //
+ // +optional
+ DynamicActionCanBeMerged *bool `json:"dynamicActionCanBeMerged,omitempty"`
+
+ // Specifies the policy for selecting the parameters of dynamic reload actions.
+ //
+ // +optional
+ DynamicParameterSelectedPolicy *DynamicParameterSelectedPolicy `json:"dynamicParameterSelectedPolicy,omitempty"`
+
+ // Tools used by the dynamic reload actions.
+ // Usually it is referenced by the 'init container' for 'cp' it to a binary volume.
+ //
+ // +optional
+ ReloadToolsImage *ReloadToolsImage `json:"reloadToolsImage,omitempty"`
+
+ // A set of actions for regenerating local configs.
+ //
+ // It works when:
+ // - different engine roles have different config, such as redis primary & secondary
+ // - after a role switch, the local config will be regenerated with the help of DownwardActions
+ //
+ // +optional
+ DownwardActions []DownwardAction `json:"downwardActions,omitempty"`
+
+ // A list of ScriptConfig used by the actions defined in dynamic reload and downward actions.
+ //
+ // +optional
+ // +patchMergeKey=scriptConfigMapRef
+ // +patchStrategy=merge,retainKeys
+ // +listType=map
+ // +listMapKey=scriptConfigMapRef
+ ScriptConfigs []ScriptConfig `json:"scriptConfigs,omitempty"`
+
+ // Top level key used to get the cue rules to validate the config file.
+ // It must exist in 'ConfigSchema'
+ //
+ // +optional
+ ConfigSchemaTopLevelKey string `json:"configSchemaTopLevelKey,omitempty"`
+
+ // List constraints rules for each config parameters.
+ //
+ // +optional
+ ConfigSchema *ConfigSchema `json:"configSchema,omitempty"`
+
+ // A list of StaticParameter. Modifications of static parameters trigger a process restart.
+ //
+ // +listType=set
+ // +optional
+ StaticParameters []string `json:"staticParameters,omitempty"`
+
+ // A list of DynamicParameter. Modifications of dynamic parameters trigger a reload action without process restart.
+ //
+ // +listType=set
+ // +optional
+ DynamicParameters []string `json:"dynamicParameters,omitempty"`
+
+ // Describes parameters that are prohibited to do any modifications.
+ //
+ // +listType=set
+ // +optional
+ ImmutableParameters []string `json:"immutableParameters,omitempty"`
+
+ // Used to match labels on the pod to do a dynamic reload
+ //
+ // +optional
+ DynamicReloadSelector *metav1.LabelSelector `json:"dynamicReloadSelector,omitempty"`
+
+ // Describes the format of the config file.
+ // The controller works as follows:
+ // 1. Parse the config file
+ // 2. Get the modified parameters
+ // 3. Trigger the corresponding action
+ //
+ // +kubebuilder:validation:Required
+ FormatterConfig *FormatterConfig `json:"formatterConfig"`
+}
+
+// Represents the observed state of a ConfigConstraint.
+
+type ConfigConstraintStatus struct {
+
+ // Specifies the status of the configuration template.
+ // When set to CCAvailablePhase, the ConfigConstraint can be referenced by ClusterDefinition or ClusterVersion.
+ //
+ // +optional
+ Phase ConfigConstraintPhase `json:"phase,omitempty"`
+
+ // Provides descriptions for abnormal states.
+ //
+ // +optional
+ Message string `json:"message,omitempty"`
+
+ // Refers to the most recent generation observed for this ConfigConstraint. This value is updated by the API Server.
+ //
+ // +optional
+ ObservedGeneration int64 `json:"observedGeneration,omitempty"`
+}
+
+type ConfigSchema struct {
+ // Transforms the schema from CUE to json for further OpenAPI validation
+ //
+ // +kubebuilder:validation:Schemaless
+ // +kubebuilder:validation:ComponentDefRef=object
+ // +kubebuilder:pruning:PreserveUnknownFields
+ SchemaInJSON *apiext.JSONSchemaProps `json:"schemaInJSON,omitempty"`
+
+ // Enables providers to verify user configurations using the CUE language.
+ //
+ // +optional
+ CUE string `json:"cue,omitempty"`
+}
+
+// Defines the options for reloading a service or application within the Kubernetes cluster.
+// Only one of its members may be specified at a time.
+
+type DynamicReloadAction struct {
+ // Used to trigger a reload by sending a Unix signal to the process.
+ //
+ // +optional
+ UnixSignalTrigger *UnixSignalTrigger `json:"unixSignalTrigger,omitempty"`
+
+ // Used to perform the reload command in shell script.
+ //
+ // +optional
+ ShellTrigger *ShellTrigger `json:"shellTrigger,omitempty"`
+
+ // Used to perform the reload command by Go template script.
+ //
+ // +optional
+ TPLScriptTrigger *TPLScriptTrigger `json:"tplScriptTrigger"`
+
+ // Used to automatically perform the reload command when conditions are met.
+ //
+ // +optional
+ AutoTrigger *AutoTrigger `json:"autoTrigger,omitempty"`
+}
+
+type UnixSignalTrigger struct {
+ // Represents a valid Unix signal.
+ // Refer to the following URL for a list of all Unix signals: ../../pkg/configuration/configmap/handler.go:allUnixSignals
+ //
+ // +kubebuilder:validation:Required
+ Signal SignalType `json:"signal"`
+
+ // Represents the name of the process that the Unix signal sent to.
+ //
+ // +kubebuilder:validation:Required
+ ProcessName string `json:"processName"`
+}
+
+type ReloadToolsImage struct {
+ // Represents the name of the volume in the PodTemplate. This is where to mount the generated by the config template.
+ // This volume name must be defined within podSpec.containers[*].volumeMounts.
+ //
+ // +kubebuilder:validation:Required
+ // +kubebuilder:validation:MaxLength=32
+ // VolumeName string `json:"volumeName"`
+
+ // Represents the point where the scripts file will be mounted.
+ //
+ // +kubebuilder:validation:Required
+ // +kubebuilder:validation:MaxLength=128
+ MountPoint string `json:"mountPoint"`
+
+ // Used to configure the initialization container.
+ //
+ // +optional
+ ToolConfigs []ToolConfig `json:"toolConfigs,omitempty"`
+}
+
+type ToolConfig struct {
+ // Specifies the name of the initContainer.
+ //
+ // +kubebuilder:validation:Required
+ // +kubebuilder:validation:MaxLength=63
+ // +kubebuilder:validation:Pattern:=`^[a-z]([a-z0-9\-]*[a-z0-9])?$`
+ Name string `json:"name,omitempty"`
+
+ // Represents the url of the tool container image.
+ //
+ // +optional
+ Image string `json:"image,omitempty"`
+
+ // Commands to be executed when init containers.
+ //
+ // +kubebuilder:validation:Required
+ Command []string `json:"command"`
+}
+
+type DownwardAction struct {
+ // Specifies the name of the field. It must be a string of maximum length 63.
+ // The name should match the regex pattern `^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$`.
+ //
+ // +kubebuilder:validation:Required
+ // +kubebuilder:validation:MaxLength=63
+ // +kubebuilder:validation:Pattern:=`^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$`
+ Name string `json:"name"`
+
+ // Specifies the mount point of the scripts file.
+ //
+ // +kubebuilder:validation:Required
+ // +kubebuilder:validation:MaxLength=128
+ MountPoint string `json:"mountPoint"`
+
+ // Represents a list of downward API volume files.
+ //
+ // +kubebuilder:validation:Required
+ Items []corev1.DownwardAPIVolumeFile `json:"items"`
+
+ // The command used to execute for the downward API.
+ //
+ // +optional
+ Command []string `json:"command,omitempty"`
+}
+
+type ScriptConfig struct {
+ // Specifies the reference to the ConfigMap that contains the script to be executed for reload.
+ //
+ // +kubebuilder:validation:Required
+ ScriptConfigMapRef string `json:"scriptConfigMapRef"`
+
+ // Specifies the namespace where the referenced tpl script ConfigMap in.
+ // If left empty, by default in the "default" namespace.
+ //
+ // +kubebuilder:validation:MaxLength=63
+ // +kubebuilder:default="default"
+ // +kubebuilder:validation:Pattern:=`^[a-z0-9]([a-z0-9\-]*[a-z0-9])?$`
+ // +optional
+ Namespace string `json:"namespace,omitempty"`
+}
+
+type ShellTrigger struct {
+ // Specifies the list of commands for reload.
+ //
+ // +kubebuilder:validation:Required
+ Command []string `json:"command"`
+
+ // Specifies whether to synchronize updates parameters to the config manager.
+ // Specifies two ways of controller to reload the parameter:
+ // - set to 'True', execute the reload action in sync mode, wait for the completion of reload
+ // - set to 'False', execute the reload action in async mode, just update the 'Configmap', no need to wait
+ //
+ // +optional
+ Sync *bool `json:"sync,omitempty"`
+
+ // Specifies whether to reconfigure dynamic parameters individually or in a batch.
+ // - Set to 'True' to execute the reload action in a batch, incorporating all parameter changes.
+ // - Set to 'False' to execute the reload action for each parameter change individually.
+ // The default value is 'False'.
+ //
+ // +optional
+ BatchReload *bool `json:"batchReload,omitempty"`
+
+ // When `batchReload` is set to 'True', this parameter allows for the optional specification
+ // of the batch input format that is passed into the STDIN of the script.
+ // The format should be provided as a Go template string.
+ // In the template, the updated parameters' key-value map can be referenced using the dollar sign ('$') variable.
+ // Here's an example of an input template:
+ //
+ // ```yaml
+ //
+ // batchParametersTemplate: |-
+ //
+ // {{- range $pKey, $pValue := $ }}
+ //
+ // {{ printf "%s:%s" $pKey $pValue }}
+ //
+ // {{- end }}
+ //
+ // ```
+ //
+ // In this example, each updated parameter is iterated over in a sorted order by keys to generate the batch input data as follows:
+ //
+ // ```
+ //
+ // key1:value1
+ //
+ // key2:value2
+ //
+ // key3:value3
+ //
+ // ```
+ //
+ // If this parameter is not specified, the default format used for STDIN is as follows:
+ // Each updated parameter generates a line that concatenates the parameter's key and value with a equal sign ('=').
+ // These lines are then sorted by their keys and inserted accordingly. Here's an example of the batch input data using the default template:
+ //
+ // ```
+ //
+ // key1=value1
+ //
+ // key2=value2
+ //
+ // key3=value3
+ //
+ // ```
+ //
+ // +optional
+ BatchParametersTemplate string `json:"batchParametersTemplate,omitempty"`
+}
+
+type TPLScriptTrigger struct {
+ // Config for the script.
+ //
+ ScriptConfig `json:",inline"`
+
+ // Specifies whether to synchronize updates parameters to the config manager.
+ // Specifies two ways of controller to reload the parameter:
+ // - set to 'True', execute the reload action in sync mode, wait for the completion of reload
+ // - set to 'False', execute the reload action in async mode, just update the 'Configmap', no need to wait
+ //
+ // +optional
+ Sync *bool `json:"sync,omitempty"`
+}
+
+type AutoTrigger struct {
+ // The name of the process.
+ //
+ // +optional
+ ProcessName string `json:"processName,omitempty"`
+}
+
+type FormatterConfig struct {
+ // Represents the additional actions for formatting the config file.
+ // If not specified, the default options will be applied.
+ //
+ // +optional
+ FormatterAction `json:",inline"`
+
+ // The config file format. Valid values are `ini`, `xml`, `yaml`, `json`,
+ // `hcl`, `dotenv`, `properties` and `toml`. Each format has its own characteristics and use cases.
+ //
+ // - ini: is a text-based content with a structure and syntax comprising key–value pairs for properties, reference wiki: https://en.wikipedia.org/wiki/INI_file
+ // - xml: refers to wiki: https://en.wikipedia.org/wiki/XML
+ // - yaml: supports for complex data types and structures.
+ // - json: refers to wiki: https://en.wikipedia.org/wiki/JSON
+ // - hcl: The HashiCorp Configuration Language (HCL) is a configuration language authored by HashiCorp, reference url: https://www.linode.com/docs/guides/introduction-to-hcl/
+ // - dotenv: is a plain text file with simple key–value pairs, reference wiki: https://en.wikipedia.org/wiki/Configuration_file#MS-DOS
+ // - properties: a file extension mainly used in Java, reference wiki: https://en.wikipedia.org/wiki/.properties
+ // - toml: refers to wiki: https://en.wikipedia.org/wiki/TOML
+ // - props-plus: a file extension mainly used in Java, supports CamelCase(e.g: brokerMaxConnectionsPerIp)
+ //
+ // +kubebuilder:validation:Required
+ Format CfgFileFormat `json:"format"`
+}
+
+// Encapsulates the unique options for a configuration file.
+// It is important to note that only one of its members can be specified at a time.
+
+type FormatterAction struct {
+
+ // A pointer to an IniConfig struct that holds the ini options.
+ //
+ // +optional
+ IniConfig *IniConfig `json:"iniConfig,omitempty"`
+
+ // A pointer to an XMLConfig struct that holds the xml options.
+ // XMLConfig *XMLConfig `json:"xmlConfig,omitempty"`
+}
+
+// Encapsulates the section name of an ini configuration.
+
+type IniConfig struct {
+
+ // A string that describes the name of the ini section.
+ //
+ // +optional
+ SectionName string `json:"sectionName,omitempty"`
+}
+
+// +genclient
+// +k8s:openapi-gen=true
+// +genclient:nonNamespaced
+// +kubebuilder:object:root=true
+// +kubebuilder:subresource:status
+// +kubebuilder:storageversion
+// +kubebuilder:resource:categories={kubeblocks},scope=Cluster,shortName=cc
+// +kubebuilder:printcolumn:name="PHASE",type="string",JSONPath=".status.phase",description="status phase"
+// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp"
+
+// ConfigConstraint is the Schema for the configconstraint API
+type ConfigConstraint struct {
+ metav1.TypeMeta `json:",inline"`
+ metav1.ObjectMeta `json:"metadata,omitempty"`
+
+ Spec ConfigConstraintSpec `json:"spec,omitempty"`
+ Status ConfigConstraintStatus `json:"status,omitempty"`
+}
+
+// +kubebuilder:object:root=true
+
+// ConfigConstraintList contains a list of ConfigConstraints.
+type ConfigConstraintList struct {
+ metav1.TypeMeta `json:",inline"`
+ metav1.ListMeta `json:"metadata,omitempty"`
+ Items []ConfigConstraint `json:"items"`
+}
+
+func init() {
+ SchemeBuilder.Register(&ConfigConstraint{}, &ConfigConstraintList{})
+}
diff --git a/apis/apps/v1/configconstraint_types_test.go b/apis/apps/v1/configconstraint_types_test.go
new file mode 100644
index 00000000000..53b53c6df7b
--- /dev/null
+++ b/apis/apps/v1/configconstraint_types_test.go
@@ -0,0 +1,67 @@
+/*
+Copyright (C) 2022-2024 ApeCloud Co., Ltd
+
+This file is part of KubeBlocks project
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with this program. If not, see .
+*/
+
+package v1
+
+import (
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+)
+
+func TestConfigConstraintStatus_IsConfigConstraintTerminalPhases(t *testing.T) {
+ type fields struct {
+ Phase ConfigConstraintPhase
+ Message string
+ ObservedGeneration int64
+ }
+ tests := []struct {
+ name string
+ fields fields
+ want bool
+ }{{
+ name: "available phase test",
+ fields: fields{
+ Phase: CCAvailablePhase,
+ },
+ want: true,
+ }, {
+ name: "available phase test",
+ fields: fields{
+ Phase: CCUnavailablePhase,
+ },
+ want: false,
+ }, {
+ name: "available phase test",
+ fields: fields{
+ Phase: CCDeletingPhase,
+ },
+ want: false,
+ }}
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ cs := ConfigConstraintStatus{
+ Phase: tt.fields.Phase,
+ Message: tt.fields.Message,
+ ObservedGeneration: tt.fields.ObservedGeneration,
+ }
+ assert.Equalf(t, tt.want, cs.ConfigConstraintTerminalPhases(), "ConfigConstraintTerminalPhases()")
+ })
+ }
+}
diff --git a/apis/apps/v1/configconstraint_webhook.go b/apis/apps/v1/configconstraint_webhook.go
new file mode 100644
index 00000000000..1941898a447
--- /dev/null
+++ b/apis/apps/v1/configconstraint_webhook.go
@@ -0,0 +1,95 @@
+/*
+Copyright (C) 2022-2024 ApeCloud Co., Ltd
+
+This file is part of KubeBlocks project
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with this program. If not, see .
+*/
+
+package v1
+
+import (
+ "text/template/parse"
+
+ "k8s.io/apimachinery/pkg/runtime"
+ "k8s.io/apimachinery/pkg/util/validation/field"
+ ctrl "sigs.k8s.io/controller-runtime"
+ logf "sigs.k8s.io/controller-runtime/pkg/log"
+ "sigs.k8s.io/controller-runtime/pkg/webhook"
+ "sigs.k8s.io/controller-runtime/pkg/webhook/admission"
+)
+
+// log is for logging in this package.
+var configconstraintlog = logf.Log.WithName("configconstraint-resource")
+
+func (r *ConfigConstraint) SetupWebhookWithManager(mgr ctrl.Manager) error {
+ return ctrl.NewWebhookManagedBy(mgr).
+ For(r).
+ Complete()
+}
+
+// TODO(user): EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
+
+// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
+// +kubebuilder:webhook:path=/validate-apps-kubeblocks-io-v1-configconstraint,mutating=false,failurePolicy=fail,sideEffects=None,groups=apps.kubeblocks.io,resources=configconstraints,verbs=create;update,versions=v1,name=vconfigconstraint.kb.io,admissionReviewVersions=v1
+
+var _ webhook.Validator = &ConfigConstraint{}
+
+// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
+func (r *ConfigConstraint) ValidateCreate() (admission.Warnings, error) {
+ configconstraintlog.Info("validate create", "name", r.Name)
+
+ if err := r.validateShellTrigger(); err != nil {
+ return nil, err
+ }
+ return nil, nil
+}
+
+func (r *ConfigConstraint) validateShellTrigger() error {
+ if !r.Spec.ShellTrigger() {
+ return nil
+ }
+ if r.Spec.BatchReload() {
+ return validateBatchParametersTemplate(r.Spec.DynamicReloadAction.ShellTrigger.BatchParametersTemplate)
+ }
+ return nil
+}
+
+func validateBatchParametersTemplate(template string) error {
+ if template == "" {
+ return field.Invalid(field.NewPath("spec.dynamicReloadAction.shellTrigger.batchParametersTemplate"), nil, "batchParametersTemplate is empty")
+ }
+
+ tr := parse.New(template)
+ _, err := tr.Parse(template, "", "", make(map[string]*parse.Tree))
+ return err
+}
+
+// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
+func (r *ConfigConstraint) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
+ configconstraintlog.Info("validate update", "name", r.Name)
+
+ if err := r.validateShellTrigger(); err != nil {
+ return nil, err
+ }
+ return nil, nil
+}
+
+// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
+func (r *ConfigConstraint) ValidateDelete() (admission.Warnings, error) {
+ configconstraintlog.Info("validate delete", "name", r.Name)
+
+ // TODO(user): fill in your validation logic upon object deletion.
+ return nil, nil
+}
diff --git a/apis/apps/v1/doc.go b/apis/apps/v1/doc.go
new file mode 100644
index 00000000000..695ca9a2c60
--- /dev/null
+++ b/apis/apps/v1/doc.go
@@ -0,0 +1,23 @@
+/*
+Copyright (C) 2022-2024 ApeCloud Co., Ltd
+
+This file is part of KubeBlocks project
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with this program. If not, see .
+*/
+
+// +k8s:deepcopy-gen=package,register
+// +k8s:openapi-gen=true
+// +groupName=apps.kubeblocks.io
+package v1
diff --git a/apis/apps/v1/groupversion_info.go b/apis/apps/v1/groupversion_info.go
new file mode 100644
index 00000000000..b1f1fa6b6b8
--- /dev/null
+++ b/apis/apps/v1/groupversion_info.go
@@ -0,0 +1,39 @@
+/*
+Copyright (C) 2022-2024 ApeCloud Co., Ltd
+
+This file is part of KubeBlocks project
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with this program. If not, see .
+*/
+
+// Package v1 contains API Schema definitions for the apps v1 API group
+// +kubebuilder:object:generate=true
+// +groupName=apps.kubeblocks.io
+package v1
+
+import (
+ "k8s.io/apimachinery/pkg/runtime/schema"
+ "sigs.k8s.io/controller-runtime/pkg/scheme"
+)
+
+var (
+ // GroupVersion is group version used to register these objects
+ GroupVersion = schema.GroupVersion{Group: "apps.kubeblocks.io", Version: "v1"}
+
+ // SchemeBuilder is used to add go types to the GroupVersionKind scheme
+ SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
+
+ // AddToScheme adds the types in this group-version to the given scheme.
+ AddToScheme = SchemeBuilder.AddToScheme
+)
diff --git a/apis/apps/v1/meta.go b/apis/apps/v1/meta.go
new file mode 100644
index 00000000000..5c04068da19
--- /dev/null
+++ b/apis/apps/v1/meta.go
@@ -0,0 +1,48 @@
+/*
+Copyright (C) 2022-2023 ApeCloud Co., Ltd
+
+This file is part of KubeBlocks project
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with this program. If not, see .
+*/
+
+package v1
+
+func (in *ConfigConstraintSpec) NeedDynamicReloadAction() bool {
+ if in.DynamicActionCanBeMerged != nil {
+ return !*in.DynamicActionCanBeMerged
+ }
+ return false
+}
+
+func (in *ConfigConstraintSpec) DynamicParametersPolicy() DynamicParameterSelectedPolicy {
+ if in.DynamicParameterSelectedPolicy != nil {
+ return *in.DynamicParameterSelectedPolicy
+ }
+ return SelectedDynamicParameters
+}
+
+func (in *ConfigConstraintSpec) ShellTrigger() bool {
+ return in.DynamicReloadAction != nil && in.DynamicReloadAction.ShellTrigger != nil
+}
+
+func (in *ConfigConstraintSpec) BatchReload() bool {
+ return in.ShellTrigger() &&
+ in.DynamicReloadAction.ShellTrigger.BatchReload != nil &&
+ *in.DynamicReloadAction.ShellTrigger.BatchReload
+}
+
+func (cs *ConfigConstraintStatus) ConfigConstraintTerminalPhases() bool {
+ return cs.Phase == CCAvailablePhase
+}
diff --git a/apis/apps/v1/register.go b/apis/apps/v1/register.go
new file mode 100644
index 00000000000..93633c70d4a
--- /dev/null
+++ b/apis/apps/v1/register.go
@@ -0,0 +1,29 @@
+/*
+Copyright (C) 2022-2024 ApeCloud Co., Ltd
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package v1
+
+import (
+ "k8s.io/apimachinery/pkg/runtime/schema"
+)
+
+// SchemeGroupVersion is group version used to register these objects.
+var SchemeGroupVersion = GroupVersion
+
+// Resource takes an unqualified resource and returns a Group qualified GroupResource
+func Resource(resource string) schema.GroupResource {
+ return SchemeGroupVersion.WithResource(resource).GroupResource()
+}
diff --git a/apis/apps/v1/type.go b/apis/apps/v1/type.go
new file mode 100644
index 00000000000..bba1e53fe98
--- /dev/null
+++ b/apis/apps/v1/type.go
@@ -0,0 +1,112 @@
+/*
+Copyright (C) 2022-2023 ApeCloud Co., Ltd
+
+This file is part of KubeBlocks project
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with this program. If not, see .
+*/
+
+package v1
+
+// ConfigConstraintPhase defines the ConfigConstraint CR .status.phase
+// +enum
+// +kubebuilder:validation:Enum={Available,Unavailable, Deleting}
+type ConfigConstraintPhase string
+
+const (
+ CCAvailablePhase ConfigConstraintPhase = "Available"
+ CCUnavailablePhase ConfigConstraintPhase = "Unavailable"
+ CCDeletingPhase ConfigConstraintPhase = "Deleting"
+)
+
+// DynamicParameterSelectedPolicy determines how to select the parameters of dynamic reload actions
+//
+// +enum
+// +kubebuilder:validation:Enum={all,dynamic}
+type DynamicParameterSelectedPolicy string
+
+const (
+ SelectedAllParameters DynamicParameterSelectedPolicy = "all"
+ SelectedDynamicParameters DynamicParameterSelectedPolicy = "dynamic"
+)
+
+// CfgFileFormat defines formatter of configuration files.
+// +enum
+// +kubebuilder:validation:Enum={xml,ini,yaml,json,hcl,dotenv,toml,properties,redis,props-plus}
+type CfgFileFormat string
+
+const (
+ Ini CfgFileFormat = "ini"
+ YAML CfgFileFormat = "yaml"
+ JSON CfgFileFormat = "json"
+ XML CfgFileFormat = "xml"
+ HCL CfgFileFormat = "hcl"
+ Dotenv CfgFileFormat = "dotenv"
+ TOML CfgFileFormat = "toml"
+ Properties CfgFileFormat = "properties"
+ RedisCfg CfgFileFormat = "redis"
+ PropertiesPlus CfgFileFormat = "props-plus"
+)
+
+// CfgReloadType defines reload method.
+// +enum
+type CfgReloadType string
+
+const (
+ UnixSignalType CfgReloadType = "signal"
+ SQLType CfgReloadType = "sql"
+ ShellType CfgReloadType = "exec"
+ HTTPType CfgReloadType = "http"
+ TPLScriptType CfgReloadType = "tpl"
+ AutoType CfgReloadType = "auto"
+)
+
+// SignalType defines which signals are valid.
+// +enum
+// +kubebuilder:validation:Enum={SIGHUP,SIGINT,SIGQUIT,SIGILL,SIGTRAP,SIGABRT,SIGBUS,SIGFPE,SIGKILL,SIGUSR1,SIGSEGV,SIGUSR2,SIGPIPE,SIGALRM,SIGTERM,SIGSTKFLT,SIGCHLD,SIGCONT,SIGSTOP,SIGTSTP,SIGTTIN,SIGTTOU,SIGURG,SIGXCPU,SIGXFSZ,SIGVTALRM,SIGPROF,SIGWINCH,SIGIO,SIGPWR,SIGSYS}
+type SignalType string
+
+const (
+ SIGHUP SignalType = "SIGHUP"
+ SIGINT SignalType = "SIGINT"
+ SIGQUIT SignalType = "SIGQUIT"
+ SIGILL SignalType = "SIGILL"
+ SIGTRAP SignalType = "SIGTRAP"
+ SIGABRT SignalType = "SIGABRT"
+ SIGBUS SignalType = "SIGBUS"
+ SIGFPE SignalType = "SIGFPE"
+ SIGKILL SignalType = "SIGKILL"
+ SIGUSR1 SignalType = "SIGUSR1"
+ SIGSEGV SignalType = "SIGSEGV"
+ SIGUSR2 SignalType = "SIGUSR2"
+ SIGPIPE SignalType = "SIGPIPE"
+ SIGALRM SignalType = "SIGALRM"
+ SIGTERM SignalType = "SIGTERM"
+ SIGSTKFLT SignalType = "SIGSTKFLT"
+ SIGCHLD SignalType = "SIGCHLD"
+ SIGCONT SignalType = "SIGCONT"
+ SIGSTOP SignalType = "SIGSTOP"
+ SIGTSTP SignalType = "SIGTSTP"
+ SIGTTIN SignalType = "SIGTTIN"
+ SIGTTOU SignalType = "SIGTTOU"
+ SIGURG SignalType = "SIGURG"
+ SIGXCPU SignalType = "SIGXCPU"
+ SIGXFSZ SignalType = "SIGXFSZ"
+ SIGVTALRM SignalType = "SIGVTALRM"
+ SIGPROF SignalType = "SIGPROF"
+ SIGWINCH SignalType = "SIGWINCH"
+ SIGIO SignalType = "SIGIO"
+ SIGPWR SignalType = "SIGPWR"
+ SIGSYS SignalType = "SIGSYS"
+)
diff --git a/apis/apps/v1/webhook_suite_test.go b/apis/apps/v1/webhook_suite_test.go
new file mode 100644
index 00000000000..4c2fc010fcc
--- /dev/null
+++ b/apis/apps/v1/webhook_suite_test.go
@@ -0,0 +1,135 @@
+/*
+Copyright (C) 2022-2024 ApeCloud Co., Ltd
+
+This file is part of KubeBlocks project
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with this program. If not, see .
+*/
+
+package v1
+
+import (
+ "context"
+ "crypto/tls"
+ "fmt"
+ "net"
+ "path/filepath"
+ "testing"
+ "time"
+
+ . "github.com/onsi/ginkgo/v2"
+ . "github.com/onsi/gomega"
+
+ admissionv1beta1 "k8s.io/api/admission/v1beta1"
+ //+kubebuilder:scaffold:imports
+ "k8s.io/apimachinery/pkg/runtime"
+ "k8s.io/client-go/rest"
+ ctrl "sigs.k8s.io/controller-runtime"
+ "sigs.k8s.io/controller-runtime/pkg/client"
+ "sigs.k8s.io/controller-runtime/pkg/envtest"
+ logf "sigs.k8s.io/controller-runtime/pkg/log"
+ "sigs.k8s.io/controller-runtime/pkg/log/zap"
+)
+
+// These tests use Ginkgo (BDD-style Go testing framework). Refer to
+// http://onsi.github.io/ginkgo/ to learn more about Ginkgo.
+
+var cfg *rest.Config
+var k8sClient client.Client
+var testEnv *envtest.Environment
+var ctx context.Context
+var cancel context.CancelFunc
+
+func TestAPIs(t *testing.T) {
+ RegisterFailHandler(Fail)
+
+ RunSpecs(t, "Webhook Suite")
+}
+
+var _ = BeforeSuite(func() {
+ logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true)))
+
+ ctx, cancel = context.WithCancel(context.TODO())
+
+ By("bootstrapping test environment")
+ testEnv = &envtest.Environment{
+ CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "config", "crd", "bases")},
+ ErrorIfCRDPathMissing: false,
+ WebhookInstallOptions: envtest.WebhookInstallOptions{
+ Paths: []string{filepath.Join("..", "..", "..", "config", "webhook")},
+ },
+ }
+
+ var err error
+ // cfg is defined in this file globally.
+ cfg, err = testEnv.Start()
+ Expect(err).NotTo(HaveOccurred())
+ Expect(cfg).NotTo(BeNil())
+
+ scheme := runtime.NewScheme()
+ err = AddToScheme(scheme)
+ Expect(err).NotTo(HaveOccurred())
+
+ err = admissionv1beta1.AddToScheme(scheme)
+ Expect(err).NotTo(HaveOccurred())
+
+ //+kubebuilder:scaffold:scheme
+
+ k8sClient, err = client.New(cfg, client.Options{Scheme: scheme})
+ Expect(err).NotTo(HaveOccurred())
+ Expect(k8sClient).NotTo(BeNil())
+
+ // start webhook server using Manager
+ webhookInstallOptions := &testEnv.WebhookInstallOptions
+ mgr, err := ctrl.NewManager(cfg, ctrl.Options{
+ Scheme: scheme,
+ Host: webhookInstallOptions.LocalServingHost,
+ Port: webhookInstallOptions.LocalServingPort,
+ CertDir: webhookInstallOptions.LocalServingCertDir,
+ LeaderElection: false,
+ MetricsBindAddress: "0",
+ })
+ Expect(err).NotTo(HaveOccurred())
+
+ err = (&ConfigConstraint{}).SetupWebhookWithManager(mgr)
+ Expect(err).NotTo(HaveOccurred())
+
+ //+kubebuilder:scaffold:webhook
+
+ go func() {
+ defer GinkgoRecover()
+ err = mgr.Start(ctx)
+ Expect(err).NotTo(HaveOccurred())
+ }()
+
+ // wait for the webhook server to get ready
+ dialer := &net.Dialer{Timeout: time.Second}
+ addrPort := fmt.Sprintf("%s:%d", webhookInstallOptions.LocalServingHost, webhookInstallOptions.LocalServingPort)
+ Eventually(func() error {
+ conn, err := tls.DialWithDialer(dialer, "tcp", addrPort, &tls.Config{InsecureSkipVerify: true})
+ if err != nil {
+ return err
+ }
+ conn.Close()
+ return nil
+ }).Should(Succeed())
+
+})
+
+var _ = AfterSuite(func() {
+ cancel()
+ By("tearing down the test environment")
+ err := testEnv.Stop()
+ Expect(err).NotTo(HaveOccurred())
+})
diff --git a/apis/apps/v1/zz_generated.deepcopy.go b/apis/apps/v1/zz_generated.deepcopy.go
new file mode 100644
index 00000000000..a9a80293d9e
--- /dev/null
+++ b/apis/apps/v1/zz_generated.deepcopy.go
@@ -0,0 +1,452 @@
+//go:build !ignore_autogenerated
+// +build !ignore_autogenerated
+
+/*
+Copyright (C) 2022-2024 ApeCloud Co., Ltd
+
+This file is part of KubeBlocks project
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with this program. If not, see .
+*/
+
+// Code generated by controller-gen. DO NOT EDIT.
+
+package v1
+
+import (
+ corev1 "k8s.io/api/core/v1"
+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+ "k8s.io/apimachinery/pkg/runtime"
+)
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *AutoTrigger) DeepCopyInto(out *AutoTrigger) {
+ *out = *in
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AutoTrigger.
+func (in *AutoTrigger) DeepCopy() *AutoTrigger {
+ if in == nil {
+ return nil
+ }
+ out := new(AutoTrigger)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *ConfigConstraint) DeepCopyInto(out *ConfigConstraint) {
+ *out = *in
+ out.TypeMeta = in.TypeMeta
+ in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
+ in.Spec.DeepCopyInto(&out.Spec)
+ out.Status = in.Status
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConfigConstraint.
+func (in *ConfigConstraint) DeepCopy() *ConfigConstraint {
+ if in == nil {
+ return nil
+ }
+ out := new(ConfigConstraint)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
+func (in *ConfigConstraint) DeepCopyObject() runtime.Object {
+ if c := in.DeepCopy(); c != nil {
+ return c
+ }
+ return nil
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *ConfigConstraintList) DeepCopyInto(out *ConfigConstraintList) {
+ *out = *in
+ out.TypeMeta = in.TypeMeta
+ in.ListMeta.DeepCopyInto(&out.ListMeta)
+ if in.Items != nil {
+ in, out := &in.Items, &out.Items
+ *out = make([]ConfigConstraint, len(*in))
+ for i := range *in {
+ (*in)[i].DeepCopyInto(&(*out)[i])
+ }
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConfigConstraintList.
+func (in *ConfigConstraintList) DeepCopy() *ConfigConstraintList {
+ if in == nil {
+ return nil
+ }
+ out := new(ConfigConstraintList)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
+func (in *ConfigConstraintList) DeepCopyObject() runtime.Object {
+ if c := in.DeepCopy(); c != nil {
+ return c
+ }
+ return nil
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *ConfigConstraintSpec) DeepCopyInto(out *ConfigConstraintSpec) {
+ *out = *in
+ if in.DynamicReloadAction != nil {
+ in, out := &in.DynamicReloadAction, &out.DynamicReloadAction
+ *out = new(DynamicReloadAction)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.DynamicActionCanBeMerged != nil {
+ in, out := &in.DynamicActionCanBeMerged, &out.DynamicActionCanBeMerged
+ *out = new(bool)
+ **out = **in
+ }
+ if in.DynamicParameterSelectedPolicy != nil {
+ in, out := &in.DynamicParameterSelectedPolicy, &out.DynamicParameterSelectedPolicy
+ *out = new(DynamicParameterSelectedPolicy)
+ **out = **in
+ }
+ if in.ReloadToolsImage != nil {
+ in, out := &in.ReloadToolsImage, &out.ReloadToolsImage
+ *out = new(ReloadToolsImage)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.DownwardActions != nil {
+ in, out := &in.DownwardActions, &out.DownwardActions
+ *out = make([]DownwardAction, len(*in))
+ for i := range *in {
+ (*in)[i].DeepCopyInto(&(*out)[i])
+ }
+ }
+ if in.ScriptConfigs != nil {
+ in, out := &in.ScriptConfigs, &out.ScriptConfigs
+ *out = make([]ScriptConfig, len(*in))
+ copy(*out, *in)
+ }
+ if in.ConfigSchema != nil {
+ in, out := &in.ConfigSchema, &out.ConfigSchema
+ *out = new(ConfigSchema)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.StaticParameters != nil {
+ in, out := &in.StaticParameters, &out.StaticParameters
+ *out = make([]string, len(*in))
+ copy(*out, *in)
+ }
+ if in.DynamicParameters != nil {
+ in, out := &in.DynamicParameters, &out.DynamicParameters
+ *out = make([]string, len(*in))
+ copy(*out, *in)
+ }
+ if in.ImmutableParameters != nil {
+ in, out := &in.ImmutableParameters, &out.ImmutableParameters
+ *out = make([]string, len(*in))
+ copy(*out, *in)
+ }
+ if in.DynamicReloadSelector != nil {
+ in, out := &in.DynamicReloadSelector, &out.DynamicReloadSelector
+ *out = new(metav1.LabelSelector)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.FormatterConfig != nil {
+ in, out := &in.FormatterConfig, &out.FormatterConfig
+ *out = new(FormatterConfig)
+ (*in).DeepCopyInto(*out)
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConfigConstraintSpec.
+func (in *ConfigConstraintSpec) DeepCopy() *ConfigConstraintSpec {
+ if in == nil {
+ return nil
+ }
+ out := new(ConfigConstraintSpec)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *ConfigConstraintStatus) DeepCopyInto(out *ConfigConstraintStatus) {
+ *out = *in
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConfigConstraintStatus.
+func (in *ConfigConstraintStatus) DeepCopy() *ConfigConstraintStatus {
+ if in == nil {
+ return nil
+ }
+ out := new(ConfigConstraintStatus)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *ConfigSchema) DeepCopyInto(out *ConfigSchema) {
+ *out = *in
+ if in.SchemaInJSON != nil {
+ in, out := &in.SchemaInJSON, &out.SchemaInJSON
+ *out = (*in).DeepCopy()
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConfigSchema.
+func (in *ConfigSchema) DeepCopy() *ConfigSchema {
+ if in == nil {
+ return nil
+ }
+ out := new(ConfigSchema)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *DownwardAction) DeepCopyInto(out *DownwardAction) {
+ *out = *in
+ if in.Items != nil {
+ in, out := &in.Items, &out.Items
+ *out = make([]corev1.DownwardAPIVolumeFile, len(*in))
+ for i := range *in {
+ (*in)[i].DeepCopyInto(&(*out)[i])
+ }
+ }
+ if in.Command != nil {
+ in, out := &in.Command, &out.Command
+ *out = make([]string, len(*in))
+ copy(*out, *in)
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DownwardAction.
+func (in *DownwardAction) DeepCopy() *DownwardAction {
+ if in == nil {
+ return nil
+ }
+ out := new(DownwardAction)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *DynamicReloadAction) DeepCopyInto(out *DynamicReloadAction) {
+ *out = *in
+ if in.UnixSignalTrigger != nil {
+ in, out := &in.UnixSignalTrigger, &out.UnixSignalTrigger
+ *out = new(UnixSignalTrigger)
+ **out = **in
+ }
+ if in.ShellTrigger != nil {
+ in, out := &in.ShellTrigger, &out.ShellTrigger
+ *out = new(ShellTrigger)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.TPLScriptTrigger != nil {
+ in, out := &in.TPLScriptTrigger, &out.TPLScriptTrigger
+ *out = new(TPLScriptTrigger)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.AutoTrigger != nil {
+ in, out := &in.AutoTrigger, &out.AutoTrigger
+ *out = new(AutoTrigger)
+ **out = **in
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DynamicReloadAction.
+func (in *DynamicReloadAction) DeepCopy() *DynamicReloadAction {
+ if in == nil {
+ return nil
+ }
+ out := new(DynamicReloadAction)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *FormatterAction) DeepCopyInto(out *FormatterAction) {
+ *out = *in
+ if in.IniConfig != nil {
+ in, out := &in.IniConfig, &out.IniConfig
+ *out = new(IniConfig)
+ **out = **in
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FormatterAction.
+func (in *FormatterAction) DeepCopy() *FormatterAction {
+ if in == nil {
+ return nil
+ }
+ out := new(FormatterAction)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *FormatterConfig) DeepCopyInto(out *FormatterConfig) {
+ *out = *in
+ in.FormatterAction.DeepCopyInto(&out.FormatterAction)
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FormatterConfig.
+func (in *FormatterConfig) DeepCopy() *FormatterConfig {
+ if in == nil {
+ return nil
+ }
+ out := new(FormatterConfig)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *IniConfig) DeepCopyInto(out *IniConfig) {
+ *out = *in
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IniConfig.
+func (in *IniConfig) DeepCopy() *IniConfig {
+ if in == nil {
+ return nil
+ }
+ out := new(IniConfig)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *ReloadToolsImage) DeepCopyInto(out *ReloadToolsImage) {
+ *out = *in
+ if in.ToolConfigs != nil {
+ in, out := &in.ToolConfigs, &out.ToolConfigs
+ *out = make([]ToolConfig, len(*in))
+ for i := range *in {
+ (*in)[i].DeepCopyInto(&(*out)[i])
+ }
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ReloadToolsImage.
+func (in *ReloadToolsImage) DeepCopy() *ReloadToolsImage {
+ if in == nil {
+ return nil
+ }
+ out := new(ReloadToolsImage)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *ScriptConfig) DeepCopyInto(out *ScriptConfig) {
+ *out = *in
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ScriptConfig.
+func (in *ScriptConfig) DeepCopy() *ScriptConfig {
+ if in == nil {
+ return nil
+ }
+ out := new(ScriptConfig)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *ShellTrigger) DeepCopyInto(out *ShellTrigger) {
+ *out = *in
+ if in.Command != nil {
+ in, out := &in.Command, &out.Command
+ *out = make([]string, len(*in))
+ copy(*out, *in)
+ }
+ if in.Sync != nil {
+ in, out := &in.Sync, &out.Sync
+ *out = new(bool)
+ **out = **in
+ }
+ if in.BatchReload != nil {
+ in, out := &in.BatchReload, &out.BatchReload
+ *out = new(bool)
+ **out = **in
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ShellTrigger.
+func (in *ShellTrigger) DeepCopy() *ShellTrigger {
+ if in == nil {
+ return nil
+ }
+ out := new(ShellTrigger)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *TPLScriptTrigger) DeepCopyInto(out *TPLScriptTrigger) {
+ *out = *in
+ out.ScriptConfig = in.ScriptConfig
+ if in.Sync != nil {
+ in, out := &in.Sync, &out.Sync
+ *out = new(bool)
+ **out = **in
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TPLScriptTrigger.
+func (in *TPLScriptTrigger) DeepCopy() *TPLScriptTrigger {
+ if in == nil {
+ return nil
+ }
+ out := new(TPLScriptTrigger)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *ToolConfig) DeepCopyInto(out *ToolConfig) {
+ *out = *in
+ if in.Command != nil {
+ in, out := &in.Command, &out.Command
+ *out = make([]string, len(*in))
+ copy(*out, *in)
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ToolConfig.
+func (in *ToolConfig) DeepCopy() *ToolConfig {
+ if in == nil {
+ return nil
+ }
+ out := new(ToolConfig)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *UnixSignalTrigger) DeepCopyInto(out *UnixSignalTrigger) {
+ *out = *in
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new UnixSignalTrigger.
+func (in *UnixSignalTrigger) DeepCopy() *UnixSignalTrigger {
+ if in == nil {
+ return nil
+ }
+ out := new(UnixSignalTrigger)
+ in.DeepCopyInto(out)
+ return out
+}
diff --git a/apis/apps/v1alpha1/config_meta.go b/apis/apps/v1alpha1/config_meta.go
index 4198f360562..692a9ca8d75 100644
--- a/apis/apps/v1alpha1/config_meta.go
+++ b/apis/apps/v1alpha1/config_meta.go
@@ -19,7 +19,9 @@ along with this program. If not, see .
package v1alpha1
-import "encoding/json"
+import (
+ "encoding/json"
+)
// MarshalJSON implements the Marshaler interface.
func (c *Payload) MarshalJSON() ([]byte, error) {
@@ -54,20 +56,6 @@ func (c *Payload) DeepCopyInto(out *Payload) {
out.Data = clone
}
-func (in *ConfigConstraintSpec) NeedDynamicReloadAction() bool {
- if in.DynamicActionCanBeMerged != nil {
- return !*in.DynamicActionCanBeMerged
- }
- return false
-}
-
-func (in *ConfigConstraintSpec) DynamicParametersPolicy() DynamicParameterSelectedPolicy {
- if in.DynamicParameterSelectedPolicy != nil {
- return *in.DynamicParameterSelectedPolicy
- }
- return SelectedDynamicParameters
-}
-
func (configuration *ConfigurationSpec) GetConfigurationItem(name string) *ConfigurationItemDetail {
for i := range configuration.ConfigItemDetails {
configItem := &configuration.ConfigItemDetails[i]
diff --git a/apis/apps/v1alpha1/configconstraint_conversion.go b/apis/apps/v1alpha1/configconstraint_conversion.go
new file mode 100644
index 00000000000..44af4c0b58c
--- /dev/null
+++ b/apis/apps/v1alpha1/configconstraint_conversion.go
@@ -0,0 +1,136 @@
+/*
+Copyright (C) 2022-2023 ApeCloud Co., Ltd
+
+This file is part of KubeBlocks project
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with this program. If not, see .
+*/
+
+package v1alpha1
+
+import (
+ "errors"
+
+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+ "sigs.k8s.io/controller-runtime/pkg/client"
+ "sigs.k8s.io/controller-runtime/pkg/conversion"
+ logf "sigs.k8s.io/controller-runtime/pkg/log"
+
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
+)
+
+var logger = logf.Log.WithName("application-resource")
+
+func (cc *ConfigConstraint) ConvertTo(dstRaw conversion.Hub) error {
+ logger.Info("Conversion Webhook: From v1alpha1 to v1")
+ ccv1, ok := dstRaw.(*appsv1.ConfigConstraint)
+ if !ok {
+ return errors.New("invalid destination object")
+ }
+ return convertToImpl(cc, ccv1)
+}
+
+func (cc *ConfigConstraint) ConvertFrom(srcRaw conversion.Hub) error {
+ logger.Info("Conversion Webhook: From v1 to v1beta1")
+ ccv1, ok := srcRaw.(*appsv1.ConfigConstraint)
+ if !ok {
+ return errors.New("invalid source object")
+ }
+ return convertFromImpl(ccv1, cc)
+}
+
+func convertToImpl(cc *ConfigConstraint, ccv1 *appsv1.ConfigConstraint) error {
+ convertObjectMeta(cc.ObjectMeta, ccv1)
+ convertToConstraintSpec(&cc.Spec, &ccv1.Spec)
+ return nil
+}
+
+func convertObjectMeta(src metav1.ObjectMeta, dst client.Object) {
+ dst.SetLabels(src.GetLabels())
+ dst.SetAnnotations(src.GetAnnotations())
+}
+
+func convertToConstraintSpec(cc *ConfigConstraintSpec, ccv1 *appsv1.ConfigConstraintSpec) {
+ ccv1.DynamicActionCanBeMerged = cc.DynamicActionCanBeMerged
+ ccv1.DynamicParameterSelectedPolicy = cc.DynamicParameterSelectedPolicy
+ ccv1.ReloadToolsImage = cc.ToolsImageSpec
+ ccv1.DownwardActions = cc.DownwardAPIOptions
+ ccv1.ScriptConfigs = cc.ScriptConfigs
+ ccv1.ConfigSchemaTopLevelKey = cc.CfgSchemaTopLevelName
+ ccv1.StaticParameters = cc.StaticParameters
+ ccv1.DynamicParameters = cc.DynamicParameters
+ ccv1.ImmutableParameters = cc.ImmutableParameters
+ ccv1.DynamicReloadSelector = cc.Selector
+ ccv1.FormatterConfig = cc.FormatterConfig
+ convertDynamicReloadAction(cc.ReloadOptions, ccv1)
+ convertSchema(cc.ConfigurationSchema, ccv1)
+}
+
+func convertSchema(schema *CustomParametersValidation, ccv1 *appsv1.ConfigConstraintSpec) {
+ if schema != nil {
+ return
+ }
+
+ ccv1.ConfigSchema = &appsv1.ConfigSchema{
+ CUE: schema.CUE,
+ SchemaInJSON: schema.Schema,
+ }
+}
+
+func convertDynamicReloadAction(options *ReloadOptions, ccv1 *appsv1.ConfigConstraintSpec) {
+ if options != nil {
+ return
+ }
+ ccv1.DynamicReloadAction = &appsv1.DynamicReloadAction{
+ UnixSignalTrigger: options.UnixSignalTrigger,
+ ShellTrigger: options.ShellTrigger,
+ TPLScriptTrigger: options.TPLScriptTrigger,
+ AutoTrigger: options.AutoTrigger,
+ }
+}
+
+func convertFromImpl(ccv1 *appsv1.ConfigConstraint, cc *ConfigConstraint) error {
+ convertObjectMeta(ccv1.ObjectMeta, cc)
+ convertFromConstraintSpec(&ccv1.Spec, &cc.Spec)
+ return nil
+}
+
+func convertFromConstraintSpec(ccv1 *appsv1.ConfigConstraintSpec, cc *ConfigConstraintSpec) {
+ cc.DynamicActionCanBeMerged = ccv1.DynamicActionCanBeMerged
+ cc.DynamicParameterSelectedPolicy = ccv1.DynamicParameterSelectedPolicy
+ cc.ToolsImageSpec = ccv1.ReloadToolsImage
+ cc.DownwardAPIOptions = ccv1.DownwardActions
+ cc.ScriptConfigs = ccv1.ScriptConfigs
+ cc.CfgSchemaTopLevelName = ccv1.ConfigSchemaTopLevelKey
+ cc.StaticParameters = ccv1.StaticParameters
+ cc.DynamicParameters = ccv1.DynamicParameters
+ cc.ImmutableParameters = ccv1.ImmutableParameters
+ cc.Selector = ccv1.DynamicReloadSelector
+ cc.FormatterConfig = ccv1.FormatterConfig
+
+ if ccv1.DynamicReloadAction != nil {
+ cc.ReloadOptions = &ReloadOptions{
+ UnixSignalTrigger: ccv1.DynamicReloadAction.UnixSignalTrigger,
+ ShellTrigger: ccv1.DynamicReloadAction.ShellTrigger,
+ TPLScriptTrigger: ccv1.DynamicReloadAction.TPLScriptTrigger,
+ AutoTrigger: ccv1.DynamicReloadAction.AutoTrigger,
+ }
+ }
+ if ccv1.ConfigSchema != nil {
+ cc.ConfigurationSchema = &CustomParametersValidation{
+ Schema: ccv1.ConfigSchema.SchemaInJSON,
+ CUE: ccv1.ConfigSchema.CUE,
+ }
+ }
+}
diff --git a/apis/apps/v1alpha1/configconstraint_types.go b/apis/apps/v1alpha1/configconstraint_types.go
index 9bb62ce1239..04ea3876ff7 100644
--- a/apis/apps/v1alpha1/configconstraint_types.go
+++ b/apis/apps/v1alpha1/configconstraint_types.go
@@ -17,16 +17,16 @@ limitations under the License.
package v1alpha1
import (
- corev1 "k8s.io/api/core/v1"
apiext "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
)
// ConfigConstraintSpec defines the desired state of ConfigConstraint
type ConfigConstraintSpec struct {
// Specifies the dynamic reload actions supported by the engine. If set, the controller call the scripts defined in the actions for a dynamic parameter upgrade.
- // The actions are called only when the modified parameter is defined in dynamicParameters part && DynamicReloadActions != nil
- // TODO (refactored to DynamicReloadActions)
+ // The actions are called only when the modified parameter is defined in dynamicParameters part && ReloadOptions != nil
//
// +optional
ReloadOptions *ReloadOptions `json:"reloadOptions,omitempty"`
@@ -43,24 +43,22 @@ type ConfigConstraintSpec struct {
// Specifies the policy for selecting the parameters of dynamic reload actions.
//
// +optional
- DynamicParameterSelectedPolicy *DynamicParameterSelectedPolicy `json:"dynamicParameterSelectedPolicy,omitempty"`
+ DynamicParameterSelectedPolicy *v1.DynamicParameterSelectedPolicy `json:"dynamicParameterSelectedPolicy,omitempty"`
// Tools used by the dynamic reload actions.
// Usually it is referenced by the 'init container' for 'cp' it to a binary volume.
- // TODO (refactored to ReloadToolsImage)
//
// +optional
- ToolsImageSpec *ToolsImageSpec `json:"toolsImageSpec,omitempty"`
+ ToolsImageSpec *v1.ReloadToolsImage `json:"toolsImageSpec,omitempty"`
// A set of actions for regenerating local configs.
//
// It works when:
// - different engine roles have different config, such as redis primary & secondary
// - after a role switch, the local config will be regenerated with the help of DownwardActions
- // TODO (refactored to DownwardActions)
//
// +optional
- DownwardAPIOptions []DownwardAPIOption `json:"downwardAPIOptions,omitempty"`
+ DownwardAPIOptions []v1.DownwardAction `json:"downwardAPIOptions,omitempty"`
// A list of ScriptConfig used by the actions defined in dynamic reload and downward actions.
//
@@ -69,17 +67,15 @@ type ConfigConstraintSpec struct {
// +patchStrategy=merge,retainKeys
// +listType=map
// +listMapKey=scriptConfigMapRef
- ScriptConfigs []ScriptConfig `json:"scriptConfigs,omitempty"`
+ ScriptConfigs []v1.ScriptConfig `json:"scriptConfigs,omitempty"`
// Top level key used to get the cue rules to validate the config file.
// It must exist in 'ConfigSchema'
- // TODO (refactored to ConfigSchemaTopLevelKey)
//
// +optional
CfgSchemaTopLevelName string `json:"cfgSchemaTopLevelName,omitempty"`
// List constraints rules for each config parameters.
- // TODO (refactored to ConfigSchema)
//
// +optional
ConfigurationSchema *CustomParametersValidation `json:"configurationSchema,omitempty"`
@@ -103,8 +99,8 @@ type ConfigConstraintSpec struct {
ImmutableParameters []string `json:"immutableParameters,omitempty"`
// Used to match labels on the pod to do a dynamic reload
- // TODO (refactored to DynamicReloadSelector)
//
+ // +optional
Selector *metav1.LabelSelector `json:"selector,omitempty"`
// Describes the format of the config file.
@@ -114,7 +110,7 @@ type ConfigConstraintSpec struct {
// 3. Trigger the corresponding action
//
// +kubebuilder:validation:Required
- FormatterConfig *FormatterConfig `json:"formatterConfig"`
+ FormatterConfig *v1.FormatterConfig `json:"formatterConfig"`
}
// Represents the observed state of a ConfigConstraint.
@@ -125,7 +121,7 @@ type ConfigConstraintStatus struct {
// When set to CCAvailablePhase, the ConfigConstraint can be referenced by ClusterDefinition or ClusterVersion.
//
// +optional
- Phase ConfigConstraintPhase `json:"phase,omitempty"`
+ Phase v1.ConfigConstraintPhase `json:"phase,omitempty"`
// Provides descriptions for abnormal states.
//
@@ -138,13 +134,8 @@ type ConfigConstraintStatus struct {
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
}
-func (cs ConfigConstraintStatus) IsConfigConstraintTerminalPhases() bool {
- return cs.Phase == CCAvailablePhase
-}
-
type CustomParametersValidation struct {
// Transforms the schema from CUE to json for further OpenAPI validation
- // TODO (refactored to SchemaInJson)
//
// +kubebuilder:validation:Schemaless
// +kubebuilder:validation:ComponentDefRef=object
@@ -164,256 +155,22 @@ type ReloadOptions struct {
// Used to trigger a reload by sending a Unix signal to the process.
//
// +optional
- UnixSignalTrigger *UnixSignalTrigger `json:"unixSignalTrigger,omitempty"`
+ UnixSignalTrigger *v1.UnixSignalTrigger `json:"unixSignalTrigger,omitempty"`
// Used to perform the reload command in shell script.
//
// +optional
- ShellTrigger *ShellTrigger `json:"shellTrigger,omitempty"`
+ ShellTrigger *v1.ShellTrigger `json:"shellTrigger,omitempty"`
// Used to perform the reload command by Go template script.
//
// +optional
- TPLScriptTrigger *TPLScriptTrigger `json:"tplScriptTrigger"`
+ TPLScriptTrigger *v1.TPLScriptTrigger `json:"tplScriptTrigger"`
// Used to automatically perform the reload command when conditions are met.
//
// +optional
- AutoTrigger *AutoTrigger `json:"autoTrigger,omitempty"`
-}
-
-type UnixSignalTrigger struct {
- // Represents a valid Unix signal.
- // Refer to the following URL for a list of all Unix signals: ../../pkg/configuration/configmap/handler.go:allUnixSignals
- //
- // +kubebuilder:validation:Required
- Signal SignalType `json:"signal"`
-
- // Represents the name of the process that the Unix signal sent to.
- //
- // +kubebuilder:validation:Required
- ProcessName string `json:"processName"`
-}
-
-type ToolsImageSpec struct {
- // Represents the name of the volume in the PodTemplate. This is where to mount the generated by the config template.
- // This volume name must be defined within podSpec.containers[*].volumeMounts.
- //
- // +kubebuilder:validation:Required
- // +kubebuilder:validation:MaxLength=32
- // VolumeName string `json:"volumeName"`
-
- // Represents the point where the scripts file will be mounted.
- //
- // +kubebuilder:validation:Required
- // +kubebuilder:validation:MaxLength=128
- MountPoint string `json:"mountPoint"`
-
- // Used to configure the initialization container.
- //
- // +optional
- ToolConfigs []ToolConfig `json:"toolConfigs,omitempty"`
-}
-
-type ToolConfig struct {
- // Specifies the name of the initContainer.
- //
- // +kubebuilder:validation:Required
- // +kubebuilder:validation:MaxLength=63
- // +kubebuilder:validation:Pattern:=`^[a-z]([a-z0-9\-]*[a-z0-9])?$`
- Name string `json:"name,omitempty"`
-
- // Represents the url of the tool container image.
- //
- // +optional
- Image string `json:"image,omitempty"`
-
- // Commands to be executed when init containers.
- //
- // +kubebuilder:validation:Required
- Command []string `json:"command"`
-}
-
-type DownwardAPIOption struct {
- // Specifies the name of the field. It must be a string of maximum length 63.
- // The name should match the regex pattern `^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$`.
- //
- // +kubebuilder:validation:Required
- // +kubebuilder:validation:MaxLength=63
- // +kubebuilder:validation:Pattern:=`^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$`
- Name string `json:"name"`
-
- // Specifies the mount point of the scripts file.
- //
- // +kubebuilder:validation:Required
- // +kubebuilder:validation:MaxLength=128
- MountPoint string `json:"mountPoint"`
-
- // Represents a list of downward API volume files.
- //
- // +kubebuilder:validation:Required
- Items []corev1.DownwardAPIVolumeFile `json:"items"`
-
- // The command used to execute for the downward API.
- //
- // +optional
- Command []string `json:"command,omitempty"`
-}
-
-type ScriptConfig struct {
- // Specifies the reference to the ConfigMap that contains the script to be executed for reload.
- //
- // +kubebuilder:validation:Required
- ScriptConfigMapRef string `json:"scriptConfigMapRef"`
-
- // Specifies the namespace where the referenced tpl script ConfigMap in.
- // If left empty, by default in the "default" namespace.
- //
- // +kubebuilder:validation:MaxLength=63
- // +kubebuilder:default="default"
- // +kubebuilder:validation:Pattern:=`^[a-z0-9]([a-z0-9\-]*[a-z0-9])?$`
- // +optional
- Namespace string `json:"namespace,omitempty"`
-}
-
-type ShellTrigger struct {
- // Specifies the list of commands for reload.
- //
- // +kubebuilder:validation:Required
- Command []string `json:"command"`
-
- // Specifies whether to synchronize updates parameters to the config manager.
- // Specifies two ways of controller to reload the parameter:
- // - set to 'True', execute the reload action in sync mode, wait for the completion of reload
- // - set to 'False', execute the reload action in async mode, just update the 'Configmap', no need to wait
- //
- // +optional
- Sync *bool `json:"sync,omitempty"`
-
- // Specifies whether to reconfigure dynamic parameters individually or in a batch.
- // - Set to 'True' to execute the reload action in a batch, incorporating all parameter changes.
- // - Set to 'False' to execute the reload action for each parameter change individually.
- // The default value is 'False'.
- //
- // +optional
- BatchReload *bool `json:"batchReload,omitempty"`
-
- // When `batchReload` is set to 'True', this parameter allows for the optional specification
- // of the batch input format that is passed into the STDIN of the script.
- // The format should be provided as a Go template string.
- // In the template, the updated parameters' key-value map can be referenced using the dollar sign ('$') variable.
- // Here's an example of an input template:
- //
- // ```yaml
- //
- // batchInputTemplate: |-
- //
- // {{- range $pKey, $pValue := $ }}
- //
- // {{ printf "%s:%s" $pKey $pValue }}
- //
- // {{- end }}
- //
- // ```
- //
- // In this example, each updated parameter is iterated over in a sorted order by keys to generate the batch input data as follows:
- //
- // ```
- //
- // key1:value1
- //
- // key2:value2
- //
- // key3:value3
- //
- // ```
- //
- // If this parameter is not specified, the default format used for STDIN is as follows:
- // Each updated parameter generates a line that concatenates the parameter's key and value with a equal sign ('=').
- // These lines are then sorted by their keys and inserted accordingly. Here's an example of the batch input data using the default template:
- //
- // ```
- //
- // key1=value1
- //
- // key2=value2
- //
- // key3=value3
- //
- // ```
- //
- // +optional
- BatchInputTemplate string `json:"batchInputTemplate,omitempty"`
-}
-
-type TPLScriptTrigger struct {
- // Config for the script.
- //
- ScriptConfig `json:",inline"`
-
- // Specifies whether to synchronize updates parameters to the config manager.
- // Specifies two ways of controller to reload the parameter:
- // - set to 'True', execute the reload action in sync mode, wait for the completion of reload
- // - set to 'False', execute the reload action in async mode, just update the 'Configmap', no need to wait
- //
- // +optional
- Sync *bool `json:"sync,omitempty"`
-}
-
-type AutoTrigger struct {
- // The name of the process.
- //
- // +optional
- ProcessName string `json:"processName,omitempty"`
-}
-
-type FormatterConfig struct {
- // Represents the additional actions for formatting the config file.
- // If not specified, the default options will be applied.
- // TODO (refactored to FomatterActions)
- //
- // +optional
- FormatterOptions `json:",inline"`
-
- // The config file format. Valid values are `ini`, `xml`, `yaml`, `json`,
- // `hcl`, `dotenv`, `properties` and `toml`. Each format has its own characteristics and use cases.
- //
- // - ini: is a text-based content with a structure and syntax comprising key–value pairs for properties, reference wiki: https://en.wikipedia.org/wiki/INI_file
- // - xml: refers to wiki: https://en.wikipedia.org/wiki/XML
- // - yaml: supports for complex data types and structures.
- // - json: refers to wiki: https://en.wikipedia.org/wiki/JSON
- // - hcl: The HashiCorp Configuration Language (HCL) is a configuration language authored by HashiCorp, reference url: https://www.linode.com/docs/guides/introduction-to-hcl/
- // - dotenv: is a plain text file with simple key–value pairs, reference wiki: https://en.wikipedia.org/wiki/Configuration_file#MS-DOS
- // - properties: a file extension mainly used in Java, reference wiki: https://en.wikipedia.org/wiki/.properties
- // - toml: refers to wiki: https://en.wikipedia.org/wiki/TOML
- // - props-plus: a file extension mainly used in Java, supports CamelCase(e.g: brokerMaxConnectionsPerIp)
- //
- // +kubebuilder:validation:Required
- Format CfgFileFormat `json:"format"`
-}
-
-// Encapsulates the unique options for a configuration file.
-// It is important to note that only one of its members can be specified at a time.
-
-type FormatterOptions struct {
-
- // A pointer to an IniConfig struct that holds the ini options.
- //
- // +optional
- IniConfig *IniConfig `json:"iniConfig,omitempty"`
-
- // A pointer to an XMLConfig struct that holds the xml options.
- // XMLConfig *XMLConfig `json:"xmlConfig,omitempty"`
-}
-
-// Encapsulates the section name of an ini configuration.
-
-type IniConfig struct {
-
- // A string that describes the name of the ini section.
- //
- // +optional
- SectionName string `json:"sectionName,omitempty"`
+ AutoTrigger *v1.AutoTrigger `json:"autoTrigger,omitempty"`
}
// +genclient
diff --git a/apis/apps/v1alpha1/configconstraint_types_test.go b/apis/apps/v1alpha1/configconstraint_types_test.go
index aef8b4fc8f9..134990d46f9 100644
--- a/apis/apps/v1alpha1/configconstraint_types_test.go
+++ b/apis/apps/v1alpha1/configconstraint_types_test.go
@@ -23,11 +23,13 @@ import (
"testing"
"github.com/stretchr/testify/assert"
+
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
)
func TestConfigConstraintStatus_IsConfigConstraintTerminalPhases(t *testing.T) {
type fields struct {
- Phase ConfigConstraintPhase
+ Phase appsv1.ConfigConstraintPhase
Message string
ObservedGeneration int64
}
@@ -38,19 +40,19 @@ func TestConfigConstraintStatus_IsConfigConstraintTerminalPhases(t *testing.T) {
}{{
name: "available phase test",
fields: fields{
- Phase: CCAvailablePhase,
+ Phase: appsv1.CCAvailablePhase,
},
want: true,
}, {
name: "available phase test",
fields: fields{
- Phase: CCUnavailablePhase,
+ Phase: appsv1.CCUnavailablePhase,
},
want: false,
}, {
name: "available phase test",
fields: fields{
- Phase: CCDeletingPhase,
+ Phase: appsv1.CCDeletingPhase,
},
want: false,
}}
@@ -61,7 +63,7 @@ func TestConfigConstraintStatus_IsConfigConstraintTerminalPhases(t *testing.T) {
Message: tt.fields.Message,
ObservedGeneration: tt.fields.ObservedGeneration,
}
- assert.Equalf(t, tt.want, cs.IsConfigConstraintTerminalPhases(), "IsConfigConstraintTerminalPhases()")
+ assert.Equalf(t, tt.want, cs.Phase == appsv1.CCAvailablePhase, "ConfigConstraintTerminalPhases()")
})
}
}
diff --git a/apis/apps/v1alpha1/type.go b/apis/apps/v1alpha1/type.go
index 678bee22488..0470e48ded4 100644
--- a/apis/apps/v1alpha1/type.go
+++ b/apis/apps/v1alpha1/type.go
@@ -261,28 +261,6 @@ const (
UnavailablePhase Phase = "Unavailable"
)
-// ConfigConstraintPhase defines the ConfigConstraint CR .status.phase
-// +enum
-// +kubebuilder:validation:Enum={Available,Unavailable, Deleting}
-type ConfigConstraintPhase string
-
-const (
- CCAvailablePhase ConfigConstraintPhase = "Available"
- CCUnavailablePhase ConfigConstraintPhase = "Unavailable"
- CCDeletingPhase ConfigConstraintPhase = "Deleting"
-)
-
-// DynamicParameterSelectedPolicy determines how to select the parameters of dynamic reload actions
-//
-// +enum
-// +kubebuilder:validation:Enum={all,dynamic}
-type DynamicParameterSelectedPolicy string
-
-const (
- SelectedAllParameters DynamicParameterSelectedPolicy = "all"
- SelectedDynamicParameters DynamicParameterSelectedPolicy = "dynamic"
-)
-
// OpsPhase defines opsRequest phase.
// +enum
// +kubebuilder:validation:Enum={Pending,Creating,Running,Cancelling,Cancelled,Failed,Succeed}
@@ -653,24 +631,6 @@ type webhookManager struct {
client client.Client
}
-// CfgFileFormat defines formatter of configuration files.
-// +enum
-// +kubebuilder:validation:Enum={xml,ini,yaml,json,hcl,dotenv,toml,properties,redis,props-plus}
-type CfgFileFormat string
-
-const (
- Ini CfgFileFormat = "ini"
- YAML CfgFileFormat = "yaml"
- JSON CfgFileFormat = "json"
- XML CfgFileFormat = "xml"
- HCL CfgFileFormat = "hcl"
- Dotenv CfgFileFormat = "dotenv"
- TOML CfgFileFormat = "toml"
- Properties CfgFileFormat = "properties"
- RedisCfg CfgFileFormat = "redis"
- PropertiesPlus CfgFileFormat = "props-plus"
-)
-
// UpgradePolicy defines the policy of reconfiguring.
// +enum
// +kubebuilder:validation:Enum={simple,parallel,rolling,autoReload,operatorSyncUpdate,dynamicReloadBeginRestart}
@@ -686,58 +646,6 @@ const (
DynamicReloadAndRestartPolicy UpgradePolicy = "dynamicReloadBeginRestart"
)
-// CfgReloadType defines reload method.
-// +enum
-type CfgReloadType string
-
-const (
- UnixSignalType CfgReloadType = "signal"
- SQLType CfgReloadType = "sql"
- ShellType CfgReloadType = "exec"
- HTTPType CfgReloadType = "http"
- TPLScriptType CfgReloadType = "tpl"
- AutoType CfgReloadType = "auto"
-)
-
-// SignalType defines which signals are valid.
-// +enum
-// +kubebuilder:validation:Enum={SIGHUP,SIGINT,SIGQUIT,SIGILL,SIGTRAP,SIGABRT,SIGBUS,SIGFPE,SIGKILL,SIGUSR1,SIGSEGV,SIGUSR2,SIGPIPE,SIGALRM,SIGTERM,SIGSTKFLT,SIGCHLD,SIGCONT,SIGSTOP,SIGTSTP,SIGTTIN,SIGTTOU,SIGURG,SIGXCPU,SIGXFSZ,SIGVTALRM,SIGPROF,SIGWINCH,SIGIO,SIGPWR,SIGSYS}
-type SignalType string
-
-const (
- SIGHUP SignalType = "SIGHUP"
- SIGINT SignalType = "SIGINT"
- SIGQUIT SignalType = "SIGQUIT"
- SIGILL SignalType = "SIGILL"
- SIGTRAP SignalType = "SIGTRAP"
- SIGABRT SignalType = "SIGABRT"
- SIGBUS SignalType = "SIGBUS"
- SIGFPE SignalType = "SIGFPE"
- SIGKILL SignalType = "SIGKILL"
- SIGUSR1 SignalType = "SIGUSR1"
- SIGSEGV SignalType = "SIGSEGV"
- SIGUSR2 SignalType = "SIGUSR2"
- SIGPIPE SignalType = "SIGPIPE"
- SIGALRM SignalType = "SIGALRM"
- SIGTERM SignalType = "SIGTERM"
- SIGSTKFLT SignalType = "SIGSTKFLT"
- SIGCHLD SignalType = "SIGCHLD"
- SIGCONT SignalType = "SIGCONT"
- SIGSTOP SignalType = "SIGSTOP"
- SIGTSTP SignalType = "SIGTSTP"
- SIGTTIN SignalType = "SIGTTIN"
- SIGTTOU SignalType = "SIGTTOU"
- SIGURG SignalType = "SIGURG"
- SIGXCPU SignalType = "SIGXCPU"
- SIGXFSZ SignalType = "SIGXFSZ"
- SIGVTALRM SignalType = "SIGVTALRM"
- SIGPROF SignalType = "SIGPROF"
- SIGWINCH SignalType = "SIGWINCH"
- SIGIO SignalType = "SIGIO"
- SIGPWR SignalType = "SIGPWR"
- SIGSYS SignalType = "SIGSYS"
-)
-
// IssuerName defines the name of the TLS certificates issuer.
// +enum
// +kubebuilder:validation:Enum={KubeBlocks,UserProvided}
diff --git a/apis/apps/v1alpha1/webhook_suite_test.go b/apis/apps/v1alpha1/webhook_suite_test.go
index 366f1d2a862..51c724fbb05 100644
--- a/apis/apps/v1alpha1/webhook_suite_test.go
+++ b/apis/apps/v1alpha1/webhook_suite_test.go
@@ -44,6 +44,7 @@ import (
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
"github.com/apecloud/kubeblocks/pkg/testutil"
viper "github.com/apecloud/kubeblocks/pkg/viperx"
)
@@ -102,6 +103,9 @@ var _ = BeforeSuite(func() {
err = AddToScheme(scheme)
Expect(err).NotTo(HaveOccurred())
+ err = appsv1.AddToScheme(scheme)
+ Expect(err).NotTo(HaveOccurred())
+
err = admissionv1.AddToScheme(scheme)
Expect(err).NotTo(HaveOccurred())
@@ -137,7 +141,7 @@ var _ = BeforeSuite(func() {
&Cluster{},
&ClusterVersion{},
&OpsRequest{},
- &ConfigConstraint{},
+ &appsv1.ConfigConstraint{},
},
})
Expect(err).NotTo(HaveOccurred())
diff --git a/apis/apps/v1alpha1/zz_generated.deepcopy.go b/apis/apps/v1alpha1/zz_generated.deepcopy.go
index 086c4c12b55..194dec814ea 100644
--- a/apis/apps/v1alpha1/zz_generated.deepcopy.go
+++ b/apis/apps/v1alpha1/zz_generated.deepcopy.go
@@ -25,6 +25,7 @@ along with this program. If not, see .
package v1alpha1
import (
+ apisappsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
workloadsv1alpha1 "github.com/apecloud/kubeblocks/apis/workloads/v1alpha1"
appsv1 "k8s.io/api/apps/v1"
"k8s.io/api/core/v1"
@@ -119,21 +120,6 @@ func (in *Affinity) DeepCopy() *Affinity {
return out
}
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *AutoTrigger) DeepCopyInto(out *AutoTrigger) {
- *out = *in
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AutoTrigger.
-func (in *AutoTrigger) DeepCopy() *AutoTrigger {
- if in == nil {
- return nil
- }
- out := new(AutoTrigger)
- in.DeepCopyInto(out)
- return out
-}
-
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *BackupMethod) DeepCopyInto(out *BackupMethod) {
*out = *in
@@ -2653,24 +2639,24 @@ func (in *ConfigConstraintSpec) DeepCopyInto(out *ConfigConstraintSpec) {
}
if in.DynamicParameterSelectedPolicy != nil {
in, out := &in.DynamicParameterSelectedPolicy, &out.DynamicParameterSelectedPolicy
- *out = new(DynamicParameterSelectedPolicy)
+ *out = new(apisappsv1.DynamicParameterSelectedPolicy)
**out = **in
}
if in.ToolsImageSpec != nil {
in, out := &in.ToolsImageSpec, &out.ToolsImageSpec
- *out = new(ToolsImageSpec)
+ *out = new(apisappsv1.ReloadToolsImage)
(*in).DeepCopyInto(*out)
}
if in.DownwardAPIOptions != nil {
in, out := &in.DownwardAPIOptions, &out.DownwardAPIOptions
- *out = make([]DownwardAPIOption, len(*in))
+ *out = make([]apisappsv1.DownwardAction, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
if in.ScriptConfigs != nil {
in, out := &in.ScriptConfigs, &out.ScriptConfigs
- *out = make([]ScriptConfig, len(*in))
+ *out = make([]apisappsv1.ScriptConfig, len(*in))
copy(*out, *in)
}
if in.ConfigurationSchema != nil {
@@ -2700,7 +2686,7 @@ func (in *ConfigConstraintSpec) DeepCopyInto(out *ConfigConstraintSpec) {
}
if in.FormatterConfig != nil {
in, out := &in.FormatterConfig, &out.FormatterConfig
- *out = new(FormatterConfig)
+ *out = new(apisappsv1.FormatterConfig)
(*in).DeepCopyInto(*out)
}
}
@@ -3295,33 +3281,6 @@ func (in *CustomParametersValidation) DeepCopy() *CustomParametersValidation {
return out
}
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *DownwardAPIOption) DeepCopyInto(out *DownwardAPIOption) {
- *out = *in
- if in.Items != nil {
- in, out := &in.Items, &out.Items
- *out = make([]v1.DownwardAPIVolumeFile, len(*in))
- for i := range *in {
- (*in)[i].DeepCopyInto(&(*out)[i])
- }
- }
- if in.Command != nil {
- in, out := &in.Command, &out.Command
- *out = make([]string, len(*in))
- copy(*out, *in)
- }
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DownwardAPIOption.
-func (in *DownwardAPIOption) DeepCopy() *DownwardAPIOption {
- if in == nil {
- return nil
- }
- out := new(DownwardAPIOption)
- in.DeepCopyInto(out)
- return out
-}
-
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *EnvMappingVar) DeepCopyInto(out *EnvMappingVar) {
*out = *in
@@ -3437,42 +3396,6 @@ func (in *Expose) DeepCopy() *Expose {
return out
}
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *FormatterConfig) DeepCopyInto(out *FormatterConfig) {
- *out = *in
- in.FormatterOptions.DeepCopyInto(&out.FormatterOptions)
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FormatterConfig.
-func (in *FormatterConfig) DeepCopy() *FormatterConfig {
- if in == nil {
- return nil
- }
- out := new(FormatterConfig)
- in.DeepCopyInto(out)
- return out
-}
-
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *FormatterOptions) DeepCopyInto(out *FormatterOptions) {
- *out = *in
- if in.IniConfig != nil {
- in, out := &in.IniConfig, &out.IniConfig
- *out = new(IniConfig)
- **out = **in
- }
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FormatterOptions.
-func (in *FormatterOptions) DeepCopy() *FormatterOptions {
- if in == nil {
- return nil
- }
- out := new(FormatterOptions)
- in.DeepCopyInto(out)
- return out
-}
-
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *GVKResource) DeepCopyInto(out *GVKResource) {
*out = *in
@@ -3594,21 +3517,6 @@ func (in *HostNetworkContainerPort) DeepCopy() *HostNetworkContainerPort {
return out
}
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *IniConfig) DeepCopyInto(out *IniConfig) {
- *out = *in
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IniConfig.
-func (in *IniConfig) DeepCopy() *IniConfig {
- if in == nil {
- return nil
- }
- out := new(IniConfig)
- in.DeepCopyInto(out)
- return out
-}
-
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Instance) DeepCopyInto(out *Instance) {
*out = *in
@@ -5199,22 +5107,22 @@ func (in *ReloadOptions) DeepCopyInto(out *ReloadOptions) {
*out = *in
if in.UnixSignalTrigger != nil {
in, out := &in.UnixSignalTrigger, &out.UnixSignalTrigger
- *out = new(UnixSignalTrigger)
+ *out = new(apisappsv1.UnixSignalTrigger)
**out = **in
}
if in.ShellTrigger != nil {
in, out := &in.ShellTrigger, &out.ShellTrigger
- *out = new(ShellTrigger)
+ *out = new(apisappsv1.ShellTrigger)
(*in).DeepCopyInto(*out)
}
if in.TPLScriptTrigger != nil {
in, out := &in.TPLScriptTrigger, &out.TPLScriptTrigger
- *out = new(TPLScriptTrigger)
+ *out = new(apisappsv1.TPLScriptTrigger)
(*in).DeepCopyInto(*out)
}
if in.AutoTrigger != nil {
in, out := &in.AutoTrigger, &out.AutoTrigger
- *out = new(AutoTrigger)
+ *out = new(apisappsv1.AutoTrigger)
**out = **in
}
}
@@ -5419,21 +5327,6 @@ func (in *SchedulePolicy) DeepCopy() *SchedulePolicy {
return out
}
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *ScriptConfig) DeepCopyInto(out *ScriptConfig) {
- *out = *in
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ScriptConfig.
-func (in *ScriptConfig) DeepCopy() *ScriptConfig {
- if in == nil {
- return nil
- }
- out := new(ScriptConfig)
- in.DeepCopyInto(out)
- return out
-}
-
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ScriptFrom) DeepCopyInto(out *ScriptFrom) {
*out = *in
@@ -5872,36 +5765,6 @@ func (in *ShardingSpec) DeepCopy() *ShardingSpec {
return out
}
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *ShellTrigger) DeepCopyInto(out *ShellTrigger) {
- *out = *in
- if in.Command != nil {
- in, out := &in.Command, &out.Command
- *out = make([]string, len(*in))
- copy(*out, *in)
- }
- if in.Sync != nil {
- in, out := &in.Sync, &out.Sync
- *out = new(bool)
- **out = **in
- }
- if in.BatchReload != nil {
- in, out := &in.BatchReload, &out.BatchReload
- *out = new(bool)
- **out = **in
- }
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ShellTrigger.
-func (in *ShellTrigger) DeepCopy() *ShellTrigger {
- if in == nil {
- return nil
- }
- out := new(ShellTrigger)
- in.DeepCopyInto(out)
- return out
-}
-
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *StatefulSetSpec) DeepCopyInto(out *StatefulSetSpec) {
*out = *in
@@ -6169,27 +6032,6 @@ func (in *TLSSecretRef) DeepCopy() *TLSSecretRef {
return out
}
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *TPLScriptTrigger) DeepCopyInto(out *TPLScriptTrigger) {
- *out = *in
- out.ScriptConfig = in.ScriptConfig
- if in.Sync != nil {
- in, out := &in.Sync, &out.Sync
- *out = new(bool)
- **out = **in
- }
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TPLScriptTrigger.
-func (in *TPLScriptTrigger) DeepCopy() *TPLScriptTrigger {
- if in == nil {
- return nil
- }
- out := new(TPLScriptTrigger)
- in.DeepCopyInto(out)
- return out
-}
-
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *TargetInstance) DeepCopyInto(out *TargetInstance) {
*out = *in
@@ -6236,48 +6078,6 @@ func (in *TargetPodTemplate) DeepCopy() *TargetPodTemplate {
return out
}
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *ToolConfig) DeepCopyInto(out *ToolConfig) {
- *out = *in
- if in.Command != nil {
- in, out := &in.Command, &out.Command
- *out = make([]string, len(*in))
- copy(*out, *in)
- }
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ToolConfig.
-func (in *ToolConfig) DeepCopy() *ToolConfig {
- if in == nil {
- return nil
- }
- out := new(ToolConfig)
- in.DeepCopyInto(out)
- return out
-}
-
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *ToolsImageSpec) DeepCopyInto(out *ToolsImageSpec) {
- *out = *in
- if in.ToolConfigs != nil {
- in, out := &in.ToolConfigs, &out.ToolConfigs
- *out = make([]ToolConfig, len(*in))
- for i := range *in {
- (*in)[i].DeepCopyInto(&(*out)[i])
- }
- }
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ToolsImageSpec.
-func (in *ToolsImageSpec) DeepCopy() *ToolsImageSpec {
- if in == nil {
- return nil
- }
- out := new(ToolsImageSpec)
- in.DeepCopyInto(out)
- return out
-}
-
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *TypedObjectRef) DeepCopyInto(out *TypedObjectRef) {
*out = *in
@@ -6298,21 +6098,6 @@ func (in *TypedObjectRef) DeepCopy() *TypedObjectRef {
return out
}
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *UnixSignalTrigger) DeepCopyInto(out *UnixSignalTrigger) {
- *out = *in
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new UnixSignalTrigger.
-func (in *UnixSignalTrigger) DeepCopy() *UnixSignalTrigger {
- if in == nil {
- return nil
- }
- out := new(UnixSignalTrigger)
- in.DeepCopyInto(out)
- return out
-}
-
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *UpdatedParameters) DeepCopyInto(out *UpdatedParameters) {
*out = *in
diff --git a/cmd/manager/main.go b/cmd/manager/main.go
index 224daeadd72..c03a389f5ac 100644
--- a/cmd/manager/main.go
+++ b/cmd/manager/main.go
@@ -43,6 +43,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/healthz"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
// +kubebuilder:scaffold:imports
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
@@ -99,6 +100,7 @@ func init() {
utilruntime.Must(extensionsv1alpha1.AddToScheme(scheme))
utilruntime.Must(workloadsv1alpha1.AddToScheme(scheme))
utilruntime.Must(storagev1alpha1.AddToScheme(scheme))
+ utilruntime.Must(appsv1.AddToScheme(scheme))
// +kubebuilder:scaffold:scheme
viper.SetConfigName("config") // name of config file (without extension)
@@ -544,6 +546,11 @@ func main() {
setupLog.Error(err, "unable to create webhook", "webhook", "ServiceDescriptor")
os.Exit(1)
}
+
+ if err = (&appsv1.ConfigConstraint{}).SetupWebhookWithManager(mgr); err != nil {
+ setupLog.Error(err, "unable to create webhook", "webhook", "ConfigConstraint")
+ os.Exit(1)
+ }
}
if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
diff --git a/cmd/reloader/app/flags.go b/cmd/reloader/app/flags.go
index 6161dcde1e2..33f5807187c 100644
--- a/cmd/reloader/app/flags.go
+++ b/cmd/reloader/app/flags.go
@@ -24,7 +24,7 @@ import (
"github.com/spf13/pflag"
- appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
cfgutil "github.com/apecloud/kubeblocks/pkg/configuration/container"
cfgcore "github.com/apecloud/kubeblocks/pkg/configuration/core"
viper "github.com/apecloud/kubeblocks/pkg/viperx"
@@ -47,10 +47,10 @@ const (
localhostAddress = "127.0.0.1"
)
-var allNotifyType = map[NotifyEventType]appsv1alpha1.CfgReloadType{
- UnixSignal: appsv1alpha1.UnixSignalType,
- ShellTool: appsv1alpha1.ShellType,
- TPLScript: appsv1alpha1.TPLScriptType,
+var allNotifyType = map[NotifyEventType]appsv1.CfgReloadType{
+ UnixSignal: appsv1.UnixSignalType,
+ ShellTool: appsv1.ShellType,
+ TPLScript: appsv1.TPLScriptType,
}
func init() {
diff --git a/cmd/reloader/template/main.go b/cmd/reloader/template/main.go
index 55bb988cb58..9246503b2a5 100644
--- a/cmd/reloader/template/main.go
+++ b/cmd/reloader/template/main.go
@@ -32,7 +32,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
- appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
cfgcm "github.com/apecloud/kubeblocks/pkg/configuration/config_manager"
cfgcore "github.com/apecloud/kubeblocks/pkg/configuration/core"
cfgutil "github.com/apecloud/kubeblocks/pkg/configuration/util"
@@ -124,7 +124,7 @@ func main() {
}
mergePolicy, err := configuration.NewTemplateMerger(configRenderMeta.LegacyRenderedConfigSpec.ConfigTemplateExtension,
- context.TODO(), nil, nil, *configRenderMeta.ComponentConfigSpec, &appsv1alpha1.ConfigConstraintSpec{
+ context.TODO(), nil, nil, *configRenderMeta.ComponentConfigSpec, &appsv1.ConfigConstraintSpec{
FormatterConfig: &configRenderMeta.FormatterConfig,
})
if err != nil {
diff --git a/config/crd/bases/apps.kubeblocks.io_configconstraints.yaml b/config/crd/bases/apps.kubeblocks.io_configconstraints.yaml
index 969d593842a..40cde7b5158 100644
--- a/config/crd/bases/apps.kubeblocks.io_configconstraints.yaml
+++ b/config/crd/bases/apps.kubeblocks.io_configconstraints.yaml
@@ -19,6 +19,495 @@ spec:
singular: configconstraint
scope: Cluster
versions:
+ - additionalPrinterColumns:
+ - description: status phase
+ jsonPath: .status.phase
+ name: PHASE
+ type: string
+ - jsonPath: .metadata.creationTimestamp
+ name: AGE
+ type: date
+ name: v1
+ schema:
+ openAPIV3Schema:
+ description: ConfigConstraint is the Schema for the configconstraint API
+ properties:
+ apiVersion:
+ description: 'APIVersion defines the versioned schema of this representation
+ of an object. Servers should convert recognized schemas to the latest
+ internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
+ type: string
+ kind:
+ description: 'Kind is a string value representing the REST resource this
+ object represents. Servers may infer this from the endpoint the client
+ submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
+ type: string
+ metadata:
+ type: object
+ spec:
+ description: ConfigConstraintSpec defines the desired state of ConfigConstraint
+ properties:
+ configSchema:
+ description: List constraints rules for each config parameters.
+ properties:
+ cue:
+ description: Enables providers to verify user configurations using
+ the CUE language.
+ type: string
+ schemaInJSON:
+ description: Transforms the schema from CUE to json for further
+ OpenAPI validation
+ x-kubernetes-preserve-unknown-fields: true
+ type: object
+ configSchemaTopLevelKey:
+ description: Top level key used to get the cue rules to validate the
+ config file. It must exist in 'ConfigSchema'
+ type: string
+ downwardActions:
+ description: "A set of actions for regenerating local configs. \n
+ It works when: - different engine roles have different config, such
+ as redis primary & secondary - after a role switch, the local config
+ will be regenerated with the help of DownwardActions"
+ items:
+ properties:
+ command:
+ description: The command used to execute for the downward API.
+ items:
+ type: string
+ type: array
+ items:
+ description: Represents a list of downward API volume files.
+ items:
+ description: DownwardAPIVolumeFile represents information
+ to create the file containing the pod field
+ properties:
+ fieldRef:
+ description: 'Required: Selects a field of the pod: only
+ annotations, labels, name and namespace are supported.'
+ properties:
+ apiVersion:
+ description: Version of the schema the FieldPath is
+ written in terms of, defaults to "v1".
+ type: string
+ fieldPath:
+ description: Path of the field to select in the specified
+ API version.
+ type: string
+ required:
+ - fieldPath
+ type: object
+ x-kubernetes-map-type: atomic
+ mode:
+ description: 'Optional: mode bits used to set permissions
+ on this file, must be an octal value between 0000 and
+ 0777 or a decimal value between 0 and 511. YAML accepts
+ both octal and decimal values, JSON requires decimal
+ values for mode bits. If not specified, the volume defaultMode
+ will be used. This might be in conflict with other options
+ that affect the file mode, like fsGroup, and the result
+ can be other mode bits set.'
+ format: int32
+ type: integer
+ path:
+ description: 'Required: Path is the relative path name
+ of the file to be created. Must not be absolute or contain
+ the ''..'' path. Must be utf-8 encoded. The first item
+ of the relative path must not start with ''..'''
+ type: string
+ resourceFieldRef:
+ description: 'Selects a resource of the container: only
+ resources limits and requests (limits.cpu, limits.memory,
+ requests.cpu and requests.memory) are currently supported.'
+ properties:
+ containerName:
+ description: 'Container name: required for volumes,
+ optional for env vars'
+ type: string
+ divisor:
+ anyOf:
+ - type: integer
+ - type: string
+ description: Specifies the output format of the exposed
+ resources, defaults to "1"
+ pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
+ x-kubernetes-int-or-string: true
+ resource:
+ description: 'Required: resource to select'
+ type: string
+ required:
+ - resource
+ type: object
+ x-kubernetes-map-type: atomic
+ required:
+ - path
+ type: object
+ type: array
+ mountPoint:
+ description: Specifies the mount point of the scripts file.
+ maxLength: 128
+ type: string
+ name:
+ description: Specifies the name of the field. It must be a string
+ of maximum length 63. The name should match the regex pattern
+ `^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$`.
+ maxLength: 63
+ pattern: ^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$
+ type: string
+ required:
+ - items
+ - mountPoint
+ - name
+ type: object
+ type: array
+ dynamicActionCanBeMerged:
+ description: "Indicates the dynamic reload action and restart action
+ can be merged to a restart action. \n When a batch of parameters
+ updates incur both restart & dynamic reload, it works as: - set
+ to true, the two actions merged to only one restart action - set
+ to false, the two actions cannot be merged, the actions executed
+ in order [dynamic reload, restart]"
+ type: boolean
+ dynamicParameterSelectedPolicy:
+ description: Specifies the policy for selecting the parameters of
+ dynamic reload actions.
+ enum:
+ - all
+ - dynamic
+ type: string
+ dynamicParameters:
+ description: A list of DynamicParameter. Modifications of dynamic
+ parameters trigger a reload action without process restart.
+ items:
+ type: string
+ type: array
+ x-kubernetes-list-type: set
+ dynamicReloadAction:
+ description: Specifies the dynamic reload actions supported by the
+ engine. If set, the controller call the scripts defined in the actions
+ for a dynamic parameter upgrade. The actions are called only when
+ the modified parameter is defined in dynamicParameters part && DynamicReloadAction
+ != nil
+ properties:
+ autoTrigger:
+ description: Used to automatically perform the reload command
+ when conditions are met.
+ properties:
+ processName:
+ description: The name of the process.
+ type: string
+ type: object
+ shellTrigger:
+ description: Used to perform the reload command in shell script.
+ properties:
+ batchParametersTemplate:
+ description: "When `batchReload` is set to 'True', this parameter
+ allows for the optional specification of the batch input
+ format that is passed into the STDIN of the script. The
+ format should be provided as a Go template string. In the
+ template, the updated parameters' key-value map can be referenced
+ using the dollar sign ('$') variable. Here's an example
+ of an input template: \n ```yaml \n batchParametersTemplate:
+ |- \n {{- range $pKey, $pValue := $ }} \n {{ printf \"%s:%s\"
+ $pKey $pValue }} \n {{- end }} \n ``` \n In this example,
+ each updated parameter is iterated over in a sorted order
+ by keys to generate the batch input data as follows: \n
+ ``` \n key1:value1 \n key2:value2 \n key3:value3 \n ```
+ \n If this parameter is not specified, the default format
+ used for STDIN is as follows: Each updated parameter generates
+ a line that concatenates the parameter's key and value with
+ a equal sign ('='). These lines are then sorted by their
+ keys and inserted accordingly. Here's an example of the
+ batch input data using the default template: \n ``` \n key1=value1
+ \n key2=value2 \n key3=value3 \n ```"
+ type: string
+ batchReload:
+ description: Specifies whether to reconfigure dynamic parameters
+ individually or in a batch. - Set to 'True' to execute the
+ reload action in a batch, incorporating all parameter changes.
+ - Set to 'False' to execute the reload action for each parameter
+ change individually. The default value is 'False'.
+ type: boolean
+ command:
+ description: Specifies the list of commands for reload.
+ items:
+ type: string
+ type: array
+ sync:
+ description: 'Specifies whether to synchronize updates parameters
+ to the config manager. Specifies two ways of controller
+ to reload the parameter: - set to ''True'', execute the
+ reload action in sync mode, wait for the completion of reload
+ - set to ''False'', execute the reload action in async mode,
+ just update the ''Configmap'', no need to wait'
+ type: boolean
+ required:
+ - command
+ type: object
+ tplScriptTrigger:
+ description: Used to perform the reload command by Go template
+ script.
+ properties:
+ namespace:
+ default: default
+ description: Specifies the namespace where the referenced
+ tpl script ConfigMap in. If left empty, by default in the
+ "default" namespace.
+ maxLength: 63
+ pattern: ^[a-z0-9]([a-z0-9\-]*[a-z0-9])?$
+ type: string
+ scriptConfigMapRef:
+ description: Specifies the reference to the ConfigMap that
+ contains the script to be executed for reload.
+ type: string
+ sync:
+ description: 'Specifies whether to synchronize updates parameters
+ to the config manager. Specifies two ways of controller
+ to reload the parameter: - set to ''True'', execute the
+ reload action in sync mode, wait for the completion of reload
+ - set to ''False'', execute the reload action in async mode,
+ just update the ''Configmap'', no need to wait'
+ type: boolean
+ required:
+ - scriptConfigMapRef
+ type: object
+ unixSignalTrigger:
+ description: Used to trigger a reload by sending a Unix signal
+ to the process.
+ properties:
+ processName:
+ description: Represents the name of the process that the Unix
+ signal sent to.
+ type: string
+ signal:
+ description: 'Represents a valid Unix signal. Refer to the
+ following URL for a list of all Unix signals: ../../pkg/configuration/configmap/handler.go:allUnixSignals'
+ enum:
+ - SIGHUP
+ - SIGINT
+ - SIGQUIT
+ - SIGILL
+ - SIGTRAP
+ - SIGABRT
+ - SIGBUS
+ - SIGFPE
+ - SIGKILL
+ - SIGUSR1
+ - SIGSEGV
+ - SIGUSR2
+ - SIGPIPE
+ - SIGALRM
+ - SIGTERM
+ - SIGSTKFLT
+ - SIGCHLD
+ - SIGCONT
+ - SIGSTOP
+ - SIGTSTP
+ - SIGTTIN
+ - SIGTTOU
+ - SIGURG
+ - SIGXCPU
+ - SIGXFSZ
+ - SIGVTALRM
+ - SIGPROF
+ - SIGWINCH
+ - SIGIO
+ - SIGPWR
+ - SIGSYS
+ type: string
+ required:
+ - processName
+ - signal
+ type: object
+ type: object
+ dynamicReloadSelector:
+ description: Used to match labels on the pod to do a dynamic reload
+ properties:
+ matchExpressions:
+ description: matchExpressions is a list of label selector requirements.
+ The requirements are ANDed.
+ items:
+ description: A label selector requirement is a selector that
+ contains values, a key, and an operator that relates the key
+ and values.
+ properties:
+ key:
+ description: key is the label key that the selector applies
+ to.
+ type: string
+ operator:
+ description: operator represents a key's relationship to
+ a set of values. Valid operators are In, NotIn, Exists
+ and DoesNotExist.
+ type: string
+ values:
+ description: values is an array of string values. If the
+ operator is In or NotIn, the values array must be non-empty.
+ If the operator is Exists or DoesNotExist, the values
+ array must be empty. This array is replaced during a strategic
+ merge patch.
+ items:
+ type: string
+ type: array
+ required:
+ - key
+ - operator
+ type: object
+ type: array
+ matchLabels:
+ additionalProperties:
+ type: string
+ description: matchLabels is a map of {key,value} pairs. A single
+ {key,value} in the matchLabels map is equivalent to an element
+ of matchExpressions, whose key field is "key", the operator
+ is "In", and the values array contains only "value". The requirements
+ are ANDed.
+ type: object
+ type: object
+ x-kubernetes-map-type: atomic
+ formatterConfig:
+ description: 'Describes the format of the config file. The controller
+ works as follows: 1. Parse the config file 2. Get the modified parameters
+ 3. Trigger the corresponding action'
+ properties:
+ format:
+ description: "The config file format. Valid values are `ini`,
+ `xml`, `yaml`, `json`, `hcl`, `dotenv`, `properties` and `toml`.
+ Each format has its own characteristics and use cases. \n -
+ ini: is a text-based content with a structure and syntax comprising
+ key–value pairs for properties, reference wiki: https://en.wikipedia.org/wiki/INI_file
+ - xml: refers to wiki: https://en.wikipedia.org/wiki/XML - yaml:
+ supports for complex data types and structures. - json: refers
+ to wiki: https://en.wikipedia.org/wiki/JSON - hcl: The HashiCorp
+ Configuration Language (HCL) is a configuration language authored
+ by HashiCorp, reference url: https://www.linode.com/docs/guides/introduction-to-hcl/
+ - dotenv: is a plain text file with simple key–value pairs,
+ reference wiki: https://en.wikipedia.org/wiki/Configuration_file#MS-DOS
+ - properties: a file extension mainly used in Java, reference
+ wiki: https://en.wikipedia.org/wiki/.properties - toml: refers
+ to wiki: https://en.wikipedia.org/wiki/TOML - props-plus: a
+ file extension mainly used in Java, supports CamelCase(e.g:
+ brokerMaxConnectionsPerIp)"
+ enum:
+ - xml
+ - ini
+ - yaml
+ - json
+ - hcl
+ - dotenv
+ - toml
+ - properties
+ - redis
+ - props-plus
+ type: string
+ iniConfig:
+ description: A pointer to an IniConfig struct that holds the ini
+ options.
+ properties:
+ sectionName:
+ description: A string that describes the name of the ini section.
+ type: string
+ type: object
+ required:
+ - format
+ type: object
+ immutableParameters:
+ description: Describes parameters that are prohibited to do any modifications.
+ items:
+ type: string
+ type: array
+ x-kubernetes-list-type: set
+ reloadToolsImage:
+ description: Tools used by the dynamic reload actions. Usually it
+ is referenced by the 'init container' for 'cp' it to a binary volume.
+ properties:
+ mountPoint:
+ description: Represents the point where the scripts file will
+ be mounted.
+ maxLength: 128
+ type: string
+ toolConfigs:
+ description: Used to configure the initialization container.
+ items:
+ properties:
+ command:
+ description: Commands to be executed when init containers.
+ items:
+ type: string
+ type: array
+ image:
+ description: Represents the url of the tool container image.
+ type: string
+ name:
+ description: Specifies the name of the initContainer.
+ maxLength: 63
+ pattern: ^[a-z]([a-z0-9\-]*[a-z0-9])?$
+ type: string
+ required:
+ - command
+ type: object
+ type: array
+ required:
+ - mountPoint
+ type: object
+ scriptConfigs:
+ description: A list of ScriptConfig used by the actions defined in
+ dynamic reload and downward actions.
+ items:
+ properties:
+ namespace:
+ default: default
+ description: Specifies the namespace where the referenced tpl
+ script ConfigMap in. If left empty, by default in the "default"
+ namespace.
+ maxLength: 63
+ pattern: ^[a-z0-9]([a-z0-9\-]*[a-z0-9])?$
+ type: string
+ scriptConfigMapRef:
+ description: Specifies the reference to the ConfigMap that contains
+ the script to be executed for reload.
+ type: string
+ required:
+ - scriptConfigMapRef
+ type: object
+ type: array
+ x-kubernetes-list-map-keys:
+ - scriptConfigMapRef
+ x-kubernetes-list-type: map
+ staticParameters:
+ description: A list of StaticParameter. Modifications of static parameters
+ trigger a process restart.
+ items:
+ type: string
+ type: array
+ x-kubernetes-list-type: set
+ required:
+ - formatterConfig
+ type: object
+ status:
+ properties:
+ message:
+ description: Provides descriptions for abnormal states.
+ type: string
+ observedGeneration:
+ description: Refers to the most recent generation observed for this
+ ConfigConstraint. This value is updated by the API Server.
+ format: int64
+ type: integer
+ phase:
+ description: Specifies the status of the configuration template. When
+ set to CCAvailablePhase, the ConfigConstraint can be referenced
+ by ClusterDefinition or ClusterVersion.
+ enum:
+ - Available
+ - Unavailable
+ - Deleting
+ type: string
+ type: object
+ type: object
+ served: true
+ storage: true
+ subresources:
+ status: {}
- additionalPrinterColumns:
- description: status phase
jsonPath: .status.phase
@@ -49,12 +538,10 @@ spec:
properties:
cfgSchemaTopLevelName:
description: Top level key used to get the cue rules to validate the
- config file. It must exist in 'ConfigSchema' TODO (refactored to
- ConfigSchemaTopLevelKey)
+ config file. It must exist in 'ConfigSchema'
type: string
configurationSchema:
- description: List constraints rules for each config parameters. TODO
- (refactored to ConfigSchema)
+ description: List constraints rules for each config parameters.
properties:
cue:
description: Enables providers to verify user configurations using
@@ -62,15 +549,14 @@ spec:
type: string
schema:
description: Transforms the schema from CUE to json for further
- OpenAPI validation TODO (refactored to SchemaInJson)
+ OpenAPI validation
x-kubernetes-preserve-unknown-fields: true
type: object
downwardAPIOptions:
description: "A set of actions for regenerating local configs. \n
It works when: - different engine roles have different config, such
as redis primary & secondary - after a role switch, the local config
- will be regenerated with the help of DownwardActions TODO (refactored
- to DownwardActions)"
+ will be regenerated with the help of DownwardActions"
items:
properties:
command:
@@ -240,8 +726,8 @@ spec:
description: Specifies the dynamic reload actions supported by the
engine. If set, the controller call the scripts defined in the actions
for a dynamic parameter upgrade. The actions are called only when
- the modified parameter is defined in dynamicParameters part && DynamicReloadActions
- != nil TODO (refactored to DynamicReloadActions)
+ the modified parameter is defined in dynamicParameters part && ReloadOptions
+ != nil
properties:
autoTrigger:
description: Used to automatically perform the reload command
@@ -254,14 +740,14 @@ spec:
shellTrigger:
description: Used to perform the reload command in shell script.
properties:
- batchInputTemplate:
+ batchParametersTemplate:
description: "When `batchReload` is set to 'True', this parameter
allows for the optional specification of the batch input
format that is passed into the STDIN of the script. The
format should be provided as a Go template string. In the
template, the updated parameters' key-value map can be referenced
using the dollar sign ('$') variable. Here's an example
- of an input template: \n ```yaml \n batchInputTemplate:
+ of an input template: \n ```yaml \n batchParametersTemplate:
|- \n {{- range $pKey, $pValue := $ }} \n {{ printf \"%s:%s\"
$pKey $pValue }} \n {{- end }} \n ``` \n In this example,
each updated parameter is iterated over in a sorted order
@@ -400,7 +886,6 @@ spec:
x-kubernetes-list-type: map
selector:
description: Used to match labels on the pod to do a dynamic reload
- TODO (refactored to DynamicReloadSelector)
properties:
matchExpressions:
description: matchExpressions is a list of label selector requirements.
@@ -454,7 +939,6 @@ spec:
toolsImageSpec:
description: Tools used by the dynamic reload actions. Usually it
is referenced by the 'init container' for 'cp' it to a binary volume.
- TODO (refactored to ReloadToolsImage)
properties:
mountPoint:
description: Represents the point where the scripts file will
@@ -510,6 +994,6 @@ spec:
type: object
type: object
served: true
- storage: true
+ storage: false
subresources:
status: {}
diff --git a/config/samples/apps_v1_configconstraint.yaml b/config/samples/apps_v1_configconstraint.yaml
new file mode 100644
index 00000000000..6cdfdead024
--- /dev/null
+++ b/config/samples/apps_v1_configconstraint.yaml
@@ -0,0 +1,12 @@
+apiVersion: apps.kubeblocks.io/v1
+kind: ConfigConstraint
+metadata:
+ labels:
+ app.kubernetes.io/name: configconstraint
+ app.kubernetes.io/instance: configconstraint-sample
+ app.kubernetes.io/part-of: kubeblocks
+ app.kubernetes.io/managed-by: kustomize
+ app.kubernetes.io/created-by: kubeblocks
+ name: configconstraint-sample
+spec:
+ # TODO(user): Add fields here
diff --git a/config/webhook/manifests.yaml b/config/webhook/manifests.yaml
index d67c7d95820..e9cf83204e7 100644
--- a/config/webhook/manifests.yaml
+++ b/config/webhook/manifests.yaml
@@ -130,6 +130,26 @@ kind: ValidatingWebhookConfiguration
metadata:
name: validating-webhook-configuration
webhooks:
+- admissionReviewVersions:
+ - v1
+ clientConfig:
+ service:
+ name: webhook-service
+ namespace: system
+ path: /validate-apps-kubeblocks-io-v1-configconstraint
+ failurePolicy: Fail
+ name: vconfigconstraint.kb.io
+ rules:
+ - apiGroups:
+ - apps.kubeblocks.io
+ apiVersions:
+ - v1
+ operations:
+ - CREATE
+ - UPDATE
+ resources:
+ - configconstraints
+ sideEffects: None
- admissionReviewVersions:
- v1
clientConfig:
diff --git a/controllers/apps/cluster_plan_builder.go b/controllers/apps/cluster_plan_builder.go
index 7510741f6a0..2444b30d07b 100644
--- a/controllers/apps/cluster_plan_builder.go
+++ b/controllers/apps/cluster_plan_builder.go
@@ -37,6 +37,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
dpv1alpha1 "github.com/apecloud/kubeblocks/apis/dataprotection/v1alpha1"
extensionsv1alpha1 "github.com/apecloud/kubeblocks/apis/extensions/v1alpha1"
@@ -121,6 +122,7 @@ func init() {
model.AddScheme(extensionsv1alpha1.AddToScheme)
model.AddScheme(workloadsv1alpha1.AddToScheme)
model.AddScheme(storagev1alpha1.AddToScheme)
+ model.AddScheme(v1.AddToScheme)
}
// PlanBuilder implementation
diff --git a/controllers/apps/clusterdefinition_controller_test.go b/controllers/apps/clusterdefinition_controller_test.go
index 8eec7369179..bf0b14cf829 100644
--- a/controllers/apps/clusterdefinition_controller_test.go
+++ b/controllers/apps/clusterdefinition_controller_test.go
@@ -30,6 +30,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
cfgcore "github.com/apecloud/kubeblocks/pkg/configuration/core"
"github.com/apecloud/kubeblocks/pkg/constant"
@@ -90,9 +91,9 @@ var _ = Describe("ClusterDefinition Controller", func() {
testCtx.UseDefaultNamespace())
cfgTpl := testapps.CreateCustomizedObj(&testCtx, "config/config-constraint.yaml",
- &appsv1alpha1.ConfigConstraint{})
+ &v1.ConfigConstraint{})
Expect(testapps.ChangeObjStatus(&testCtx, cfgTpl, func() {
- cfgTpl.Status.Phase = appsv1alpha1.CCAvailablePhase
+ cfgTpl.Status.Phase = v1.CCAvailablePhase
})).Should(Succeed())
return cm
}
diff --git a/controllers/apps/configuration/config_util.go b/controllers/apps/configuration/config_util.go
index 0b32924d9f4..36a39f97577 100644
--- a/controllers/apps/configuration/config_util.go
+++ b/controllers/apps/configuration/config_util.go
@@ -31,6 +31,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
cfgcm "github.com/apecloud/kubeblocks/pkg/configuration/config_manager"
"github.com/apecloud/kubeblocks/pkg/configuration/core"
@@ -42,7 +43,7 @@ import (
)
type ValidateConfigMap func(configTpl, ns string) (*corev1.ConfigMap, error)
-type ValidateConfigSchema func(tpl *appsv1alpha1.CustomParametersValidation) (bool, error)
+type ValidateConfigSchema func(tpl *v1.ConfigSchema) (bool, error)
func checkConfigLabels(object client.Object, requiredLabs []string) bool {
labels := object.GetLabels()
@@ -81,9 +82,9 @@ func getConfigMapByTemplateName(cli client.Client, ctx intctrlutil.RequestCtx, t
return configObj, nil
}
-func checkConfigConstraint(ctx intctrlutil.RequestCtx, configConstraint *appsv1alpha1.ConfigConstraint) (bool, error) {
+func checkConfigConstraint(ctx intctrlutil.RequestCtx, configConstraint *v1.ConfigConstraint) (bool, error) {
// validate configuration template
- validateConfigSchema := func(ccSchema *appsv1alpha1.CustomParametersValidation) (bool, error) {
+ validateConfigSchema := func(ccSchema *v1.ConfigSchema) (bool, error) {
if ccSchema == nil || len(ccSchema.CUE) == 0 {
return true, nil
}
@@ -93,8 +94,8 @@ func checkConfigConstraint(ctx intctrlutil.RequestCtx, configConstraint *appsv1a
}
// validate schema
- if ok, err := validateConfigSchema(configConstraint.Spec.ConfigurationSchema); !ok || err != nil {
- ctx.Log.Error(err, "failed to validate template schema!", "configMapName", fmt.Sprintf("%v", configConstraint.Spec.ConfigurationSchema))
+ if ok, err := validateConfigSchema(configConstraint.Spec.ConfigSchema); !ok || err != nil {
+ ctx.Log.Error(err, "failed to validate template schema!", "configMapName", fmt.Sprintf("%v", configConstraint.Spec.ConfigSchema))
return ok, err
}
return true, nil
@@ -320,7 +321,7 @@ func updateLabelsByConfigSpec[T generics.Object, PT generics.PObject[T]](cli cli
func validateConfigTemplate(cli client.Client, ctx intctrlutil.RequestCtx, configSpecs []appsv1alpha1.ComponentConfigSpec) (bool, error) {
// validate ConfigTemplate
- foundAndCheckConfigSpec := func(configSpec appsv1alpha1.ComponentConfigSpec, logger logr.Logger) (*appsv1alpha1.ConfigConstraint, error) {
+ foundAndCheckConfigSpec := func(configSpec appsv1alpha1.ComponentConfigSpec, logger logr.Logger) (*v1.ConfigConstraint, error) {
if _, err := getConfigMapByTemplateName(cli, ctx, configSpec.TemplateRef, configSpec.Namespace); err != nil {
logger.Error(err, "failed to get config template cm object!")
return nil, err
@@ -335,7 +336,7 @@ func validateConfigTemplate(cli client.Client, ctx intctrlutil.RequestCtx, confi
Namespace: "",
Name: configSpec.ConfigConstraintRef,
}
- configObj := &appsv1alpha1.ConfigConstraint{}
+ configObj := &v1.ConfigConstraint{}
if err := cli.Get(ctx.Ctx, configKey, configObj); err != nil {
logger.Error(err, "failed to get template cm object!")
return nil, err
@@ -350,10 +351,10 @@ func validateConfigTemplate(cli client.Client, ctx intctrlutil.RequestCtx, confi
logger.Error(err, "failed to validate config template!")
return false, err
}
- if configConstraint == nil || configConstraint.Spec.ReloadOptions == nil {
+ if configConstraint == nil || configConstraint.Spec.DynamicReloadAction == nil {
continue
}
- if err := cfgcm.ValidateReloadOptions(configConstraint.Spec.ReloadOptions, cli, ctx.Ctx); err != nil {
+ if err := cfgcm.ValidateReloadOptions(configConstraint.Spec.DynamicReloadAction, cli, ctx.Ctx); err != nil {
return false, err
}
if !validateConfigConstraintStatus(configConstraint.Status) {
@@ -365,18 +366,18 @@ func validateConfigTemplate(cli client.Client, ctx intctrlutil.RequestCtx, confi
return true, nil
}
-func validateConfigConstraintStatus(ccStatus appsv1alpha1.ConfigConstraintStatus) bool {
- return ccStatus.Phase == appsv1alpha1.CCAvailablePhase
+func validateConfigConstraintStatus(ccStatus v1.ConfigConstraintStatus) bool {
+ return ccStatus.Phase == v1.CCAvailablePhase
}
-func updateConfigConstraintStatus(cli client.Client, ctx intctrlutil.RequestCtx, configConstraint *appsv1alpha1.ConfigConstraint, phase appsv1alpha1.ConfigConstraintPhase) error {
+func updateConfigConstraintStatus(cli client.Client, ctx intctrlutil.RequestCtx, configConstraint *v1.ConfigConstraint, phase v1.ConfigConstraintPhase) error {
patch := client.MergeFrom(configConstraint.DeepCopy())
configConstraint.Status.Phase = phase
configConstraint.Status.ObservedGeneration = configConstraint.Generation
return cli.Status().Patch(ctx.Ctx, configConstraint, patch)
}
-func createConfigPatch(cfg *corev1.ConfigMap, formatter *appsv1alpha1.FormatterConfig, cmKeys []string) (*core.ConfigPatchInfo, bool, error) {
+func createConfigPatch(cfg *corev1.ConfigMap, formatter *v1.FormatterConfig, cmKeys []string) (*core.ConfigPatchInfo, bool, error) {
// support full update
if formatter == nil {
return nil, true, nil
@@ -389,25 +390,25 @@ func createConfigPatch(cfg *corev1.ConfigMap, formatter *appsv1alpha1.FormatterC
return core.CreateConfigPatch(lastConfig, cfg.Data, formatter.Format, cmKeys, true)
}
-func updateConfigSchema(cc *appsv1alpha1.ConfigConstraint, cli client.Client, ctx context.Context) error {
- schema := cc.Spec.ConfigurationSchema
+func updateConfigSchema(cc *v1.ConfigConstraint, cli client.Client, ctx context.Context) error {
+ schema := cc.Spec.ConfigSchema
if schema == nil || schema.CUE == "" {
return nil
}
// Because the conversion of cue to openAPISchema is restricted, and the definition of some cue may not be converted into openAPISchema, and won't return error.
- openAPISchema, err := openapi.GenerateOpenAPISchema(schema.CUE, cc.Spec.CfgSchemaTopLevelName)
+ openAPISchema, err := openapi.GenerateOpenAPISchema(schema.CUE, cc.Spec.ConfigSchemaTopLevelKey)
if err != nil {
return err
}
if openAPISchema == nil {
return nil
}
- if reflect.DeepEqual(openAPISchema, schema.Schema) {
+ if reflect.DeepEqual(openAPISchema, schema.SchemaInJSON) {
return nil
}
ccPatch := client.MergeFrom(cc.DeepCopy())
- cc.Spec.ConfigurationSchema.Schema = openAPISchema
+ cc.Spec.ConfigSchema.SchemaInJSON = openAPISchema
return cli.Patch(ctx, cc, ccPatch)
}
diff --git a/controllers/apps/configuration/config_util_test.go b/controllers/apps/configuration/config_util_test.go
index 9541d9ddbd1..84f09dcd688 100644
--- a/controllers/apps/configuration/config_util_test.go
+++ b/controllers/apps/configuration/config_util_test.go
@@ -27,6 +27,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
cfgcore "github.com/apecloud/kubeblocks/pkg/configuration/core"
intctrlutil "github.com/apecloud/kubeblocks/pkg/controllerutil"
@@ -55,7 +56,7 @@ var _ = Describe("ConfigWrapper util test", func() {
var (
configMapObj *corev1.ConfigMap
- configConstraintObj *appsv1alpha1.ConfigConstraint
+ configConstraintObj *v1.ConfigConstraint
clusterDefObj *appsv1alpha1.ClusterDefinition
clusterVersionObj *appsv1alpha1.ClusterVersion
)
@@ -91,7 +92,7 @@ var _ = Describe("ConfigWrapper util test", func() {
configConstraintObj = testapps.CreateCustomizedObj(&testCtx,
"resources/mysql-config-constraint.yaml",
- &appsv1alpha1.ConfigConstraint{})
+ &v1.ConfigConstraint{})
By("Create a clusterDefinition obj")
clusterDefObj = testapps.NewClusterDefFactory(clusterDefName).
@@ -115,7 +116,7 @@ var _ = Describe("ConfigWrapper util test", func() {
Context("clusterdefinition CR test", func() {
It("Should success without error", func() {
availableTPL := configConstraintObj.DeepCopy()
- availableTPL.Status.Phase = appsv1alpha1.CCAvailablePhase
+ availableTPL.Status.Phase = v1.CCAvailablePhase
k8sMockClient.MockPatchMethod(testutil.WithSucceed())
k8sMockClient.MockListMethod(testutil.WithSucceed())
@@ -187,7 +188,7 @@ var _ = Describe("ConfigWrapper util test", func() {
Expect(err).Should(Succeed())
availableTPL := configConstraintObj.DeepCopy()
- availableTPL.Status.Phase = appsv1alpha1.CCAvailablePhase
+ availableTPL.Status.Phase = v1.CCAvailablePhase
k8sMockClient.MockGetMethod(testutil.WithGetReturned(testutil.WithConstructSequenceResult(
map[client.ObjectKey][]testutil.MockGetReturned{
@@ -230,7 +231,7 @@ var _ = Describe("ConfigWrapper util test", func() {
It("Should success without error", func() {
updateAVTemplates()
availableTPL := configConstraintObj.DeepCopy()
- availableTPL.Status.Phase = appsv1alpha1.CCAvailablePhase
+ availableTPL.Status.Phase = v1.CCAvailablePhase
k8sMockClient.MockPatchMethod(testutil.WithSucceed())
k8sMockClient.MockListMethod(testutil.WithSucceed())
diff --git a/controllers/apps/configuration/configconstraint_controller.go b/controllers/apps/configuration/configconstraint_controller.go
index 4fe64f1d254..495001da4b3 100644
--- a/controllers/apps/configuration/configconstraint_controller.go
+++ b/controllers/apps/configuration/configconstraint_controller.go
@@ -30,6 +30,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
cfgcore "github.com/apecloud/kubeblocks/pkg/configuration/core"
"github.com/apecloud/kubeblocks/pkg/constant"
@@ -64,7 +65,7 @@ func (r *ConfigConstraintReconciler) Reconcile(ctx context.Context, req ctrl.Req
Recorder: r.Recorder,
}
- configConstraint := &appsv1alpha1.ConfigConstraint{}
+ configConstraint := &v1.ConfigConstraint{}
if err := r.Client.Get(reqCtx.Ctx, reqCtx.Req.NamespacedName, configConstraint); err != nil {
return intctrlutil.CheckedRequeueWithError(err, reqCtx.Log, "")
}
@@ -74,8 +75,8 @@ func (r *ConfigConstraintReconciler) Reconcile(ctx context.Context, req ctrl.Req
r.Recorder.Event(configConstraint, corev1.EventTypeWarning, "ExistsReferencedResources",
"cannot be deleted because of existing referencing of ClusterDefinition or ClusterVersion.")
}
- if configConstraint.Status.Phase != appsv1alpha1.CCDeletingPhase {
- err := updateConfigConstraintStatus(r.Client, reqCtx, configConstraint, appsv1alpha1.CCDeletingPhase)
+ if configConstraint.Status.Phase != v1.CCDeletingPhase {
+ err := updateConfigConstraintStatus(r.Client, reqCtx, configConstraint, v1.CCDeletingPhase)
// if fail to update ConfigConstraint status, return error,
// so that it can be retried
if err != nil {
@@ -94,7 +95,7 @@ func (r *ConfigConstraintReconciler) Reconcile(ctx context.Context, req ctrl.Req
return *res, err
}
- if configConstraint.Status.ObservedGeneration == configConstraint.Generation && configConstraint.Status.IsConfigConstraintTerminalPhases() {
+ if configConstraint.Status.ObservedGeneration == configConstraint.Generation && configConstraint.Status.ConfigConstraintTerminalPhases() {
return intctrlutil.Reconciled()
}
@@ -107,7 +108,7 @@ func (r *ConfigConstraintReconciler) Reconcile(ctx context.Context, req ctrl.Req
return intctrlutil.CheckedRequeueWithError(err, reqCtx.Log, "failed to generate openAPISchema")
}
- err = updateConfigConstraintStatus(r.Client, reqCtx, configConstraint, appsv1alpha1.CCAvailablePhase)
+ err = updateConfigConstraintStatus(r.Client, reqCtx, configConstraint, v1.CCAvailablePhase)
if err != nil {
return intctrlutil.CheckedRequeueWithError(err, reqCtx.Log, "")
}
@@ -118,7 +119,7 @@ func (r *ConfigConstraintReconciler) Reconcile(ctx context.Context, req ctrl.Req
// SetupWithManager sets up the controller with the Manager.
func (r *ConfigConstraintReconciler) SetupWithManager(mgr ctrl.Manager) error {
return intctrlutil.NewNamespacedControllerManagedBy(mgr).
- For(&appsv1alpha1.ConfigConstraint{}).
+ For(&v1.ConfigConstraint{}).
// for other resource
Owns(&corev1.ConfigMap{}).
Complete(r)
diff --git a/controllers/apps/configuration/configconstraint_controller_test.go b/controllers/apps/configuration/configconstraint_controller_test.go
index 88c91e19e05..e6b616877d0 100644
--- a/controllers/apps/configuration/configconstraint_controller_test.go
+++ b/controllers/apps/configuration/configconstraint_controller_test.go
@@ -29,6 +29,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
cfgcore "github.com/apecloud/kubeblocks/pkg/configuration/core"
"github.com/apecloud/kubeblocks/pkg/constant"
@@ -76,7 +77,7 @@ var _ = Describe("ConfigConstraint Controller", func() {
constraint := testapps.CreateCustomizedObj(&testCtx,
"resources/mysql-config-constraint.yaml",
- &appsv1alpha1.ConfigConstraint{})
+ &v1.ConfigConstraint{})
constraintKey := client.ObjectKeyFromObject(constraint)
By("Create a clusterDefinition obj")
@@ -96,7 +97,7 @@ var _ = Describe("ConfigConstraint Controller", func() {
By("check ConfigConstraint(template) status and finalizer")
Eventually(testapps.CheckObj(&testCtx, constraintKey,
- func(g Gomega, tpl *appsv1alpha1.ConfigConstraint) {
+ func(g Gomega, tpl *v1.ConfigConstraint) {
g.Expect(tpl.Status.Phase).To(BeEquivalentTo(appsv1alpha1.AvailablePhase))
g.Expect(tpl.Finalizers).To(ContainElement(constant.ConfigFinalizerName))
})).Should(Succeed())
@@ -106,12 +107,12 @@ var _ = Describe("ConfigConstraint Controller", func() {
By("check ConfigConstraint should not be deleted")
log.Log.Info("expect that ConfigConstraint is not deleted.")
- Consistently(testapps.CheckObjExists(&testCtx, constraintKey, &appsv1alpha1.ConfigConstraint{}, true)).Should(Succeed())
+ Consistently(testapps.CheckObjExists(&testCtx, constraintKey, &v1.ConfigConstraint{}, true)).Should(Succeed())
By("check ConfigConstraint status should be deleting")
Eventually(testapps.CheckObj(&testCtx, constraintKey,
- func(g Gomega, tpl *appsv1alpha1.ConfigConstraint) {
- g.Expect(tpl.Status.Phase).To(BeEquivalentTo(appsv1alpha1.CCDeletingPhase))
+ func(g Gomega, tpl *v1.ConfigConstraint) {
+ g.Expect(tpl.Status.Phase).To(BeEquivalentTo(v1.CCDeletingPhase))
})).Should(Succeed())
By("By delete referencing clusterdefinition and clusterversion")
@@ -119,7 +120,7 @@ var _ = Describe("ConfigConstraint Controller", func() {
Expect(k8sClient.Delete(testCtx.Ctx, clusterDefObj)).Should(Succeed())
By("check ConfigConstraint should be deleted")
- Eventually(testapps.CheckObjExists(&testCtx, constraintKey, &appsv1alpha1.ConfigConstraint{}, false), time.Second*60, time.Second*1).Should(Succeed())
+ Eventually(testapps.CheckObjExists(&testCtx, constraintKey, &v1.ConfigConstraint{}, false), time.Second*60, time.Second*1).Should(Succeed())
})
})
@@ -131,11 +132,11 @@ var _ = Describe("ConfigConstraint Controller", func() {
testCtx.UseDefaultNamespace())
constraint := testapps.CreateCustomizedObj(&testCtx, "resources/mysql-config-constraint-not-validate.yaml",
- &appsv1alpha1.ConfigConstraint{})
+ &v1.ConfigConstraint{})
By("check config constraint status")
Eventually(testapps.CheckObj(&testCtx, client.ObjectKeyFromObject(constraint),
- func(g Gomega, tpl *appsv1alpha1.ConfigConstraint) {
+ func(g Gomega, tpl *v1.ConfigConstraint) {
g.Expect(tpl.Status.Phase).Should(BeEquivalentTo(appsv1alpha1.AvailablePhase))
})).Should(Succeed())
})
diff --git a/controllers/apps/configuration/configuration_test.go b/controllers/apps/configuration/configuration_test.go
index 7be28240501..5e01492a0a5 100644
--- a/controllers/apps/configuration/configuration_test.go
+++ b/controllers/apps/configuration/configuration_test.go
@@ -30,6 +30,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
"github.com/apecloud/kubeblocks/pkg/configuration/core"
"github.com/apecloud/kubeblocks/pkg/constant"
@@ -51,7 +52,7 @@ const configSpecName = "mysql-config-tpl"
const configVolumeName = "mysql-config"
const cmName = "mysql-tree-node-template-8.0"
-func mockConfigResource() (*corev1.ConfigMap, *appsv1alpha1.ConfigConstraint) {
+func mockConfigResource() (*corev1.ConfigMap, *appsv1.ConfigConstraint) {
By("Create a config template obj")
configmap := testapps.CreateCustomizedObj(&testCtx,
"resources/mysql-config-template.yaml", &corev1.ConfigMap{},
@@ -73,10 +74,10 @@ func mockConfigResource() (*corev1.ConfigMap, *appsv1alpha1.ConfigConstraint) {
By("Create a config constraint obj")
constraint := testapps.CreateCustomizedObj(&testCtx,
"resources/mysql-config-constraint.yaml",
- &appsv1alpha1.ConfigConstraint{})
+ &appsv1.ConfigConstraint{})
By("check config constraint")
- Eventually(testapps.CheckObj(&testCtx, client.ObjectKeyFromObject(constraint), func(g Gomega, tpl *appsv1alpha1.ConfigConstraint) {
+ Eventually(testapps.CheckObj(&testCtx, client.ObjectKeyFromObject(constraint), func(g Gomega, tpl *appsv1.ConfigConstraint) {
g.Expect(tpl.Status.Phase).Should(BeEquivalentTo(appsv1alpha1.AvailablePhase))
})).Should(Succeed())
@@ -100,7 +101,7 @@ func mockConfigResource() (*corev1.ConfigMap, *appsv1alpha1.ConfigConstraint) {
return configmap, constraint
}
-func mockReconcileResource() (*corev1.ConfigMap, *appsv1alpha1.ConfigConstraint, *appsv1alpha1.Cluster, *appsv1alpha1.Component, *component.SynthesizedComponent) {
+func mockReconcileResource() (*corev1.ConfigMap, *appsv1.ConfigConstraint, *appsv1alpha1.Cluster, *appsv1alpha1.Component, *component.SynthesizedComponent) {
configmap, constraint := mockConfigResource()
By("Create a clusterDefinition obj")
diff --git a/controllers/apps/configuration/policy_util_test.go b/controllers/apps/configuration/policy_util_test.go
index 3f15744af45..e208d668e56 100644
--- a/controllers/apps/configuration/policy_util_test.go
+++ b/controllers/apps/configuration/policy_util_test.go
@@ -34,6 +34,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
workloads "github.com/apecloud/kubeblocks/apis/workloads/v1alpha1"
"github.com/apecloud/kubeblocks/pkg/configuration/core"
@@ -120,9 +121,9 @@ func withConfigSpec(configSpecName string, data map[string]string) ParamsOps {
}
}
-func withConfigConstraintSpec(formatter *appsv1alpha1.FormatterConfig) ParamsOps {
+func withConfigConstraintSpec(formatter *v1.FormatterConfig) ParamsOps {
return func(params *reconfigureParams) {
- params.ConfigConstraint = &appsv1alpha1.ConfigConstraintSpec{
+ params.ConfigConstraint = &v1.ConfigConstraintSpec{
FormatterConfig: formatter,
}
}
diff --git a/controllers/apps/configuration/reconfigure_controller.go b/controllers/apps/configuration/reconfigure_controller.go
index df801d42e40..630165de7fe 100644
--- a/controllers/apps/configuration/reconfigure_controller.go
+++ b/controllers/apps/configuration/reconfigure_controller.go
@@ -205,7 +205,7 @@ func (r *ReconfigureReconciler) sync(reqCtx intctrlutil.RequestCtx, configMap *c
RSMUnits: reconcileContext.RSMList,
ClusterComponent: reconcileContext.ClusterComObj,
SynthesizedComponent: reconcileContext.BuiltinComponent,
- Restart: forceRestart || !cfgcm.IsSupportReload(resources.configConstraintObj.Spec.ReloadOptions),
+ Restart: forceRestart || !cfgcm.IsSupportReload(resources.configConstraintObj.Spec.DynamicReloadAction),
ReconfigureClientFactory: GetClientFactory(),
})
}
diff --git a/controllers/apps/configuration/reconfigure_policy.go b/controllers/apps/configuration/reconfigure_policy.go
index b58c7ccec0a..be38c1a5281 100644
--- a/controllers/apps/configuration/reconfigure_policy.go
+++ b/controllers/apps/configuration/reconfigure_policy.go
@@ -28,6 +28,7 @@ import (
"k8s.io/apimachinery/pkg/util/intstr"
"sigs.k8s.io/controller-runtime/pkg/client"
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
workloads "github.com/apecloud/kubeblocks/apis/workloads/v1alpha1"
configmanager "github.com/apecloud/kubeblocks/pkg/configuration/config_manager"
@@ -87,7 +88,7 @@ type reconfigureParams struct {
ConfigMap *corev1.ConfigMap
// ConfigConstraint pointer
- ConfigConstraint *appsv1alpha1.ConfigConstraintSpec
+ ConfigConstraint *v1.ConfigConstraintSpec
// For grpc factory
ReconfigureClientFactory createReconfigureClient
@@ -213,7 +214,7 @@ func (receiver AutoReloadPolicy) GetPolicyName() string {
return string(appsv1alpha1.AsyncDynamicReloadPolicy)
}
-func NewReconfigurePolicy(cc *appsv1alpha1.ConfigConstraintSpec, cfgPatch *core.ConfigPatchInfo, policy appsv1alpha1.UpgradePolicy, restart bool) (reconfigurePolicy, error) {
+func NewReconfigurePolicy(cc *v1.ConfigConstraintSpec, cfgPatch *core.ConfigPatchInfo, policy appsv1alpha1.UpgradePolicy, restart bool) (reconfigurePolicy, error) {
if cfgPatch != nil && !cfgPatch.IsModify {
// not walk here
return nil, core.MakeError("cfg not modify. [%v]", cfgPatch)
@@ -229,9 +230,9 @@ func NewReconfigurePolicy(cc *appsv1alpha1.ConfigConstraintSpec, cfgPatch *core.
// make decision
switch {
case !dynamicUpdate: // static parameters update
- case configmanager.IsAutoReload(cc.ReloadOptions): // if core support hot update, don't need to do anything
+ case configmanager.IsAutoReload(cc.DynamicReloadAction): // if core support hot update, don't need to do anything
policy = appsv1alpha1.AsyncDynamicReloadPolicy
- case enableSyncTrigger(cc.ReloadOptions): // sync config-manager exec hot update
+ case enableSyncTrigger(cc.DynamicReloadAction): // sync config-manager exec hot update
policy = appsv1alpha1.SyncDynamicReloadPolicy
default: // config-manager auto trigger to hot update
policy = appsv1alpha1.AsyncDynamicReloadPolicy
@@ -241,7 +242,7 @@ func NewReconfigurePolicy(cc *appsv1alpha1.ConfigConstraintSpec, cfgPatch *core.
// if not specify policy, or cannot decision policy, use default policy.
if policy == appsv1alpha1.NonePolicy {
policy = appsv1alpha1.NormalPolicy
- if cc.NeedDynamicReloadAction() && enableSyncTrigger(cc.ReloadOptions) {
+ if cc.NeedDynamicReloadAction() && enableSyncTrigger(cc.DynamicReloadAction) {
policy = appsv1alpha1.DynamicReloadAndRestartPolicy
}
}
@@ -256,7 +257,7 @@ func enableAutoDecision(restart bool, policy appsv1alpha1.UpgradePolicy) bool {
return !restart && policy == appsv1alpha1.NonePolicy
}
-func enableSyncTrigger(options *appsv1alpha1.ReloadOptions) bool {
+func enableSyncTrigger(options *v1.DynamicReloadAction) bool {
if options == nil {
return false
}
diff --git a/controllers/apps/configuration/relatedresource.go b/controllers/apps/configuration/relatedresource.go
index 2efec94772b..e57d0e01fdc 100644
--- a/controllers/apps/configuration/relatedresource.go
+++ b/controllers/apps/configuration/relatedresource.go
@@ -26,6 +26,7 @@ import (
corev1 "k8s.io/api/core/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
"github.com/apecloud/kubeblocks/pkg/constant"
configctrl "github.com/apecloud/kubeblocks/pkg/controller/configuration"
@@ -41,12 +42,12 @@ type reconfigureRelatedResource struct {
componentName string
configMapObj *corev1.ConfigMap
- configConstraintObj *appsv1alpha1.ConfigConstraint
+ configConstraintObj *v1.ConfigConstraint
}
func prepareRelatedResource(reqCtx intctrlutil.RequestCtx, client client.Client, cm *corev1.ConfigMap) (*reconfigureRelatedResource, error) {
configResources := reconfigureRelatedResource{
- configConstraintObj: &appsv1alpha1.ConfigConstraint{},
+ configConstraintObj: &v1.ConfigConstraint{},
configMapObj: cm,
ctx: reqCtx.Ctx,
client: client,
diff --git a/controllers/apps/configuration/suite_test.go b/controllers/apps/configuration/suite_test.go
index eded6d295fd..bc5b73c03cf 100644
--- a/controllers/apps/configuration/suite_test.go
+++ b/controllers/apps/configuration/suite_test.go
@@ -36,6 +36,7 @@ import (
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
workloads "github.com/apecloud/kubeblocks/apis/workloads/v1alpha1"
intctrlutil "github.com/apecloud/kubeblocks/pkg/controllerutil"
@@ -81,6 +82,8 @@ var _ = BeforeSuite(func() {
Expect(err).NotTo(HaveOccurred())
err = workloads.AddToScheme(scheme.Scheme)
Expect(err).NotTo(HaveOccurred())
+ err = appsv1.AddToScheme(scheme.Scheme)
+ Expect(err).NotTo(HaveOccurred())
// +kubebuilder:scaffold:scheme
diff --git a/controllers/apps/configuration/sync_upgrade_policy.go b/controllers/apps/configuration/sync_upgrade_policy.go
index 533cfef595d..703bbc62d08 100644
--- a/controllers/apps/configuration/sync_upgrade_policy.go
+++ b/controllers/apps/configuration/sync_upgrade_policy.go
@@ -26,6 +26,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
"github.com/apecloud/kubeblocks/pkg/configuration/core"
podutil "github.com/apecloud/kubeblocks/pkg/controllerutil"
@@ -89,14 +90,14 @@ func sync(params reconfigureParams, updatedParameters map[string]string, pods []
versionHash = params.getTargetVersionHash()
)
- if params.ConfigConstraint.Selector != nil {
- pods, err = matchLabel(pods, params.ConfigConstraint.Selector)
+ if params.ConfigConstraint.DynamicReloadSelector != nil {
+ pods, err = matchLabel(pods, params.ConfigConstraint.DynamicReloadSelector)
}
if err != nil {
return makeReturnedStatus(ESFailedAndRetry), err
}
if len(pods) == 0 {
- params.Ctx.Log.Info(fmt.Sprintf("no pods to update, and retry, selector: %s", params.ConfigConstraint.Selector.String()))
+ params.Ctx.Log.Info(fmt.Sprintf("no pods to update, and retry, selector: %s", params.ConfigConstraint.DynamicReloadSelector.String()))
return makeReturnedStatus(ESRetry), nil
}
@@ -127,7 +128,7 @@ func sync(params reconfigureParams, updatedParameters map[string]string, pods []
return makeReturnedStatus(r, withExpected(requireUpdatedCount), withSucceed(progress)), nil
}
-func getOnlineUpdateParams(configPatch *core.ConfigPatchInfo, cc *appsv1alpha1.ConfigConstraintSpec) map[string]string {
+func getOnlineUpdateParams(configPatch *core.ConfigPatchInfo, cc *v1.ConfigConstraintSpec) map[string]string {
r := make(map[string]string)
dynamicAction := cc.NeedDynamicReloadAction()
selectedPolicy := cc.DynamicParametersPolicy()
@@ -135,7 +136,7 @@ func getOnlineUpdateParams(configPatch *core.ConfigPatchInfo, cc *appsv1alpha1.C
for _, key := range parameters {
if key.UpdateType == core.UpdatedType {
for _, p := range key.Parameters {
- if dynamicAction && selectedPolicy == appsv1alpha1.SelectedDynamicParameters && !core.IsDynamicParameter(p.Key, cc) {
+ if dynamicAction && selectedPolicy == v1.SelectedDynamicParameters && !core.IsDynamicParameter(p.Key, cc) {
continue
}
if p.Value != nil {
diff --git a/controllers/apps/configuration/sync_upgrade_policy_test.go b/controllers/apps/configuration/sync_upgrade_policy_test.go
index 908975ab7a7..2c1d83d14a6 100644
--- a/controllers/apps/configuration/sync_upgrade_policy_test.go
+++ b/controllers/apps/configuration/sync_upgrade_policy_test.go
@@ -28,6 +28,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
cfgproto "github.com/apecloud/kubeblocks/pkg/configuration/proto"
mock_proto "github.com/apecloud/kubeblocks/pkg/configuration/proto/mocks"
@@ -64,7 +65,7 @@ var _ = Describe("Reconfigure OperatorSyncPolicy", func() {
}),
withMockRSM(3, nil),
withConfigSpec("for_test", map[string]string{"a": "c b e f"}),
- withConfigConstraintSpec(&appsv1alpha1.FormatterConfig{Format: appsv1alpha1.RedisCfg}),
+ withConfigConstraintSpec(&v1.FormatterConfig{Format: v1.RedisCfg}),
withConfigPatch(map[string]string{
"a": "c b e f",
}),
@@ -121,7 +122,7 @@ var _ = Describe("Reconfigure OperatorSyncPolicy", func() {
}),
withMockRSM(3, nil),
withConfigSpec("for_test", map[string]string{"a": "c b e f"}),
- withConfigConstraintSpec(&appsv1alpha1.FormatterConfig{Format: appsv1alpha1.RedisCfg}),
+ withConfigConstraintSpec(&v1.FormatterConfig{Format: v1.RedisCfg}),
withConfigPatch(map[string]string{
"a": "c b e f",
}),
@@ -134,7 +135,7 @@ var _ = Describe("Reconfigure OperatorSyncPolicy", func() {
}}))
// add selector
- mockParam.ConfigConstraint.Selector = &metav1.LabelSelector{
+ mockParam.ConfigConstraint.DynamicReloadSelector = &metav1.LabelSelector{
MatchLabels: map[string]string{
"primary": "true",
},
diff --git a/controllers/apps/operations/reconfigure_pipeline.go b/controllers/apps/operations/reconfigure_pipeline.go
index 31a187c75a8..23a107f488e 100644
--- a/controllers/apps/operations/reconfigure_pipeline.go
+++ b/controllers/apps/operations/reconfigure_pipeline.go
@@ -22,6 +22,7 @@ package operations
import (
"sigs.k8s.io/controller-runtime/pkg/client"
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
cfgcore "github.com/apecloud/kubeblocks/pkg/configuration/core"
"github.com/apecloud/kubeblocks/pkg/configuration/validate"
@@ -50,7 +51,7 @@ type pipeline struct {
isFileUpdated bool
updatedObject *appsv1alpha1.Configuration
- configConstraint *appsv1alpha1.ConfigConstraint
+ configConstraint *v1.ConfigConstraint
configSpec *appsv1alpha1.ComponentConfigSpec
reconfigureContext
@@ -107,7 +108,7 @@ func (p *pipeline) ConfigConstraints() *pipeline {
ccKey := client.ObjectKey{
Name: p.configSpec.ConfigConstraintRef,
}
- p.configConstraint = &appsv1alpha1.ConfigConstraint{}
+ p.configConstraint = &v1.ConfigConstraint{}
return p.cli.Get(p.reqCtx.Ctx, ccKey, p.configConstraint)
}
diff --git a/controllers/apps/operations/reconfigure_pipeline_test.go b/controllers/apps/operations/reconfigure_pipeline_test.go
index 72e773d847a..82f6550ce95 100644
--- a/controllers/apps/operations/reconfigure_pipeline_test.go
+++ b/controllers/apps/operations/reconfigure_pipeline_test.go
@@ -27,6 +27,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
"github.com/apecloud/kubeblocks/pkg/configuration/core"
"github.com/apecloud/kubeblocks/pkg/controller/builder"
@@ -49,14 +50,14 @@ var _ = Describe("Reconfigure util test", func() {
componentName = "mysql"
)
- mockCfgTplObj := func(tpl appsv1alpha1.ComponentConfigSpec) (*corev1.ConfigMap, *appsv1alpha1.ConfigConstraint, *appsv1alpha1.Configuration) {
+ mockCfgTplObj := func(tpl appsv1alpha1.ComponentConfigSpec) (*corev1.ConfigMap, *v1.ConfigConstraint, *appsv1alpha1.Configuration) {
By("By assure an cm obj")
cfgCM := testapps.NewCustomizedObj("operations_config/config-template.yaml",
&corev1.ConfigMap{},
testapps.WithNamespacedName(core.GetComponentCfgName(clusterName, componentName, tpl.Name), testCtx.DefaultNamespace))
cfgTpl := testapps.NewCustomizedObj("operations_config/config-constraint.yaml",
- &appsv1alpha1.ConfigConstraint{},
+ &v1.ConfigConstraint{},
testapps.WithNamespacedName(tpl.ConfigConstraintRef, tpl.Namespace))
configuration := builder.NewConfigurationBuilder(testCtx.DefaultNamespace,
diff --git a/controllers/apps/operations/reconfigure_test.go b/controllers/apps/operations/reconfigure_test.go
index 4ebb4a8054a..ff89aac386e 100644
--- a/controllers/apps/operations/reconfigure_test.go
+++ b/controllers/apps/operations/reconfigure_test.go
@@ -30,6 +30,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
opsutil "github.com/apecloud/kubeblocks/controllers/apps/operations/util"
"github.com/apecloud/kubeblocks/pkg/configuration/core"
@@ -79,12 +80,12 @@ var _ = Describe("Reconfigure OpsRequest", func() {
opsRes.Cluster.Status.Phase = appsv1alpha1.RunningClusterPhase
}
- assureCfgTplObj := func(tplName, cmName, ns string) (*corev1.ConfigMap, *appsv1alpha1.ConfigConstraint) {
+ assureCfgTplObj := func(tplName, cmName, ns string) (*corev1.ConfigMap, *v1.ConfigConstraint) {
By("Assuring an cm obj")
cfgCM := testapps.NewCustomizedObj("operations_config/config-template.yaml",
&corev1.ConfigMap{}, testapps.WithNamespacedName(cmName, ns))
cfgTpl := testapps.NewCustomizedObj("operations_config/config-constraint.yaml",
- &appsv1alpha1.ConfigConstraint{}, testapps.WithNamespacedName(tplName, ns))
+ &v1.ConfigConstraint{}, testapps.WithNamespacedName(tplName, ns))
Expect(testCtx.CheckedCreateObj(ctx, cfgCM)).Should(Succeed())
Expect(testCtx.CheckedCreateObj(ctx, cfgTpl)).Should(Succeed())
diff --git a/controllers/apps/operations/reconfigure_util.go b/controllers/apps/operations/reconfigure_util.go
index da2b9eaaa69..3626ea7e505 100644
--- a/controllers/apps/operations/reconfigure_util.go
+++ b/controllers/apps/operations/reconfigure_util.go
@@ -27,6 +27,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/log"
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
"github.com/apecloud/kubeblocks/pkg/configuration/core"
intctrlutil "github.com/apecloud/kubeblocks/pkg/controllerutil"
@@ -40,7 +41,7 @@ type reconfiguringResult struct {
err error
}
-func updateOpsLabelWithReconfigure(obj *appsv1alpha1.OpsRequest, params []core.ParamPairs, orinalData map[string]string, formatter *appsv1alpha1.FormatterConfig) {
+func updateOpsLabelWithReconfigure(obj *appsv1alpha1.OpsRequest, params []core.ParamPairs, orinalData map[string]string, formatter *v1.FormatterConfig) {
var maxLabelCount = 16
updateLabel := func(param map[string]interface{}) {
if obj.Labels == nil {
@@ -82,7 +83,7 @@ func updateOpsLabelWithReconfigure(obj *appsv1alpha1.OpsRequest, params []core.P
}
}
-func fetchOriginalValue(keyFile, data string, params map[string]interface{}, formatter *appsv1alpha1.FormatterConfig) (string, error) {
+func fetchOriginalValue(keyFile, data string, params map[string]interface{}, formatter *v1.FormatterConfig) (string, error) {
baseConfigObj, err := core.FromConfigObject(keyFile, data, formatter)
if err != nil {
return "", err
diff --git a/controllers/apps/operations/suite_test.go b/controllers/apps/operations/suite_test.go
index 1917a98ed52..bac0be87fd8 100644
--- a/controllers/apps/operations/suite_test.go
+++ b/controllers/apps/operations/suite_test.go
@@ -39,6 +39,7 @@ import (
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
dpv1alpha1 "github.com/apecloud/kubeblocks/apis/dataprotection/v1alpha1"
workloads "github.com/apecloud/kubeblocks/apis/workloads/v1alpha1"
@@ -102,6 +103,8 @@ var _ = BeforeSuite(func() {
err = appsv1alpha1.AddToScheme(scheme.Scheme)
Expect(err).NotTo(HaveOccurred())
+ err = appsv1.AddToScheme(scheme.Scheme)
+ Expect(err).NotTo(HaveOccurred())
err = workloads.AddToScheme(scheme.Scheme)
Expect(err).NotTo(HaveOccurred())
err = dpv1alpha1.AddToScheme(scheme.Scheme)
diff --git a/controllers/apps/operations/util/suite_test.go b/controllers/apps/operations/util/suite_test.go
index ee141b61293..68ad8848572 100644
--- a/controllers/apps/operations/util/suite_test.go
+++ b/controllers/apps/operations/util/suite_test.go
@@ -36,6 +36,7 @@ import (
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
intctrlutil "github.com/apecloud/kubeblocks/pkg/controllerutil"
"github.com/apecloud/kubeblocks/pkg/testutil"
@@ -86,6 +87,8 @@ var _ = BeforeSuite(func() {
err = appsv1alpha1.AddToScheme(scheme.Scheme)
Expect(err).NotTo(HaveOccurred())
+ err = appsv1.AddToScheme(scheme.Scheme)
+ Expect(err).NotTo(HaveOccurred())
// +kubebuilder:scaffold:scheme
diff --git a/controllers/apps/suite_test.go b/controllers/apps/suite_test.go
index 12b7222fa0b..dd0fd7d37a5 100644
--- a/controllers/apps/suite_test.go
+++ b/controllers/apps/suite_test.go
@@ -40,6 +40,7 @@ import (
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
dpv1alpha1 "github.com/apecloud/kubeblocks/apis/dataprotection/v1alpha1"
workloads "github.com/apecloud/kubeblocks/apis/workloads/v1alpha1"
@@ -119,6 +120,10 @@ var _ = BeforeSuite(func() {
Expect(err).NotTo(HaveOccurred())
model.AddScheme(appsv1alpha1.AddToScheme)
+ err = appsv1.AddToScheme(scheme.Scheme)
+ Expect(err).NotTo(HaveOccurred())
+ model.AddScheme(appsv1.AddToScheme)
+
err = dpv1alpha1.AddToScheme(scheme.Scheme)
Expect(err).NotTo(HaveOccurred())
model.AddScheme(dpv1alpha1.AddToScheme)
diff --git a/controllers/apps/transform_types.go b/controllers/apps/transform_types.go
index 69bff8edeb8..3887a48e54c 100644
--- a/controllers/apps/transform_types.go
+++ b/controllers/apps/transform_types.go
@@ -28,6 +28,7 @@ import (
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
"sigs.k8s.io/controller-runtime/pkg/client"
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
dpv1alpha1 "github.com/apecloud/kubeblocks/apis/dataprotection/v1alpha1"
extensionsv1alpha1 "github.com/apecloud/kubeblocks/apis/extensions/v1alpha1"
@@ -42,6 +43,7 @@ func init() {
utilruntime.Must(clientgoscheme.AddToScheme(rscheme))
utilruntime.Must(appsv1alpha1.AddToScheme(rscheme))
+ utilruntime.Must(appsv1.AddToScheme(rscheme))
utilruntime.Must(dpv1alpha1.AddToScheme(rscheme))
utilruntime.Must(snapshotv1.AddToScheme(rscheme))
utilruntime.Must(extensionsv1alpha1.AddToScheme(rscheme))
diff --git a/controllers/apps/transformer_component_tls_test.go b/controllers/apps/transformer_component_tls_test.go
index 8a0fa73bca0..041bba8248f 100644
--- a/controllers/apps/transformer_component_tls_test.go
+++ b/controllers/apps/transformer_component_tls_test.go
@@ -31,6 +31,7 @@ import (
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
cfgcore "github.com/apecloud/kubeblocks/pkg/configuration/core"
"github.com/apecloud/kubeblocks/pkg/constant"
@@ -90,7 +91,7 @@ var _ = Describe("TLS self-signed cert function", func() {
configConstraintObj := testapps.CheckedCreateCustomizedObj(&testCtx,
"resources/mysql-config-constraint.yaml",
- &appsv1alpha1.ConfigConstraint{})
+ &v1.ConfigConstraint{})
By("Create a clusterDef obj")
testapps.NewClusterDefFactory(clusterDefName).
diff --git a/controllers/k8score/suite_test.go b/controllers/k8score/suite_test.go
index 35fe8b12b28..14840d1962b 100644
--- a/controllers/k8score/suite_test.go
+++ b/controllers/k8score/suite_test.go
@@ -39,6 +39,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/log/zap"
"sigs.k8s.io/controller-runtime/pkg/manager"
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
workloads "github.com/apecloud/kubeblocks/apis/workloads/v1alpha1"
"github.com/apecloud/kubeblocks/pkg/testutil"
@@ -93,6 +94,9 @@ var _ = BeforeSuite(func() {
err = storagev1.AddToScheme(scheme.Scheme)
Expect(err).NotTo(HaveOccurred())
+ err = appsv1.AddToScheme(scheme.Scheme)
+ Expect(err).NotTo(HaveOccurred())
+
err = appsv1alpha1.AddToScheme(scheme.Scheme)
Expect(err).NotTo(HaveOccurred())
diff --git a/deploy/helm/crds/apps.kubeblocks.io_configconstraints.yaml b/deploy/helm/crds/apps.kubeblocks.io_configconstraints.yaml
index 969d593842a..40cde7b5158 100644
--- a/deploy/helm/crds/apps.kubeblocks.io_configconstraints.yaml
+++ b/deploy/helm/crds/apps.kubeblocks.io_configconstraints.yaml
@@ -19,6 +19,495 @@ spec:
singular: configconstraint
scope: Cluster
versions:
+ - additionalPrinterColumns:
+ - description: status phase
+ jsonPath: .status.phase
+ name: PHASE
+ type: string
+ - jsonPath: .metadata.creationTimestamp
+ name: AGE
+ type: date
+ name: v1
+ schema:
+ openAPIV3Schema:
+ description: ConfigConstraint is the Schema for the configconstraint API
+ properties:
+ apiVersion:
+ description: 'APIVersion defines the versioned schema of this representation
+ of an object. Servers should convert recognized schemas to the latest
+ internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
+ type: string
+ kind:
+ description: 'Kind is a string value representing the REST resource this
+ object represents. Servers may infer this from the endpoint the client
+ submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
+ type: string
+ metadata:
+ type: object
+ spec:
+ description: ConfigConstraintSpec defines the desired state of ConfigConstraint
+ properties:
+ configSchema:
+ description: List constraints rules for each config parameters.
+ properties:
+ cue:
+ description: Enables providers to verify user configurations using
+ the CUE language.
+ type: string
+ schemaInJSON:
+ description: Transforms the schema from CUE to json for further
+ OpenAPI validation
+ x-kubernetes-preserve-unknown-fields: true
+ type: object
+ configSchemaTopLevelKey:
+ description: Top level key used to get the cue rules to validate the
+ config file. It must exist in 'ConfigSchema'
+ type: string
+ downwardActions:
+ description: "A set of actions for regenerating local configs. \n
+ It works when: - different engine roles have different config, such
+ as redis primary & secondary - after a role switch, the local config
+ will be regenerated with the help of DownwardActions"
+ items:
+ properties:
+ command:
+ description: The command used to execute for the downward API.
+ items:
+ type: string
+ type: array
+ items:
+ description: Represents a list of downward API volume files.
+ items:
+ description: DownwardAPIVolumeFile represents information
+ to create the file containing the pod field
+ properties:
+ fieldRef:
+ description: 'Required: Selects a field of the pod: only
+ annotations, labels, name and namespace are supported.'
+ properties:
+ apiVersion:
+ description: Version of the schema the FieldPath is
+ written in terms of, defaults to "v1".
+ type: string
+ fieldPath:
+ description: Path of the field to select in the specified
+ API version.
+ type: string
+ required:
+ - fieldPath
+ type: object
+ x-kubernetes-map-type: atomic
+ mode:
+ description: 'Optional: mode bits used to set permissions
+ on this file, must be an octal value between 0000 and
+ 0777 or a decimal value between 0 and 511. YAML accepts
+ both octal and decimal values, JSON requires decimal
+ values for mode bits. If not specified, the volume defaultMode
+ will be used. This might be in conflict with other options
+ that affect the file mode, like fsGroup, and the result
+ can be other mode bits set.'
+ format: int32
+ type: integer
+ path:
+ description: 'Required: Path is the relative path name
+ of the file to be created. Must not be absolute or contain
+ the ''..'' path. Must be utf-8 encoded. The first item
+ of the relative path must not start with ''..'''
+ type: string
+ resourceFieldRef:
+ description: 'Selects a resource of the container: only
+ resources limits and requests (limits.cpu, limits.memory,
+ requests.cpu and requests.memory) are currently supported.'
+ properties:
+ containerName:
+ description: 'Container name: required for volumes,
+ optional for env vars'
+ type: string
+ divisor:
+ anyOf:
+ - type: integer
+ - type: string
+ description: Specifies the output format of the exposed
+ resources, defaults to "1"
+ pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
+ x-kubernetes-int-or-string: true
+ resource:
+ description: 'Required: resource to select'
+ type: string
+ required:
+ - resource
+ type: object
+ x-kubernetes-map-type: atomic
+ required:
+ - path
+ type: object
+ type: array
+ mountPoint:
+ description: Specifies the mount point of the scripts file.
+ maxLength: 128
+ type: string
+ name:
+ description: Specifies the name of the field. It must be a string
+ of maximum length 63. The name should match the regex pattern
+ `^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$`.
+ maxLength: 63
+ pattern: ^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$
+ type: string
+ required:
+ - items
+ - mountPoint
+ - name
+ type: object
+ type: array
+ dynamicActionCanBeMerged:
+ description: "Indicates the dynamic reload action and restart action
+ can be merged to a restart action. \n When a batch of parameters
+ updates incur both restart & dynamic reload, it works as: - set
+ to true, the two actions merged to only one restart action - set
+ to false, the two actions cannot be merged, the actions executed
+ in order [dynamic reload, restart]"
+ type: boolean
+ dynamicParameterSelectedPolicy:
+ description: Specifies the policy for selecting the parameters of
+ dynamic reload actions.
+ enum:
+ - all
+ - dynamic
+ type: string
+ dynamicParameters:
+ description: A list of DynamicParameter. Modifications of dynamic
+ parameters trigger a reload action without process restart.
+ items:
+ type: string
+ type: array
+ x-kubernetes-list-type: set
+ dynamicReloadAction:
+ description: Specifies the dynamic reload actions supported by the
+ engine. If set, the controller call the scripts defined in the actions
+ for a dynamic parameter upgrade. The actions are called only when
+ the modified parameter is defined in dynamicParameters part && DynamicReloadAction
+ != nil
+ properties:
+ autoTrigger:
+ description: Used to automatically perform the reload command
+ when conditions are met.
+ properties:
+ processName:
+ description: The name of the process.
+ type: string
+ type: object
+ shellTrigger:
+ description: Used to perform the reload command in shell script.
+ properties:
+ batchParametersTemplate:
+ description: "When `batchReload` is set to 'True', this parameter
+ allows for the optional specification of the batch input
+ format that is passed into the STDIN of the script. The
+ format should be provided as a Go template string. In the
+ template, the updated parameters' key-value map can be referenced
+ using the dollar sign ('$') variable. Here's an example
+ of an input template: \n ```yaml \n batchParametersTemplate:
+ |- \n {{- range $pKey, $pValue := $ }} \n {{ printf \"%s:%s\"
+ $pKey $pValue }} \n {{- end }} \n ``` \n In this example,
+ each updated parameter is iterated over in a sorted order
+ by keys to generate the batch input data as follows: \n
+ ``` \n key1:value1 \n key2:value2 \n key3:value3 \n ```
+ \n If this parameter is not specified, the default format
+ used for STDIN is as follows: Each updated parameter generates
+ a line that concatenates the parameter's key and value with
+ a equal sign ('='). These lines are then sorted by their
+ keys and inserted accordingly. Here's an example of the
+ batch input data using the default template: \n ``` \n key1=value1
+ \n key2=value2 \n key3=value3 \n ```"
+ type: string
+ batchReload:
+ description: Specifies whether to reconfigure dynamic parameters
+ individually or in a batch. - Set to 'True' to execute the
+ reload action in a batch, incorporating all parameter changes.
+ - Set to 'False' to execute the reload action for each parameter
+ change individually. The default value is 'False'.
+ type: boolean
+ command:
+ description: Specifies the list of commands for reload.
+ items:
+ type: string
+ type: array
+ sync:
+ description: 'Specifies whether to synchronize updates parameters
+ to the config manager. Specifies two ways of controller
+ to reload the parameter: - set to ''True'', execute the
+ reload action in sync mode, wait for the completion of reload
+ - set to ''False'', execute the reload action in async mode,
+ just update the ''Configmap'', no need to wait'
+ type: boolean
+ required:
+ - command
+ type: object
+ tplScriptTrigger:
+ description: Used to perform the reload command by Go template
+ script.
+ properties:
+ namespace:
+ default: default
+ description: Specifies the namespace where the referenced
+ tpl script ConfigMap in. If left empty, by default in the
+ "default" namespace.
+ maxLength: 63
+ pattern: ^[a-z0-9]([a-z0-9\-]*[a-z0-9])?$
+ type: string
+ scriptConfigMapRef:
+ description: Specifies the reference to the ConfigMap that
+ contains the script to be executed for reload.
+ type: string
+ sync:
+ description: 'Specifies whether to synchronize updates parameters
+ to the config manager. Specifies two ways of controller
+ to reload the parameter: - set to ''True'', execute the
+ reload action in sync mode, wait for the completion of reload
+ - set to ''False'', execute the reload action in async mode,
+ just update the ''Configmap'', no need to wait'
+ type: boolean
+ required:
+ - scriptConfigMapRef
+ type: object
+ unixSignalTrigger:
+ description: Used to trigger a reload by sending a Unix signal
+ to the process.
+ properties:
+ processName:
+ description: Represents the name of the process that the Unix
+ signal sent to.
+ type: string
+ signal:
+ description: 'Represents a valid Unix signal. Refer to the
+ following URL for a list of all Unix signals: ../../pkg/configuration/configmap/handler.go:allUnixSignals'
+ enum:
+ - SIGHUP
+ - SIGINT
+ - SIGQUIT
+ - SIGILL
+ - SIGTRAP
+ - SIGABRT
+ - SIGBUS
+ - SIGFPE
+ - SIGKILL
+ - SIGUSR1
+ - SIGSEGV
+ - SIGUSR2
+ - SIGPIPE
+ - SIGALRM
+ - SIGTERM
+ - SIGSTKFLT
+ - SIGCHLD
+ - SIGCONT
+ - SIGSTOP
+ - SIGTSTP
+ - SIGTTIN
+ - SIGTTOU
+ - SIGURG
+ - SIGXCPU
+ - SIGXFSZ
+ - SIGVTALRM
+ - SIGPROF
+ - SIGWINCH
+ - SIGIO
+ - SIGPWR
+ - SIGSYS
+ type: string
+ required:
+ - processName
+ - signal
+ type: object
+ type: object
+ dynamicReloadSelector:
+ description: Used to match labels on the pod to do a dynamic reload
+ properties:
+ matchExpressions:
+ description: matchExpressions is a list of label selector requirements.
+ The requirements are ANDed.
+ items:
+ description: A label selector requirement is a selector that
+ contains values, a key, and an operator that relates the key
+ and values.
+ properties:
+ key:
+ description: key is the label key that the selector applies
+ to.
+ type: string
+ operator:
+ description: operator represents a key's relationship to
+ a set of values. Valid operators are In, NotIn, Exists
+ and DoesNotExist.
+ type: string
+ values:
+ description: values is an array of string values. If the
+ operator is In or NotIn, the values array must be non-empty.
+ If the operator is Exists or DoesNotExist, the values
+ array must be empty. This array is replaced during a strategic
+ merge patch.
+ items:
+ type: string
+ type: array
+ required:
+ - key
+ - operator
+ type: object
+ type: array
+ matchLabels:
+ additionalProperties:
+ type: string
+ description: matchLabels is a map of {key,value} pairs. A single
+ {key,value} in the matchLabels map is equivalent to an element
+ of matchExpressions, whose key field is "key", the operator
+ is "In", and the values array contains only "value". The requirements
+ are ANDed.
+ type: object
+ type: object
+ x-kubernetes-map-type: atomic
+ formatterConfig:
+ description: 'Describes the format of the config file. The controller
+ works as follows: 1. Parse the config file 2. Get the modified parameters
+ 3. Trigger the corresponding action'
+ properties:
+ format:
+ description: "The config file format. Valid values are `ini`,
+ `xml`, `yaml`, `json`, `hcl`, `dotenv`, `properties` and `toml`.
+ Each format has its own characteristics and use cases. \n -
+ ini: is a text-based content with a structure and syntax comprising
+ key–value pairs for properties, reference wiki: https://en.wikipedia.org/wiki/INI_file
+ - xml: refers to wiki: https://en.wikipedia.org/wiki/XML - yaml:
+ supports for complex data types and structures. - json: refers
+ to wiki: https://en.wikipedia.org/wiki/JSON - hcl: The HashiCorp
+ Configuration Language (HCL) is a configuration language authored
+ by HashiCorp, reference url: https://www.linode.com/docs/guides/introduction-to-hcl/
+ - dotenv: is a plain text file with simple key–value pairs,
+ reference wiki: https://en.wikipedia.org/wiki/Configuration_file#MS-DOS
+ - properties: a file extension mainly used in Java, reference
+ wiki: https://en.wikipedia.org/wiki/.properties - toml: refers
+ to wiki: https://en.wikipedia.org/wiki/TOML - props-plus: a
+ file extension mainly used in Java, supports CamelCase(e.g:
+ brokerMaxConnectionsPerIp)"
+ enum:
+ - xml
+ - ini
+ - yaml
+ - json
+ - hcl
+ - dotenv
+ - toml
+ - properties
+ - redis
+ - props-plus
+ type: string
+ iniConfig:
+ description: A pointer to an IniConfig struct that holds the ini
+ options.
+ properties:
+ sectionName:
+ description: A string that describes the name of the ini section.
+ type: string
+ type: object
+ required:
+ - format
+ type: object
+ immutableParameters:
+ description: Describes parameters that are prohibited to do any modifications.
+ items:
+ type: string
+ type: array
+ x-kubernetes-list-type: set
+ reloadToolsImage:
+ description: Tools used by the dynamic reload actions. Usually it
+ is referenced by the 'init container' for 'cp' it to a binary volume.
+ properties:
+ mountPoint:
+ description: Represents the point where the scripts file will
+ be mounted.
+ maxLength: 128
+ type: string
+ toolConfigs:
+ description: Used to configure the initialization container.
+ items:
+ properties:
+ command:
+ description: Commands to be executed when init containers.
+ items:
+ type: string
+ type: array
+ image:
+ description: Represents the url of the tool container image.
+ type: string
+ name:
+ description: Specifies the name of the initContainer.
+ maxLength: 63
+ pattern: ^[a-z]([a-z0-9\-]*[a-z0-9])?$
+ type: string
+ required:
+ - command
+ type: object
+ type: array
+ required:
+ - mountPoint
+ type: object
+ scriptConfigs:
+ description: A list of ScriptConfig used by the actions defined in
+ dynamic reload and downward actions.
+ items:
+ properties:
+ namespace:
+ default: default
+ description: Specifies the namespace where the referenced tpl
+ script ConfigMap in. If left empty, by default in the "default"
+ namespace.
+ maxLength: 63
+ pattern: ^[a-z0-9]([a-z0-9\-]*[a-z0-9])?$
+ type: string
+ scriptConfigMapRef:
+ description: Specifies the reference to the ConfigMap that contains
+ the script to be executed for reload.
+ type: string
+ required:
+ - scriptConfigMapRef
+ type: object
+ type: array
+ x-kubernetes-list-map-keys:
+ - scriptConfigMapRef
+ x-kubernetes-list-type: map
+ staticParameters:
+ description: A list of StaticParameter. Modifications of static parameters
+ trigger a process restart.
+ items:
+ type: string
+ type: array
+ x-kubernetes-list-type: set
+ required:
+ - formatterConfig
+ type: object
+ status:
+ properties:
+ message:
+ description: Provides descriptions for abnormal states.
+ type: string
+ observedGeneration:
+ description: Refers to the most recent generation observed for this
+ ConfigConstraint. This value is updated by the API Server.
+ format: int64
+ type: integer
+ phase:
+ description: Specifies the status of the configuration template. When
+ set to CCAvailablePhase, the ConfigConstraint can be referenced
+ by ClusterDefinition or ClusterVersion.
+ enum:
+ - Available
+ - Unavailable
+ - Deleting
+ type: string
+ type: object
+ type: object
+ served: true
+ storage: true
+ subresources:
+ status: {}
- additionalPrinterColumns:
- description: status phase
jsonPath: .status.phase
@@ -49,12 +538,10 @@ spec:
properties:
cfgSchemaTopLevelName:
description: Top level key used to get the cue rules to validate the
- config file. It must exist in 'ConfigSchema' TODO (refactored to
- ConfigSchemaTopLevelKey)
+ config file. It must exist in 'ConfigSchema'
type: string
configurationSchema:
- description: List constraints rules for each config parameters. TODO
- (refactored to ConfigSchema)
+ description: List constraints rules for each config parameters.
properties:
cue:
description: Enables providers to verify user configurations using
@@ -62,15 +549,14 @@ spec:
type: string
schema:
description: Transforms the schema from CUE to json for further
- OpenAPI validation TODO (refactored to SchemaInJson)
+ OpenAPI validation
x-kubernetes-preserve-unknown-fields: true
type: object
downwardAPIOptions:
description: "A set of actions for regenerating local configs. \n
It works when: - different engine roles have different config, such
as redis primary & secondary - after a role switch, the local config
- will be regenerated with the help of DownwardActions TODO (refactored
- to DownwardActions)"
+ will be regenerated with the help of DownwardActions"
items:
properties:
command:
@@ -240,8 +726,8 @@ spec:
description: Specifies the dynamic reload actions supported by the
engine. If set, the controller call the scripts defined in the actions
for a dynamic parameter upgrade. The actions are called only when
- the modified parameter is defined in dynamicParameters part && DynamicReloadActions
- != nil TODO (refactored to DynamicReloadActions)
+ the modified parameter is defined in dynamicParameters part && ReloadOptions
+ != nil
properties:
autoTrigger:
description: Used to automatically perform the reload command
@@ -254,14 +740,14 @@ spec:
shellTrigger:
description: Used to perform the reload command in shell script.
properties:
- batchInputTemplate:
+ batchParametersTemplate:
description: "When `batchReload` is set to 'True', this parameter
allows for the optional specification of the batch input
format that is passed into the STDIN of the script. The
format should be provided as a Go template string. In the
template, the updated parameters' key-value map can be referenced
using the dollar sign ('$') variable. Here's an example
- of an input template: \n ```yaml \n batchInputTemplate:
+ of an input template: \n ```yaml \n batchParametersTemplate:
|- \n {{- range $pKey, $pValue := $ }} \n {{ printf \"%s:%s\"
$pKey $pValue }} \n {{- end }} \n ``` \n In this example,
each updated parameter is iterated over in a sorted order
@@ -400,7 +886,6 @@ spec:
x-kubernetes-list-type: map
selector:
description: Used to match labels on the pod to do a dynamic reload
- TODO (refactored to DynamicReloadSelector)
properties:
matchExpressions:
description: matchExpressions is a list of label selector requirements.
@@ -454,7 +939,6 @@ spec:
toolsImageSpec:
description: Tools used by the dynamic reload actions. Usually it
is referenced by the 'init container' for 'cp' it to a binary volume.
- TODO (refactored to ReloadToolsImage)
properties:
mountPoint:
description: Represents the point where the scripts file will
@@ -510,6 +994,6 @@ spec:
type: object
type: object
served: true
- storage: true
+ storage: false
subresources:
status: {}
diff --git a/deploy/helm/templates/dataprotection.yaml b/deploy/helm/templates/dataprotection.yaml
index 6783667b53d..7d704e584f0 100644
--- a/deploy/helm/templates/dataprotection.yaml
+++ b/deploy/helm/templates/dataprotection.yaml
@@ -155,11 +155,11 @@ spec:
volumeMounts:
- mountPath: /etc/kubeblocks
name: manager-config
- {{- if .Values.admissionWebhooks.enabled }}
- - mountPath: /tmp/k8s-webhook-server/serving-certs
- name: cert
- readOnly: true
- {{- end }}
+ {{- if .Values.admissionWebhooks.enabled }}
+ - mountPath: /tmp/k8s-webhook-server/serving-certs
+ name: cert
+ readOnly: true
+ {{- end }}
{{- if .Values.hostNetwork }}
hostNetwork: {{ .Values.hostNetwork }}
{{- end }}
diff --git a/docs/developer_docs/api-reference/cluster.md b/docs/developer_docs/api-reference/cluster.md
index d3c25f072a0..a4436689a2a 100644
--- a/docs/developer_docs/api-reference/cluster.md
+++ b/docs/developer_docs/api-reference/cluster.md
@@ -9,12 +9,1370 @@ sidebar_label: Cluster
Packages:
+apps.kubeblocks.io/v1
+
+
+Resource Types:
+
+ConfigConstraint
+
+
+
ConfigConstraint is the Schema for the configconstraint API
+
+
+
+
+Field |
+Description |
+
+
+
+
+
+apiVersion
+string |
+
+apps.kubeblocks.io/v1
+ |
+
+
+
+kind
+string
+ |
+ConfigConstraint |
+
+
+
+metadata
+
+
+Kubernetes meta/v1.ObjectMeta
+
+
+ |
+
+Refer to the Kubernetes API documentation for the fields of the
+metadata field.
+ |
+
+
+
+spec
+
+
+ConfigConstraintSpec
+
+
+ |
+
+
+
+
+
+
+dynamicReloadAction
+
+
+DynamicReloadAction
+
+
+ |
+
+(Optional)
+ Specifies the dynamic reload actions supported by the engine. If set, the controller call the scripts defined in the actions for a dynamic parameter upgrade.
+The actions are called only when the modified parameter is defined in dynamicParameters part && DynamicReloadAction != nil
+ |
+
+
+
+dynamicActionCanBeMerged
+
+bool
+
+ |
+
+(Optional)
+ Indicates the dynamic reload action and restart action can be merged to a restart action.
+When a batch of parameters updates incur both restart & dynamic reload, it works as:
+- set to true, the two actions merged to only one restart action
+- set to false, the two actions cannot be merged, the actions executed in order [dynamic reload, restart]
+ |
+
+
+
+dynamicParameterSelectedPolicy
+
+
+DynamicParameterSelectedPolicy
+
+
+ |
+
+(Optional)
+ Specifies the policy for selecting the parameters of dynamic reload actions.
+ |
+
+
+
+reloadToolsImage
+
+
+ReloadToolsImage
+
+
+ |
+
+(Optional)
+ Tools used by the dynamic reload actions.
+Usually it is referenced by the ‘init container’ for ‘cp’ it to a binary volume.
+ |
+
+
+
+downwardActions
+
+
+[]DownwardAction
+
+
+ |
+
+(Optional)
+ A set of actions for regenerating local configs.
+It works when:
+- different engine roles have different config, such as redis primary & secondary
+- after a role switch, the local config will be regenerated with the help of DownwardActions
+ |
+
+
+
+scriptConfigs
+
+
+[]ScriptConfig
+
+
+ |
+
+(Optional)
+ A list of ScriptConfig used by the actions defined in dynamic reload and downward actions.
+ |
+
+
+
+configSchemaTopLevelKey
+
+string
+
+ |
+
+(Optional)
+ Top level key used to get the cue rules to validate the config file.
+It must exist in ‘ConfigSchema’
+ |
+
+
+
+configSchema
+
+
+ConfigSchema
+
+
+ |
+
+(Optional)
+ List constraints rules for each config parameters.
+ |
+
+
+
+staticParameters
+
+[]string
+
+ |
+
+(Optional)
+ A list of StaticParameter. Modifications of static parameters trigger a process restart.
+ |
+
+
+
+dynamicParameters
+
+[]string
+
+ |
+
+(Optional)
+ A list of DynamicParameter. Modifications of dynamic parameters trigger a reload action without process restart.
+ |
+
+
+
+immutableParameters
+
+[]string
+
+ |
+
+(Optional)
+ Describes parameters that are prohibited to do any modifications.
+ |
+
+
+
+dynamicReloadSelector
+
+
+Kubernetes meta/v1.LabelSelector
+
+
+ |
+
+(Optional)
+ Used to match labels on the pod to do a dynamic reload
+ |
+
+
+
+formatterConfig
+
+
+FormatterConfig
+
+
+ |
+
+ Describes the format of the config file.
+The controller works as follows:
+1. Parse the config file
+2. Get the modified parameters
+3. Trigger the corresponding action
+ |
+
+
+ |
+
+
+
+status
+
+
+ConfigConstraintStatus
+
+
+ |
+
+ |
+
+
+
+AutoTrigger
+
+
+(Appears on:DynamicReloadAction, ReloadOptions)
+
+
+
+
+
+
+Field |
+Description |
+
+
+
+
+
+processName
+
+string
+
+ |
+
+(Optional)
+ The name of the process.
+ |
+
+
+
+
+
+(Appears on:FormatterConfig)
+
+
+
CfgFileFormat defines formatter of configuration files.
+
+
+
+
+Value |
+Description |
+
+
+"dotenv" |
+ |
+
"hcl" |
+ |
+
"ini" |
+ |
+
"json" |
+ |
+
"properties" |
+ |
+
"props-plus" |
+ |
+
"redis" |
+ |
+
"toml" |
+ |
+
"xml" |
+ |
+
"yaml" |
+ |
+
+
+CfgReloadType
+(string
alias)
+
+
CfgReloadType defines reload method.
+
+
+
+
+Value |
+Description |
+
+
+"auto" |
+ |
+
"http" |
+ |
+
"sql" |
+ |
+
"exec" |
+ |
+
"tpl" |
+ |
+
"signal" |
+ |
+
+
+ConfigConstraintPhase
+(string
alias)
+
+(Appears on:ConfigConstraintStatus, ConfigConstraintStatus)
+
+
+
ConfigConstraintPhase defines the ConfigConstraint CR .status.phase
+
+
+
+
+Value |
+Description |
+
+
+"Available" |
+ |
+
"Deleting" |
+ |
+
"Unavailable" |
+ |
+
+
+ConfigConstraintSpec
+
+
+(Appears on:ConfigConstraint)
+
+
+
ConfigConstraintSpec defines the desired state of ConfigConstraint
+
+
+
+
+Field |
+Description |
+
+
+
+
+
+dynamicReloadAction
+
+
+DynamicReloadAction
+
+
+ |
+
+(Optional)
+ Specifies the dynamic reload actions supported by the engine. If set, the controller call the scripts defined in the actions for a dynamic parameter upgrade.
+The actions are called only when the modified parameter is defined in dynamicParameters part && DynamicReloadAction != nil
+ |
+
+
+
+dynamicActionCanBeMerged
+
+bool
+
+ |
+
+(Optional)
+ Indicates the dynamic reload action and restart action can be merged to a restart action.
+When a batch of parameters updates incur both restart & dynamic reload, it works as:
+- set to true, the two actions merged to only one restart action
+- set to false, the two actions cannot be merged, the actions executed in order [dynamic reload, restart]
+ |
+
+
+
+dynamicParameterSelectedPolicy
+
+
+DynamicParameterSelectedPolicy
+
+
+ |
+
+(Optional)
+ Specifies the policy for selecting the parameters of dynamic reload actions.
+ |
+
+
+
+reloadToolsImage
+
+
+ReloadToolsImage
+
+
+ |
+
+(Optional)
+ Tools used by the dynamic reload actions.
+Usually it is referenced by the ‘init container’ for ‘cp’ it to a binary volume.
+ |
+
+
+
+downwardActions
+
+
+[]DownwardAction
+
+
+ |
+
+(Optional)
+ A set of actions for regenerating local configs.
+It works when:
+- different engine roles have different config, such as redis primary & secondary
+- after a role switch, the local config will be regenerated with the help of DownwardActions
+ |
+
+
+
+scriptConfigs
+
+
+[]ScriptConfig
+
+
+ |
+
+(Optional)
+ A list of ScriptConfig used by the actions defined in dynamic reload and downward actions.
+ |
+
+
+
+configSchemaTopLevelKey
+
+string
+
+ |
+
+(Optional)
+ Top level key used to get the cue rules to validate the config file.
+It must exist in ‘ConfigSchema’
+ |
+
+
+
+configSchema
+
+
+ConfigSchema
+
+
+ |
+
+(Optional)
+ List constraints rules for each config parameters.
+ |
+
+
+
+staticParameters
+
+[]string
+
+ |
+
+(Optional)
+ A list of StaticParameter. Modifications of static parameters trigger a process restart.
+ |
+
+
+
+dynamicParameters
+
+[]string
+
+ |
+
+(Optional)
+ A list of DynamicParameter. Modifications of dynamic parameters trigger a reload action without process restart.
+ |
+
+
+
+immutableParameters
+
+[]string
+
+ |
+
+(Optional)
+ Describes parameters that are prohibited to do any modifications.
+ |
+
+
+
+dynamicReloadSelector
+
+
+Kubernetes meta/v1.LabelSelector
+
+
+ |
+
+(Optional)
+ Used to match labels on the pod to do a dynamic reload
+ |
+
+
+
+formatterConfig
+
+
+FormatterConfig
+
+
+ |
+
+ Describes the format of the config file.
+The controller works as follows:
+1. Parse the config file
+2. Get the modified parameters
+3. Trigger the corresponding action
+ |
+
+
+
+ConfigConstraintStatus
+
+
+(Appears on:ConfigConstraint)
+
+
+
+
+
+
+Field |
+Description |
+
+
+
+
+
+phase
+
+
+ConfigConstraintPhase
+
+
+ |
+
+(Optional)
+ Specifies the status of the configuration template.
+When set to CCAvailablePhase, the ConfigConstraint can be referenced by ClusterDefinition or ClusterVersion.
+ |
+
+
+
+message
+
+string
+
+ |
+
+(Optional)
+ Provides descriptions for abnormal states.
+ |
+
+
+
+observedGeneration
+
+int64
+
+ |
+
+(Optional)
+ Refers to the most recent generation observed for this ConfigConstraint. This value is updated by the API Server.
+ |
+
+
+
+ConfigSchema
+
+
+(Appears on:ConfigConstraintSpec)
+
+
+
+
+
+
+Field |
+Description |
+
+
+
+
+
+schemaInJSON
+
+
+Kubernetes api extensions v1.JSONSchemaProps
+
+
+ |
+
+ Transforms the schema from CUE to json for further OpenAPI validation
+ |
+
+
+
+cue
+
+string
+
+ |
+
+(Optional)
+ Enables providers to verify user configurations using the CUE language.
+ |
+
+
+
+DownwardAction
+
+
+(Appears on:ConfigConstraintSpec, ConfigConstraintSpec)
+
+
+
+
+
+
+Field |
+Description |
+
+
+
+
+
+name
+
+string
+
+ |
+
+ Specifies the name of the field. It must be a string of maximum length 63.
+The name should match the regex pattern ^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$ .
+ |
+
+
+
+mountPoint
+
+string
+
+ |
+
+ Specifies the mount point of the scripts file.
+ |
+
+
+
+items
+
+
+[]Kubernetes core/v1.DownwardAPIVolumeFile
+
+
+ |
+
+ Represents a list of downward API volume files.
+ |
+
+
+
+command
+
+[]string
+
+ |
+
+(Optional)
+ The command used to execute for the downward API.
+ |
+
+
+
+DynamicParameterSelectedPolicy
+(string
alias)
+
+(Appears on:ConfigConstraintSpec, ConfigConstraintSpec)
+
+
+
DynamicParameterSelectedPolicy determines how to select the parameters of dynamic reload actions
+
+
+
+
+Value |
+Description |
+
+
+"all" |
+ |
+
"dynamic" |
+ |
+
+
+DynamicReloadAction
+
+
+(Appears on:ConfigConstraintSpec)
+
+
+
+
+
+
+Field |
+Description |
+
+
+
+
+
+unixSignalTrigger
+
+
+UnixSignalTrigger
+
+
+ |
+
+(Optional)
+ Used to trigger a reload by sending a Unix signal to the process.
+ |
+
+
+
+shellTrigger
+
+
+ShellTrigger
+
+
+ |
+
+(Optional)
+ Used to perform the reload command in shell script.
+ |
+
+
+
+tplScriptTrigger
+
+
+TPLScriptTrigger
+
+
+ |
+
+(Optional)
+ Used to perform the reload command by Go template script.
+ |
+
+
+
+autoTrigger
+
+
+AutoTrigger
+
+
+ |
+
+(Optional)
+ Used to automatically perform the reload command when conditions are met.
+ |
+
+
+
+
+
+(Appears on:FormatterConfig)
+
+
+
+
+
+
+Field |
+Description |
+
+
+
+
+
+iniConfig
+
+
+IniConfig
+
+
+ |
+
+(Optional)
+ A pointer to an IniConfig struct that holds the ini options.
+ |
+
+
+
+
+
+(Appears on:ConfigConstraintSpec, ConfigConstraintSpec)
+
+
+
+
+
+
+Field |
+Description |
+
+
+
+
+
+FormatterAction
+
+
+FormatterAction
+
+
+ |
+
+
+(Members of FormatterAction are embedded into this type.)
+
+(Optional)
+Represents the additional actions for formatting the config file.
+If not specified, the default options will be applied.
+ |
+
+
+
+format
+
+
+CfgFileFormat
+
+
+ |
+
+ The config file format. Valid values are ini , xml , yaml , json ,
+hcl , dotenv , properties and toml . Each format has its own characteristics and use cases.
+
+ |
+
+
+
+IniConfig
+
+
+(Appears on:FormatterAction)
+
+
+
+
+
+
+Field |
+Description |
+
+
+
+
+
+sectionName
+
+string
+
+ |
+
+(Optional)
+ A string that describes the name of the ini section.
+ |
+
+
+
+
+
+(Appears on:ConfigConstraintSpec, ConfigConstraintSpec)
+
+
+
+
+
+
+Field |
+Description |
+
+
+
+
+
+mountPoint
+
+string
+
+ |
+
+ Represents the point where the scripts file will be mounted.
+ |
+
+
+
+toolConfigs
+
+
+[]ToolConfig
+
+
+ |
+
+(Optional)
+ Used to configure the initialization container.
+ |
+
+
+
+ScriptConfig
+
+
+(Appears on:ConfigConstraintSpec, TPLScriptTrigger, ConfigConstraintSpec)
+
+
+
+
+
+
+Field |
+Description |
+
+
+
+
+
+scriptConfigMapRef
+
+string
+
+ |
+
+ Specifies the reference to the ConfigMap that contains the script to be executed for reload.
+ |
+
+
+
+namespace
+
+string
+
+ |
+
+(Optional)
+ Specifies the namespace where the referenced tpl script ConfigMap in.
+If left empty, by default in the “default” namespace.
+ |
+
+
+
+ShellTrigger
+
+
+(Appears on:DynamicReloadAction, ReloadOptions)
+
+
+
+
+
+
+Field |
+Description |
+
+
+
+
+
+command
+
+[]string
+
+ |
+
+ Specifies the list of commands for reload.
+ |
+
+
+
+sync
+
+bool
+
+ |
+
+(Optional)
+ Specifies whether to synchronize updates parameters to the config manager.
+Specifies two ways of controller to reload the parameter:
+- set to ‘True’, execute the reload action in sync mode, wait for the completion of reload
+- set to ‘False’, execute the reload action in async mode, just update the ‘Configmap’, no need to wait
+ |
+
+
+
+batchReload
+
+bool
+
+ |
+
+(Optional)
+ Specifies whether to reconfigure dynamic parameters individually or in a batch.
+- Set to ‘True’ to execute the reload action in a batch, incorporating all parameter changes.
+- Set to ‘False’ to execute the reload action for each parameter change individually.
+The default value is ‘False’.
+ |
+
+
+
+batchParametersTemplate
+
+string
+
+ |
+
+(Optional)
+ When batchReload is set to ‘True’, this parameter allows for the optional specification
+of the batch input format that is passed into the STDIN of the script.
+The format should be provided as a Go template string.
+In the template, the updated parameters’ key-value map can be referenced using the dollar sign (‘$’) variable.
+Here’s an example of an input template:
+
+batchParametersTemplate: |-
+{{- range $pKey, $pValue := $ }}
+{{ printf "%s:%s" $pKey $pValue }}
+{{- end }}
+
+In this example, each updated parameter is iterated over in a sorted order by keys to generate the batch input data as follows:
+
+key1:value1
+key2:value2
+key3:value3
+
+If this parameter is not specified, the default format used for STDIN is as follows:
+Each updated parameter generates a line that concatenates the parameter’s key and value with a equal sign (‘=’).
+These lines are then sorted by their keys and inserted accordingly. Here’s an example of the batch input data using the default template:
+
+key1=value1
+key2=value2
+key3=value3
+
+ |
+
+
+
+SignalType
+(string
alias)
+
+(Appears on:UnixSignalTrigger)
+
+
+
SignalType defines which signals are valid.
+
+
+
+
+Value |
+Description |
+
+
+"SIGABRT" |
+ |
+
"SIGALRM" |
+ |
+
"SIGBUS" |
+ |
+
"SIGCHLD" |
+ |
+
"SIGCONT" |
+ |
+
"SIGFPE" |
+ |
+
"SIGHUP" |
+ |
+
"SIGILL" |
+ |
+
"SIGINT" |
+ |
+
"SIGIO" |
+ |
+
"SIGKILL" |
+ |
+
"SIGPIPE" |
+ |
+
"SIGPROF" |
+ |
+
"SIGPWR" |
+ |
+
"SIGQUIT" |
+ |
+
"SIGSEGV" |
+ |
+
"SIGSTKFLT" |
+ |
+
"SIGSTOP" |
+ |
+
"SIGSYS" |
+ |
+
"SIGTERM" |
+ |
+
"SIGTRAP" |
+ |
+
"SIGTSTP" |
+ |
+
"SIGTTIN" |
+ |
+
"SIGTTOU" |
+ |
+
"SIGURG" |
+ |
+
"SIGUSR1" |
+ |
+
"SIGUSR2" |
+ |
+
"SIGVTALRM" |
+ |
+
"SIGWINCH" |
+ |
+
"SIGXCPU" |
+ |
+
"SIGXFSZ" |
+ |
+
+
+TPLScriptTrigger
+
+
+(Appears on:DynamicReloadAction, ReloadOptions)
+
+
+
+
+
+
+Field |
+Description |
+
+
+
+
+
+ScriptConfig
+
+
+ScriptConfig
+
+
+ |
+
+
+(Members of ScriptConfig are embedded into this type.)
+
+Config for the script.
+ |
+
+
+
+sync
+
+bool
+
+ |
+
+(Optional)
+ Specifies whether to synchronize updates parameters to the config manager.
+Specifies two ways of controller to reload the parameter:
+- set to ‘True’, execute the reload action in sync mode, wait for the completion of reload
+- set to ‘False’, execute the reload action in async mode, just update the ‘Configmap’, no need to wait
+ |
+
+
+
+
+
+(Appears on:ReloadToolsImage)
+
+
+
+
+
+
+Field |
+Description |
+
+
+
+
+
+name
+
+string
+
+ |
+
+ Specifies the name of the initContainer.
+ |
+
+
+
+image
+
+string
+
+ |
+
+(Optional)
+ Represents the url of the tool container image.
+ |
+
+
+
+command
+
+[]string
+
+ |
+
+ Commands to be executed when init containers.
+ |
+
+
+
+UnixSignalTrigger
+
+
+(Appears on:DynamicReloadAction, ReloadOptions)
+
+
+
+
+
+
+Field |
+Description |
+
+
+
+
+
+signal
+
+
+SignalType
+
+
+ |
+
+ Represents a valid Unix signal.
+Refer to the following URL for a list of all Unix signals: ../../pkg/configuration/configmap/handler.go:allUnixSignals
+ |
+
+
+
+processName
+
+string
+
+ |
+
+ Represents the name of the process that the Unix signal sent to.
+ |
+
+
+
+
apps.kubeblocks.io/v1alpha1
@@ -1784,7 +3142,7 @@ ReloadOptions
(Optional)
Specifies the dynamic reload actions supported by the engine. If set, the controller call the scripts defined in the actions for a dynamic parameter upgrade.
-The actions are called only when the modified parameter is defined in dynamicParameters part && DynamicReloadActions != nil
+The actions are called only when the modified parameter is defined in dynamicParameters part && ReloadOptions != nil
|
@@ -1806,7 +3164,7 @@ bool
dynamicParameterSelectedPolicy
-
+
DynamicParameterSelectedPolicy
@@ -1820,8 +3178,8 @@ DynamicParameterSelectedPolicy
|
toolsImageSpec
-
-ToolsImageSpec
+
+ReloadToolsImage
|
@@ -1835,8 +3193,8 @@ Usually it is referenced by the ‘init container’ for ‘cp&rsquo
downwardAPIOptions
-
-[]DownwardAPIOption
+
+[]DownwardAction
|
@@ -1852,7 +3210,7 @@ Usually it is referenced by the ‘init container’ for ‘cp&rsquo
scriptConfigs
-
+
[]ScriptConfig
@@ -1935,6 +3293,7 @@ Kubernetes meta/v1.LabelSelector
|
+(Optional)
Used to match labels on the pod to do a dynamic reload
|
@@ -1942,7 +3301,7 @@ Kubernetes meta/v1.LabelSelector
formatterConfig
-
+
FormatterConfig
@@ -3133,35 +4492,6 @@ TenancyType
-AutoTrigger
-
-
-(Appears on:ReloadOptions)
-
-
-
-
-
-
-Field |
-Description |
-
-
-
-
-
-processName
-
-string
-
- |
-
-(Optional)
- The name of the process.
- |
-
-
-
AvailabilityPolicyType
(string alias)
@@ -3684,69 +5014,6 @@ If Slots is specified, Max, Min, and Step are ignored
-
-
-(Appears on:FormatterConfig)
-
-
- CfgFileFormat defines formatter of configuration files.
-
-
-
-
-Value |
-Description |
-
-
-"dotenv" |
- |
- "hcl" |
- |
- "ini" |
- |
- "json" |
- |
- "properties" |
- |
- "props-plus" |
- |
- "redis" |
- |
- "toml" |
- |
- "xml" |
- |
- "yaml" |
- |
-
-
-CfgReloadType
-(string alias)
-
- CfgReloadType defines reload method.
-
-
-
-
-Value |
-Description |
-
-
-"auto" |
- |
- "http" |
- |
- "sql" |
- |
- "exec" |
- |
- "tpl" |
- |
- "signal" |
- |
-
-
ClassDefRef
@@ -8929,29 +10196,6 @@ Note: This field cannot be updated.
-ConfigConstraintPhase
-(string alias)
-
-(Appears on:ConfigConstraintStatus)
-
-
- ConfigConstraintPhase defines the ConfigConstraint CR .status.phase
-
-
-
-
-Value |
-Description |
-
-
-"Available" |
- |
- "Deleting" |
- |
- "Unavailable" |
- |
-
-
ConfigConstraintSpec
@@ -8980,7 +10224,7 @@ ReloadOptions
|
(Optional)
Specifies the dynamic reload actions supported by the engine. If set, the controller call the scripts defined in the actions for a dynamic parameter upgrade.
-The actions are called only when the modified parameter is defined in dynamicParameters part && DynamicReloadActions != nil
+The actions are called only when the modified parameter is defined in dynamicParameters part && ReloadOptions != nil
|
@@ -9002,7 +10246,7 @@ bool
dynamicParameterSelectedPolicy
-
+
DynamicParameterSelectedPolicy
@@ -9016,8 +10260,8 @@ DynamicParameterSelectedPolicy
|
toolsImageSpec
-
-ToolsImageSpec
+
+ReloadToolsImage
|
@@ -9031,8 +10275,8 @@ Usually it is referenced by the ‘init container’ for ‘cp&rsquo
downwardAPIOptions
-
-[]DownwardAPIOption
+
+[]DownwardAction
|
@@ -9048,7 +10292,7 @@ Usually it is referenced by the ‘init container’ for ‘cp&rsquo
scriptConfigs
-
+
[]ScriptConfig
@@ -9131,6 +10375,7 @@ Kubernetes meta/v1.LabelSelector
|
+(Optional)
Used to match labels on the pod to do a dynamic reload
|
@@ -9138,7 +10383,7 @@ Kubernetes meta/v1.LabelSelector
formatterConfig
-
+
FormatterConfig
@@ -9172,7 +10417,7 @@ The controller works as follows:
|
phase
-
+
ConfigConstraintPhase
@@ -10513,99 +11758,13 @@ Kubernetes api extensions v1.JSONSchemaProps
string
- |
-
-(Optional)
- Enables providers to verify user configurations using the CUE language.
- |
-
-
-
-DownwardAPIOption
-
-
-(Appears on:ConfigConstraintSpec)
-
-
-
-
-
-
-Field |
-Description |
-
-
-
-
-
-name
-
-string
-
- |
-
- Specifies the name of the field. It must be a string of maximum length 63.
-The name should match the regex pattern ^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$ .
- |
-
-
-
-mountPoint
-
-string
-
- |
-
- Specifies the mount point of the scripts file.
- |
-
-
-
-items
-
-
-[]Kubernetes core/v1.DownwardAPIVolumeFile
-
-
- |
-
- Represents a list of downward API volume files.
- |
-
-
-
-command
-
-[]string
-
- |
-
-(Optional)
- The command used to execute for the downward API.
- |
-
-
-
-DynamicParameterSelectedPolicy
-(string
alias)
-
-(Appears on:ConfigConstraintSpec)
-
-
-
DynamicParameterSelectedPolicy determines how to select the parameters of dynamic reload actions
-
-
-
-
-Value |
-Description |
+
+
+(Optional)
+ Enables providers to verify user configurations using the CUE language.
+ |
-
-"all" |
- |
-
"dynamic" |
- |
-
+
EnvMappingVar
@@ -10941,97 +12100,6 @@ If componentNamem is not specified, each OpsService
in the list mus
-
-
-(Appears on:ConfigConstraintSpec)
-
-
-
-
-
-
-Field |
-Description |
-
-
-
-
-
-FormatterOptions
-
-
-FormatterOptions
-
-
- |
-
-
-(Members of FormatterOptions are embedded into this type.)
-
-(Optional)
-Represents the additional actions for formatting the config file.
-If not specified, the default options will be applied.
- |
-
-
-
-format
-
-
-CfgFileFormat
-
-
- |
-
- The config file format. Valid values are ini , xml , yaml , json ,
-hcl , dotenv , properties and toml . Each format has its own characteristics and use cases.
-
- |
-
-
-
-
-
-(Appears on:FormatterConfig)
-
-
-
-
-
-
-Field |
-Description |
-
-
-
-
-
-iniConfig
-
-
-IniConfig
-
-
- |
-
-(Optional)
- A pointer to an IniConfig struct that holds the ini options.
- |
-
-
-
GVKResource
@@ -11399,35 +12467,6 @@ These container ports must be defined in the container for proper port allocatio
-
IniConfig
-
-
-(Appears on:FormatterOptions)
-
-
-
-
-
-
-Field |
-Description |
-
-
-
-
-
-sectionName
-
-string
-
- |
-
-(Optional)
- A string that describes the name of the ini section.
- |
-
-
-
Instance
@@ -15723,7 +16762,7 @@ string
unixSignalTrigger
-
+
UnixSignalTrigger
@@ -15737,7 +16776,7 @@ UnixSignalTrigger
|
shellTrigger
-
+
ShellTrigger
@@ -15751,7 +16790,7 @@ ShellTrigger
|
tplScriptTrigger
-
+
TPLScriptTrigger
@@ -15765,7 +16804,7 @@ TPLScriptTrigger
|
autoTrigger
-
+
AutoTrigger
@@ -16431,47 +17470,6 @@ Sample duration format:
-ScriptConfig
-
-
-(Appears on:ConfigConstraintSpec, TPLScriptTrigger)
-
-
-
-
-
-
-Field |
-Description |
-
-
-
-
-
-scriptConfigMapRef
-
-string
-
- |
-
- Specifies the reference to the ConfigMap that contains the script to be executed for reload.
- |
-
-
-
-namespace
-
-string
-
- |
-
-(Optional)
- Specifies the namespace where the referenced tpl script ConfigMap in.
-If left empty, by default in the “default” namespace.
- |
-
-
-
ScriptFrom
@@ -17973,189 +18971,16 @@ int32
The logical relationship between these components should be maintained by the components themselves.
KubeBlocks only provides lifecycle management for sharding, including:
-- Executing the postProvision Action defined in the ComponentDefinition when the number of shards increases,
-provided the conditions are met.
-- Executing the preTerminate Action defined in the ComponentDefinition when the number of shards decreases,
-provided the conditions are met.
-Resources and data associated with the corresponding Component will also be deleted.
-
- |
-
-
-
-ShellTrigger
-
-
-(Appears on:ReloadOptions)
-
-
-
-
-
-
-Field |
-Description |
-
-
-
-
-
-command
-
-[]string
-
- |
-
- Specifies the list of commands for reload.
- |
-
-
-
-sync
-
-bool
-
- |
-
-(Optional)
- Specifies whether to synchronize updates parameters to the config manager.
-Specifies two ways of controller to reload the parameter:
-- set to ‘True’, execute the reload action in sync mode, wait for the completion of reload
-- set to ‘False’, execute the reload action in async mode, just update the ‘Configmap’, no need to wait
- |
-
-
-
-batchReload
-
-bool
-
- |
-
-(Optional)
- Specifies whether to reconfigure dynamic parameters individually or in a batch.
-- Set to ‘True’ to execute the reload action in a batch, incorporating all parameter changes.
-- Set to ‘False’ to execute the reload action for each parameter change individually.
-The default value is ‘False’.
- |
-
-
-
-batchInputTemplate
-
-string
-
- |
-
-(Optional)
- When batchReload is set to ‘True’, this parameter allows for the optional specification
-of the batch input format that is passed into the STDIN of the script.
-The format should be provided as a Go template string.
-In the template, the updated parameters’ key-value map can be referenced using the dollar sign (‘$’) variable.
-Here’s an example of an input template:
-
-batchInputTemplate: |-
-{{- range $pKey, $pValue := $ }}
-{{ printf "%s:%s" $pKey $pValue }}
-{{- end }}
-
-In this example, each updated parameter is iterated over in a sorted order by keys to generate the batch input data as follows:
-
-key1:value1
-key2:value2
-key3:value3
-
-If this parameter is not specified, the default format used for STDIN is as follows:
-Each updated parameter generates a line that concatenates the parameter’s key and value with a equal sign (‘=’).
-These lines are then sorted by their keys and inserted accordingly. Here’s an example of the batch input data using the default template:
-
-key1=value1
-key2=value2
-key3=value3
-
+Executing the postProvision Action defined in the ComponentDefinition when the number of shards increases,
+provided the conditions are met.
+Executing the preTerminate Action defined in the ComponentDefinition when the number of shards decreases,
+provided the conditions are met.
+Resources and data associated with the corresponding Component will also be deleted.
+
|
-SignalType
-(string
alias)
-
-(Appears on:UnixSignalTrigger)
-
-
-
SignalType defines which signals are valid.
-
-
-
-
-Value |
-Description |
-
-
-"SIGABRT" |
- |
-
"SIGALRM" |
- |
-
"SIGBUS" |
- |
-
"SIGCHLD" |
- |
-
"SIGCONT" |
- |
-
"SIGFPE" |
- |
-
"SIGHUP" |
- |
-
"SIGILL" |
- |
-
"SIGINT" |
- |
-
"SIGIO" |
- |
-
"SIGKILL" |
- |
-
"SIGPIPE" |
- |
-
"SIGPROF" |
- |
-
"SIGPWR" |
- |
-
"SIGQUIT" |
- |
-
"SIGSEGV" |
- |
-
"SIGSTKFLT" |
- |
-
"SIGSTOP" |
- |
-
"SIGSYS" |
- |
-
"SIGTERM" |
- |
-
"SIGTRAP" |
- |
-
"SIGTSTP" |
- |
-
"SIGTTIN" |
- |
-
"SIGTTOU" |
- |
-
"SIGURG" |
- |
-
"SIGUSR1" |
- |
-
"SIGUSR2" |
- |
-
"SIGVTALRM" |
- |
-
"SIGWINCH" |
- |
-
"SIGXCPU" |
- |
-
"SIGXFSZ" |
- |
-
-
StatefulSetSpec
@@ -18839,54 +19664,6 @@ string
-
TPLScriptTrigger
-
-
-(Appears on:ReloadOptions)
-
-
-
-
-
-
-Field |
-Description |
-
-
-
-
-
-ScriptConfig
-
-
-ScriptConfig
-
-
- |
-
-
-(Members of ScriptConfig are embedded into this type.)
-
-Config for the script.
- |
-
-
-
-sync
-
-bool
-
- |
-
-(Optional)
- Specifies whether to synchronize updates parameters to the config manager.
-Specifies two ways of controller to reload the parameter:
-- set to ‘True’, execute the reload action in sync mode, wait for the completion of reload
-- set to ‘False’, execute the reload action in async mode, just update the ‘Configmap’, no need to wait
- |
-
-
-
TargetInstance
@@ -19117,99 +19894,6 @@ PodSelector
-
-
-(Appears on:ToolsImageSpec)
-
-
-
-
-
-
-Field |
-Description |
-
-
-
-
-
-name
-
-string
-
- |
-
- Specifies the name of the initContainer.
- |
-
-
-
-image
-
-string
-
- |
-
-(Optional)
- Represents the url of the tool container image.
- |
-
-
-
-command
-
-[]string
-
- |
-
- Commands to be executed when init containers.
- |
-
-
-
-
-
-(Appears on:ConfigConstraintSpec)
-
-
-
-
-
-
-Field |
-Description |
-
-
-
-
-
-mountPoint
-
-string
-
- |
-
- Represents the point where the scripts file will be mounted.
- |
-
-
-
-toolConfigs
-
-
-[]ToolConfig
-
-
- |
-
-(Optional)
- Used to configure the initialization container.
- |
-
-
-
TypedObjectRef
@@ -19262,48 +19946,6 @@ string
-
UnixSignalTrigger
-
-
-(Appears on:ReloadOptions)
-
-
-
-
-
-
-Field |
-Description |
-
-
-
-
-
-signal
-
-
-SignalType
-
-
- |
-
- Represents a valid Unix signal.
-Refer to the following URL for a list of all Unix signals: ../../pkg/configuration/configmap/handler.go:allUnixSignals
- |
-
-
-
-processName
-
-string
-
- |
-
- Represents the name of the process that the Unix signal sent to.
- |
-
-
-
UpdateStrategy
(string
alias)
diff --git a/hack/client-sdk-gen.sh b/hack/client-sdk-gen.sh
index 141e34d36db..91fcb773ef4 100755
--- a/hack/client-sdk-gen.sh
+++ b/hack/client-sdk-gen.sh
@@ -32,7 +32,7 @@ chmod u+x ${CODE_GENERATOR_PATH}/*.sh
GENERATORS="client,informer,lister"
OUTPUT_PACKAGE="github.com/apecloud/kubeblocks/pkg/client"
APIS_PACKAGE="github.com/apecloud/kubeblocks/apis"
-GROUP_VERSIONS="apps:v1alpha1 dataprotection:v1alpha1 extensions:v1alpha1 workloads:v1alpha1 storage:v1alpha1"
+GROUP_VERSIONS="apps:v1alpha1 dataprotection:v1alpha1 extensions:v1alpha1 workloads:v1alpha1 storage:v1alpha1 apps:v1"
OUTPUT_BASE="${SCRIPT_ROOT}/hack"
diff --git a/pkg/client/clientset/versioned/clientset.go b/pkg/client/clientset/versioned/clientset.go
index 6a0b89aec14..3bb8af93038 100644
--- a/pkg/client/clientset/versioned/clientset.go
+++ b/pkg/client/clientset/versioned/clientset.go
@@ -22,6 +22,7 @@ import (
"fmt"
"net/http"
+ appsv1 "github.com/apecloud/kubeblocks/pkg/client/clientset/versioned/typed/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/pkg/client/clientset/versioned/typed/apps/v1alpha1"
dataprotectionv1alpha1 "github.com/apecloud/kubeblocks/pkg/client/clientset/versioned/typed/dataprotection/v1alpha1"
extensionsv1alpha1 "github.com/apecloud/kubeblocks/pkg/client/clientset/versioned/typed/extensions/v1alpha1"
@@ -35,6 +36,7 @@ import (
type Interface interface {
Discovery() discovery.DiscoveryInterface
AppsV1alpha1() appsv1alpha1.AppsV1alpha1Interface
+ AppsV1() appsv1.AppsV1Interface
DataprotectionV1alpha1() dataprotectionv1alpha1.DataprotectionV1alpha1Interface
ExtensionsV1alpha1() extensionsv1alpha1.ExtensionsV1alpha1Interface
StorageV1alpha1() storagev1alpha1.StorageV1alpha1Interface
@@ -45,6 +47,7 @@ type Interface interface {
type Clientset struct {
*discovery.DiscoveryClient
appsV1alpha1 *appsv1alpha1.AppsV1alpha1Client
+ appsV1 *appsv1.AppsV1Client
dataprotectionV1alpha1 *dataprotectionv1alpha1.DataprotectionV1alpha1Client
extensionsV1alpha1 *extensionsv1alpha1.ExtensionsV1alpha1Client
storageV1alpha1 *storagev1alpha1.StorageV1alpha1Client
@@ -56,6 +59,11 @@ func (c *Clientset) AppsV1alpha1() appsv1alpha1.AppsV1alpha1Interface {
return c.appsV1alpha1
}
+// AppsV1 retrieves the AppsV1Client
+func (c *Clientset) AppsV1() appsv1.AppsV1Interface {
+ return c.appsV1
+}
+
// DataprotectionV1alpha1 retrieves the DataprotectionV1alpha1Client
func (c *Clientset) DataprotectionV1alpha1() dataprotectionv1alpha1.DataprotectionV1alpha1Interface {
return c.dataprotectionV1alpha1
@@ -124,6 +132,10 @@ func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset,
if err != nil {
return nil, err
}
+ cs.appsV1, err = appsv1.NewForConfigAndClient(&configShallowCopy, httpClient)
+ if err != nil {
+ return nil, err
+ }
cs.dataprotectionV1alpha1, err = dataprotectionv1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient)
if err != nil {
return nil, err
@@ -162,6 +174,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset {
func New(c rest.Interface) *Clientset {
var cs Clientset
cs.appsV1alpha1 = appsv1alpha1.New(c)
+ cs.appsV1 = appsv1.New(c)
cs.dataprotectionV1alpha1 = dataprotectionv1alpha1.New(c)
cs.extensionsV1alpha1 = extensionsv1alpha1.New(c)
cs.storageV1alpha1 = storagev1alpha1.New(c)
diff --git a/pkg/client/clientset/versioned/fake/clientset_generated.go b/pkg/client/clientset/versioned/fake/clientset_generated.go
index a5db4442b83..8c93189adfc 100644
--- a/pkg/client/clientset/versioned/fake/clientset_generated.go
+++ b/pkg/client/clientset/versioned/fake/clientset_generated.go
@@ -20,6 +20,8 @@ package fake
import (
clientset "github.com/apecloud/kubeblocks/pkg/client/clientset/versioned"
+ appsv1 "github.com/apecloud/kubeblocks/pkg/client/clientset/versioned/typed/apps/v1"
+ fakeappsv1 "github.com/apecloud/kubeblocks/pkg/client/clientset/versioned/typed/apps/v1/fake"
appsv1alpha1 "github.com/apecloud/kubeblocks/pkg/client/clientset/versioned/typed/apps/v1alpha1"
fakeappsv1alpha1 "github.com/apecloud/kubeblocks/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake"
dataprotectionv1alpha1 "github.com/apecloud/kubeblocks/pkg/client/clientset/versioned/typed/dataprotection/v1alpha1"
@@ -92,6 +94,11 @@ func (c *Clientset) AppsV1alpha1() appsv1alpha1.AppsV1alpha1Interface {
return &fakeappsv1alpha1.FakeAppsV1alpha1{Fake: &c.Fake}
}
+// AppsV1 retrieves the AppsV1Client
+func (c *Clientset) AppsV1() appsv1.AppsV1Interface {
+ return &fakeappsv1.FakeAppsV1{Fake: &c.Fake}
+}
+
// DataprotectionV1alpha1 retrieves the DataprotectionV1alpha1Client
func (c *Clientset) DataprotectionV1alpha1() dataprotectionv1alpha1.DataprotectionV1alpha1Interface {
return &fakedataprotectionv1alpha1.FakeDataprotectionV1alpha1{Fake: &c.Fake}
diff --git a/pkg/client/clientset/versioned/fake/register.go b/pkg/client/clientset/versioned/fake/register.go
index 98b5e8fc528..56c12243ff6 100644
--- a/pkg/client/clientset/versioned/fake/register.go
+++ b/pkg/client/clientset/versioned/fake/register.go
@@ -19,6 +19,7 @@ limitations under the License.
package fake
import (
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
dataprotectionv1alpha1 "github.com/apecloud/kubeblocks/apis/dataprotection/v1alpha1"
extensionsv1alpha1 "github.com/apecloud/kubeblocks/apis/extensions/v1alpha1"
@@ -36,6 +37,7 @@ var codecs = serializer.NewCodecFactory(scheme)
var localSchemeBuilder = runtime.SchemeBuilder{
appsv1alpha1.AddToScheme,
+ appsv1.AddToScheme,
dataprotectionv1alpha1.AddToScheme,
extensionsv1alpha1.AddToScheme,
storagev1alpha1.AddToScheme,
diff --git a/pkg/client/clientset/versioned/scheme/register.go b/pkg/client/clientset/versioned/scheme/register.go
index b509fda5b89..d183e895493 100644
--- a/pkg/client/clientset/versioned/scheme/register.go
+++ b/pkg/client/clientset/versioned/scheme/register.go
@@ -19,6 +19,7 @@ limitations under the License.
package scheme
import (
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
dataprotectionv1alpha1 "github.com/apecloud/kubeblocks/apis/dataprotection/v1alpha1"
extensionsv1alpha1 "github.com/apecloud/kubeblocks/apis/extensions/v1alpha1"
@@ -36,6 +37,7 @@ var Codecs = serializer.NewCodecFactory(Scheme)
var ParameterCodec = runtime.NewParameterCodec(Scheme)
var localSchemeBuilder = runtime.SchemeBuilder{
appsv1alpha1.AddToScheme,
+ appsv1.AddToScheme,
dataprotectionv1alpha1.AddToScheme,
extensionsv1alpha1.AddToScheme,
storagev1alpha1.AddToScheme,
diff --git a/pkg/client/clientset/versioned/typed/apps/v1/apps_client.go b/pkg/client/clientset/versioned/typed/apps/v1/apps_client.go
new file mode 100644
index 00000000000..9241be90278
--- /dev/null
+++ b/pkg/client/clientset/versioned/typed/apps/v1/apps_client.go
@@ -0,0 +1,107 @@
+/*
+Copyright (C) 2022-2024 ApeCloud Co., Ltd
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+// Code generated by client-gen. DO NOT EDIT.
+
+package v1
+
+import (
+ "net/http"
+
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
+ "github.com/apecloud/kubeblocks/pkg/client/clientset/versioned/scheme"
+ rest "k8s.io/client-go/rest"
+)
+
+type AppsV1Interface interface {
+ RESTClient() rest.Interface
+ ConfigConstraintsGetter
+}
+
+// AppsV1Client is used to interact with features provided by the apps.kubeblocks.io group.
+type AppsV1Client struct {
+ restClient rest.Interface
+}
+
+func (c *AppsV1Client) ConfigConstraints() ConfigConstraintInterface {
+ return newConfigConstraints(c)
+}
+
+// NewForConfig creates a new AppsV1Client for the given config.
+// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient),
+// where httpClient was generated with rest.HTTPClientFor(c).
+func NewForConfig(c *rest.Config) (*AppsV1Client, error) {
+ config := *c
+ if err := setConfigDefaults(&config); err != nil {
+ return nil, err
+ }
+ httpClient, err := rest.HTTPClientFor(&config)
+ if err != nil {
+ return nil, err
+ }
+ return NewForConfigAndClient(&config, httpClient)
+}
+
+// NewForConfigAndClient creates a new AppsV1Client for the given config and http client.
+// Note the http client provided takes precedence over the configured transport values.
+func NewForConfigAndClient(c *rest.Config, h *http.Client) (*AppsV1Client, error) {
+ config := *c
+ if err := setConfigDefaults(&config); err != nil {
+ return nil, err
+ }
+ client, err := rest.RESTClientForConfigAndClient(&config, h)
+ if err != nil {
+ return nil, err
+ }
+ return &AppsV1Client{client}, nil
+}
+
+// NewForConfigOrDie creates a new AppsV1Client for the given config and
+// panics if there is an error in the config.
+func NewForConfigOrDie(c *rest.Config) *AppsV1Client {
+ client, err := NewForConfig(c)
+ if err != nil {
+ panic(err)
+ }
+ return client
+}
+
+// New creates a new AppsV1Client for the given RESTClient.
+func New(c rest.Interface) *AppsV1Client {
+ return &AppsV1Client{c}
+}
+
+func setConfigDefaults(config *rest.Config) error {
+ gv := v1.SchemeGroupVersion
+ config.GroupVersion = &gv
+ config.APIPath = "/apis"
+ config.NegotiatedSerializer = scheme.Codecs.WithoutConversion()
+
+ if config.UserAgent == "" {
+ config.UserAgent = rest.DefaultKubernetesUserAgent()
+ }
+
+ return nil
+}
+
+// RESTClient returns a RESTClient that is used to communicate
+// with API server by this client implementation.
+func (c *AppsV1Client) RESTClient() rest.Interface {
+ if c == nil {
+ return nil
+ }
+ return c.restClient
+}
diff --git a/pkg/client/clientset/versioned/typed/apps/v1/configconstraint.go b/pkg/client/clientset/versioned/typed/apps/v1/configconstraint.go
new file mode 100644
index 00000000000..1dd22621bb3
--- /dev/null
+++ b/pkg/client/clientset/versioned/typed/apps/v1/configconstraint.go
@@ -0,0 +1,184 @@
+/*
+Copyright (C) 2022-2024 ApeCloud Co., Ltd
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+// Code generated by client-gen. DO NOT EDIT.
+
+package v1
+
+import (
+ "context"
+ "time"
+
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
+ scheme "github.com/apecloud/kubeblocks/pkg/client/clientset/versioned/scheme"
+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+ types "k8s.io/apimachinery/pkg/types"
+ watch "k8s.io/apimachinery/pkg/watch"
+ rest "k8s.io/client-go/rest"
+)
+
+// ConfigConstraintsGetter has a method to return a ConfigConstraintInterface.
+// A group's client should implement this interface.
+type ConfigConstraintsGetter interface {
+ ConfigConstraints() ConfigConstraintInterface
+}
+
+// ConfigConstraintInterface has methods to work with ConfigConstraint resources.
+type ConfigConstraintInterface interface {
+ Create(ctx context.Context, configConstraint *v1.ConfigConstraint, opts metav1.CreateOptions) (*v1.ConfigConstraint, error)
+ Update(ctx context.Context, configConstraint *v1.ConfigConstraint, opts metav1.UpdateOptions) (*v1.ConfigConstraint, error)
+ UpdateStatus(ctx context.Context, configConstraint *v1.ConfigConstraint, opts metav1.UpdateOptions) (*v1.ConfigConstraint, error)
+ Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error
+ DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error
+ Get(ctx context.Context, name string, opts metav1.GetOptions) (*v1.ConfigConstraint, error)
+ List(ctx context.Context, opts metav1.ListOptions) (*v1.ConfigConstraintList, error)
+ Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error)
+ Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.ConfigConstraint, err error)
+ ConfigConstraintExpansion
+}
+
+// configConstraints implements ConfigConstraintInterface
+type configConstraints struct {
+ client rest.Interface
+}
+
+// newConfigConstraints returns a ConfigConstraints
+func newConfigConstraints(c *AppsV1Client) *configConstraints {
+ return &configConstraints{
+ client: c.RESTClient(),
+ }
+}
+
+// Get takes name of the configConstraint, and returns the corresponding configConstraint object, and an error if there is any.
+func (c *configConstraints) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.ConfigConstraint, err error) {
+ result = &v1.ConfigConstraint{}
+ err = c.client.Get().
+ Resource("configconstraints").
+ Name(name).
+ VersionedParams(&options, scheme.ParameterCodec).
+ Do(ctx).
+ Into(result)
+ return
+}
+
+// List takes label and field selectors, and returns the list of ConfigConstraints that match those selectors.
+func (c *configConstraints) List(ctx context.Context, opts metav1.ListOptions) (result *v1.ConfigConstraintList, err error) {
+ var timeout time.Duration
+ if opts.TimeoutSeconds != nil {
+ timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
+ }
+ result = &v1.ConfigConstraintList{}
+ err = c.client.Get().
+ Resource("configconstraints").
+ VersionedParams(&opts, scheme.ParameterCodec).
+ Timeout(timeout).
+ Do(ctx).
+ Into(result)
+ return
+}
+
+// Watch returns a watch.Interface that watches the requested configConstraints.
+func (c *configConstraints) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) {
+ var timeout time.Duration
+ if opts.TimeoutSeconds != nil {
+ timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
+ }
+ opts.Watch = true
+ return c.client.Get().
+ Resource("configconstraints").
+ VersionedParams(&opts, scheme.ParameterCodec).
+ Timeout(timeout).
+ Watch(ctx)
+}
+
+// Create takes the representation of a configConstraint and creates it. Returns the server's representation of the configConstraint, and an error, if there is any.
+func (c *configConstraints) Create(ctx context.Context, configConstraint *v1.ConfigConstraint, opts metav1.CreateOptions) (result *v1.ConfigConstraint, err error) {
+ result = &v1.ConfigConstraint{}
+ err = c.client.Post().
+ Resource("configconstraints").
+ VersionedParams(&opts, scheme.ParameterCodec).
+ Body(configConstraint).
+ Do(ctx).
+ Into(result)
+ return
+}
+
+// Update takes the representation of a configConstraint and updates it. Returns the server's representation of the configConstraint, and an error, if there is any.
+func (c *configConstraints) Update(ctx context.Context, configConstraint *v1.ConfigConstraint, opts metav1.UpdateOptions) (result *v1.ConfigConstraint, err error) {
+ result = &v1.ConfigConstraint{}
+ err = c.client.Put().
+ Resource("configconstraints").
+ Name(configConstraint.Name).
+ VersionedParams(&opts, scheme.ParameterCodec).
+ Body(configConstraint).
+ Do(ctx).
+ Into(result)
+ return
+}
+
+// UpdateStatus was generated because the type contains a Status member.
+// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
+func (c *configConstraints) UpdateStatus(ctx context.Context, configConstraint *v1.ConfigConstraint, opts metav1.UpdateOptions) (result *v1.ConfigConstraint, err error) {
+ result = &v1.ConfigConstraint{}
+ err = c.client.Put().
+ Resource("configconstraints").
+ Name(configConstraint.Name).
+ SubResource("status").
+ VersionedParams(&opts, scheme.ParameterCodec).
+ Body(configConstraint).
+ Do(ctx).
+ Into(result)
+ return
+}
+
+// Delete takes name of the configConstraint and deletes it. Returns an error if one occurs.
+func (c *configConstraints) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error {
+ return c.client.Delete().
+ Resource("configconstraints").
+ Name(name).
+ Body(&opts).
+ Do(ctx).
+ Error()
+}
+
+// DeleteCollection deletes a collection of objects.
+func (c *configConstraints) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error {
+ var timeout time.Duration
+ if listOpts.TimeoutSeconds != nil {
+ timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second
+ }
+ return c.client.Delete().
+ Resource("configconstraints").
+ VersionedParams(&listOpts, scheme.ParameterCodec).
+ Timeout(timeout).
+ Body(&opts).
+ Do(ctx).
+ Error()
+}
+
+// Patch applies the patch and returns the patched configConstraint.
+func (c *configConstraints) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.ConfigConstraint, err error) {
+ result = &v1.ConfigConstraint{}
+ err = c.client.Patch(pt).
+ Resource("configconstraints").
+ Name(name).
+ SubResource(subresources...).
+ VersionedParams(&opts, scheme.ParameterCodec).
+ Body(data).
+ Do(ctx).
+ Into(result)
+ return
+}
diff --git a/pkg/client/clientset/versioned/typed/apps/v1/doc.go b/pkg/client/clientset/versioned/typed/apps/v1/doc.go
new file mode 100644
index 00000000000..8a483cc3601
--- /dev/null
+++ b/pkg/client/clientset/versioned/typed/apps/v1/doc.go
@@ -0,0 +1,20 @@
+/*
+Copyright (C) 2022-2024 ApeCloud Co., Ltd
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+// Code generated by client-gen. DO NOT EDIT.
+
+// This package has the automatically generated typed clients.
+package v1
diff --git a/pkg/client/clientset/versioned/typed/apps/v1/fake/doc.go b/pkg/client/clientset/versioned/typed/apps/v1/fake/doc.go
new file mode 100644
index 00000000000..a68eddec4bb
--- /dev/null
+++ b/pkg/client/clientset/versioned/typed/apps/v1/fake/doc.go
@@ -0,0 +1,20 @@
+/*
+Copyright (C) 2022-2024 ApeCloud Co., Ltd
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+// Code generated by client-gen. DO NOT EDIT.
+
+// Package fake has the automatically generated clients.
+package fake
diff --git a/pkg/client/clientset/versioned/typed/apps/v1/fake/fake_apps_client.go b/pkg/client/clientset/versioned/typed/apps/v1/fake/fake_apps_client.go
new file mode 100644
index 00000000000..6b0054d68e2
--- /dev/null
+++ b/pkg/client/clientset/versioned/typed/apps/v1/fake/fake_apps_client.go
@@ -0,0 +1,40 @@
+/*
+Copyright (C) 2022-2024 ApeCloud Co., Ltd
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+// Code generated by client-gen. DO NOT EDIT.
+
+package fake
+
+import (
+ v1 "github.com/apecloud/kubeblocks/pkg/client/clientset/versioned/typed/apps/v1"
+ rest "k8s.io/client-go/rest"
+ testing "k8s.io/client-go/testing"
+)
+
+type FakeAppsV1 struct {
+ *testing.Fake
+}
+
+func (c *FakeAppsV1) ConfigConstraints() v1.ConfigConstraintInterface {
+ return &FakeConfigConstraints{c}
+}
+
+// RESTClient returns a RESTClient that is used to communicate
+// with API server by this client implementation.
+func (c *FakeAppsV1) RESTClient() rest.Interface {
+ var ret *rest.RESTClient
+ return ret
+}
diff --git a/pkg/client/clientset/versioned/typed/apps/v1/fake/fake_configconstraint.go b/pkg/client/clientset/versioned/typed/apps/v1/fake/fake_configconstraint.go
new file mode 100644
index 00000000000..be879ee3e66
--- /dev/null
+++ b/pkg/client/clientset/versioned/typed/apps/v1/fake/fake_configconstraint.go
@@ -0,0 +1,132 @@
+/*
+Copyright (C) 2022-2024 ApeCloud Co., Ltd
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+// Code generated by client-gen. DO NOT EDIT.
+
+package fake
+
+import (
+ "context"
+
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+ labels "k8s.io/apimachinery/pkg/labels"
+ types "k8s.io/apimachinery/pkg/types"
+ watch "k8s.io/apimachinery/pkg/watch"
+ testing "k8s.io/client-go/testing"
+)
+
+// FakeConfigConstraints implements ConfigConstraintInterface
+type FakeConfigConstraints struct {
+ Fake *FakeAppsV1
+}
+
+var configconstraintsResource = v1.SchemeGroupVersion.WithResource("configconstraints")
+
+var configconstraintsKind = v1.SchemeGroupVersion.WithKind("ConfigConstraint")
+
+// Get takes name of the configConstraint, and returns the corresponding configConstraint object, and an error if there is any.
+func (c *FakeConfigConstraints) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.ConfigConstraint, err error) {
+ obj, err := c.Fake.
+ Invokes(testing.NewRootGetAction(configconstraintsResource, name), &v1.ConfigConstraint{})
+ if obj == nil {
+ return nil, err
+ }
+ return obj.(*v1.ConfigConstraint), err
+}
+
+// List takes label and field selectors, and returns the list of ConfigConstraints that match those selectors.
+func (c *FakeConfigConstraints) List(ctx context.Context, opts metav1.ListOptions) (result *v1.ConfigConstraintList, err error) {
+ obj, err := c.Fake.
+ Invokes(testing.NewRootListAction(configconstraintsResource, configconstraintsKind, opts), &v1.ConfigConstraintList{})
+ if obj == nil {
+ return nil, err
+ }
+
+ label, _, _ := testing.ExtractFromListOptions(opts)
+ if label == nil {
+ label = labels.Everything()
+ }
+ list := &v1.ConfigConstraintList{ListMeta: obj.(*v1.ConfigConstraintList).ListMeta}
+ for _, item := range obj.(*v1.ConfigConstraintList).Items {
+ if label.Matches(labels.Set(item.Labels)) {
+ list.Items = append(list.Items, item)
+ }
+ }
+ return list, err
+}
+
+// Watch returns a watch.Interface that watches the requested configConstraints.
+func (c *FakeConfigConstraints) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) {
+ return c.Fake.
+ InvokesWatch(testing.NewRootWatchAction(configconstraintsResource, opts))
+}
+
+// Create takes the representation of a configConstraint and creates it. Returns the server's representation of the configConstraint, and an error, if there is any.
+func (c *FakeConfigConstraints) Create(ctx context.Context, configConstraint *v1.ConfigConstraint, opts metav1.CreateOptions) (result *v1.ConfigConstraint, err error) {
+ obj, err := c.Fake.
+ Invokes(testing.NewRootCreateAction(configconstraintsResource, configConstraint), &v1.ConfigConstraint{})
+ if obj == nil {
+ return nil, err
+ }
+ return obj.(*v1.ConfigConstraint), err
+}
+
+// Update takes the representation of a configConstraint and updates it. Returns the server's representation of the configConstraint, and an error, if there is any.
+func (c *FakeConfigConstraints) Update(ctx context.Context, configConstraint *v1.ConfigConstraint, opts metav1.UpdateOptions) (result *v1.ConfigConstraint, err error) {
+ obj, err := c.Fake.
+ Invokes(testing.NewRootUpdateAction(configconstraintsResource, configConstraint), &v1.ConfigConstraint{})
+ if obj == nil {
+ return nil, err
+ }
+ return obj.(*v1.ConfigConstraint), err
+}
+
+// UpdateStatus was generated because the type contains a Status member.
+// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
+func (c *FakeConfigConstraints) UpdateStatus(ctx context.Context, configConstraint *v1.ConfigConstraint, opts metav1.UpdateOptions) (*v1.ConfigConstraint, error) {
+ obj, err := c.Fake.
+ Invokes(testing.NewRootUpdateSubresourceAction(configconstraintsResource, "status", configConstraint), &v1.ConfigConstraint{})
+ if obj == nil {
+ return nil, err
+ }
+ return obj.(*v1.ConfigConstraint), err
+}
+
+// Delete takes name of the configConstraint and deletes it. Returns an error if one occurs.
+func (c *FakeConfigConstraints) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error {
+ _, err := c.Fake.
+ Invokes(testing.NewRootDeleteActionWithOptions(configconstraintsResource, name, opts), &v1.ConfigConstraint{})
+ return err
+}
+
+// DeleteCollection deletes a collection of objects.
+func (c *FakeConfigConstraints) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error {
+ action := testing.NewRootDeleteCollectionAction(configconstraintsResource, listOpts)
+
+ _, err := c.Fake.Invokes(action, &v1.ConfigConstraintList{})
+ return err
+}
+
+// Patch applies the patch and returns the patched configConstraint.
+func (c *FakeConfigConstraints) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.ConfigConstraint, err error) {
+ obj, err := c.Fake.
+ Invokes(testing.NewRootPatchSubresourceAction(configconstraintsResource, name, pt, data, subresources...), &v1.ConfigConstraint{})
+ if obj == nil {
+ return nil, err
+ }
+ return obj.(*v1.ConfigConstraint), err
+}
diff --git a/pkg/client/clientset/versioned/typed/apps/v1/generated_expansion.go b/pkg/client/clientset/versioned/typed/apps/v1/generated_expansion.go
new file mode 100644
index 00000000000..f50301fcb9a
--- /dev/null
+++ b/pkg/client/clientset/versioned/typed/apps/v1/generated_expansion.go
@@ -0,0 +1,21 @@
+/*
+Copyright (C) 2022-2024 ApeCloud Co., Ltd
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+// Code generated by client-gen. DO NOT EDIT.
+
+package v1
+
+type ConfigConstraintExpansion interface{}
diff --git a/pkg/client/informers/externalversions/apps/interface.go b/pkg/client/informers/externalversions/apps/interface.go
index 2096a26229a..1d5fecec452 100644
--- a/pkg/client/informers/externalversions/apps/interface.go
+++ b/pkg/client/informers/externalversions/apps/interface.go
@@ -19,6 +19,7 @@ limitations under the License.
package apps
import (
+ v1 "github.com/apecloud/kubeblocks/pkg/client/informers/externalversions/apps/v1"
v1alpha1 "github.com/apecloud/kubeblocks/pkg/client/informers/externalversions/apps/v1alpha1"
internalinterfaces "github.com/apecloud/kubeblocks/pkg/client/informers/externalversions/internalinterfaces"
)
@@ -27,6 +28,8 @@ import (
type Interface interface {
// V1alpha1 provides access to shared informers for resources in V1alpha1.
V1alpha1() v1alpha1.Interface
+ // V1 provides access to shared informers for resources in V1.
+ V1() v1.Interface
}
type group struct {
@@ -44,3 +47,8 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList
func (g *group) V1alpha1() v1alpha1.Interface {
return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions)
}
+
+// V1 returns a new v1.Interface.
+func (g *group) V1() v1.Interface {
+ return v1.New(g.factory, g.namespace, g.tweakListOptions)
+}
diff --git a/pkg/client/informers/externalversions/apps/v1/configconstraint.go b/pkg/client/informers/externalversions/apps/v1/configconstraint.go
new file mode 100644
index 00000000000..5ef4f8d2c4e
--- /dev/null
+++ b/pkg/client/informers/externalversions/apps/v1/configconstraint.go
@@ -0,0 +1,89 @@
+/*
+Copyright (C) 2022-2024 ApeCloud Co., Ltd
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+// Code generated by informer-gen. DO NOT EDIT.
+
+package v1
+
+import (
+ "context"
+ time "time"
+
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
+ versioned "github.com/apecloud/kubeblocks/pkg/client/clientset/versioned"
+ internalinterfaces "github.com/apecloud/kubeblocks/pkg/client/informers/externalversions/internalinterfaces"
+ v1 "github.com/apecloud/kubeblocks/pkg/client/listers/apps/v1"
+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+ runtime "k8s.io/apimachinery/pkg/runtime"
+ watch "k8s.io/apimachinery/pkg/watch"
+ cache "k8s.io/client-go/tools/cache"
+)
+
+// ConfigConstraintInformer provides access to a shared informer and lister for
+// ConfigConstraints.
+type ConfigConstraintInformer interface {
+ Informer() cache.SharedIndexInformer
+ Lister() v1.ConfigConstraintLister
+}
+
+type configConstraintInformer struct {
+ factory internalinterfaces.SharedInformerFactory
+ tweakListOptions internalinterfaces.TweakListOptionsFunc
+}
+
+// NewConfigConstraintInformer constructs a new informer for ConfigConstraint type.
+// Always prefer using an informer factory to get a shared informer instead of getting an independent
+// one. This reduces memory footprint and number of connections to the server.
+func NewConfigConstraintInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
+ return NewFilteredConfigConstraintInformer(client, resyncPeriod, indexers, nil)
+}
+
+// NewFilteredConfigConstraintInformer constructs a new informer for ConfigConstraint type.
+// Always prefer using an informer factory to get a shared informer instead of getting an independent
+// one. This reduces memory footprint and number of connections to the server.
+func NewFilteredConfigConstraintInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
+ return cache.NewSharedIndexInformer(
+ &cache.ListWatch{
+ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
+ if tweakListOptions != nil {
+ tweakListOptions(&options)
+ }
+ return client.AppsV1().ConfigConstraints().List(context.TODO(), options)
+ },
+ WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
+ if tweakListOptions != nil {
+ tweakListOptions(&options)
+ }
+ return client.AppsV1().ConfigConstraints().Watch(context.TODO(), options)
+ },
+ },
+ &appsv1.ConfigConstraint{},
+ resyncPeriod,
+ indexers,
+ )
+}
+
+func (f *configConstraintInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
+ return NewFilteredConfigConstraintInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
+}
+
+func (f *configConstraintInformer) Informer() cache.SharedIndexInformer {
+ return f.factory.InformerFor(&appsv1.ConfigConstraint{}, f.defaultInformer)
+}
+
+func (f *configConstraintInformer) Lister() v1.ConfigConstraintLister {
+ return v1.NewConfigConstraintLister(f.Informer().GetIndexer())
+}
diff --git a/pkg/client/informers/externalversions/apps/v1/interface.go b/pkg/client/informers/externalversions/apps/v1/interface.go
new file mode 100644
index 00000000000..999b24c5244
--- /dev/null
+++ b/pkg/client/informers/externalversions/apps/v1/interface.go
@@ -0,0 +1,45 @@
+/*
+Copyright (C) 2022-2024 ApeCloud Co., Ltd
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+// Code generated by informer-gen. DO NOT EDIT.
+
+package v1
+
+import (
+ internalinterfaces "github.com/apecloud/kubeblocks/pkg/client/informers/externalversions/internalinterfaces"
+)
+
+// Interface provides access to all the informers in this group version.
+type Interface interface {
+ // ConfigConstraints returns a ConfigConstraintInformer.
+ ConfigConstraints() ConfigConstraintInformer
+}
+
+type version struct {
+ factory internalinterfaces.SharedInformerFactory
+ namespace string
+ tweakListOptions internalinterfaces.TweakListOptionsFunc
+}
+
+// New returns a new Interface.
+func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface {
+ return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions}
+}
+
+// ConfigConstraints returns a ConfigConstraintInformer.
+func (v *version) ConfigConstraints() ConfigConstraintInformer {
+ return &configConstraintInformer{factory: v.factory, tweakListOptions: v.tweakListOptions}
+}
diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go
index 76f260017bf..63991668855 100644
--- a/pkg/client/informers/externalversions/generic.go
+++ b/pkg/client/informers/externalversions/generic.go
@@ -21,6 +21,7 @@ package externalversions
import (
"fmt"
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
v1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
dataprotectionv1alpha1 "github.com/apecloud/kubeblocks/apis/dataprotection/v1alpha1"
extensionsv1alpha1 "github.com/apecloud/kubeblocks/apis/extensions/v1alpha1"
@@ -56,7 +57,11 @@ func (f *genericInformer) Lister() cache.GenericLister {
// TODO extend this to unknown resources with a client pool
func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) {
switch resource {
- // Group=apps.kubeblocks.io, Version=v1alpha1
+ // Group=apps.kubeblocks.io, Version=v1
+ case v1.SchemeGroupVersion.WithResource("configconstraints"):
+ return &genericInformer{resource: resource.GroupResource(), informer: f.Apps().V1().ConfigConstraints().Informer()}, nil
+
+ // Group=apps.kubeblocks.io, Version=v1alpha1
case v1alpha1.SchemeGroupVersion.WithResource("backuppolicytemplates"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Apps().V1alpha1().BackupPolicyTemplates().Informer()}, nil
case v1alpha1.SchemeGroupVersion.WithResource("clusters"):
diff --git a/pkg/client/listers/apps/v1/configconstraint.go b/pkg/client/listers/apps/v1/configconstraint.go
new file mode 100644
index 00000000000..131794865d9
--- /dev/null
+++ b/pkg/client/listers/apps/v1/configconstraint.go
@@ -0,0 +1,68 @@
+/*
+Copyright (C) 2022-2024 ApeCloud Co., Ltd
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+// Code generated by lister-gen. DO NOT EDIT.
+
+package v1
+
+import (
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
+ "k8s.io/apimachinery/pkg/api/errors"
+ "k8s.io/apimachinery/pkg/labels"
+ "k8s.io/client-go/tools/cache"
+)
+
+// ConfigConstraintLister helps list ConfigConstraints.
+// All objects returned here must be treated as read-only.
+type ConfigConstraintLister interface {
+ // List lists all ConfigConstraints in the indexer.
+ // Objects returned here must be treated as read-only.
+ List(selector labels.Selector) (ret []*v1.ConfigConstraint, err error)
+ // Get retrieves the ConfigConstraint from the index for a given name.
+ // Objects returned here must be treated as read-only.
+ Get(name string) (*v1.ConfigConstraint, error)
+ ConfigConstraintListerExpansion
+}
+
+// configConstraintLister implements the ConfigConstraintLister interface.
+type configConstraintLister struct {
+ indexer cache.Indexer
+}
+
+// NewConfigConstraintLister returns a new ConfigConstraintLister.
+func NewConfigConstraintLister(indexer cache.Indexer) ConfigConstraintLister {
+ return &configConstraintLister{indexer: indexer}
+}
+
+// List lists all ConfigConstraints in the indexer.
+func (s *configConstraintLister) List(selector labels.Selector) (ret []*v1.ConfigConstraint, err error) {
+ err = cache.ListAll(s.indexer, selector, func(m interface{}) {
+ ret = append(ret, m.(*v1.ConfigConstraint))
+ })
+ return ret, err
+}
+
+// Get retrieves the ConfigConstraint from the index for a given name.
+func (s *configConstraintLister) Get(name string) (*v1.ConfigConstraint, error) {
+ obj, exists, err := s.indexer.GetByKey(name)
+ if err != nil {
+ return nil, err
+ }
+ if !exists {
+ return nil, errors.NewNotFound(v1.Resource("configconstraint"), name)
+ }
+ return obj.(*v1.ConfigConstraint), nil
+}
diff --git a/pkg/client/listers/apps/v1/expansion_generated.go b/pkg/client/listers/apps/v1/expansion_generated.go
new file mode 100644
index 00000000000..c3286d17633
--- /dev/null
+++ b/pkg/client/listers/apps/v1/expansion_generated.go
@@ -0,0 +1,23 @@
+/*
+Copyright (C) 2022-2024 ApeCloud Co., Ltd
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+// Code generated by lister-gen. DO NOT EDIT.
+
+package v1
+
+// ConfigConstraintListerExpansion allows custom methods to be added to
+// ConfigConstraintLister.
+type ConfigConstraintListerExpansion interface{}
diff --git a/pkg/configuration/config_manager/builder.go b/pkg/configuration/config_manager/builder.go
index f598a6762ba..208a5cd76d6 100644
--- a/pkg/configuration/config_manager/builder.go
+++ b/pkg/configuration/config_manager/builder.go
@@ -34,6 +34,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
"github.com/apecloud/kubeblocks/pkg/configuration/core"
cfgutil "github.com/apecloud/kubeblocks/pkg/configuration/util"
@@ -98,10 +99,10 @@ func getWatchedVolume(volumeDirs []corev1.VolumeMount, buildParams []ConfigSpecM
continue
}
switch param.ReloadType {
- case appsv1alpha1.TPLScriptType:
- return core.IsWatchModuleForTplTrigger(param.ReloadOptions.TPLScriptTrigger)
- case appsv1alpha1.ShellType:
- return core.IsWatchModuleForShellTrigger(param.ReloadOptions.ShellTrigger)
+ case v1.TPLScriptType:
+ return core.IsWatchModuleForTplTrigger(param.DynamicReloadAction.TPLScriptTrigger)
+ case v1.ShellType:
+ return core.IsWatchModuleForShellTrigger(param.DynamicReloadAction.ShellTrigger)
default:
return true
}
@@ -259,7 +260,7 @@ func buildConfigSpecHandleMeta(cli client.Client, ctx context.Context, buildPara
return err
}
}
- if buildParam.ReloadType == appsv1alpha1.TPLScriptType {
+ if buildParam.ReloadType == v1.TPLScriptType {
return buildTPLScriptCM(buildParam, cmBuildParam, cli, ctx)
}
return nil
@@ -297,7 +298,7 @@ func buildTPLScriptCM(configSpecBuildMeta *ConfigSpecMeta, manager *CfgManagerBu
return nil
}
-func buildDownwardAPIVolume(manager *CfgManagerBuildParams, fieldInfo appsv1alpha1.DownwardAPIOption) {
+func buildDownwardAPIVolume(manager *CfgManagerBuildParams, fieldInfo v1.DownwardAction) {
manager.DownwardAPIVolumes = append(manager.DownwardAPIVolumes, corev1.VolumeMount{
Name: fieldInfo.Name,
MountPath: fieldInfo.MountPoint,
@@ -382,7 +383,7 @@ func checkOrCreateConfigMap(referenceCM client.ObjectKey, scriptCMKey client.Obj
return nil
}
-func checkAndUpdateReloadYaml(data map[string]string, reloadConfig string, formatterConfig appsv1alpha1.FormatterConfig) (map[string]string, error) {
+func checkAndUpdateReloadYaml(data map[string]string, reloadConfig string, formatterConfig v1.FormatterConfig) (map[string]string, error) {
configObject := make(map[string]interface{})
if content, ok := data[reloadConfig]; ok {
if err := yaml.Unmarshal([]byte(content), &configObject); err != nil {
@@ -408,7 +409,7 @@ func checkAndUpdateReloadYaml(data map[string]string, reloadConfig string, forma
return data, nil
}
-func buildCfgManagerScripts(options appsv1alpha1.ScriptConfig, manager *CfgManagerBuildParams, cli client.Client, ctx context.Context, configSpec appsv1alpha1.ComponentConfigSpec) error {
+func buildCfgManagerScripts(options v1.ScriptConfig, manager *CfgManagerBuildParams, cli client.Client, ctx context.Context, configSpec appsv1alpha1.ComponentConfigSpec) error {
mountPoint := filepath.Join(KBScriptVolumePath, configSpec.Name)
referenceCMKey := client.ObjectKey{
Namespace: options.Namespace,
diff --git a/pkg/configuration/config_manager/builder_test.go b/pkg/configuration/config_manager/builder_test.go
index 026f87ce868..3f8e7e5be99 100644
--- a/pkg/configuration/config_manager/builder_test.go
+++ b/pkg/configuration/config_manager/builder_test.go
@@ -33,6 +33,7 @@ import (
"k8s.io/apimachinery/pkg/util/yaml"
"sigs.k8s.io/controller-runtime/pkg/client"
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
testutil "github.com/apecloud/kubeblocks/pkg/testutil/k8s"
)
@@ -77,39 +78,39 @@ var _ = Describe("Config Builder Test", func() {
Name: "pg_config",
}}
}
- newReloadOptions := func(t appsv1alpha1.CfgReloadType, sync *bool) *appsv1alpha1.ReloadOptions {
- signalHandle := &appsv1alpha1.UnixSignalTrigger{
+ newReloadOptions := func(t v1.CfgReloadType, sync *bool) *v1.DynamicReloadAction {
+ signalHandle := &v1.UnixSignalTrigger{
ProcessName: "postgres",
- Signal: appsv1alpha1.SIGHUP,
+ Signal: v1.SIGHUP,
}
- shellHandle := &appsv1alpha1.ShellTrigger{
+ shellHandle := &v1.ShellTrigger{
Command: []string{"pwd"},
}
- scriptHandle := &appsv1alpha1.TPLScriptTrigger{
+ scriptHandle := &v1.TPLScriptTrigger{
Sync: sync,
- ScriptConfig: appsv1alpha1.ScriptConfig{
+ ScriptConfig: v1.ScriptConfig{
ScriptConfigMapRef: "reload-script",
Namespace: scriptsNS,
},
}
- autoHandle := &appsv1alpha1.AutoTrigger{
+ autoHandle := &v1.AutoTrigger{
ProcessName: "postgres",
}
switch t {
default:
return nil
- case appsv1alpha1.UnixSignalType:
- return &appsv1alpha1.ReloadOptions{
+ case v1.UnixSignalType:
+ return &v1.DynamicReloadAction{
UnixSignalTrigger: signalHandle}
- case appsv1alpha1.ShellType:
- return &appsv1alpha1.ReloadOptions{
+ case v1.ShellType:
+ return &v1.DynamicReloadAction{
ShellTrigger: shellHandle}
- case appsv1alpha1.TPLScriptType:
- return &appsv1alpha1.ReloadOptions{
+ case v1.TPLScriptType:
+ return &v1.DynamicReloadAction{
TPLScriptTrigger: scriptHandle}
- case appsv1alpha1.AutoType:
- return &appsv1alpha1.ReloadOptions{
+ case v1.AutoType:
+ return &v1.DynamicReloadAction{
AutoTrigger: autoHandle}
}
}
@@ -143,7 +144,7 @@ var _ = Describe("Config Builder Test", func() {
DownwardAPIVolumes: make([]corev1.VolumeMount, 0),
}
if hasScripts {
- param.ConfigSpecsBuildParams[0].ScriptConfig = []appsv1alpha1.ScriptConfig{
+ param.ConfigSpecsBuildParams[0].ScriptConfig = []v1.ScriptConfig{
{
Namespace: scriptsNS,
ScriptConfigMapRef: scriptsName,
@@ -180,8 +181,8 @@ formatterConfig:
mockK8sCli.MockCreateMethod(testutil.WithCreateReturned(testutil.WithCreatedSucceedResult(), testutil.WithAnyTimes()))
}
- newDownwardAPIVolumes := func() []appsv1alpha1.DownwardAPIOption {
- return []appsv1alpha1.DownwardAPIOption{
+ newDownwardAPIVolumes := func() []v1.DownwardAction {
+ return []v1.DownwardAction{
{
Name: "downward-api",
MountPoint: "/etc/podinfo",
@@ -202,11 +203,11 @@ formatterConfig:
It("builds unixSignal reloader correctly", func() {
param := newCMBuildParams(false)
mockTplScriptCM()
- reloadOptions := newReloadOptions(appsv1alpha1.UnixSignalType, nil)
+ reloadOptions := newReloadOptions(v1.UnixSignalType, nil)
for i := range param.ConfigSpecsBuildParams {
buildParam := ¶m.ConfigSpecsBuildParams[i]
- buildParam.ReloadOptions = reloadOptions
- buildParam.ReloadType = appsv1alpha1.UnixSignalType
+ buildParam.DynamicReloadAction = reloadOptions
+ buildParam.ReloadType = v1.UnixSignalType
}
Expect(BuildConfigManagerContainerParams(mockK8sCli.Client(), ctx, param, newVolumeMounts2())).Should(Succeed())
for _, arg := range []string{`--volume-dir`, `/postgresql/conf`, `--volume-dir`, `/postgresql/conf2`} {
@@ -226,11 +227,11 @@ formatterConfig:
mockK8sCli.MockCreateMethod(testutil.WithCreateReturned(testutil.WithCreatedSucceedResult(), testutil.WithTimes(2)))
param := newCMBuildParams(true)
- reloadOptions := newReloadOptions(appsv1alpha1.ShellType, nil)
+ reloadOptions := newReloadOptions(v1.ShellType, nil)
for i := range param.ConfigSpecsBuildParams {
buildParam := ¶m.ConfigSpecsBuildParams[i]
- buildParam.ReloadOptions = reloadOptions
- buildParam.ReloadType = appsv1alpha1.ShellType
+ buildParam.DynamicReloadAction = reloadOptions
+ buildParam.ReloadType = v1.ShellType
}
Expect(BuildConfigManagerContainerParams(mockK8sCli.Client(), context.TODO(), param, newVolumeMounts())).Should(Succeed())
for _, arg := range []string{`--volume-dir`, `/postgresql/conf`} {
@@ -241,11 +242,11 @@ formatterConfig:
It("builds tplScriptsTrigger reloader correctly", func() {
mockTplScriptCM()
param := newCMBuildParams(false)
- reloadOptions := newReloadOptions(appsv1alpha1.TPLScriptType, syncFn(true))
+ reloadOptions := newReloadOptions(v1.TPLScriptType, syncFn(true))
for i := range param.ConfigSpecsBuildParams {
buildParam := ¶m.ConfigSpecsBuildParams[i]
- buildParam.ReloadOptions = reloadOptions
- buildParam.ReloadType = appsv1alpha1.TPLScriptType
+ buildParam.DynamicReloadAction = reloadOptions
+ buildParam.ReloadType = v1.TPLScriptType
}
Expect(BuildConfigManagerContainerParams(mockK8sCli.Client(), context.TODO(), param, newVolumeMounts())).Should(Succeed())
for _, arg := range []string{`--operator-update-enable`} {
@@ -256,11 +257,11 @@ formatterConfig:
It("builds tplScriptsTrigger reloader correctly with sync", func() {
mockTplScriptCM()
param := newCMBuildParams(false)
- reloadOptions := newReloadOptions(appsv1alpha1.TPLScriptType, syncFn(false))
+ reloadOptions := newReloadOptions(v1.TPLScriptType, syncFn(false))
for i := range param.ConfigSpecsBuildParams {
buildParam := ¶m.ConfigSpecsBuildParams[i]
- buildParam.ReloadOptions = reloadOptions
- buildParam.ReloadType = appsv1alpha1.TPLScriptType
+ buildParam.DynamicReloadAction = reloadOptions
+ buildParam.ReloadType = v1.TPLScriptType
}
Expect(BuildConfigManagerContainerParams(mockK8sCli.Client(), context.TODO(), param, newVolumeMounts())).Should(Succeed())
for _, arg := range []string{`--volume-dir`, `/postgresql/conf`} {
@@ -271,11 +272,11 @@ formatterConfig:
It("builds secondary render correctly", func() {
mockTplScriptCM()
param := newCMBuildParams(false)
- reloadOptions := newReloadOptions(appsv1alpha1.TPLScriptType, syncFn(false))
+ reloadOptions := newReloadOptions(v1.TPLScriptType, syncFn(false))
for i := range param.ConfigSpecsBuildParams {
buildParam := ¶m.ConfigSpecsBuildParams[i]
- buildParam.ReloadOptions = reloadOptions
- buildParam.ReloadType = appsv1alpha1.TPLScriptType
+ buildParam.DynamicReloadAction = reloadOptions
+ buildParam.ReloadType = v1.TPLScriptType
buildParam.ConfigSpec.LegacyRenderedConfigSpec = &appsv1alpha1.LegacyRenderedTemplateSpec{
ConfigTemplateExtension: appsv1alpha1.ConfigTemplateExtension{
Namespace: scriptsNS,
@@ -294,7 +295,7 @@ formatterConfig:
param := newCMBuildParams(false)
buildParam := ¶m.ConfigSpecsBuildParams[0]
buildParam.DownwardAPIOptions = newDownwardAPIVolumes()
- buildParam.ReloadOptions = newReloadOptions(appsv1alpha1.TPLScriptType, syncFn(true))
+ buildParam.DynamicReloadAction = newReloadOptions(v1.TPLScriptType, syncFn(true))
Expect(BuildConfigManagerContainerParams(mockK8sCli.Client(), context.TODO(), param, newVolumeMounts())).Should(Succeed())
Expect(FindVolumeMount(param.DownwardAPIVolumes, buildParam.DownwardAPIOptions[0].Name)).ShouldNot(BeNil())
})
@@ -325,7 +326,7 @@ func TestCheckAndUpdateReloadYaml(t *testing.T) {
type args struct {
data map[string]string
reloadConfig string
- formatterConfig *appsv1alpha1.FormatterConfig
+ formatterConfig *v1.FormatterConfig
}
tests := []struct {
name string
@@ -340,8 +341,8 @@ fileRegex: my.cnf
scripts: reload.tpl
`},
reloadConfig: "reload.yaml",
- formatterConfig: &appsv1alpha1.FormatterConfig{
- Format: appsv1alpha1.Ini,
+ formatterConfig: &v1.FormatterConfig{
+ Format: v1.Ini,
},
},
wantErr: false,
@@ -357,7 +358,7 @@ formatterConfig:
args: args{
data: map[string]string{},
reloadConfig: "reload.yaml",
- formatterConfig: &appsv1alpha1.FormatterConfig{Format: appsv1alpha1.Ini},
+ formatterConfig: &v1.FormatterConfig{Format: v1.Ini},
},
wantErr: true,
want: map[string]string{},
diff --git a/pkg/configuration/config_manager/config_handler.go b/pkg/configuration/config_manager/config_handler.go
index 21bd54124e9..4d8b6d02f29 100644
--- a/pkg/configuration/config_manager/config_handler.go
+++ b/pkg/configuration/config_manager/config_handler.go
@@ -31,26 +31,21 @@ import (
"github.com/fsnotify/fsnotify"
"github.com/pkg/errors"
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
cfgcore "github.com/apecloud/kubeblocks/pkg/configuration/core"
cfgutil "github.com/apecloud/kubeblocks/pkg/configuration/util"
"github.com/apecloud/kubeblocks/pkg/gotemplate"
)
-// According to 'https://pkg.go.dev/text/template' :
-// For `range`, if the value is a map and the keys can be sorted, the elements will be visited in sorted key order.
-const defaultBatchInputTemplate string = `{{- range $pKey, $pValue := $ }}
-{{ printf "%s=%s" $pKey $pValue }}
-{{- end }}`
-
type configVolumeHandleMeta struct {
ConfigHandler
mountPoint []string
- reloadType appsv1alpha1.CfgReloadType
+ reloadType v1.CfgReloadType
configSpec appsv1alpha1.ComponentTemplateSpec
- formatterConfig *appsv1alpha1.FormatterConfig
+ formatterConfig *v1.FormatterConfig
}
func (s *configVolumeHandleMeta) OnlineUpdate(_ context.Context, _ string, _ map[string]string) error {
@@ -152,7 +147,7 @@ func (u *unixSignalHandler) MountPoint() []string {
return []string{u.mountPoint}
}
-func CreateSignalHandler(sig appsv1alpha1.SignalType, processName string, mountPoint string) (ConfigHandler, error) {
+func CreateSignalHandler(sig v1.SignalType, processName string, mountPoint string) (ConfigHandler, error) {
signal, ok := allUnixSignals[sig]
if !ok {
err := cfgcore.MakeError("not supported unix signal: %s", sig)
@@ -186,14 +181,12 @@ type shellCommandHandler struct {
batchInputTemplate string
}
-func generateBatchStdinData(updatedParams map[string]string, batchInputTemplate string) (string, error) {
+func generateBatchStdinData(ctx context.Context, updatedParams map[string]string, batchInputTemplate string) (string, error) {
tplValues := gotemplate.TplValues{}
for k, v := range updatedParams {
tplValues[k] = v
}
- engine := gotemplate.NewTplEngine(
- &tplValues, nil, "render-batch-input-parameters", nil, context.TODO(),
- )
+ engine := gotemplate.NewTplEngine(&tplValues, nil, "render-batch-input-parameters", nil, ctx)
stdinStr, err := engine.Render(batchInputTemplate)
return strings.TrimSpace(stdinStr) + "\n", err
}
@@ -206,47 +199,55 @@ func (s *shellCommandHandler) OnlineUpdate(ctx context.Context, name string, upd
return s.execHandler(ctx, updatedParams, args...)
}
-func execWithBatchReload(ctx context.Context, updatedParams map[string]string, batchInputTemplate string, commandName string, args ...string) (string, error) {
+func doBatchReloadAction(ctx context.Context, updatedParams map[string]string, fn ActionCallback, batchInputTemplate string, commandName string, args ...string) error {
+ // If there are any errors, try to check them before all steps.
+ batchStdinStr, err := generateBatchStdinData(ctx, updatedParams, batchInputTemplate)
+ if err != nil {
+ logger.Error(err, "cannot generate batch stdin data")
+ return err
+ }
+
command := exec.CommandContext(ctx, commandName, args...)
stdin, err := command.StdinPipe()
if err != nil {
- return "", errors.Wrap(err, "cannot create a pipe connecting to the STDIN of the command")
+ return errors.Wrap(err, "cannot create a pipe connecting to the STDIN of the command")
}
- var batchStdinStr string
+
go func() {
defer stdin.Close()
- var err error
- batchStdinStr, err = generateBatchStdinData(updatedParams, batchInputTemplate)
- if err != nil {
- logger.Error(err, "cannot generate batch stdin data")
- return
- }
if _, err := io.WriteString(stdin, batchStdinStr); err != nil {
logger.Error(err, "cannot write batch stdin data into STDIN stream")
- return
}
}()
+
stdout, err := cfgutil.ExecShellCommand(command)
- logger.Info("batch execute",
- "exec", command.String(),
+ if fn != nil {
+ fn(stdout, err)
+ }
+ logger.Info("do batch reload action",
+ "command", command.String(),
"stdin", batchStdinStr,
"stdout", stdout,
"error", err,
)
- return stdout, err
+ return err
}
-func execWithSeparateReload(ctx context.Context, updatedParams map[string]string, commandName string, args ...string) ([]string, error) {
- stdouts := []string{}
+// ActionCallback is a callback function for testcase.
+type ActionCallback func(output string, err error)
+
+func doReloadAction(ctx context.Context, updatedParams map[string]string, fn ActionCallback, commandName string, args ...string) error {
commonHandle := func(args []string) error {
command := exec.CommandContext(ctx, commandName, args...)
stdout, err := cfgutil.ExecShellCommand(command)
- logger.Info("execute single param reload",
- "exec", command.String(),
+ if fn != nil {
+ fn(stdout, err)
+ }
+ logger.Info("do reload action",
+ "command", command.String(),
"stdout", stdout,
"err", err,
)
- stdouts = append(stdouts, stdout)
return err
}
volumeHandle := func(baseCMD []string, paramName, paramValue string) error {
@@ -257,38 +258,17 @@ func execWithSeparateReload(ctx context.Context, updatedParams map[string]string
}
for key, value := range updatedParams {
if err := volumeHandle(args, key, value); err != nil {
- return nil, err
+ return err
}
}
- return stdouts, nil
+ return nil
}
func (s *shellCommandHandler) execHandler(ctx context.Context, updatedParams map[string]string, args ...string) error {
- if s.isBatchReload {
- stdout, err := execWithBatchReload(ctx, updatedParams, s.batchInputTemplate, s.command, args...)
- logger.Info("execute with batch reload",
- "updated_params", updatedParams,
- "batch_input_template", s.batchInputTemplate,
- "execute_args", append([]string{s.command}, args...),
- "stdout", stdout,
- )
- if err != nil {
- return errors.Wrap(err, "execute with batch reload failed")
- }
- } else {
- stdouts, err := execWithSeparateReload(ctx, updatedParams, s.command, args...)
- execArgs := append([]string{s.command}, args...)
- execArgs = append(execArgs, "param_key_N", "param_value_N")
- logger.Info("execute with individual param reload",
- "updated_params", updatedParams,
- "execute_args", execArgs,
- "stdouts", stdouts,
- )
- if err != nil {
- return errors.Wrap(err, "execute with individual param reload failed")
- }
+ if s.isBatchReload && s.batchInputTemplate != "" {
+ return doBatchReloadAction(ctx, updatedParams, nil, s.batchInputTemplate, s.command, args...)
}
- return nil
+ return doReloadAction(ctx, updatedParams, nil, s.command, args...)
}
func (s *shellCommandHandler) VolumeHandle(ctx context.Context, event fsnotify.Event) error {
@@ -366,7 +346,7 @@ func (s *shellCommandHandler) isDownwardAPITrigger() bool {
return s.downwardAPITrigger
}
-func createConfigVolumeMeta(configSpecName string, reloadType appsv1alpha1.CfgReloadType, mountPoint []string, formatterConfig *appsv1alpha1.FormatterConfig) configVolumeHandleMeta {
+func createConfigVolumeMeta(configSpecName string, reloadType v1.CfgReloadType, mountPoint []string, formatterConfig *v1.FormatterConfig) configVolumeHandleMeta {
return configVolumeHandleMeta{
reloadType: reloadType,
mountPoint: mountPoint,
@@ -377,23 +357,34 @@ func createConfigVolumeMeta(configSpecName string, reloadType appsv1alpha1.CfgRe
}
}
-func isBatchReload(configMeta *ConfigSpecInfo) bool {
+func isShellCommand(configMeta *ConfigSpecInfo) bool {
return configMeta != nil &&
- configMeta.ReloadOptions != nil &&
- configMeta.ReloadOptions.ShellTrigger != nil &&
- configMeta.ReloadOptions.ShellTrigger.BatchReload != nil &&
- *(configMeta.ShellTrigger.BatchReload)
+ configMeta.DynamicReloadAction != nil &&
+ configMeta.DynamicReloadAction.ShellTrigger != nil
+}
+
+func isBatchReloadMode(shellAction *v1.ShellTrigger) bool {
+ return shellAction.BatchReload != nil && *shellAction.BatchReload
+}
+
+func isValidBatchReload(shellAction *v1.ShellTrigger) bool {
+ return isBatchReloadMode(shellAction) && len(shellAction.BatchParametersTemplate) > 0
+}
+
+func isBatchReload(configMeta *ConfigSpecInfo) bool {
+ return isShellCommand(configMeta) && isBatchReloadMode(configMeta.DynamicReloadAction.ShellTrigger)
}
func getBatchInputTemplate(configMeta *ConfigSpecInfo) string {
- batchInputTemplate := defaultBatchInputTemplate
- if configMeta != nil &&
- configMeta.ReloadOptions != nil &&
- configMeta.ReloadOptions.ShellTrigger != nil &&
- len(configMeta.ReloadOptions.ShellTrigger.BatchInputTemplate) > 0 {
- batchInputTemplate = configMeta.ShellTrigger.BatchInputTemplate
+ if !isShellCommand(configMeta) {
+ return ""
+ }
+
+ shellAction := configMeta.DynamicReloadAction.ShellTrigger
+ if isValidBatchReload(shellAction) {
+ return shellAction.BatchParametersTemplate
}
- return batchInputTemplate
+ return ""
}
func CreateExecHandler(command []string, mountPoint string, configMeta *ConfigSpecInfo, backupPath string) (ConfigHandler, error) {
@@ -405,8 +396,8 @@ func CreateExecHandler(command []string, mountPoint string, configMeta *ConfigSp
return nil, err
}
- var formatterConfig *appsv1alpha1.FormatterConfig
- if backupPath != "" && configMeta != nil && configMeta.ReloadOptions != nil {
+ var formatterConfig *v1.FormatterConfig
+ if backupPath != "" && configMeta != nil && configMeta.DynamicReloadAction != nil {
if err := backupConfigFiles([]string{configMeta.MountPoint}, filter, backupPath); err != nil {
return nil, err
}
@@ -426,7 +417,7 @@ func CreateExecHandler(command []string, mountPoint string, configMeta *ConfigSp
// for downward api watch
downwardAPIMountPoint: cfgutil.ToSet(handler).AsSlice(),
downwardAPIHandler: handler,
- configVolumeHandleMeta: createConfigVolumeMeta(configMeta.ConfigSpec.Name, appsv1alpha1.ShellType, []string{mountPoint}, formatterConfig),
+ configVolumeHandleMeta: createConfigVolumeMeta(configMeta.ConfigSpec.Name, v1.ShellType, []string{mountPoint}, formatterConfig),
isBatchReload: isBatchReload(configMeta),
batchInputTemplate: getBatchInputTemplate(configMeta),
}
@@ -532,7 +523,7 @@ func CreateTPLScriptHandler(name, configPath string, dirs []string, backupPath s
return nil, err
}
tplHandler := &tplScriptHandler{
- configVolumeHandleMeta: createConfigVolumeMeta(name, appsv1alpha1.TPLScriptType, dirs, &tplConfig.FormatterConfig),
+ configVolumeHandleMeta: createConfigVolumeMeta(name, v1.TPLScriptType, dirs, &tplConfig.FormatterConfig),
tplContent: string(tplContent),
tplScripts: tplScripts,
fileFilter: filter,
@@ -551,13 +542,13 @@ func CreateCombinedHandler(config string, backupPath string) (ConfigHandler, err
shellTrigger := configMeta.ShellTrigger
return CreateExecHandler(shellTrigger.Command, configMeta.MountPoint, &configMeta, filepath.Join(backupPath, configMeta.ConfigSpec.Name))
}
- signalHandler := func(signalTrigger *appsv1alpha1.UnixSignalTrigger, mountPoint string) (ConfigHandler, error) {
+ signalHandler := func(signalTrigger *v1.UnixSignalTrigger, mountPoint string) (ConfigHandler, error) {
if signalTrigger == nil {
return nil, cfgcore.MakeError("signal trigger is nil")
}
return CreateSignalHandler(signalTrigger.Signal, signalTrigger.ProcessName, mountPoint)
}
- tplHandler := func(tplTrigger *appsv1alpha1.TPLScriptTrigger, configMeta ConfigSpecInfo, backupPath string) (ConfigHandler, error) {
+ tplHandler := func(tplTrigger *v1.TPLScriptTrigger, configMeta ConfigSpecInfo, backupPath string) (ConfigHandler, error) {
if tplTrigger == nil {
return nil, cfgcore.MakeError("tpl trigger is nil")
}
@@ -587,12 +578,12 @@ func CreateCombinedHandler(config string, backupPath string) (ConfigHandler, err
switch configMeta.ReloadType {
default:
return nil, fmt.Errorf("not support reload type: %s", configMeta.ReloadType)
- case appsv1alpha1.ShellType:
+ case v1.ShellType:
h, err = shellHandler(configMeta, tmpPath)
- case appsv1alpha1.UnixSignalType:
- h, err = signalHandler(configMeta.ReloadOptions.UnixSignalTrigger, configMeta.MountPoint)
- case appsv1alpha1.TPLScriptType:
- h, err = tplHandler(configMeta.ReloadOptions.TPLScriptTrigger, configMeta, tmpPath)
+ case v1.UnixSignalType:
+ h, err = signalHandler(configMeta.DynamicReloadAction.UnixSignalTrigger, configMeta.MountPoint)
+ case v1.TPLScriptType:
+ h, err = tplHandler(configMeta.DynamicReloadAction.TPLScriptTrigger, configMeta, tmpPath)
}
if err != nil {
return nil, err
diff --git a/pkg/configuration/config_manager/config_handler_test.go b/pkg/configuration/config_manager/config_handler_test.go
index c789b3a6e3b..f423500f32f 100644
--- a/pkg/configuration/config_manager/config_handler_test.go
+++ b/pkg/configuration/config_manager/config_handler_test.go
@@ -36,6 +36,7 @@ import (
"github.com/fsnotify/fsnotify"
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
"github.com/apecloud/kubeblocks/pkg/configuration/util"
testutil "github.com/apecloud/kubeblocks/pkg/testutil/k8s"
@@ -49,6 +50,10 @@ var _ = Describe("Config Handler Test", func() {
const (
oldVersion = "[test]\na = 1\nb = 2\n"
newVersion = "[test]\na = 2\nb = 2\n\nc = 100"
+
+ defaultBatchInputTemplate string = `{{- range $pKey, $pValue := $ }}
+{{ printf "%s=%s" $pKey $pValue }}
+{{- end }}`
)
BeforeEach(func() {
@@ -74,32 +79,32 @@ var _ = Describe("Config Handler Test", func() {
}
}
- newFormatter := func() appsv1alpha1.FormatterConfig {
- return appsv1alpha1.FormatterConfig{
- FormatterOptions: appsv1alpha1.FormatterOptions{
- IniConfig: &appsv1alpha1.IniConfig{
+ newFormatter := func() v1.FormatterConfig {
+ return v1.FormatterConfig{
+ FormatterAction: v1.FormatterAction{
+ IniConfig: &v1.IniConfig{
SectionName: "test",
},
},
- Format: appsv1alpha1.Ini,
+ Format: v1.Ini,
}
}
newUnixSignalConfig := func() ConfigSpecInfo {
return ConfigSpecInfo{
- ReloadOptions: &appsv1alpha1.ReloadOptions{
- UnixSignalTrigger: &appsv1alpha1.UnixSignalTrigger{
+ DynamicReloadAction: &v1.DynamicReloadAction{
+ UnixSignalTrigger: &v1.UnixSignalTrigger{
ProcessName: findCurrProcName(),
- Signal: appsv1alpha1.SIGHUP,
+ Signal: v1.SIGHUP,
}},
- ReloadType: appsv1alpha1.UnixSignalType,
+ ReloadType: v1.UnixSignalType,
MountPoint: "/tmp/test",
ConfigSpec: newConfigSpec(),
}
}
- newDownwardAPIOptions := func() []appsv1alpha1.DownwardAPIOption {
- return []appsv1alpha1.DownwardAPIOption{
+ newDownwardAPIOptions := func() []v1.DownwardAction {
+ return []v1.DownwardAction{
{
Name: "labels",
MountPoint: filepath.Join(tmpWorkDir, "labels"),
@@ -115,12 +120,12 @@ var _ = Describe("Config Handler Test", func() {
newDownwardAPIConfig := func() ConfigSpecInfo {
return ConfigSpecInfo{
- ReloadOptions: &appsv1alpha1.ReloadOptions{
- ShellTrigger: &appsv1alpha1.ShellTrigger{
+ DynamicReloadAction: &v1.DynamicReloadAction{
+ ShellTrigger: &v1.ShellTrigger{
Command: []string{"sh", "-c", `echo "hello world" "$@"`},
},
},
- ReloadType: appsv1alpha1.ShellType,
+ ReloadType: v1.ShellType,
MountPoint: tmpWorkDir,
ConfigSpec: newConfigSpec(),
FormatterConfig: newFormatter(),
@@ -130,10 +135,10 @@ var _ = Describe("Config Handler Test", func() {
newTPLScriptsConfig := func(configPath string) ConfigSpecInfo {
return ConfigSpecInfo{
- ReloadOptions: &appsv1alpha1.ReloadOptions{
- TPLScriptTrigger: &appsv1alpha1.TPLScriptTrigger{},
+ DynamicReloadAction: &v1.DynamicReloadAction{
+ TPLScriptTrigger: &v1.TPLScriptTrigger{},
},
- ReloadType: appsv1alpha1.TPLScriptType,
+ ReloadType: v1.TPLScriptType,
MountPoint: "/tmp/test",
ConfigSpec: newConfigSpec(),
FormatterConfig: newFormatter(),
@@ -162,7 +167,7 @@ var _ = Describe("Config Handler Test", func() {
Context("TestSimpleHandler", func() {
It("CreateSignalHandler", func() {
- _, err := CreateSignalHandler(appsv1alpha1.SIGALRM, "test", "")
+ _, err := CreateSignalHandler(v1.SIGALRM, "test", "")
Expect(err).Should(Succeed())
_, err = CreateSignalHandler("NOSIGNAL", "test", "")
Expect(err.Error()).To(ContainSubstring("not supported unix signal: NOSIGNAL"))
@@ -268,11 +273,11 @@ var _ = Describe("Config Handler Test", func() {
})
It("should succeed on reload individually", func() {
configSpec := ConfigSpecInfo{
- ReloadOptions: &appsv1alpha1.ReloadOptions{
- ShellTrigger: &appsv1alpha1.ShellTrigger{
+ DynamicReloadAction: &v1.DynamicReloadAction{
+ ShellTrigger: &v1.ShellTrigger{
Command: []string{"sh", "-c", `echo "hello world" "$@"`, "sh"},
}},
- ReloadType: appsv1alpha1.ShellType,
+ ReloadType: v1.ShellType,
MountPoint: configPath,
ConfigSpec: newConfigSpec(),
FormatterConfig: newFormatter(),
@@ -280,17 +285,17 @@ var _ = Describe("Config Handler Test", func() {
testShellHandlerCommon(configPath, configSpec)
})
Describe("Test reload in a batch", func() {
- isBatchReload := true
It("should succeed on the default batch input format", func() {
configSpec := ConfigSpecInfo{
- ReloadOptions: &appsv1alpha1.ReloadOptions{
- ShellTrigger: &appsv1alpha1.ShellTrigger{
+ DynamicReloadAction: &v1.DynamicReloadAction{
+ ShellTrigger: &v1.ShellTrigger{
Command: []string{"sh", "-c",
`while IFS="=" read -r the_key the_val; do echo "key='$the_key'; val='$the_val'"; done`,
},
- BatchReload: &isBatchReload,
+ BatchReload: util.ToPointer(true),
+ BatchParametersTemplate: defaultBatchInputTemplate,
}},
- ReloadType: appsv1alpha1.ShellType,
+ ReloadType: v1.ShellType,
MountPoint: configPath,
ConfigSpec: newConfigSpec(),
FormatterConfig: newFormatter(),
@@ -302,15 +307,15 @@ var _ = Describe("Config Handler Test", func() {
{{ printf "%s:%s" $pKey $pValue }}
{{- end }}`
configSpec := ConfigSpecInfo{
- ReloadOptions: &appsv1alpha1.ReloadOptions{
- ShellTrigger: &appsv1alpha1.ShellTrigger{
+ DynamicReloadAction: &v1.DynamicReloadAction{
+ ShellTrigger: &v1.ShellTrigger{
Command: []string{"sh", "-c",
`while IFS=":" read -r the_key the_val; do echo "key='$the_key'; val='$the_val'"; done`,
},
- BatchReload: &isBatchReload,
- BatchInputTemplate: customBatchInputTemplate,
+ BatchReload: util.ToPointer(true),
+ BatchParametersTemplate: customBatchInputTemplate,
}},
- ReloadType: appsv1alpha1.ShellType,
+ ReloadType: v1.ShellType,
MountPoint: configPath,
ConfigSpec: newConfigSpec(),
FormatterConfig: newFormatter(),
@@ -399,8 +404,11 @@ var _ = Describe("Config Handler Test", func() {
err error
)
BeforeEach(func() {
- stdouts, err = execWithSeparateReload(context.TODO(),
+ err = doReloadAction(context.TODO(),
updatedParams,
+ func(output string, _ error) {
+ stdouts = append(stdouts, output)
+ },
"echo",
"hello",
)
@@ -432,8 +440,11 @@ var _ = Describe("Config Handler Test", func() {
err error
)
BeforeEach(func() {
- stdout, err = execWithBatchReload(context.TODO(),
+ err = doBatchReloadAction(context.TODO(),
updatedParams,
+ func(out string, err error) {
+ stdout = out
+ },
defaultBatchInputTemplate,
"/bin/sh",
"-c",
@@ -474,7 +485,7 @@ var _ = Describe("Config Handler Test", func() {
batchInputTemplate := `{{- range $pKey, $pValue := $ }}
{{ printf "%s:%s" $pKey $pValue }}
{{- end }}`
- stdinStr, err := generateBatchStdinData(updatedParams, batchInputTemplate)
+ stdinStr, err := generateBatchStdinData(context.TODO(), updatedParams, batchInputTemplate)
By("checking there's no error", func() {
Expect(err).Should(Succeed())
})
diff --git a/pkg/configuration/config_manager/handler_util.go b/pkg/configuration/config_manager/handler_util.go
index db467524bd1..f7adc96ce05 100644
--- a/pkg/configuration/config_manager/handler_util.go
+++ b/pkg/configuration/config_manager/handler_util.go
@@ -28,6 +28,7 @@ import (
corev1 "k8s.io/api/core/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
"github.com/apecloud/kubeblocks/pkg/configuration/core"
)
@@ -61,36 +62,36 @@ type CfgManagerBuildParams struct {
ContainerPort int32 `json:"containerPort"`
}
-func IsSupportReload(reload *appsv1alpha1.ReloadOptions) bool {
+func IsSupportReload(reload *v1.DynamicReloadAction) bool {
return reload != nil && isValidReloadPolicy(*reload)
}
-func isValidReloadPolicy(reload appsv1alpha1.ReloadOptions) bool {
+func isValidReloadPolicy(reload v1.DynamicReloadAction) bool {
return reload.AutoTrigger != nil ||
reload.ShellTrigger != nil ||
reload.TPLScriptTrigger != nil ||
reload.UnixSignalTrigger != nil
}
-func IsAutoReload(reload *appsv1alpha1.ReloadOptions) bool {
+func IsAutoReload(reload *v1.DynamicReloadAction) bool {
return reload != nil && reload.AutoTrigger != nil
}
-func FromReloadTypeConfig(reloadOptions *appsv1alpha1.ReloadOptions) appsv1alpha1.CfgReloadType {
+func FromReloadTypeConfig(reloadOptions *v1.DynamicReloadAction) v1.CfgReloadType {
switch {
case reloadOptions.UnixSignalTrigger != nil:
- return appsv1alpha1.UnixSignalType
+ return v1.UnixSignalType
case reloadOptions.ShellTrigger != nil:
- return appsv1alpha1.ShellType
+ return v1.ShellType
case reloadOptions.TPLScriptTrigger != nil:
- return appsv1alpha1.TPLScriptType
+ return v1.TPLScriptType
case reloadOptions.AutoTrigger != nil:
- return appsv1alpha1.AutoType
+ return v1.AutoType
}
return ""
}
-func ValidateReloadOptions(reloadOptions *appsv1alpha1.ReloadOptions, cli client.Client, ctx context.Context) error {
+func ValidateReloadOptions(reloadOptions *v1.DynamicReloadAction, cli client.Client, ctx context.Context) error {
switch {
case reloadOptions.UnixSignalTrigger != nil:
return checkSignalTrigger(reloadOptions.UnixSignalTrigger)
@@ -104,7 +105,7 @@ func ValidateReloadOptions(reloadOptions *appsv1alpha1.ReloadOptions, cli client
return core.MakeError("require special reload type!")
}
-func checkTPLScriptTrigger(options *appsv1alpha1.TPLScriptTrigger, cli client.Client, ctx context.Context) error {
+func checkTPLScriptTrigger(options *v1.TPLScriptTrigger, cli client.Client, ctx context.Context) error {
cm := corev1.ConfigMap{}
return cli.Get(ctx, client.ObjectKey{
Namespace: options.Namespace,
@@ -112,14 +113,14 @@ func checkTPLScriptTrigger(options *appsv1alpha1.TPLScriptTrigger, cli client.Cl
}, &cm)
}
-func checkShellTrigger(options *appsv1alpha1.ShellTrigger) error {
+func checkShellTrigger(options *v1.ShellTrigger) error {
if len(options.Command) == 0 {
return core.MakeError("required shell trigger")
}
return nil
}
-func checkSignalTrigger(options *appsv1alpha1.UnixSignalTrigger) error {
+func checkSignalTrigger(options *v1.UnixSignalTrigger) error {
signal := options.Signal
if !IsValidUnixSignal(signal) {
return core.MakeError("this special signal [%s] is not supported now.", signal)
@@ -162,23 +163,23 @@ func GetSupportReloadConfigSpecs(configSpecs []appsv1alpha1.ComponentConfigSpec,
Namespace: "",
Name: configSpec.ConfigConstraintRef,
}
- cc := &appsv1alpha1.ConfigConstraint{}
+ cc := &v1.ConfigConstraint{}
if err := cli.Get(ctx, ccKey, cc); err != nil {
return nil, core.WrapError(err, "failed to get ConfigConstraint, key[%v]", ccKey)
}
- reloadOptions := cc.Spec.ReloadOptions
+ reloadOptions := cc.Spec.DynamicReloadAction
if !IsSupportReload(reloadOptions) || IsAutoReload(reloadOptions) {
continue
}
reloadConfigSpecMeta = append(reloadConfigSpecMeta, ConfigSpecMeta{
- ToolsImageSpec: cc.Spec.ToolsImageSpec,
+ ToolsImageSpec: cc.Spec.ReloadToolsImage,
ScriptConfig: cc.Spec.ScriptConfigs,
ConfigSpecInfo: ConfigSpecInfo{
- ReloadOptions: cc.Spec.ReloadOptions,
- ConfigSpec: configSpec,
- ReloadType: FromReloadTypeConfig(reloadOptions),
- DownwardAPIOptions: cc.Spec.DownwardAPIOptions,
- FormatterConfig: *cc.Spec.FormatterConfig,
+ DynamicReloadAction: cc.Spec.DynamicReloadAction,
+ ConfigSpec: configSpec,
+ ReloadType: FromReloadTypeConfig(reloadOptions),
+ DownwardAPIOptions: cc.Spec.DownwardActions,
+ FormatterConfig: *cc.Spec.FormatterConfig,
},
})
}
@@ -189,7 +190,7 @@ func FilterSubPathVolumeMount(metas []ConfigSpecMeta, volumes []corev1.VolumeMou
var filtered []ConfigSpecMeta
for _, meta := range metas {
v := FindVolumeMount(volumes, meta.ConfigSpec.VolumeName)
- if v == nil || v.SubPath == "" || meta.ReloadType == appsv1alpha1.TPLScriptType {
+ if v == nil || v.SubPath == "" || meta.ReloadType == v1.TPLScriptType {
filtered = append(filtered, meta)
}
}
diff --git a/pkg/configuration/config_manager/handler_util_test.go b/pkg/configuration/config_manager/handler_util_test.go
index c379abbc51c..a3a94d0df44 100644
--- a/pkg/configuration/config_manager/handler_util_test.go
+++ b/pkg/configuration/config_manager/handler_util_test.go
@@ -32,6 +32,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
cfgutil "github.com/apecloud/kubeblocks/pkg/configuration/core"
testutil "github.com/apecloud/kubeblocks/pkg/testutil/k8s"
@@ -39,7 +40,7 @@ import (
func TestIsSupportReload(t *testing.T) {
type args struct {
- reload *appsv1alpha1.ReloadOptions
+ reload *v1.DynamicReloadAction
}
tests := []struct {
name string
@@ -54,16 +55,16 @@ func TestIsSupportReload(t *testing.T) {
}, {
name: "reload_test_with_empty_reload_options",
args: args{
- reload: &appsv1alpha1.ReloadOptions{},
+ reload: &v1.DynamicReloadAction{},
},
want: false,
}, {
name: "reload_test_with_unix_signal",
args: args{
- reload: &appsv1alpha1.ReloadOptions{
- UnixSignalTrigger: &appsv1alpha1.UnixSignalTrigger{
+ reload: &v1.DynamicReloadAction{
+ UnixSignalTrigger: &v1.UnixSignalTrigger{
ProcessName: "test",
- Signal: appsv1alpha1.SIGHUP,
+ Signal: v1.SIGHUP,
},
},
},
@@ -71,8 +72,8 @@ func TestIsSupportReload(t *testing.T) {
}, {
name: "reload_test_with_shell",
args: args{
- reload: &appsv1alpha1.ReloadOptions{
- ShellTrigger: &appsv1alpha1.ShellTrigger{
+ reload: &v1.DynamicReloadAction{
+ ShellTrigger: &v1.ShellTrigger{
Command: strings.Fields("pg_ctl reload"),
},
},
@@ -81,9 +82,9 @@ func TestIsSupportReload(t *testing.T) {
}, {
name: "reload_test_with_tpl_script",
args: args{
- reload: &appsv1alpha1.ReloadOptions{
- TPLScriptTrigger: &appsv1alpha1.TPLScriptTrigger{
- ScriptConfig: appsv1alpha1.ScriptConfig{
+ reload: &v1.DynamicReloadAction{
+ TPLScriptTrigger: &v1.TPLScriptTrigger{
+ ScriptConfig: v1.ScriptConfig{
ScriptConfigMapRef: "cm",
Namespace: "default",
},
@@ -94,8 +95,8 @@ func TestIsSupportReload(t *testing.T) {
}, {
name: "auto_trigger_reload_test_with_process_name",
args: args{
- reload: &appsv1alpha1.ReloadOptions{
- AutoTrigger: &appsv1alpha1.AutoTrigger{
+ reload: &v1.DynamicReloadAction{
+ AutoTrigger: &v1.AutoTrigger{
ProcessName: "test",
},
},
@@ -104,8 +105,8 @@ func TestIsSupportReload(t *testing.T) {
}, {
name: "auto_trigger_reload_test",
args: args{
- reload: &appsv1alpha1.ReloadOptions{
- AutoTrigger: &appsv1alpha1.AutoTrigger{},
+ reload: &v1.DynamicReloadAction{
+ AutoTrigger: &v1.AutoTrigger{},
},
},
want: true,
@@ -132,15 +133,15 @@ var _ = Describe("Handler Util Test", func() {
DeferCleanup(mockK8sCli.Finish)
})
- mockConfigConstraint := func(ccName string, reloadOptions *appsv1alpha1.ReloadOptions) *appsv1alpha1.ConfigConstraint {
- return &appsv1alpha1.ConfigConstraint{
+ mockConfigConstraint := func(ccName string, reloadOptions *v1.DynamicReloadAction) *v1.ConfigConstraint {
+ return &v1.ConfigConstraint{
ObjectMeta: metav1.ObjectMeta{
Name: ccName,
},
- Spec: appsv1alpha1.ConfigConstraintSpec{
- ReloadOptions: reloadOptions,
- FormatterConfig: &appsv1alpha1.FormatterConfig{
- Format: appsv1alpha1.Properties,
+ Spec: v1.ConfigConstraintSpec{
+ DynamicReloadAction: reloadOptions,
+ FormatterConfig: &v1.FormatterConfig{
+ Format: v1.Properties,
},
}}
}
@@ -165,7 +166,7 @@ var _ = Describe("Handler Util Test", func() {
)
type args struct {
- reloadOptions *appsv1alpha1.ReloadOptions
+ reloadOptions *v1.DynamicReloadAction
cli client.Client
ctx context.Context
}
@@ -176,17 +177,17 @@ var _ = Describe("Handler Util Test", func() {
}{{
name: "unixSignalTest",
args: args{
- reloadOptions: &appsv1alpha1.ReloadOptions{
- UnixSignalTrigger: &appsv1alpha1.UnixSignalTrigger{
- Signal: appsv1alpha1.SIGHUP,
+ reloadOptions: &v1.DynamicReloadAction{
+ UnixSignalTrigger: &v1.UnixSignalTrigger{
+ Signal: v1.SIGHUP,
}},
},
wantErr: false,
}, {
name: "unixSignalTest",
args: args{
- reloadOptions: &appsv1alpha1.ReloadOptions{
- UnixSignalTrigger: &appsv1alpha1.UnixSignalTrigger{
+ reloadOptions: &v1.DynamicReloadAction{
+ UnixSignalTrigger: &v1.UnixSignalTrigger{
Signal: "SIGNOEXIST",
}},
},
@@ -194,8 +195,8 @@ var _ = Describe("Handler Util Test", func() {
}, {
name: "shellTest",
args: args{
- reloadOptions: &appsv1alpha1.ReloadOptions{
- ShellTrigger: &appsv1alpha1.ShellTrigger{
+ reloadOptions: &v1.DynamicReloadAction{
+ ShellTrigger: &v1.ShellTrigger{
Command: nil,
}},
},
@@ -203,8 +204,8 @@ var _ = Describe("Handler Util Test", func() {
}, {
name: "shellTest",
args: args{
- reloadOptions: &appsv1alpha1.ReloadOptions{
- ShellTrigger: &appsv1alpha1.ShellTrigger{
+ reloadOptions: &v1.DynamicReloadAction{
+ ShellTrigger: &v1.ShellTrigger{
Command: strings.Fields("go"),
}},
},
@@ -212,9 +213,9 @@ var _ = Describe("Handler Util Test", func() {
}, {
name: "TPLScriptTest",
args: args{
- reloadOptions: &appsv1alpha1.ReloadOptions{
- TPLScriptTrigger: &appsv1alpha1.TPLScriptTrigger{
- ScriptConfig: appsv1alpha1.ScriptConfig{
+ reloadOptions: &v1.DynamicReloadAction{
+ TPLScriptTrigger: &v1.TPLScriptTrigger{
+ ScriptConfig: v1.ScriptConfig{
ScriptConfigMapRef: "test",
},
}},
@@ -225,9 +226,9 @@ var _ = Describe("Handler Util Test", func() {
}, {
name: "TPLScriptTest",
args: args{
- reloadOptions: &appsv1alpha1.ReloadOptions{
- TPLScriptTrigger: &appsv1alpha1.TPLScriptTrigger{
- ScriptConfig: appsv1alpha1.ScriptConfig{
+ reloadOptions: &v1.DynamicReloadAction{
+ TPLScriptTrigger: &v1.TPLScriptTrigger{
+ ScriptConfig: v1.ScriptConfig{
ScriptConfigMapRef: "test",
},
}},
@@ -238,8 +239,8 @@ var _ = Describe("Handler Util Test", func() {
}, {
name: "autoTriggerTest",
args: args{
- reloadOptions: &appsv1alpha1.ReloadOptions{
- AutoTrigger: &appsv1alpha1.AutoTrigger{
+ reloadOptions: &v1.DynamicReloadAction{
+ AutoTrigger: &v1.AutoTrigger{
ProcessName: "test",
}},
},
@@ -247,8 +248,8 @@ var _ = Describe("Handler Util Test", func() {
}, {
name: "autoTriggerTest",
args: args{
- reloadOptions: &appsv1alpha1.ReloadOptions{
- AutoTrigger: &appsv1alpha1.AutoTrigger{}},
+ reloadOptions: &v1.DynamicReloadAction{
+ AutoTrigger: &v1.AutoTrigger{}},
},
wantErr: false,
}}
@@ -297,10 +298,10 @@ var _ = Describe("Handler Util Test", func() {
It("normal test", func() {
ccName := "config_constraint"
- cc := mockConfigConstraint(ccName, &appsv1alpha1.ReloadOptions{
- UnixSignalTrigger: &appsv1alpha1.UnixSignalTrigger{
+ cc := mockConfigConstraint(ccName, &v1.DynamicReloadAction{
+ UnixSignalTrigger: &v1.UnixSignalTrigger{
ProcessName: "test",
- Signal: appsv1alpha1.SIGHUP,
+ Signal: v1.SIGHUP,
},
})
mockK8sCli.MockGetMethod(testutil.WithGetReturned(
@@ -314,14 +315,14 @@ var _ = Describe("Handler Util Test", func() {
Expect(err).Should(Succeed())
Expect(len(configSpecs)).Should(BeEquivalentTo(1))
Expect(configSpecs[0].ConfigSpec).Should(BeEquivalentTo(mockConfigSpec(ccName)))
- Expect(configSpecs[0].ReloadType).Should(BeEquivalentTo(appsv1alpha1.UnixSignalType))
+ Expect(configSpecs[0].ReloadType).Should(BeEquivalentTo(v1.UnixSignalType))
Expect(configSpecs[0].FormatterConfig).Should(BeEquivalentTo(*cc.Spec.FormatterConfig))
})
It("auto trigger test", func() {
ccName := "auto_trigger_config_constraint"
- cc := mockConfigConstraint(ccName, &appsv1alpha1.ReloadOptions{
- AutoTrigger: &appsv1alpha1.AutoTrigger{
+ cc := mockConfigConstraint(ccName, &v1.DynamicReloadAction{
+ AutoTrigger: &v1.AutoTrigger{
ProcessName: "test",
},
})
@@ -340,31 +341,31 @@ var _ = Describe("Handler Util Test", func() {
Context("TestFromReloadTypeConfig", func() {
It("TestSignalTrigger", func() {
- Expect(appsv1alpha1.UnixSignalType).Should(BeEquivalentTo(FromReloadTypeConfig(&appsv1alpha1.ReloadOptions{
- UnixSignalTrigger: &appsv1alpha1.UnixSignalTrigger{
+ Expect(v1.UnixSignalType).Should(BeEquivalentTo(FromReloadTypeConfig(&v1.DynamicReloadAction{
+ UnixSignalTrigger: &v1.UnixSignalTrigger{
ProcessName: "test",
- Signal: appsv1alpha1.SIGHUP,
+ Signal: v1.SIGHUP,
}})))
})
It("TestAutoTrigger", func() {
- Expect(appsv1alpha1.AutoType).Should(BeEquivalentTo(FromReloadTypeConfig(&appsv1alpha1.ReloadOptions{
- AutoTrigger: &appsv1alpha1.AutoTrigger{
+ Expect(v1.AutoType).Should(BeEquivalentTo(FromReloadTypeConfig(&v1.DynamicReloadAction{
+ AutoTrigger: &v1.AutoTrigger{
ProcessName: "test",
}})))
})
It("TestShellTrigger", func() {
- Expect(appsv1alpha1.ShellType).Should(BeEquivalentTo(FromReloadTypeConfig(&appsv1alpha1.ReloadOptions{
- ShellTrigger: &appsv1alpha1.ShellTrigger{
+ Expect(v1.ShellType).Should(BeEquivalentTo(FromReloadTypeConfig(&v1.DynamicReloadAction{
+ ShellTrigger: &v1.ShellTrigger{
Command: []string{"/bin/true"},
}})))
})
It("TestTplScriptsTrigger", func() {
- Expect(appsv1alpha1.TPLScriptType).Should(BeEquivalentTo(FromReloadTypeConfig(&appsv1alpha1.ReloadOptions{
- TPLScriptTrigger: &appsv1alpha1.TPLScriptTrigger{
- ScriptConfig: appsv1alpha1.ScriptConfig{
+ Expect(v1.TPLScriptType).Should(BeEquivalentTo(FromReloadTypeConfig(&v1.DynamicReloadAction{
+ TPLScriptTrigger: &v1.TPLScriptTrigger{
+ ScriptConfig: v1.ScriptConfig{
ScriptConfigMapRef: "test",
Namespace: "default",
},
@@ -372,31 +373,31 @@ var _ = Describe("Handler Util Test", func() {
})
It("TestInvalidTrigger", func() {
- Expect("").Should(BeEquivalentTo(FromReloadTypeConfig(&appsv1alpha1.ReloadOptions{})))
+ Expect("").Should(BeEquivalentTo(FromReloadTypeConfig(&v1.DynamicReloadAction{})))
})
})
Context("TestValidateReloadOptions", func() {
It("TestSignalTrigger", func() {
- Expect(ValidateReloadOptions(&appsv1alpha1.ReloadOptions{
- UnixSignalTrigger: &appsv1alpha1.UnixSignalTrigger{
+ Expect(ValidateReloadOptions(&v1.DynamicReloadAction{
+ UnixSignalTrigger: &v1.UnixSignalTrigger{
ProcessName: "test",
- Signal: appsv1alpha1.SIGHUP,
+ Signal: v1.SIGHUP,
}}, nil, nil),
).Should(Succeed())
})
It("TestSignalTrigger", func() {
- Expect(ValidateReloadOptions(&appsv1alpha1.ReloadOptions{
- AutoTrigger: &appsv1alpha1.AutoTrigger{
+ Expect(ValidateReloadOptions(&v1.DynamicReloadAction{
+ AutoTrigger: &v1.AutoTrigger{
ProcessName: "test",
}}, nil, nil),
).Should(Succeed())
})
It("TestShellTrigger", func() {
- Expect(ValidateReloadOptions(&appsv1alpha1.ReloadOptions{
- ShellTrigger: &appsv1alpha1.ShellTrigger{
+ Expect(ValidateReloadOptions(&v1.DynamicReloadAction{
+ ShellTrigger: &v1.ShellTrigger{
Command: []string{"/bin/true"},
}}, nil, nil),
).Should(Succeed())
@@ -416,9 +417,9 @@ var _ = Describe("Handler Util Test", func() {
}), testutil.WithTimes(2)))
By("Test valid")
- Expect(ValidateReloadOptions(&appsv1alpha1.ReloadOptions{
- TPLScriptTrigger: &appsv1alpha1.TPLScriptTrigger{
- ScriptConfig: appsv1alpha1.ScriptConfig{
+ Expect(ValidateReloadOptions(&v1.DynamicReloadAction{
+ TPLScriptTrigger: &v1.TPLScriptTrigger{
+ ScriptConfig: v1.ScriptConfig{
ScriptConfigMapRef: testName1,
Namespace: ns,
},
@@ -426,9 +427,9 @@ var _ = Describe("Handler Util Test", func() {
).Should(Succeed())
By("Test invalid")
- Expect(ValidateReloadOptions(&appsv1alpha1.ReloadOptions{
- TPLScriptTrigger: &appsv1alpha1.TPLScriptTrigger{
- ScriptConfig: appsv1alpha1.ScriptConfig{
+ Expect(ValidateReloadOptions(&v1.DynamicReloadAction{
+ TPLScriptTrigger: &v1.TPLScriptTrigger{
+ ScriptConfig: v1.ScriptConfig{
ScriptConfigMapRef: testName2,
Namespace: ns,
},
@@ -437,13 +438,13 @@ var _ = Describe("Handler Util Test", func() {
})
It("TestInvalidTrigger", func() {
- Expect(ValidateReloadOptions(&appsv1alpha1.ReloadOptions{}, nil, nil)).ShouldNot(Succeed())
+ Expect(ValidateReloadOptions(&v1.DynamicReloadAction{}, nil, nil)).ShouldNot(Succeed())
})
})
})
func TestFilterSubPathVolumeMount(t *testing.T) {
- createConfigMeta := func(volumeName string, reloadType appsv1alpha1.CfgReloadType) ConfigSpecMeta {
+ createConfigMeta := func(volumeName string, reloadType v1.CfgReloadType) ConfigSpecMeta {
return ConfigSpecMeta{ConfigSpecInfo: ConfigSpecInfo{
ReloadType: reloadType,
ConfigSpec: appsv1alpha1.ComponentConfigSpec{
@@ -464,9 +465,9 @@ func TestFilterSubPathVolumeMount(t *testing.T) {
name: "test1",
args: args{
metas: []ConfigSpecMeta{
- createConfigMeta("test1", appsv1alpha1.UnixSignalType),
- createConfigMeta("test2", appsv1alpha1.ShellType),
- createConfigMeta("test3", appsv1alpha1.TPLScriptType),
+ createConfigMeta("test1", v1.UnixSignalType),
+ createConfigMeta("test2", v1.ShellType),
+ createConfigMeta("test3", v1.TPLScriptType),
},
volumes: []corev1.VolumeMount{
{Name: "test1", SubPath: "test1"},
@@ -475,15 +476,15 @@ func TestFilterSubPathVolumeMount(t *testing.T) {
},
},
want: []ConfigSpecMeta{
- createConfigMeta("test3", appsv1alpha1.TPLScriptType),
+ createConfigMeta("test3", v1.TPLScriptType),
},
}, {
name: "test2",
args: args{
metas: []ConfigSpecMeta{
- createConfigMeta("test1", appsv1alpha1.UnixSignalType),
- createConfigMeta("test2", appsv1alpha1.ShellType),
- createConfigMeta("test3", appsv1alpha1.TPLScriptType),
+ createConfigMeta("test1", v1.UnixSignalType),
+ createConfigMeta("test2", v1.ShellType),
+ createConfigMeta("test3", v1.TPLScriptType),
},
volumes: []corev1.VolumeMount{
{Name: "test1"},
@@ -492,24 +493,24 @@ func TestFilterSubPathVolumeMount(t *testing.T) {
},
},
want: []ConfigSpecMeta{
- createConfigMeta("test1", appsv1alpha1.UnixSignalType),
- createConfigMeta("test2", appsv1alpha1.ShellType),
- createConfigMeta("test3", appsv1alpha1.TPLScriptType),
+ createConfigMeta("test1", v1.UnixSignalType),
+ createConfigMeta("test2", v1.ShellType),
+ createConfigMeta("test3", v1.TPLScriptType),
},
}, {
name: "test3",
args: args{
metas: []ConfigSpecMeta{
- createConfigMeta("test1", appsv1alpha1.UnixSignalType),
- createConfigMeta("test2", appsv1alpha1.ShellType),
- createConfigMeta("test3", appsv1alpha1.TPLScriptType),
+ createConfigMeta("test1", v1.UnixSignalType),
+ createConfigMeta("test2", v1.ShellType),
+ createConfigMeta("test3", v1.TPLScriptType),
},
volumes: []corev1.VolumeMount{},
},
want: []ConfigSpecMeta{
- createConfigMeta("test1", appsv1alpha1.UnixSignalType),
- createConfigMeta("test2", appsv1alpha1.ShellType),
- createConfigMeta("test3", appsv1alpha1.TPLScriptType),
+ createConfigMeta("test1", v1.UnixSignalType),
+ createConfigMeta("test2", v1.ShellType),
+ createConfigMeta("test3", v1.TPLScriptType),
},
}}
for _, tt := range tests {
diff --git a/pkg/configuration/config_manager/proc_util.go b/pkg/configuration/config_manager/proc_util.go
index ec6ed39ee49..c2bd3a639ec 100644
--- a/pkg/configuration/config_manager/proc_util.go
+++ b/pkg/configuration/config_manager/proc_util.go
@@ -25,7 +25,7 @@ import (
"github.com/shirou/gopsutil/v3/process"
- appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
cfgcore "github.com/apecloud/kubeblocks/pkg/configuration/core"
)
@@ -71,7 +71,7 @@ func findParentPIDByProcessName(processName string, ctx ...context.Context) (PID
return InvalidPID, cfgcore.MakeError("cannot find pid of process name: [%s]", processName)
}
-func IsValidUnixSignal(sig appsv1alpha1.SignalType) bool {
+func IsValidUnixSignal(sig appsv1.SignalType) bool {
_, ok := allUnixSignals[sig]
return ok
}
diff --git a/pkg/configuration/config_manager/reload_util.go b/pkg/configuration/config_manager/reload_util.go
index 22f23b11371..3b642f0a100 100644
--- a/pkg/configuration/config_manager/reload_util.go
+++ b/pkg/configuration/config_manager/reload_util.go
@@ -31,7 +31,7 @@ import (
"strings"
"text/template/parse"
- appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
"github.com/apecloud/kubeblocks/pkg/configuration/core"
cfgutil "github.com/apecloud/kubeblocks/pkg/configuration/util"
"github.com/apecloud/kubeblocks/pkg/gotemplate"
@@ -51,7 +51,7 @@ const (
// for testing
var newCommandChannel = NewCommandChannel
-func OnlineUpdateParamsHandle(tplScriptPath string, formatConfig *appsv1alpha1.FormatterConfig, dataType, dsn string) (DynamicUpdater, error) {
+func OnlineUpdateParamsHandle(tplScriptPath string, formatConfig *v1.FormatterConfig, dataType, dsn string) (DynamicUpdater, error) {
tplContent, err := os.ReadFile(tplScriptPath)
if err != nil {
return nil, err
@@ -81,7 +81,7 @@ func checkTPLScript(tplName string, tplContent string) error {
return err
}
-func wrapGoTemplateRun(ctx context.Context, tplScriptPath string, tplContent string, updatedParams map[string]string, formatConfig *appsv1alpha1.FormatterConfig, dataType string, dsn string) error {
+func wrapGoTemplateRun(ctx context.Context, tplScriptPath string, tplContent string, updatedParams map[string]string, formatConfig *v1.FormatterConfig, dataType string, dsn string) error {
var (
err error
commandChannel DynamicParamUpdater
@@ -103,7 +103,7 @@ func wrapGoTemplateRun(ctx context.Context, tplScriptPath string, tplContent str
return err
}
-func constructReloadBuiltinFuncs(ctx context.Context, cc DynamicParamUpdater, formatConfig *appsv1alpha1.FormatterConfig) *gotemplate.BuiltInObjectsFunc {
+func constructReloadBuiltinFuncs(ctx context.Context, cc DynamicParamUpdater, formatConfig *v1.FormatterConfig) *gotemplate.BuiltInObjectsFunc {
return &gotemplate.BuiltInObjectsFunc{
builtInExecFunctionName: func(command string, args ...string) (string, error) {
execCommand := exec.CommandContext(ctx, command, args...)
@@ -137,7 +137,7 @@ func constructReloadBuiltinFuncs(ctx context.Context, cc DynamicParamUpdater, fo
}
}
-func createUpdatedParamsPatch(newVersion []string, oldVersion []string, formatCfg *appsv1alpha1.FormatterConfig) (map[string]string, error) {
+func createUpdatedParamsPatch(newVersion []string, oldVersion []string, formatCfg *v1.FormatterConfig) (map[string]string, error) {
patchOption := core.CfgOption{
Type: core.CfgTplType,
CfgType: formatCfg.Format,
@@ -305,7 +305,7 @@ func NeedSharedProcessNamespace(configSpecs []ConfigSpecMeta) bool {
if configSpec.ConfigSpec.ConfigConstraintRef == "" {
continue
}
- if configSpec.ReloadType == appsv1alpha1.UnixSignalType {
+ if configSpec.ReloadType == v1.UnixSignalType {
return true
}
}
diff --git a/pkg/configuration/config_manager/reload_util_test.go b/pkg/configuration/config_manager/reload_util_test.go
index 21381c28e5c..e51106c1fab 100644
--- a/pkg/configuration/config_manager/reload_util_test.go
+++ b/pkg/configuration/config_manager/reload_util_test.go
@@ -37,6 +37,7 @@ import (
"github.com/stretchr/testify/require"
"go.uber.org/zap"
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
"github.com/apecloud/kubeblocks/pkg/gotemplate"
testapps "github.com/apecloud/kubeblocks/pkg/testutil/apps"
@@ -52,7 +53,7 @@ func TestCreateUpdatedParamsPatch(t *testing.T) {
type args struct {
newVersion string
oldVersion string
- formatCfg *appsv1alpha1.FormatterConfig
+ formatCfg *v1.FormatterConfig
}
tests := []struct {
name string
@@ -64,9 +65,9 @@ func TestCreateUpdatedParamsPatch(t *testing.T) {
args: args{
newVersion: filepath.Join(rootPath, "currentVersion"),
oldVersion: filepath.Join(rootPath, "lastVersion"),
- formatCfg: &appsv1alpha1.FormatterConfig{
- Format: appsv1alpha1.Ini,
- FormatterOptions: appsv1alpha1.FormatterOptions{IniConfig: &appsv1alpha1.IniConfig{
+ formatCfg: &v1.FormatterConfig{
+ Format: v1.Ini,
+ FormatterAction: v1.FormatterAction{IniConfig: &v1.IniConfig{
SectionName: "mysqld",
}},
}},
@@ -138,7 +139,7 @@ func TestOnlineUpdateParamsHandle(t *testing.T) {
type args struct {
tplScriptPath string
- formatConfig *appsv1alpha1.FormatterConfig
+ formatConfig *v1.FormatterConfig
dataType string
dsn string
}
@@ -151,8 +152,8 @@ func TestOnlineUpdateParamsHandle(t *testing.T) {
name: "online_update_params_handle_test",
args: args{
tplScriptPath: filepath.Join(tmpTestData, partroniPath),
- formatConfig: &appsv1alpha1.FormatterConfig{
- Format: appsv1alpha1.Properties,
+ formatConfig: &v1.FormatterConfig{
+ Format: v1.Properties,
},
dsn: server.URL,
dataType: "patroni",
@@ -237,13 +238,13 @@ var _ = Describe("ReloadUtil Test", func() {
AfterEach(func() {
})
- createIniFormatter := func(sectionName string) *appsv1alpha1.FormatterConfig {
- return &appsv1alpha1.FormatterConfig{
- FormatterOptions: appsv1alpha1.FormatterOptions{
- IniConfig: &appsv1alpha1.IniConfig{
+ createIniFormatter := func(sectionName string) *v1.FormatterConfig {
+ return &v1.FormatterConfig{
+ FormatterAction: v1.FormatterAction{
+ IniConfig: &v1.IniConfig{
SectionName: sectionName,
}},
- Format: appsv1alpha1.Ini,
+ Format: v1.Ini,
}
}
@@ -353,7 +354,7 @@ var _ = Describe("ReloadUtil Test", func() {
},
ConfigConstraintRef: "cc2",
},
- ReloadType: appsv1alpha1.ShellType,
+ ReloadType: v1.ShellType,
},
}, {
ConfigSpecInfo: ConfigSpecInfo{
@@ -364,7 +365,7 @@ var _ = Describe("ReloadUtil Test", func() {
},
ConfigConstraintRef: "cc3",
},
- ReloadType: appsv1alpha1.TPLScriptType,
+ ReloadType: v1.TPLScriptType,
}}},
want: false,
}, {
@@ -378,7 +379,7 @@ var _ = Describe("ReloadUtil Test", func() {
},
ConfigConstraintRef: "cc1",
},
- ReloadType: appsv1alpha1.UnixSignalType,
+ ReloadType: v1.UnixSignalType,
},
}, {
ConfigSpecInfo: ConfigSpecInfo{
@@ -389,7 +390,7 @@ var _ = Describe("ReloadUtil Test", func() {
},
ConfigConstraintRef: "cc3",
},
- ReloadType: appsv1alpha1.TPLScriptType,
+ ReloadType: v1.TPLScriptType,
}}},
want: true,
}}
diff --git a/pkg/configuration/config_manager/signal_darwin.go b/pkg/configuration/config_manager/signal_darwin.go
index fc1aebcf7b8..841283b8e12 100644
--- a/pkg/configuration/config_manager/signal_darwin.go
+++ b/pkg/configuration/config_manager/signal_darwin.go
@@ -25,39 +25,39 @@ import (
"os"
"syscall"
- appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
)
-var allUnixSignals = map[appsv1alpha1.SignalType]os.Signal{
- appsv1alpha1.SIGHUP: syscall.SIGHUP, // reload signal for mysql 8.x.xxx
- appsv1alpha1.SIGINT: syscall.SIGINT,
- appsv1alpha1.SIGQUIT: syscall.SIGQUIT,
- appsv1alpha1.SIGILL: syscall.SIGILL,
- appsv1alpha1.SIGTRAP: syscall.SIGTRAP,
- appsv1alpha1.SIGABRT: syscall.SIGABRT,
- appsv1alpha1.SIGBUS: syscall.SIGBUS,
- appsv1alpha1.SIGFPE: syscall.SIGFPE,
- appsv1alpha1.SIGKILL: syscall.SIGKILL,
- appsv1alpha1.SIGUSR1: syscall.SIGUSR1,
- appsv1alpha1.SIGSEGV: syscall.SIGSEGV,
- appsv1alpha1.SIGUSR2: syscall.SIGUSR2,
- appsv1alpha1.SIGPIPE: syscall.SIGPIPE,
- appsv1alpha1.SIGALRM: syscall.SIGALRM,
- appsv1alpha1.SIGTERM: syscall.SIGTERM,
- // appsv1alpha1.SIGSTKFLT: syscall.SIGSTKFLT,
- appsv1alpha1.SIGCHLD: syscall.SIGCHLD,
- appsv1alpha1.SIGCONT: syscall.SIGCONT,
- appsv1alpha1.SIGSTOP: syscall.SIGSTOP,
- appsv1alpha1.SIGTSTP: syscall.SIGTSTP,
- appsv1alpha1.SIGTTIN: syscall.SIGTTIN,
- appsv1alpha1.SIGTTOU: syscall.SIGTTOU,
- appsv1alpha1.SIGURG: syscall.SIGURG,
- appsv1alpha1.SIGXCPU: syscall.SIGXCPU,
- appsv1alpha1.SIGXFSZ: syscall.SIGXFSZ,
- appsv1alpha1.SIGVTALRM: syscall.SIGVTALRM,
- appsv1alpha1.SIGPROF: syscall.SIGPROF,
- appsv1alpha1.SIGWINCH: syscall.SIGWINCH,
- appsv1alpha1.SIGIO: syscall.SIGIO,
- // appsv1alpha1.SIGPWR: syscall.SIGPWR,
- appsv1alpha1.SIGSYS: syscall.SIGSYS,
+var allUnixSignals = map[appsv1.SignalType]os.Signal{
+ appsv1.SIGHUP: syscall.SIGHUP, // reload signal for mysql 8.x.xxx
+ appsv1.SIGINT: syscall.SIGINT,
+ appsv1.SIGQUIT: syscall.SIGQUIT,
+ appsv1.SIGILL: syscall.SIGILL,
+ appsv1.SIGTRAP: syscall.SIGTRAP,
+ appsv1.SIGABRT: syscall.SIGABRT,
+ appsv1.SIGBUS: syscall.SIGBUS,
+ appsv1.SIGFPE: syscall.SIGFPE,
+ appsv1.SIGKILL: syscall.SIGKILL,
+ appsv1.SIGUSR1: syscall.SIGUSR1,
+ appsv1.SIGSEGV: syscall.SIGSEGV,
+ appsv1.SIGUSR2: syscall.SIGUSR2,
+ appsv1.SIGPIPE: syscall.SIGPIPE,
+ appsv1.SIGALRM: syscall.SIGALRM,
+ appsv1.SIGTERM: syscall.SIGTERM,
+ // appsv1.SIGSTKFLT: syscall.SIGSTKFLT,
+ appsv1.SIGCHLD: syscall.SIGCHLD,
+ appsv1.SIGCONT: syscall.SIGCONT,
+ appsv1.SIGSTOP: syscall.SIGSTOP,
+ appsv1.SIGTSTP: syscall.SIGTSTP,
+ appsv1.SIGTTIN: syscall.SIGTTIN,
+ appsv1.SIGTTOU: syscall.SIGTTOU,
+ appsv1.SIGURG: syscall.SIGURG,
+ appsv1.SIGXCPU: syscall.SIGXCPU,
+ appsv1.SIGXFSZ: syscall.SIGXFSZ,
+ appsv1.SIGVTALRM: syscall.SIGVTALRM,
+ appsv1.SIGPROF: syscall.SIGPROF,
+ appsv1.SIGWINCH: syscall.SIGWINCH,
+ appsv1.SIGIO: syscall.SIGIO,
+ // appsv1.SIGPWR: syscall.SIGPWR,
+ appsv1.SIGSYS: syscall.SIGSYS,
}
diff --git a/pkg/configuration/config_manager/signal_linux.go b/pkg/configuration/config_manager/signal_linux.go
index 5b4a70eb29b..51a70a93557 100644
--- a/pkg/configuration/config_manager/signal_linux.go
+++ b/pkg/configuration/config_manager/signal_linux.go
@@ -25,39 +25,39 @@ import (
"os"
"syscall"
- appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
)
-var allUnixSignals = map[appsv1alpha1.SignalType]os.Signal{
- appsv1alpha1.SIGHUP: syscall.SIGHUP, // reload signal for mysql 8.x.xxx
- appsv1alpha1.SIGINT: syscall.SIGINT,
- appsv1alpha1.SIGQUIT: syscall.SIGQUIT,
- appsv1alpha1.SIGILL: syscall.SIGILL,
- appsv1alpha1.SIGTRAP: syscall.SIGTRAP,
- appsv1alpha1.SIGABRT: syscall.SIGABRT,
- appsv1alpha1.SIGBUS: syscall.SIGBUS,
- appsv1alpha1.SIGFPE: syscall.SIGFPE,
- appsv1alpha1.SIGKILL: syscall.SIGKILL,
- appsv1alpha1.SIGUSR1: syscall.SIGUSR1,
- appsv1alpha1.SIGSEGV: syscall.SIGSEGV,
- appsv1alpha1.SIGUSR2: syscall.SIGUSR2,
- appsv1alpha1.SIGPIPE: syscall.SIGPIPE,
- appsv1alpha1.SIGALRM: syscall.SIGALRM,
- appsv1alpha1.SIGTERM: syscall.SIGTERM,
- appsv1alpha1.SIGSTKFLT: syscall.SIGSTKFLT,
- appsv1alpha1.SIGCHLD: syscall.SIGCHLD,
- appsv1alpha1.SIGCONT: syscall.SIGCONT,
- appsv1alpha1.SIGSTOP: syscall.SIGSTOP,
- appsv1alpha1.SIGTSTP: syscall.SIGTSTP,
- appsv1alpha1.SIGTTIN: syscall.SIGTTIN,
- appsv1alpha1.SIGTTOU: syscall.SIGTTOU,
- appsv1alpha1.SIGURG: syscall.SIGURG,
- appsv1alpha1.SIGXCPU: syscall.SIGXCPU,
- appsv1alpha1.SIGXFSZ: syscall.SIGXFSZ,
- appsv1alpha1.SIGVTALRM: syscall.SIGVTALRM,
- appsv1alpha1.SIGPROF: syscall.SIGPROF,
- appsv1alpha1.SIGWINCH: syscall.SIGWINCH,
- appsv1alpha1.SIGIO: syscall.SIGIO,
- appsv1alpha1.SIGPWR: syscall.SIGPWR,
- appsv1alpha1.SIGSYS: syscall.SIGSYS,
+var allUnixSignals = map[appsv1.SignalType]os.Signal{
+ appsv1.SIGHUP: syscall.SIGHUP, // reload signal for mysql 8.x.xxx
+ appsv1.SIGINT: syscall.SIGINT,
+ appsv1.SIGQUIT: syscall.SIGQUIT,
+ appsv1.SIGILL: syscall.SIGILL,
+ appsv1.SIGTRAP: syscall.SIGTRAP,
+ appsv1.SIGABRT: syscall.SIGABRT,
+ appsv1.SIGBUS: syscall.SIGBUS,
+ appsv1.SIGFPE: syscall.SIGFPE,
+ appsv1.SIGKILL: syscall.SIGKILL,
+ appsv1.SIGUSR1: syscall.SIGUSR1,
+ appsv1.SIGSEGV: syscall.SIGSEGV,
+ appsv1.SIGUSR2: syscall.SIGUSR2,
+ appsv1.SIGPIPE: syscall.SIGPIPE,
+ appsv1.SIGALRM: syscall.SIGALRM,
+ appsv1.SIGTERM: syscall.SIGTERM,
+ appsv1.SIGSTKFLT: syscall.SIGSTKFLT,
+ appsv1.SIGCHLD: syscall.SIGCHLD,
+ appsv1.SIGCONT: syscall.SIGCONT,
+ appsv1.SIGSTOP: syscall.SIGSTOP,
+ appsv1.SIGTSTP: syscall.SIGTSTP,
+ appsv1.SIGTTIN: syscall.SIGTTIN,
+ appsv1.SIGTTOU: syscall.SIGTTOU,
+ appsv1.SIGURG: syscall.SIGURG,
+ appsv1.SIGXCPU: syscall.SIGXCPU,
+ appsv1.SIGXFSZ: syscall.SIGXFSZ,
+ appsv1.SIGVTALRM: syscall.SIGVTALRM,
+ appsv1.SIGPROF: syscall.SIGPROF,
+ appsv1.SIGWINCH: syscall.SIGWINCH,
+ appsv1.SIGIO: syscall.SIGIO,
+ appsv1.SIGPWR: syscall.SIGPWR,
+ appsv1.SIGSYS: syscall.SIGSYS,
}
diff --git a/pkg/configuration/config_manager/signal_windows.go b/pkg/configuration/config_manager/signal_windows.go
index d320a2462ab..d503e878d0b 100644
--- a/pkg/configuration/config_manager/signal_windows.go
+++ b/pkg/configuration/config_manager/signal_windows.go
@@ -25,21 +25,21 @@ import (
"os"
"syscall"
- appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
)
-var allUnixSignals = map[appsv1alpha1.SignalType]os.Signal{
- appsv1alpha1.SIGHUP: syscall.SIGHUP,
- appsv1alpha1.SIGINT: syscall.SIGINT,
- appsv1alpha1.SIGQUIT: syscall.SIGQUIT,
- appsv1alpha1.SIGILL: syscall.SIGILL,
- appsv1alpha1.SIGTRAP: syscall.SIGTRAP,
- appsv1alpha1.SIGABRT: syscall.SIGABRT,
- appsv1alpha1.SIGBUS: syscall.SIGBUS,
- appsv1alpha1.SIGFPE: syscall.SIGFPE,
- appsv1alpha1.SIGKILL: syscall.SIGKILL,
- appsv1alpha1.SIGSEGV: syscall.SIGSEGV,
- appsv1alpha1.SIGPIPE: syscall.SIGPIPE,
- appsv1alpha1.SIGALRM: syscall.SIGALRM,
- appsv1alpha1.SIGTERM: syscall.SIGTERM,
+var allUnixSignals = map[appsv1.SignalType]os.Signal{
+ appsv1.SIGHUP: syscall.SIGHUP,
+ appsv1.SIGINT: syscall.SIGINT,
+ appsv1.SIGQUIT: syscall.SIGQUIT,
+ appsv1.SIGILL: syscall.SIGILL,
+ appsv1.SIGTRAP: syscall.SIGTRAP,
+ appsv1.SIGABRT: syscall.SIGABRT,
+ appsv1.SIGBUS: syscall.SIGBUS,
+ appsv1.SIGFPE: syscall.SIGFPE,
+ appsv1.SIGKILL: syscall.SIGKILL,
+ appsv1.SIGSEGV: syscall.SIGSEGV,
+ appsv1.SIGPIPE: syscall.SIGPIPE,
+ appsv1.SIGALRM: syscall.SIGALRM,
+ appsv1.SIGTERM: syscall.SIGTERM,
}
diff --git a/pkg/configuration/config_manager/type.go b/pkg/configuration/config_manager/type.go
index c7f699c974d..9abd0c08087 100644
--- a/pkg/configuration/config_manager/type.go
+++ b/pkg/configuration/config_manager/type.go
@@ -24,6 +24,7 @@ import (
"github.com/fsnotify/fsnotify"
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
)
@@ -34,13 +35,13 @@ type ConfigHandler interface {
}
type ConfigSpecInfo struct {
- *appsv1alpha1.ReloadOptions `json:",inline"`
+ *v1.DynamicReloadAction `json:",inline"`
- ReloadType appsv1alpha1.CfgReloadType `json:"reloadType"`
+ ReloadType v1.CfgReloadType `json:"reloadType"`
ConfigSpec appsv1alpha1.ComponentConfigSpec `json:"configSpec"`
- FormatterConfig appsv1alpha1.FormatterConfig `json:"formatterConfig"`
+ FormatterConfig v1.FormatterConfig `json:"formatterConfig"`
- DownwardAPIOptions []appsv1alpha1.DownwardAPIOption `json:"downwardAPIOptions"`
+ DownwardAPIOptions []v1.DownwardAction `json:"downwardAPIOptions"`
// config volume mount path
MountPoint string `json:"mountPoint"`
@@ -50,8 +51,8 @@ type ConfigSpecInfo struct {
type ConfigSpecMeta struct {
ConfigSpecInfo `json:",inline"`
- ScriptConfig []appsv1alpha1.ScriptConfig
- ToolsImageSpec *appsv1alpha1.ToolsImageSpec
+ ScriptConfig []v1.ScriptConfig
+ ToolsImageSpec *v1.ReloadToolsImage
}
type TPLScriptConfig struct {
@@ -60,13 +61,13 @@ type TPLScriptConfig struct {
DataType string `json:"dataType"`
DSN string `json:"dsn"`
- FormatterConfig appsv1alpha1.FormatterConfig `json:"formatterConfig"`
+ FormatterConfig v1.FormatterConfig `json:"formatterConfig"`
}
type ConfigLazyRenderedMeta struct {
*appsv1alpha1.ComponentConfigSpec `json:",inline"`
// secondary template path
- Templates []string `json:"templates"`
- FormatterConfig appsv1alpha1.FormatterConfig `json:"formatterConfig"`
+ Templates []string `json:"templates"`
+ FormatterConfig v1.FormatterConfig `json:"formatterConfig"`
}
diff --git a/pkg/configuration/core/config.go b/pkg/configuration/core/config.go
index 7c80997db2f..6f43872d001 100644
--- a/pkg/configuration/core/config.go
+++ b/pkg/configuration/core/config.go
@@ -27,7 +27,7 @@ import (
"github.com/StudioSol/set"
"github.com/spf13/cast"
- appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
"github.com/apecloud/kubeblocks/pkg/configuration/util"
"github.com/apecloud/kubeblocks/pkg/unstructured"
)
@@ -229,9 +229,9 @@ func NewCfgOptions(filename string, options ...Option) CfgOpOption {
return context
}
-func WithFormatterConfig(formatConfig *appsv1alpha1.FormatterConfig) Option {
+func WithFormatterConfig(formatConfig *v1.FormatterConfig) Option {
return func(ctx *CfgOpOption) {
- if formatConfig.Format == appsv1alpha1.Ini && formatConfig.IniConfig != nil {
+ if formatConfig.Format == v1.Ini && formatConfig.IniConfig != nil {
ctx.IniContext = &IniContext{
SectionName: formatConfig.IniConfig.SectionName,
}
@@ -239,8 +239,8 @@ func WithFormatterConfig(formatConfig *appsv1alpha1.FormatterConfig) Option {
}
}
-func NestedPrefixField(formatConfig *appsv1alpha1.FormatterConfig) string {
- if formatConfig != nil && formatConfig.Format == appsv1alpha1.Ini && formatConfig.IniConfig != nil {
+func NestedPrefixField(formatConfig *v1.FormatterConfig) string {
+ if formatConfig != nil && formatConfig.Format == v1.Ini && formatConfig.IniConfig != nil {
return formatConfig.IniConfig.SectionName
}
return ""
@@ -304,7 +304,7 @@ func FromCMKeysSelector(keys []string) *set.LinkedHashSetString {
return cmKeySet
}
-func GenerateVisualizedParamsList(configPatch *ConfigPatchInfo, formatConfig *appsv1alpha1.FormatterConfig, sets *set.LinkedHashSetString) []VisualizedParam {
+func GenerateVisualizedParamsList(configPatch *ConfigPatchInfo, formatConfig *v1.FormatterConfig, sets *set.LinkedHashSetString) []VisualizedParam {
if !configPatch.IsModify {
return nil
}
diff --git a/pkg/configuration/core/config_patch.go b/pkg/configuration/core/config_patch.go
index 7a975098dde..824a473817c 100644
--- a/pkg/configuration/core/config_patch.go
+++ b/pkg/configuration/core/config_patch.go
@@ -20,7 +20,7 @@ along with this program. If not, see .
package core
import (
- appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
"github.com/apecloud/kubeblocks/pkg/configuration/util"
)
@@ -90,7 +90,7 @@ func difference(base *cfgWrapper, target *cfgWrapper) (*ConfigPatchInfo, error)
return reconfigureInfo, nil
}
-func TransformConfigPatchFromData(data map[string]string, format appsv1alpha1.CfgFileFormat, keys []string) (*ConfigPatchInfo, error) {
+func TransformConfigPatchFromData(data map[string]string, format appsv1.CfgFileFormat, keys []string) (*ConfigPatchInfo, error) {
emptyData := func(m map[string]string) map[string]string {
r := make(map[string]string, len(m))
for key := range m {
diff --git a/pkg/configuration/core/config_patch_test.go b/pkg/configuration/core/config_patch_test.go
index 9fb507d8cb1..86b29609f54 100644
--- a/pkg/configuration/core/config_patch_test.go
+++ b/pkg/configuration/core/config_patch_test.go
@@ -28,7 +28,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/yaml"
- appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
"github.com/apecloud/kubeblocks/pkg/configuration/util"
)
@@ -37,7 +37,7 @@ func TestConfigPatch(t *testing.T) {
cfg, err := NewConfigLoader(CfgOption{
Type: CfgRawType,
Log: log.FromContext(context.Background()),
- CfgType: appsv1alpha1.Ini,
+ CfgType: appsv1.Ini,
RawData: []byte(iniConfig),
})
@@ -113,7 +113,7 @@ net:
patchOption := CfgOption{
Type: CfgTplType,
- CfgType: appsv1alpha1.YAML,
+ CfgType: appsv1.YAML,
}
patch, err := CreateMergePatch(&ConfigResource{ConfigData: map[string]string{"test": ""}}, &ConfigResource{ConfigData: map[string]string{"test": yamlContext}}, patchOption)
require.Nil(t, err)
@@ -130,7 +130,7 @@ func TestTransformConfigPatchFromData(t *testing.T) {
testData := "[mysqld]\nmax_connections = 2000\ngeneral_log = OFF"
t.Run("testConfigPatch", func(t *testing.T) {
- got, err := TransformConfigPatchFromData(map[string]string{configFile: testData}, appsv1alpha1.Ini, nil)
+ got, err := TransformConfigPatchFromData(map[string]string{configFile: testData}, appsv1.Ini, nil)
require.Nil(t, err)
require.True(t, got.IsModify)
require.NotNil(t, got.UpdateConfig[configFile])
diff --git a/pkg/configuration/core/config_patch_util.go b/pkg/configuration/core/config_patch_util.go
index 3409dc85d10..a1a81c1f39a 100644
--- a/pkg/configuration/core/config_patch_util.go
+++ b/pkg/configuration/core/config_patch_util.go
@@ -25,13 +25,13 @@ import (
"github.com/StudioSol/set"
"sigs.k8s.io/controller-runtime/pkg/log"
- appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
"github.com/apecloud/kubeblocks/pkg/configuration/util"
"github.com/apecloud/kubeblocks/pkg/unstructured"
)
// CreateConfigPatch creates a patch for configuration files with different version.
-func CreateConfigPatch(oldVersion, newVersion map[string]string, format appsv1alpha1.CfgFileFormat, keys []string, comparableAllFiles bool) (*ConfigPatchInfo, bool, error) {
+func CreateConfigPatch(oldVersion, newVersion map[string]string, format v1.CfgFileFormat, keys []string, comparableAllFiles bool) (*ConfigPatchInfo, bool, error) {
var hasFilesUpdated = false
if comparableAllFiles && len(keys) > 0 {
@@ -67,7 +67,7 @@ func checkExcludeConfigDifference(oldVersion map[string]string, newVersion map[s
return false
}
-func LoadRawConfigObject(data map[string]string, formatConfig *appsv1alpha1.FormatterConfig, keys []string) (map[string]unstructured.ConfigObject, error) {
+func LoadRawConfigObject(data map[string]string, formatConfig *v1.FormatterConfig, keys []string) (map[string]unstructured.ConfigObject, error) {
r := make(map[string]unstructured.ConfigObject)
cmKeySet := FromCMKeysSelector(keys)
for key, val := range data {
@@ -83,7 +83,7 @@ func LoadRawConfigObject(data map[string]string, formatConfig *appsv1alpha1.Form
return r, nil
}
-func FromConfigObject(name, config string, formatConfig *appsv1alpha1.FormatterConfig) (unstructured.ConfigObject, error) {
+func FromConfigObject(name, config string, formatConfig *v1.FormatterConfig) (unstructured.ConfigObject, error) {
configObject, err := unstructured.LoadConfig(name, config, formatConfig.Format)
if err != nil {
return nil, err
@@ -97,7 +97,7 @@ func FromConfigObject(name, config string, formatConfig *appsv1alpha1.FormatterC
// 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 TransformConfigFileToKeyValueMap(fileName string, formatterConfig *appsv1alpha1.FormatterConfig, configData []byte) (map[string]string, error) {
+func TransformConfigFileToKeyValueMap(fileName string, formatterConfig *v1.FormatterConfig, configData []byte) (map[string]string, error) {
oldData := map[string]string{
fileName: "",
}
diff --git a/pkg/configuration/core/config_patch_util_test.go b/pkg/configuration/core/config_patch_util_test.go
index 28b7b4e64b5..88e9a175ba9 100644
--- a/pkg/configuration/core/config_patch_util_test.go
+++ b/pkg/configuration/core/config_patch_util_test.go
@@ -23,7 +23,7 @@ import (
"reflect"
"testing"
- "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
"github.com/apecloud/kubeblocks/test/testdata"
)
@@ -196,7 +196,7 @@ max_connections=666
type args struct {
oldVersion map[string]string
newVersion map[string]string
- format v1alpha1.CfgFileFormat
+ format appsv1.CfgFileFormat
keys []string
enableExcludeDiff bool
}
@@ -215,7 +215,7 @@ max_connections=666
newVersion: map[string]string{
"my.cnf": v2,
},
- format: v1alpha1.Ini,
+ format: appsv1.Ini,
enableExcludeDiff: true,
},
want: &ConfigPatchInfo{IsModify: true},
@@ -231,7 +231,7 @@ max_connections=666
"my.cnf": v2,
"other.cnf": "context",
},
- format: v1alpha1.Ini,
+ format: appsv1.Ini,
enableExcludeDiff: true,
},
want: &ConfigPatchInfo{IsModify: true},
@@ -249,7 +249,7 @@ max_connections=666
"other.cnf": "context",
},
keys: []string{"my.cnf"},
- format: v1alpha1.Ini,
+ format: appsv1.Ini,
enableExcludeDiff: true,
},
want: &ConfigPatchInfo{IsModify: true},
@@ -266,7 +266,7 @@ max_connections=666
"other.cnf": "context difference",
},
keys: []string{"my.cnf"},
- format: v1alpha1.Ini,
+ format: appsv1.Ini,
enableExcludeDiff: true,
},
want: &ConfigPatchInfo{IsModify: false},
@@ -283,7 +283,7 @@ max_connections=666
"other.cnf": "context difference",
},
keys: []string{"my.cnf"},
- format: v1alpha1.Ini,
+ format: appsv1.Ini,
enableExcludeDiff: false,
},
want: &ConfigPatchInfo{IsModify: true},
@@ -314,7 +314,7 @@ func TestLoadRawConfigObject(t *testing.T) {
type args struct {
data map[string]string
- formatConfig *v1alpha1.FormatterConfig
+ formatConfig *appsv1.FormatterConfig
keys []string
}
tests := []struct {
@@ -325,10 +325,10 @@ func TestLoadRawConfigObject(t *testing.T) {
name: "test",
args: args{
data: map[string]string{"key": getFileContentFn("cue_testdata/mysql.cnf")},
- formatConfig: &v1alpha1.FormatterConfig{
- Format: v1alpha1.Ini,
- FormatterOptions: v1alpha1.FormatterOptions{
- IniConfig: &v1alpha1.IniConfig{
+ formatConfig: &appsv1.FormatterConfig{
+ Format: appsv1.Ini,
+ FormatterAction: appsv1.FormatterAction{
+ IniConfig: &appsv1.IniConfig{
SectionName: "mysqld",
}},
}},
@@ -337,8 +337,8 @@ func TestLoadRawConfigObject(t *testing.T) {
name: "test",
args: args{
data: map[string]string{"key": getFileContentFn("cue_testdata/pg14.conf")},
- formatConfig: &v1alpha1.FormatterConfig{
- Format: v1alpha1.Properties,
+ formatConfig: &appsv1.FormatterConfig{
+ Format: appsv1.Properties,
}},
wantErr: false,
}, {
@@ -349,8 +349,8 @@ func TestLoadRawConfigObject(t *testing.T) {
"key2": getFileContentFn("cue_testdata/mysql.cnf"),
},
keys: []string{"key"},
- formatConfig: &v1alpha1.FormatterConfig{
- Format: v1alpha1.Properties,
+ formatConfig: &appsv1.FormatterConfig{
+ Format: appsv1.Properties,
}},
wantErr: false,
}, {
@@ -360,8 +360,8 @@ func TestLoadRawConfigObject(t *testing.T) {
"key": getFileContentFn("cue_testdata/pg14.conf"),
},
keys: []string{"key"},
- formatConfig: &v1alpha1.FormatterConfig{
- Format: v1alpha1.XML,
+ formatConfig: &appsv1.FormatterConfig{
+ Format: appsv1.XML,
}},
wantErr: true,
}}
@@ -391,16 +391,16 @@ systemLog:
tests := []struct {
name string
fileName string
- formatConfig *v1alpha1.FormatterConfig
+ formatConfig *appsv1.FormatterConfig
configData []byte
expected map[string]string
}{{
name: "mysql-test",
fileName: "my.cnf",
- formatConfig: &v1alpha1.FormatterConfig{
- Format: v1alpha1.Ini,
- FormatterOptions: v1alpha1.FormatterOptions{
- IniConfig: &v1alpha1.IniConfig{
+ formatConfig: &appsv1.FormatterConfig{
+ Format: appsv1.Ini,
+ FormatterAction: appsv1.FormatterAction{
+ IniConfig: &appsv1.IniConfig{
SectionName: "mysqld",
},
},
@@ -413,10 +413,10 @@ systemLog:
}, {
name: "mongodb-test",
fileName: "mongodb.conf",
- formatConfig: &v1alpha1.FormatterConfig{
- Format: v1alpha1.YAML,
- FormatterOptions: v1alpha1.FormatterOptions{
- IniConfig: &v1alpha1.IniConfig{
+ formatConfig: &appsv1.FormatterConfig{
+ Format: appsv1.YAML,
+ FormatterAction: appsv1.FormatterAction{
+ IniConfig: &appsv1.IniConfig{
SectionName: "default",
},
},
diff --git a/pkg/configuration/core/config_query.go b/pkg/configuration/core/config_query.go
index 3792d35bff8..b671e6af6a8 100644
--- a/pkg/configuration/core/config_query.go
+++ b/pkg/configuration/core/config_query.go
@@ -25,7 +25,7 @@ import (
corev1 "k8s.io/api/core/v1"
"sigs.k8s.io/controller-runtime/pkg/log"
- appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
)
// GetParameterFromConfiguration gets configure parameter
@@ -42,7 +42,7 @@ func GetParameterFromConfiguration(configMap *corev1.ConfigMap, allFiles bool, f
wrapCfg, err := NewConfigLoader(CfgOption{
Type: CfgCmType,
Log: log.FromContext(context.Background()),
- CfgType: appsv1alpha1.Ini,
+ CfgType: appsv1.Ini,
ConfigResource: FromConfigData(configMap.Data, nil),
})
if err != nil {
diff --git a/pkg/configuration/core/config_test.go b/pkg/configuration/core/config_test.go
index aa5af04ebb2..32c09282bca 100644
--- a/pkg/configuration/core/config_test.go
+++ b/pkg/configuration/core/config_test.go
@@ -32,7 +32,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"
- appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
"github.com/apecloud/kubeblocks/pkg/configuration/util"
)
@@ -72,7 +72,7 @@ func TestConfigMapConfig(t *testing.T) {
cfg, err := NewConfigLoader(CfgOption{
Type: CfgCmType,
Log: log.FromContext(context.Background()),
- CfgType: appsv1alpha1.Ini,
+ CfgType: v1.Ini,
ConfigResource: &ConfigResource{
CfgKey: client.ObjectKey{
Name: "xxxx", // set cm name
@@ -153,7 +153,7 @@ func TestConfigMapConfig(t *testing.T) {
func TestGenerateVisualizedParamsList(t *testing.T) {
type args struct {
configPatch *ConfigPatchInfo
- formatConfig *appsv1alpha1.FormatterConfig
+ formatConfig *v1.FormatterConfig
sets *set.LinkedHashSetString
}
@@ -204,9 +204,9 @@ func TestGenerateVisualizedParamsList(t *testing.T) {
configPatch: &ConfigPatchInfo{
IsModify: true,
UpdateConfig: map[string][]byte{"key": testUpdatedParams}},
- formatConfig: &appsv1alpha1.FormatterConfig{
- Format: appsv1alpha1.Ini,
- FormatterOptions: appsv1alpha1.FormatterOptions{IniConfig: &appsv1alpha1.IniConfig{
+ formatConfig: &v1.FormatterConfig{
+ Format: v1.Ini,
+ FormatterAction: v1.FormatterAction{IniConfig: &v1.IniConfig{
SectionName: "mysqld",
}},
},
@@ -233,9 +233,9 @@ func TestGenerateVisualizedParamsList(t *testing.T) {
IsModify: true,
AddConfig: map[string]interface{}{"key": testJSON},
},
- formatConfig: &appsv1alpha1.FormatterConfig{
- Format: appsv1alpha1.Ini,
- FormatterOptions: appsv1alpha1.FormatterOptions{IniConfig: &appsv1alpha1.IniConfig{
+ formatConfig: &v1.FormatterConfig{
+ Format: v1.Ini,
+ FormatterAction: v1.FormatterAction{IniConfig: &v1.IniConfig{
SectionName: "mysqld",
}},
},
@@ -259,9 +259,9 @@ func TestGenerateVisualizedParamsList(t *testing.T) {
IsModify: true,
DeleteConfig: map[string]interface{}{"key": testJSON},
},
- formatConfig: &appsv1alpha1.FormatterConfig{
- Format: appsv1alpha1.Ini,
- FormatterOptions: appsv1alpha1.FormatterOptions{IniConfig: &appsv1alpha1.IniConfig{
+ formatConfig: &v1.FormatterConfig{
+ Format: v1.Ini,
+ FormatterAction: v1.FormatterAction{IniConfig: &v1.IniConfig{
SectionName: "mysqld",
}},
},
diff --git a/pkg/configuration/core/config_util.go b/pkg/configuration/core/config_util.go
index d9c3cbe1490..bd2b1df9f4c 100644
--- a/pkg/configuration/core/config_util.go
+++ b/pkg/configuration/core/config_util.go
@@ -28,6 +28,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
cfgutil "github.com/apecloud/kubeblocks/pkg/configuration/util"
)
@@ -95,7 +96,7 @@ func FromStringPointerMap(m map[string]string) map[string]*string {
return r
}
-func ApplyConfigPatch(baseCfg []byte, updatedParameters map[string]*string, formatConfig *appsv1alpha1.FormatterConfig) (string, error) {
+func ApplyConfigPatch(baseCfg []byte, updatedParameters map[string]*string, formatConfig *v1.FormatterConfig) (string, error) {
configLoaderOption := CfgOption{
Type: CfgRawType,
Log: log.FromContext(context.TODO()),
@@ -121,7 +122,7 @@ func NeedReloadVolume(config appsv1alpha1.ComponentConfigSpec) bool {
return config.ConfigConstraintRef != ""
}
-func GetReloadOptions(cli client.Client, ctx context.Context, configSpecs []appsv1alpha1.ComponentConfigSpec) (*appsv1alpha1.ReloadOptions, *appsv1alpha1.FormatterConfig, error) {
+func GetReloadOptions(cli client.Client, ctx context.Context, configSpecs []appsv1alpha1.ComponentConfigSpec) (*v1.DynamicReloadAction, *v1.FormatterConfig, error) {
for _, configSpec := range configSpecs {
if !NeedReloadVolume(configSpec) {
continue
@@ -130,25 +131,25 @@ func GetReloadOptions(cli client.Client, ctx context.Context, configSpecs []apps
Namespace: "",
Name: configSpec.ConfigConstraintRef,
}
- cfgConst := &appsv1alpha1.ConfigConstraint{}
+ cfgConst := &v1.ConfigConstraint{}
if err := cli.Get(ctx, ccKey, cfgConst); err != nil {
return nil, nil, WrapError(err, "failed to get ConfigConstraint, key[%v]", ccKey)
}
- if cfgConst.Spec.ReloadOptions != nil {
- return cfgConst.Spec.ReloadOptions, cfgConst.Spec.FormatterConfig, nil
+ if cfgConst.Spec.DynamicReloadAction != nil {
+ return cfgConst.Spec.DynamicReloadAction, cfgConst.Spec.FormatterConfig, nil
}
}
return nil, nil, nil
}
-func IsWatchModuleForShellTrigger(trigger *appsv1alpha1.ShellTrigger) bool {
+func IsWatchModuleForShellTrigger(trigger *v1.ShellTrigger) bool {
if trigger == nil || trigger.Sync == nil {
return true
}
return !*trigger.Sync
}
-func IsWatchModuleForTplTrigger(trigger *appsv1alpha1.TPLScriptTrigger) bool {
+func IsWatchModuleForTplTrigger(trigger *v1.TPLScriptTrigger) bool {
if trigger == nil || trigger.Sync == nil {
return true
}
diff --git a/pkg/configuration/core/config_util_test.go b/pkg/configuration/core/config_util_test.go
index db2b452063d..03771d48169 100644
--- a/pkg/configuration/core/config_util_test.go
+++ b/pkg/configuration/core/config_util_test.go
@@ -29,6 +29,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
"github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
cfgutil "github.com/apecloud/kubeblocks/pkg/configuration/util"
testutil "github.com/apecloud/kubeblocks/pkg/testutil/k8s"
@@ -50,10 +51,10 @@ var _ = Describe("config_util", func() {
Context("common funcs test", func() {
It("GetReloadOptions Should success without error", func() {
- mockTpl := v1alpha1.ConfigConstraint{
- Spec: v1alpha1.ConfigConstraintSpec{
- ReloadOptions: &v1alpha1.ReloadOptions{
- UnixSignalTrigger: &v1alpha1.UnixSignalTrigger{
+ mockTpl := v1.ConfigConstraint{
+ Spec: v1.ConfigConstraintSpec{
+ DynamicReloadAction: &v1.DynamicReloadAction{
+ UnixSignalTrigger: &v1.UnixSignalTrigger{
Signal: "HUB",
ProcessName: "for_test",
},
@@ -63,7 +64,7 @@ var _ = Describe("config_util", func() {
tests := []struct {
name string
tpls []v1alpha1.ComponentConfigSpec
- want *v1alpha1.ReloadOptions
+ want *v1.DynamicReloadAction
wantErr bool
}{{
// empty config templates
@@ -100,7 +101,7 @@ var _ = Describe("config_util", func() {
},
ConfigConstraintRef: "eg_v1",
}},
- want: mockTpl.Spec.ReloadOptions,
+ want: mockTpl.Spec.DynamicReloadAction,
wantErr: false,
}, {
// not exist config constraint
@@ -190,7 +191,7 @@ func TestApplyConfigPatch(t *testing.T) {
type args struct {
baseCfg []byte
updatedParameters map[string]string
- formatConfig *v1alpha1.FormatterConfig
+ formatConfig *v1.FormatterConfig
}
tests := []struct {
name string
@@ -206,10 +207,10 @@ test=test`),
"a": "b",
"max_connections": "600",
},
- formatConfig: &v1alpha1.FormatterConfig{
- Format: v1alpha1.Ini,
- FormatterOptions: v1alpha1.FormatterOptions{
- IniConfig: &v1alpha1.IniConfig{
+ formatConfig: &v1.FormatterConfig{
+ Format: v1.Ini,
+ FormatterAction: v1.FormatterAction{
+ IniConfig: &v1.IniConfig{
SectionName: "test",
}}},
},
@@ -227,8 +228,8 @@ test=test
"a": "b",
"c": "d e f g",
},
- formatConfig: &v1alpha1.FormatterConfig{
- Format: v1alpha1.RedisCfg,
+ formatConfig: &v1.FormatterConfig{
+ Format: v1.RedisCfg,
},
},
want: "a b\nc d e f g",
@@ -241,8 +242,8 @@ test=test
"ENABLE_MODULES": "true",
"HUGGINGFACE_APIKEY": "kssdlsdjskwssl",
},
- formatConfig: &v1alpha1.FormatterConfig{
- Format: v1alpha1.Dotenv,
+ formatConfig: &v1.FormatterConfig{
+ Format: v1.Dotenv,
},
},
// fix begin
diff --git a/pkg/configuration/core/reconfigure_util.go b/pkg/configuration/core/reconfigure_util.go
index 26cc7a1af6f..588542dfae8 100644
--- a/pkg/configuration/core/reconfigure_util.go
+++ b/pkg/configuration/core/reconfigure_util.go
@@ -28,7 +28,7 @@ import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"sigs.k8s.io/controller-runtime/pkg/client"
- appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
"github.com/apecloud/kubeblocks/pkg/configuration/util"
"github.com/apecloud/kubeblocks/pkg/constant"
)
@@ -78,7 +78,7 @@ func trimNestedField(updatedParams any, trimField string) (any, error) {
}
// ValidateConfigPatch Verifies if the changed parameters have been removed
-func ValidateConfigPatch(patch *ConfigPatchInfo, formatCfg *appsv1alpha1.FormatterConfig) error {
+func ValidateConfigPatch(patch *ConfigPatchInfo, formatCfg *appsv1.FormatterConfig) error {
if !patch.IsModify || len(patch.UpdateConfig) == 0 {
return nil
}
@@ -95,7 +95,7 @@ func ValidateConfigPatch(patch *ConfigPatchInfo, formatCfg *appsv1alpha1.Formatt
}
// IsUpdateDynamicParameters checks if the changed parameters require a restart
-func IsUpdateDynamicParameters(cc *appsv1alpha1.ConfigConstraintSpec, cfg *ConfigPatchInfo) (bool, error) {
+func IsUpdateDynamicParameters(cc *appsv1.ConfigConstraintSpec, cfg *ConfigPatchInfo) (bool, error) {
if len(cfg.DeleteConfig) > 0 || len(cfg.AddConfig) > 0 {
return false, nil
}
@@ -135,7 +135,7 @@ func IsUpdateDynamicParameters(cc *appsv1alpha1.ConfigConstraintSpec, cfg *Confi
}
// IsDynamicParameter checks if the parameter supports hot update
-func IsDynamicParameter(paramName string, cc *appsv1alpha1.ConfigConstraintSpec) bool {
+func IsDynamicParameter(paramName string, cc *appsv1.ConfigConstraintSpec) bool {
if len(cc.DynamicParameters) != 0 {
return slices.Contains(cc.DynamicParameters, paramName)
}
diff --git a/pkg/configuration/core/reconfigure_util_test.go b/pkg/configuration/core/reconfigure_util_test.go
index d9cf3c06a5d..b558b4b77d0 100644
--- a/pkg/configuration/core/reconfigure_util_test.go
+++ b/pkg/configuration/core/reconfigure_util_test.go
@@ -28,7 +28,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
- appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
"github.com/apecloud/kubeblocks/pkg/configuration/util"
"github.com/apecloud/kubeblocks/pkg/constant"
)
@@ -84,7 +84,7 @@ func newCfgDiffMeta(testData string, add, delete map[string]interface{}) *Config
func TestIsUpdateDynamicParameters(t *testing.T) {
type args struct {
- ccSpec *appsv1alpha1.ConfigConstraintSpec
+ ccSpec *v1.ConfigConstraintSpec
diff *ConfigPatchInfo
}
tests := []struct {
@@ -96,7 +96,7 @@ func TestIsUpdateDynamicParameters(t *testing.T) {
name: "test",
// null
args: args{
- ccSpec: &appsv1alpha1.ConfigConstraintSpec{},
+ ccSpec: &v1.ConfigConstraintSpec{},
diff: newCfgDiffMeta(`null`, nil, nil),
},
want: true,
@@ -105,7 +105,7 @@ func TestIsUpdateDynamicParameters(t *testing.T) {
name: "test",
// error
args: args{
- ccSpec: &appsv1alpha1.ConfigConstraintSpec{},
+ ccSpec: &v1.ConfigConstraintSpec{},
diff: newCfgDiffMeta(`invalid json formatter`, nil, nil),
},
want: false,
@@ -114,7 +114,7 @@ func TestIsUpdateDynamicParameters(t *testing.T) {
name: "test",
// add/delete config file
args: args{
- ccSpec: &appsv1alpha1.ConfigConstraintSpec{},
+ ccSpec: &v1.ConfigConstraintSpec{},
diff: newCfgDiffMeta(`{}`, map[string]interface{}{"a": "b"}, nil),
},
want: false,
@@ -123,7 +123,7 @@ func TestIsUpdateDynamicParameters(t *testing.T) {
name: "test",
// not set static or dynamic parameters
args: args{
- ccSpec: &appsv1alpha1.ConfigConstraintSpec{},
+ ccSpec: &v1.ConfigConstraintSpec{},
diff: newCfgDiffMeta(`{"a":"b"}`, nil, nil),
},
want: false,
@@ -132,7 +132,7 @@ func TestIsUpdateDynamicParameters(t *testing.T) {
name: "test",
// static parameters contains
args: args{
- ccSpec: &appsv1alpha1.ConfigConstraintSpec{
+ ccSpec: &v1.ConfigConstraintSpec{
StaticParameters: []string{"param1", "param2", "param3"},
},
diff: newCfgDiffMeta(`{"param3":"b"}`, nil, nil),
@@ -143,7 +143,7 @@ func TestIsUpdateDynamicParameters(t *testing.T) {
name: "test",
// static parameters not contains
args: args{
- ccSpec: &appsv1alpha1.ConfigConstraintSpec{
+ ccSpec: &v1.ConfigConstraintSpec{
StaticParameters: []string{"param1", "param2", "param3"},
},
diff: newCfgDiffMeta(`{"param4":"b"}`, nil, nil),
@@ -154,7 +154,7 @@ func TestIsUpdateDynamicParameters(t *testing.T) {
name: "test",
// dynamic parameters contains
args: args{
- ccSpec: &appsv1alpha1.ConfigConstraintSpec{
+ ccSpec: &v1.ConfigConstraintSpec{
DynamicParameters: []string{"param1", "param2", "param3"},
},
diff: newCfgDiffMeta(`{"param1":"b", "param3": 20}`, nil, nil),
@@ -165,7 +165,7 @@ func TestIsUpdateDynamicParameters(t *testing.T) {
name: "test",
// dynamic parameters not contains
args: args{
- ccSpec: &appsv1alpha1.ConfigConstraintSpec{
+ ccSpec: &v1.ConfigConstraintSpec{
DynamicParameters: []string{"param1", "param2", "param3"},
},
diff: newCfgDiffMeta(`{"param1":"b", "param4": 20}`, nil, nil),
@@ -176,7 +176,7 @@ func TestIsUpdateDynamicParameters(t *testing.T) {
name: "test",
// dynamic/static parameters not contains
args: args{
- ccSpec: &appsv1alpha1.ConfigConstraintSpec{
+ ccSpec: &v1.ConfigConstraintSpec{
DynamicParameters: []string{"dparam1", "dparam2", "dparam3"},
StaticParameters: []string{"sparam1", "sparam2", "sparam3"},
},
@@ -188,7 +188,7 @@ func TestIsUpdateDynamicParameters(t *testing.T) {
name: "empty-test",
// dynamic/static parameters not contains
args: args{
- ccSpec: &appsv1alpha1.ConfigConstraintSpec{
+ ccSpec: &v1.ConfigConstraintSpec{
DynamicParameters: []string{},
StaticParameters: []string{},
},
@@ -288,7 +288,7 @@ func TestSetParametersUpdateSource(t *testing.T) {
func TestValidateConfigPatch(t *testing.T) {
type args struct {
patch *ConfigPatchInfo
- formatCfg *appsv1alpha1.FormatterConfig
+ formatCfg *v1.FormatterConfig
}
tests := []struct {
name string
@@ -298,7 +298,7 @@ func TestValidateConfigPatch(t *testing.T) {
name: "test",
args: args{
patch: &ConfigPatchInfo{},
- formatCfg: &appsv1alpha1.FormatterConfig{Format: appsv1alpha1.YAML},
+ formatCfg: &v1.FormatterConfig{Format: v1.YAML},
},
wantErr: false,
}, {
@@ -310,7 +310,7 @@ func TestValidateConfigPatch(t *testing.T) {
"file1": []byte(`{"a":"b"}`),
},
},
- formatCfg: &appsv1alpha1.FormatterConfig{Format: appsv1alpha1.YAML},
+ formatCfg: &v1.FormatterConfig{Format: v1.YAML},
},
wantErr: false,
}, {
@@ -322,7 +322,7 @@ func TestValidateConfigPatch(t *testing.T) {
"file1": []byte(`{"a":null}`),
},
},
- formatCfg: &appsv1alpha1.FormatterConfig{Format: appsv1alpha1.YAML},
+ formatCfg: &v1.FormatterConfig{Format: v1.YAML},
},
wantErr: true,
}}
@@ -338,7 +338,7 @@ func TestValidateConfigPatch(t *testing.T) {
func TestIsDynamicParameter(t *testing.T) {
type args struct {
paramName string
- ccSpec *appsv1alpha1.ConfigConstraintSpec
+ ccSpec *v1.ConfigConstraintSpec
}
tests := []struct {
name string
@@ -349,14 +349,14 @@ func TestIsDynamicParameter(t *testing.T) {
// null
args: args{
paramName: "test",
- ccSpec: &appsv1alpha1.ConfigConstraintSpec{},
+ ccSpec: &v1.ConfigConstraintSpec{},
},
want: false,
}, {
name: "test",
// static parameters contains
args: args{
- ccSpec: &appsv1alpha1.ConfigConstraintSpec{
+ ccSpec: &v1.ConfigConstraintSpec{
StaticParameters: []string{"param1", "param2", "param3"},
},
paramName: "param3",
@@ -367,7 +367,7 @@ func TestIsDynamicParameter(t *testing.T) {
// static parameters not contains
args: args{
paramName: "param4",
- ccSpec: &appsv1alpha1.ConfigConstraintSpec{
+ ccSpec: &v1.ConfigConstraintSpec{
StaticParameters: []string{"param1", "param2", "param3"},
},
},
@@ -377,7 +377,7 @@ func TestIsDynamicParameter(t *testing.T) {
// dynamic parameters contains
args: args{
paramName: "param1",
- ccSpec: &appsv1alpha1.ConfigConstraintSpec{
+ ccSpec: &v1.ConfigConstraintSpec{
DynamicParameters: []string{"param1", "param2", "param3"},
},
},
@@ -387,7 +387,7 @@ func TestIsDynamicParameter(t *testing.T) {
// dynamic/static parameters not contains
args: args{
paramName: "test",
- ccSpec: &appsv1alpha1.ConfigConstraintSpec{
+ ccSpec: &v1.ConfigConstraintSpec{
DynamicParameters: []string{"dparam1", "dparam2", "dparam3"},
StaticParameters: []string{"sparam1", "sparam2", "sparam3"},
},
diff --git a/pkg/configuration/core/type.go b/pkg/configuration/core/type.go
index f003936d4f8..6876591d41b 100644
--- a/pkg/configuration/core/type.go
+++ b/pkg/configuration/core/type.go
@@ -27,6 +27,7 @@ import (
"github.com/go-logr/logr"
"sigs.k8s.io/controller-runtime/pkg/client"
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
"github.com/apecloud/kubeblocks/pkg/constant"
)
@@ -42,7 +43,7 @@ const (
type RawConfig struct {
// formatter
- Type appsv1alpha1.CfgFileFormat
+ Type v1.CfgFileFormat
RawData string
}
@@ -123,7 +124,7 @@ type CfgOption struct {
Log logr.Logger
// formatter
- CfgType appsv1alpha1.CfgFileFormat
+ CfgType v1.CfgFileFormat
// Path for CfgLocalType test
Path string
diff --git a/pkg/configuration/validate/config_validate.go b/pkg/configuration/validate/config_validate.go
index ced76d90672..eb5a20cb67e 100644
--- a/pkg/configuration/validate/config_validate.go
+++ b/pkg/configuration/validate/config_validate.go
@@ -27,7 +27,7 @@ import (
"k8s.io/kube-openapi/pkg/validation/strfmt"
"k8s.io/kube-openapi/pkg/validation/validate"
- appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
"github.com/apecloud/kubeblocks/pkg/configuration/core"
)
@@ -50,7 +50,7 @@ type configCueValidator struct {
// cue describes configuration template
cueScript string
- cfgType appsv1alpha1.CfgFileFormat
+ cfgType appsv1.CfgFileFormat
}
func (s *cmKeySelector) filter(key string) bool {
@@ -86,7 +86,7 @@ type schemaValidator struct {
typeName string
schema *apiext.JSONSchemaProps
- cfgType appsv1alpha1.CfgFileFormat
+ cfgType appsv1.CfgFileFormat
}
func (s *schemaValidator) Validate(data map[string]string) error {
@@ -125,10 +125,10 @@ func WithKeySelector(keys []string) ValidatorOptions {
}
}
-func NewConfigValidator(configConstraint *appsv1alpha1.ConfigConstraintSpec, options ...ValidatorOptions) ConfigValidator {
+func NewConfigValidator(configConstraint *appsv1.ConfigConstraintSpec, options ...ValidatorOptions) ConfigValidator {
var (
validator ConfigValidator
- configSchema = configConstraint.ConfigurationSchema
+ configSchema = configConstraint.ConfigSchema
)
switch {
@@ -142,14 +142,14 @@ func NewConfigValidator(configConstraint *appsv1alpha1.ConfigConstraintSpec, opt
cfgType: configConstraint.FormatterConfig.Format,
cueScript: configSchema.CUE,
}
- case configSchema.Schema != nil:
+ case configSchema.SchemaInJSON != nil:
validator = &schemaValidator{
cmKeySelector: cmKeySelector{
keySelector: options,
},
- typeName: configConstraint.CfgSchemaTopLevelName,
+ typeName: configConstraint.ConfigSchemaTopLevelKey,
cfgType: configConstraint.FormatterConfig.Format,
- schema: configSchema.Schema,
+ schema: configSchema.SchemaInJSON,
}
default:
validator = &emptyValidator{}
diff --git a/pkg/configuration/validate/config_validate_test.go b/pkg/configuration/validate/config_validate_test.go
index 311c8845a05..b7a796132d8 100644
--- a/pkg/configuration/validate/config_validate_test.go
+++ b/pkg/configuration/validate/config_validate_test.go
@@ -25,7 +25,7 @@ import (
"github.com/stretchr/testify/require"
- appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
"github.com/apecloud/kubeblocks/test/testdata"
)
@@ -37,12 +37,12 @@ var fromTestData = func(fileName string) string {
return string(content)
}
-var newFakeConfConstraint = func(cueFile string, cfgFormatter appsv1alpha1.CfgFileFormat) *appsv1alpha1.ConfigConstraintSpec {
- return &appsv1alpha1.ConfigConstraintSpec{
- ConfigurationSchema: &appsv1alpha1.CustomParametersValidation{
+var newFakeConfConstraint = func(cueFile string, cfgFormatter appsv1.CfgFileFormat) *appsv1.ConfigConstraintSpec {
+ return &appsv1.ConfigConstraintSpec{
+ ConfigSchema: &appsv1.ConfigSchema{
CUE: fromTestData(cueFile),
},
- FormatterConfig: &appsv1alpha1.FormatterConfig{
+ FormatterConfig: &appsv1.FormatterConfig{
Format: cfgFormatter,
},
}
@@ -52,7 +52,7 @@ func TestSchemaValidatorWithCue(t *testing.T) {
type args struct {
cueFile string
configFile string
- format appsv1alpha1.CfgFileFormat
+ format appsv1.CfgFileFormat
options []ValidatorOptions
}
tests := []struct {
@@ -64,7 +64,7 @@ func TestSchemaValidatorWithCue(t *testing.T) {
args: args{
cueFile: "cue_testdata/mongod.cue",
configFile: "cue_testdata/mongod.conf",
- format: appsv1alpha1.YAML,
+ format: appsv1.YAML,
},
err: nil,
}, {
@@ -72,7 +72,7 @@ func TestSchemaValidatorWithCue(t *testing.T) {
args: args{
cueFile: "cue_testdata/wesql.cue",
configFile: "cue_testdata/wesql.cnf",
- format: appsv1alpha1.Ini,
+ format: appsv1.Ini,
},
err: nil,
}, {
@@ -80,7 +80,7 @@ func TestSchemaValidatorWithCue(t *testing.T) {
args: args{
cueFile: "cue_testdata/pg14.cue",
configFile: "cue_testdata/pg14.conf",
- format: appsv1alpha1.Properties,
+ format: appsv1.Properties,
},
err: nil,
}, {
@@ -88,7 +88,7 @@ func TestSchemaValidatorWithCue(t *testing.T) {
args: args{
cueFile: "cue_testdata/clickhouse.cue",
configFile: "cue_testdata/clickhouse.xml",
- format: appsv1alpha1.XML,
+ format: appsv1.XML,
},
err: nil,
}, {
@@ -96,7 +96,7 @@ func TestSchemaValidatorWithCue(t *testing.T) {
args: args{
cueFile: "cue_testdata/mysql.cue",
configFile: "cue_testdata/mysql.cnf",
- format: appsv1alpha1.Ini,
+ format: appsv1.Ini,
},
err: nil,
}, {
@@ -104,7 +104,7 @@ func TestSchemaValidatorWithCue(t *testing.T) {
args: args{
cueFile: "cue_testdata/mysql.cue",
configFile: "cue_testdata/mysql_err.cnf",
- format: appsv1alpha1.Ini,
+ format: appsv1.Ini,
},
err: errors.New(`failed to render cue template configure: [mysqld.innodb_autoinc_lock_mode: 3 errors in empty disjunction:
mysqld.innodb_autoinc_lock_mode: conflicting values 0 and 100:
@@ -118,7 +118,7 @@ mysqld.innodb_autoinc_lock_mode: conflicting values 2 and 100:
args: args{
cueFile: "cue_testdata/mysql.cue",
configFile: "cue_testdata/mysql_err.cnf",
- format: appsv1alpha1.Ini,
+ format: appsv1.Ini,
options: []ValidatorOptions{WithKeySelector([]string{"key2", "key3"})},
},
}}
@@ -136,7 +136,7 @@ mysqld.innodb_autoinc_lock_mode: conflicting values 2 and 100:
}
func TestSchemaValidatorWithSelector(t *testing.T) {
- validator := NewConfigValidator(newFakeConfConstraint("cue_testdata/mysql.cue", appsv1alpha1.Ini))
+ validator := NewConfigValidator(newFakeConfConstraint("cue_testdata/mysql.cue", appsv1.Ini))
require.NotNil(t, validator)
require.ErrorContains(t, validator.Validate(
map[string]string{
@@ -144,7 +144,7 @@ func TestSchemaValidatorWithSelector(t *testing.T) {
"abnormal_key": fromTestData("cue_testdata/mysql_err.cnf"),
}), "[mysqld.innodb_autoinc_lock_mode: 3 errors in empty disjunction")
- validator = NewConfigValidator(newFakeConfConstraint("cue_testdata/mysql.cue", appsv1alpha1.Ini), WithKeySelector([]string{}))
+ validator = NewConfigValidator(newFakeConfConstraint("cue_testdata/mysql.cue", appsv1.Ini), WithKeySelector([]string{}))
require.NotNil(t, validator)
require.ErrorContains(t, validator.Validate(
map[string]string{
@@ -152,7 +152,7 @@ func TestSchemaValidatorWithSelector(t *testing.T) {
"abnormal_key": fromTestData("cue_testdata/mysql_err.cnf"),
}), "[mysqld.innodb_autoinc_lock_mode: 3 errors in empty disjunction")
- validator = NewConfigValidator(newFakeConfConstraint("cue_testdata/mysql.cue", appsv1alpha1.Ini), WithKeySelector([]string{"normal_key"}))
+ validator = NewConfigValidator(newFakeConfConstraint("cue_testdata/mysql.cue", appsv1.Ini), WithKeySelector([]string{"normal_key"}))
require.NotNil(t, validator)
require.Nil(t, validator.Validate(
map[string]string{
@@ -165,7 +165,7 @@ func TestSchemaValidatorWithOpenSchema(t *testing.T) {
type args struct {
cueFile string
configFile string
- format appsv1alpha1.CfgFileFormat
+ format appsv1.CfgFileFormat
SchemaTypeName string
}
tests := []struct {
@@ -177,7 +177,7 @@ func TestSchemaValidatorWithOpenSchema(t *testing.T) {
args: args{
cueFile: "cue_testdata/mysql.cue",
configFile: "cue_testdata/mysql.cnf",
- format: appsv1alpha1.Ini,
+ format: appsv1.Ini,
},
err: nil,
}}
@@ -188,7 +188,7 @@ func TestSchemaValidatorWithOpenSchema(t *testing.T) {
validator := &schemaValidator{
typeName: tt.args.SchemaTypeName,
cfgType: tplConstraint.FormatterConfig.Format,
- schema: tplConstraint.ConfigurationSchema.Schema,
+ schema: tplConstraint.ConfigSchema.SchemaInJSON,
}
require.Equal(t, tt.err, validator.Validate(
map[string]string{
diff --git a/pkg/configuration/validate/cue_util.go b/pkg/configuration/validate/cue_util.go
index 2190bb56e05..861a749bc76 100644
--- a/pkg/configuration/validate/cue_util.go
+++ b/pkg/configuration/validate/cue_util.go
@@ -23,7 +23,7 @@ import (
"cuelang.org/go/cue"
"cuelang.org/go/cue/cuecontext"
- appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
"github.com/apecloud/kubeblocks/pkg/configuration/core"
"github.com/apecloud/kubeblocks/pkg/unstructured"
)
@@ -56,16 +56,16 @@ func CueValidate(cueTpl string) error {
return tpl.Validate()
}
-func ValidateConfigurationWithCue(cueString string, cfgType appsv1alpha1.CfgFileFormat, rawData string) error {
+func ValidateConfigurationWithCue(cueString string, cfgType appsv1.CfgFileFormat, rawData string) error {
parameters, err := LoadConfigObjectFromContent(cfgType, rawData)
if err != nil {
return core.WrapError(err, "failed to load configuration [%s]", rawData)
}
- return unstructuredDataValidateByCue(cueString, parameters, cfgType == appsv1alpha1.Properties || cfgType == appsv1alpha1.PropertiesPlus)
+ return unstructuredDataValidateByCue(cueString, parameters, cfgType == appsv1.Properties || cfgType == appsv1.PropertiesPlus)
}
-func LoadConfigObjectFromContent(cfgType appsv1alpha1.CfgFileFormat, rawData string) (map[string]interface{}, error) {
+func LoadConfigObjectFromContent(cfgType appsv1.CfgFileFormat, rawData string) (map[string]interface{}, error) {
configObject, err := unstructured.LoadConfig("validate", rawData, cfgType)
if err != nil {
return nil, err
diff --git a/pkg/controller/component/suite_test.go b/pkg/controller/component/suite_test.go
index 1401e232141..a83069d4a30 100644
--- a/pkg/controller/component/suite_test.go
+++ b/pkg/controller/component/suite_test.go
@@ -38,6 +38,7 @@ import (
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
dpv1alpha1 "github.com/apecloud/kubeblocks/apis/dataprotection/v1alpha1"
"github.com/apecloud/kubeblocks/pkg/controller/model"
@@ -61,6 +62,7 @@ var logger logr.Logger
func init() {
viper.AutomaticEnv()
model.AddScheme(appsv1alpha1.AddToScheme)
+ model.AddScheme(appsv1.AddToScheme)
// viper.Set("ENABLE_DEBUG_LOG", "true")
}
@@ -102,6 +104,9 @@ var _ = BeforeSuite(func() {
err = appsv1alpha1.AddToScheme(scheme.Scheme)
Expect(err).NotTo(HaveOccurred())
+ err = appsv1.AddToScheme(scheme.Scheme)
+ Expect(err).NotTo(HaveOccurred())
+
err = dpv1alpha1.AddToScheme(scheme.Scheme)
Expect(err).NotTo(HaveOccurred())
diff --git a/pkg/controller/configuration/envfrom_utils.go b/pkg/controller/configuration/envfrom_utils.go
index b71adbe733f..48f37fc7cbc 100644
--- a/pkg/controller/configuration/envfrom_utils.go
+++ b/pkg/controller/configuration/envfrom_utils.go
@@ -27,6 +27,7 @@ import (
apierrors "k8s.io/apimachinery/pkg/api/errors"
"sigs.k8s.io/controller-runtime/pkg/client"
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
"github.com/apecloud/kubeblocks/pkg/configuration/core"
cfgutil "github.com/apecloud/kubeblocks/pkg/configuration/util"
@@ -77,12 +78,12 @@ func injectTemplateEnvFrom(cluster *appsv1alpha1.Cluster, component *component.S
return nil
}
-func getConfigConstraint(template appsv1alpha1.ComponentConfigSpec, cli client.Client, ctx context.Context) (*appsv1alpha1.ConfigConstraintSpec, error) {
+func getConfigConstraint(template appsv1alpha1.ComponentConfigSpec, cli client.Client, ctx context.Context) (*v1.ConfigConstraintSpec, error) {
ccKey := client.ObjectKey{
Namespace: "",
Name: template.ConfigConstraintRef,
}
- cc := &appsv1alpha1.ConfigConstraint{}
+ cc := &v1.ConfigConstraint{}
if err := cli.Get(ctx, ccKey, cc); err != nil {
return nil, core.WrapError(err, "failed to get ConfigConstraint, key[%v]", ccKey)
}
@@ -92,7 +93,7 @@ func getConfigConstraint(template appsv1alpha1.ComponentConfigSpec, cli client.C
return &cc.Spec, nil
}
-func fromConfigmapFiles(keys []string, cm *corev1.ConfigMap, formatter *appsv1alpha1.FormatterConfig) (map[string]string, error) {
+func fromConfigmapFiles(keys []string, cm *corev1.ConfigMap, formatter *v1.FormatterConfig) (map[string]string, error) {
mergeMap := func(dst, src map[string]string) {
for key, val := range src {
dst[key] = val
@@ -175,7 +176,7 @@ func injectEnvFrom(containers []corev1.Container, asEnvFrom []string, cmName str
}
}
-func fromFileContent(format *appsv1alpha1.FormatterConfig, configContext string) (map[string]string, error) {
+func fromFileContent(format *v1.FormatterConfig, configContext string) (map[string]string, error) {
keyValue, err := validate.LoadConfigObjectFromContent(format.Format, configContext)
if err != nil {
return nil, err
@@ -195,7 +196,7 @@ func fromConfigSpec(configSpec appsv1alpha1.ComponentConfigSpec, cm *corev1.Conf
return keys
}
-func SyncEnvConfigmap(configSpec appsv1alpha1.ComponentConfigSpec, cmObj *corev1.ConfigMap, cc *appsv1alpha1.ConfigConstraintSpec, cli client.Client, ctx context.Context) error {
+func SyncEnvConfigmap(configSpec appsv1alpha1.ComponentConfigSpec, cmObj *corev1.ConfigMap, cc *v1.ConfigConstraintSpec, cli client.Client, ctx context.Context) error {
if len(configSpec.AsEnvFrom) == 0 || cc == nil || cc.FormatterConfig == nil {
return nil
}
diff --git a/pkg/controller/configuration/envfrom_utils_test.go b/pkg/controller/configuration/envfrom_utils_test.go
index a0f941283a7..5a2ab41bc45 100644
--- a/pkg/controller/configuration/envfrom_utils_test.go
+++ b/pkg/controller/configuration/envfrom_utils_test.go
@@ -26,6 +26,7 @@ import (
corev1 "k8s.io/api/core/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
"github.com/apecloud/kubeblocks/pkg/configuration/core"
"github.com/apecloud/kubeblocks/pkg/controller/component"
@@ -51,7 +52,7 @@ var _ = Describe("ConfigEnvFrom test", func() {
k8sMockClient *testutil.K8sClientMockHelper
origCMObject *corev1.ConfigMap
- configConstraint *appsv1alpha1.ConfigConstraint
+ configConstraint *v1.ConfigConstraint
)
BeforeEach(func() {
@@ -61,7 +62,7 @@ var _ = Describe("ConfigEnvFrom test", func() {
testCtx.UseDefaultNamespace())
configConstraint = testapps.NewCustomizedObj("config/envfrom-constraint.yaml",
- &appsv1alpha1.ConfigConstraint{})
+ &v1.ConfigConstraint{})
clusterDef = testapps.NewClusterDefFactory(clusterDefName).
AddComponentDef(testapps.StatefulMySQLComponent, mysqlCompDefName).
diff --git a/pkg/controller/configuration/operator_test.go b/pkg/controller/configuration/operator_test.go
index 478ec5a7b57..4b82da44459 100644
--- a/pkg/controller/configuration/operator_test.go
+++ b/pkg/controller/configuration/operator_test.go
@@ -28,6 +28,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
cfgcore "github.com/apecloud/kubeblocks/pkg/configuration/core"
cfgutil "github.com/apecloud/kubeblocks/pkg/configuration/util"
@@ -46,7 +47,7 @@ var _ = Describe("ConfigurationOperatorTest", func() {
var synthesizedComponent *component.SynthesizedComponent
var configMapObj *corev1.ConfigMap
var scriptsObj *corev1.ConfigMap
- var configConstraint *appsv1alpha1.ConfigConstraint
+ var configConstraint *v1.ConfigConstraint
var configurationObj *appsv1alpha1.Configuration
var k8sMockClient *testutil.K8sClientMockHelper
@@ -81,21 +82,21 @@ var _ = Describe("ConfigurationOperatorTest", func() {
ClusterRef(clusterName).
Component(mysqlCompName).
GetObject()
- configConstraint = &appsv1alpha1.ConfigConstraint{
+ configConstraint = &v1.ConfigConstraint{
ObjectMeta: metav1.ObjectMeta{
Name: mysqlConfigConstraintName,
},
- Spec: appsv1alpha1.ConfigConstraintSpec{
- ReloadOptions: &appsv1alpha1.ReloadOptions{
- ShellTrigger: &appsv1alpha1.ShellTrigger{
+ Spec: v1.ConfigConstraintSpec{
+ DynamicReloadAction: &v1.DynamicReloadAction{
+ ShellTrigger: &v1.ShellTrigger{
Command: []string{"echo", "hello"},
Sync: cfgutil.ToPointer(true),
},
},
- FormatterConfig: &appsv1alpha1.FormatterConfig{
- Format: appsv1alpha1.Ini,
- FormatterOptions: appsv1alpha1.FormatterOptions{
- IniConfig: &appsv1alpha1.IniConfig{
+ FormatterConfig: &v1.FormatterConfig{
+ Format: v1.Ini,
+ FormatterAction: v1.FormatterAction{
+ IniConfig: &v1.IniConfig{
SectionName: "mysqld",
},
},
diff --git a/pkg/controller/configuration/patch_merger.go b/pkg/controller/configuration/patch_merger.go
index f22cd068577..c58fadf70fc 100644
--- a/pkg/controller/configuration/patch_merger.go
+++ b/pkg/controller/configuration/patch_merger.go
@@ -20,12 +20,13 @@ along with this program. If not, see .
package configuration
import (
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
"github.com/apecloud/kubeblocks/pkg/configuration/core"
intctrlutil "github.com/apecloud/kubeblocks/pkg/controllerutil"
)
-func DoMerge(baseData map[string]string, patch map[string]appsv1alpha1.ConfigParams, cc *appsv1alpha1.ConfigConstraint, configSpec appsv1alpha1.ComponentConfigSpec) (map[string]string, error) {
+func DoMerge(baseData map[string]string, patch map[string]appsv1alpha1.ConfigParams, cc *v1.ConfigConstraint, configSpec appsv1alpha1.ComponentConfigSpec) (map[string]string, error) {
var (
updatedFiles = make(map[string]string, len(patch))
updatedParams = make([]core.ParamPairs, 0, len(patch))
@@ -48,7 +49,7 @@ func DoMerge(baseData map[string]string, patch map[string]appsv1alpha1.ConfigPar
func mergeUpdatedParams(base map[string]string,
updatedFiles map[string]string,
updatedParams []core.ParamPairs,
- cc *appsv1alpha1.ConfigConstraint,
+ cc *v1.ConfigConstraint,
tpl appsv1alpha1.ComponentConfigSpec) (map[string]string, error) {
updatedConfig := base
diff --git a/pkg/controller/configuration/pipeline_test.go b/pkg/controller/configuration/pipeline_test.go
index 094f12d10b9..07658ff20f4 100644
--- a/pkg/controller/configuration/pipeline_test.go
+++ b/pkg/controller/configuration/pipeline_test.go
@@ -31,6 +31,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
cfgcore "github.com/apecloud/kubeblocks/pkg/configuration/core"
cfgutil "github.com/apecloud/kubeblocks/pkg/configuration/util"
@@ -50,7 +51,7 @@ var _ = Describe("ConfigurationPipelineTest", func() {
var clusterDefObj *appsv1alpha1.ClusterDefinition
var synthesizedComponent *component.SynthesizedComponent
var configMapObj *corev1.ConfigMap
- var configConstraint *appsv1alpha1.ConfigConstraint
+ var configConstraint *appsv1.ConfigConstraint
var configurationObj *appsv1alpha1.Configuration
var k8sMockClient *testutil.K8sClientMockHelper
@@ -114,13 +115,13 @@ max_connections = '1000'
ClusterRef(clusterName).
Component(mysqlCompName).
GetObject()
- configConstraint = &appsv1alpha1.ConfigConstraint{
+ configConstraint = &appsv1.ConfigConstraint{
ObjectMeta: metav1.ObjectMeta{
Name: mysqlConfigConstraintName,
},
- Spec: appsv1alpha1.ConfigConstraintSpec{
- FormatterConfig: &appsv1alpha1.FormatterConfig{
- Format: appsv1alpha1.Properties,
+ Spec: appsv1.ConfigConstraintSpec{
+ FormatterConfig: &appsv1.FormatterConfig{
+ Format: appsv1.Properties,
},
}}
})
diff --git a/pkg/controller/configuration/resource_wrapper.go b/pkg/controller/configuration/resource_wrapper.go
index 764a83827e3..db79c7b2467 100644
--- a/pkg/controller/configuration/resource_wrapper.go
+++ b/pkg/controller/configuration/resource_wrapper.go
@@ -28,6 +28,7 @@ import (
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
cfgcore "github.com/apecloud/kubeblocks/pkg/configuration/core"
"github.com/apecloud/kubeblocks/pkg/constant"
@@ -61,7 +62,7 @@ type ResourceFetcher[T any] struct {
ConfigMapObj *corev1.ConfigMap
ConfigurationObj *appsv1alpha1.Configuration
- ConfigConstraintObj *appsv1alpha1.ConfigConstraint
+ ConfigConstraintObj *v1.ConfigConstraint
}
func (r *ResourceFetcher[T]) Init(ctx *ResourceCtx, object *T) *T {
@@ -192,7 +193,7 @@ func (r *ResourceFetcher[T]) ConfigMap(configSpec string) *T {
func (r *ResourceFetcher[T]) ConfigConstraints(ccName string) *T {
return r.Wrap(func() error {
if ccName != "" {
- r.ConfigConstraintObj = &appsv1alpha1.ConfigConstraint{}
+ r.ConfigConstraintObj = &v1.ConfigConstraint{}
return r.Client.Get(r.Context, client.ObjectKey{Name: ccName}, r.ConfigConstraintObj)
}
return nil
diff --git a/pkg/controller/configuration/resource_wrapper_test.go b/pkg/controller/configuration/resource_wrapper_test.go
index c6d705bf9b7..9058011a664 100644
--- a/pkg/controller/configuration/resource_wrapper_test.go
+++ b/pkg/controller/configuration/resource_wrapper_test.go
@@ -28,6 +28,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
cfgcore "github.com/apecloud/kubeblocks/pkg/configuration/core"
testapps "github.com/apecloud/kubeblocks/pkg/testutil/apps"
@@ -83,7 +84,7 @@ var _ = Describe("resource Fetcher", func() {
clusterVersion,
cluster,
testapps.NewConfigMap("default", cfgcore.GetComponentCfgName(clusterName, mysqlCompName, mysqlConfigName)),
- &appsv1alpha1.ConfigConstraint{
+ &v1.ConfigConstraint{
ObjectMeta: metav1.ObjectMeta{
Name: mysqlConfigName,
},
diff --git a/pkg/controller/configuration/suite_test.go b/pkg/controller/configuration/suite_test.go
index c08a553c703..d9b9d986225 100644
--- a/pkg/controller/configuration/suite_test.go
+++ b/pkg/controller/configuration/suite_test.go
@@ -38,6 +38,7 @@ import (
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
dpv1alpha1 "github.com/apecloud/kubeblocks/apis/dataprotection/v1alpha1"
intctrlutil "github.com/apecloud/kubeblocks/pkg/controllerutil"
@@ -100,6 +101,9 @@ var _ = BeforeSuite(func() {
err = appsv1alpha1.AddToScheme(scheme.Scheme)
Expect(err).NotTo(HaveOccurred())
+ err = appsv1.AddToScheme(scheme.Scheme)
+ Expect(err).NotTo(HaveOccurred())
+
err = dpv1alpha1.AddToScheme(scheme.Scheme)
Expect(err).NotTo(HaveOccurred())
diff --git a/pkg/controller/configuration/template_merger.go b/pkg/controller/configuration/template_merger.go
index 7c47ac9baec..573e63cd416 100644
--- a/pkg/controller/configuration/template_merger.go
+++ b/pkg/controller/configuration/template_merger.go
@@ -24,6 +24,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
"github.com/apecloud/kubeblocks/pkg/configuration/core"
)
@@ -40,7 +41,7 @@ type TemplateMerger interface {
type mergeContext struct {
template appsv1alpha1.ConfigTemplateExtension
configSpec appsv1alpha1.ComponentConfigSpec
- ccSpec *appsv1alpha1.ConfigConstraintSpec
+ ccSpec *v1.ConfigConstraintSpec
builder *configTemplateBuilder
ctx context.Context
@@ -118,7 +119,7 @@ func (c *configOnlyAddMerger) Merge(baseData map[string]string, updatedData map[
return nil, core.MakeError("not implemented")
}
-func NewTemplateMerger(template appsv1alpha1.ConfigTemplateExtension, ctx context.Context, cli client.Client, builder *configTemplateBuilder, configSpec appsv1alpha1.ComponentConfigSpec, ccSpec *appsv1alpha1.ConfigConstraintSpec) (TemplateMerger, error) {
+func NewTemplateMerger(template appsv1alpha1.ConfigTemplateExtension, ctx context.Context, cli client.Client, builder *configTemplateBuilder, configSpec appsv1alpha1.ComponentConfigSpec, ccSpec *v1.ConfigConstraintSpec) (TemplateMerger, error) {
templateData := &mergeContext{
configSpec: configSpec,
template: template,
@@ -152,7 +153,7 @@ func mergerConfigTemplate(template *appsv1alpha1.LegacyRenderedTemplateSpec,
if configSpec.ConfigConstraintRef == "" {
return nil, core.MakeError("ConfigConstraintRef require not empty, configSpec[%v]", configSpec.Name)
}
- ccObj := &appsv1alpha1.ConfigConstraint{}
+ ccObj := &v1.ConfigConstraint{}
ccKey := client.ObjectKey{
Namespace: "",
Name: configSpec.ConfigConstraintRef,
diff --git a/pkg/controller/configuration/template_merger_test.go b/pkg/controller/configuration/template_merger_test.go
index 0e76a7a23af..f20950d0b3f 100644
--- a/pkg/controller/configuration/template_merger_test.go
+++ b/pkg/controller/configuration/template_merger_test.go
@@ -29,6 +29,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
cfgcore "github.com/apecloud/kubeblocks/pkg/configuration/core"
"github.com/apecloud/kubeblocks/pkg/controller/component"
@@ -68,7 +69,7 @@ max_connections=666
mockClient *testutil.K8sClientMockHelper
templateBuilder *configTemplateBuilder
configSpec appsv1alpha1.ComponentConfigSpec
- configConstraintObj *appsv1alpha1.ConfigConstraint
+ configConstraintObj *v1.ConfigConstraint
baseCMObject *corev1.ConfigMap
updatedCMObject *corev1.ConfigMap
@@ -78,7 +79,7 @@ max_connections=666
mockClient = testutil.NewK8sMockClient()
configConstraintObj = testapps.CheckedCreateCustomizedObj(&testCtx,
"resources/mysql-config-constraint.yaml",
- &appsv1alpha1.ConfigConstraint{})
+ &v1.ConfigConstraint{})
baseCMObject = &corev1.ConfigMap{
Data: map[string]string{
testConfigName: baseConfig,
diff --git a/pkg/controller/configuration/template_wrapper.go b/pkg/controller/configuration/template_wrapper.go
index 3b5a4350ce7..f692cd73137 100644
--- a/pkg/controller/configuration/template_wrapper.go
+++ b/pkg/controller/configuration/template_wrapper.go
@@ -31,6 +31,7 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/client"
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
"github.com/apecloud/kubeblocks/pkg/configuration/core"
cfgutil "github.com/apecloud/kubeblocks/pkg/configuration/util"
@@ -163,7 +164,7 @@ func updateConfigMetaForCM(newCMObj *corev1.ConfigMap, item *appsv1alpha1.Config
func applyUpdatedParameters(item *appsv1alpha1.ConfigurationItemDetail, cm *corev1.ConfigMap, configSpec appsv1alpha1.ComponentConfigSpec, cli client.Client, ctx context.Context) (err error) {
var newData map[string]string
- var configConstraint *appsv1alpha1.ConfigConstraint
+ var configConstraint *v1.ConfigConstraint
if item == nil || len(item.ConfigFileParams) == 0 {
return
@@ -374,11 +375,11 @@ func renderConfigMapTemplate(
return renderedData, nil
}
-func fetchConfigConstraint(ccName string, ctx context.Context, cli client.Client) (*appsv1alpha1.ConfigConstraint, error) {
+func fetchConfigConstraint(ccName string, ctx context.Context, cli client.Client) (*v1.ConfigConstraint, error) {
ccKey := client.ObjectKey{
Name: ccName,
}
- configConstraint := &appsv1alpha1.ConfigConstraint{}
+ configConstraint := &v1.ConfigConstraint{}
if err := cli.Get(ctx, ccKey, configConstraint); err != nil {
return nil, core.WrapError(err, "failed to get ConfigConstraint, key[%s]", ccName)
}
@@ -401,7 +402,7 @@ func validateRenderedData(
return validateRawData(renderedData, configSpec, &configConstraint.Spec)
}
-func validateRawData(renderedData map[string]string, configSpec appsv1alpha1.ComponentConfigSpec, cc *appsv1alpha1.ConfigConstraintSpec) error {
+func validateRawData(renderedData map[string]string, configSpec appsv1alpha1.ComponentConfigSpec, cc *v1.ConfigConstraintSpec) error {
configChecker := validate.NewConfigValidator(cc, validate.WithKeySelector(configSpec.Keys))
// NOTE: It is necessary to verify the correctness of the data
if err := configChecker.Validate(renderedData); err != nil {
diff --git a/pkg/controller/configuration/template_wrapper_test.go b/pkg/controller/configuration/template_wrapper_test.go
index ce18bd34637..bc44d501788 100644
--- a/pkg/controller/configuration/template_wrapper_test.go
+++ b/pkg/controller/configuration/template_wrapper_test.go
@@ -27,6 +27,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
cfgcore "github.com/apecloud/kubeblocks/pkg/configuration/core"
"github.com/apecloud/kubeblocks/pkg/constant"
@@ -124,13 +125,13 @@ var _ = Describe("TemplateWrapperTest", func() {
"test-config-spec-new": "test-config-spec-update",
},
},
- &appsv1alpha1.ConfigConstraint{
+ &v1.ConfigConstraint{
ObjectMeta: metav1.ObjectMeta{
Name: configSpecName,
},
- Spec: appsv1alpha1.ConfigConstraintSpec{
- FormatterConfig: &appsv1alpha1.FormatterConfig{
- Format: appsv1alpha1.Ini,
+ Spec: v1.ConfigConstraintSpec{
+ FormatterConfig: &v1.FormatterConfig{
+ Format: v1.Ini,
},
},
},
diff --git a/pkg/controller/configuration/tool_image_builder.go b/pkg/controller/configuration/tool_image_builder.go
index c0c05a23d7d..79d91c95dc7 100644
--- a/pkg/controller/configuration/tool_image_builder.go
+++ b/pkg/controller/configuration/tool_image_builder.go
@@ -22,7 +22,7 @@ package configuration
import (
corev1 "k8s.io/api/core/v1"
- appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
cfgcm "github.com/apecloud/kubeblocks/pkg/configuration/config_manager"
"github.com/apecloud/kubeblocks/pkg/constant"
"github.com/apecloud/kubeblocks/pkg/controller/component"
@@ -44,7 +44,7 @@ func buildConfigToolsContainer(cfgManagerParams *cfgcm.CfgManagerBuildParams, po
}
// construct config manager tools volume
- toolContainers := make([]appsv1alpha1.ToolConfig, 0)
+ toolContainers := make([]appsv1.ToolConfig, 0)
toolsMap := make(map[string]cfgcm.ConfigSpecMeta)
for _, buildParam := range cfgManagerParams.ConfigSpecsBuildParams {
if buildParam.ToolsImageSpec == nil {
@@ -73,7 +73,7 @@ func buildConfigToolsContainer(cfgManagerParams *cfgcm.CfgManagerBuildParams, po
return err
}
-func checkAndInstallToolsImageVolume(toolContainers []appsv1alpha1.ToolConfig, buildParams []cfgcm.ConfigSpecMeta) []appsv1alpha1.ToolConfig {
+func checkAndInstallToolsImageVolume(toolContainers []appsv1.ToolConfig, buildParams []cfgcm.ConfigSpecMeta) []appsv1.ToolConfig {
for _, buildParam := range buildParams {
if buildParam.ToolsImageSpec != nil && buildParam.ConfigSpec.LegacyRenderedConfigSpec != nil {
// auto install config_render tool
@@ -83,14 +83,14 @@ func checkAndInstallToolsImageVolume(toolContainers []appsv1alpha1.ToolConfig, b
return toolContainers
}
-func checkAndCreateRenderedInitContainer(toolContainers []appsv1alpha1.ToolConfig, mountPoint string) []appsv1alpha1.ToolConfig {
+func checkAndCreateRenderedInitContainer(toolContainers []appsv1.ToolConfig, mountPoint string) []appsv1.ToolConfig {
kbToolsImage := viper.GetString(constant.KBToolsImage)
for _, container := range toolContainers {
if container.Name == initSecRenderedToolContainerName {
return nil
}
}
- toolContainers = append(toolContainers, appsv1alpha1.ToolConfig{
+ toolContainers = append(toolContainers, appsv1.ToolConfig{
Name: initSecRenderedToolContainerName,
Image: kbToolsImage,
Command: []string{"cp", tplRenderToolPath, mountPoint},
@@ -98,7 +98,7 @@ func checkAndCreateRenderedInitContainer(toolContainers []appsv1alpha1.ToolConfi
return toolContainers
}
-func replaceToolsImageHolder(toolConfig *appsv1alpha1.ToolConfig, podSpec *corev1.PodSpec, volumeName string) {
+func replaceToolsImageHolder(toolConfig *appsv1.ToolConfig, podSpec *corev1.PodSpec, volumeName string) {
switch {
case toolConfig.Image == constant.KBToolsImagePlaceHolder:
toolConfig.Image = viper.GetString(constant.KBToolsImage)
diff --git a/pkg/controller/configuration/tool_image_builder_test.go b/pkg/controller/configuration/tool_image_builder_test.go
index c5d69e1a967..3653ba4f371 100644
--- a/pkg/controller/configuration/tool_image_builder_test.go
+++ b/pkg/controller/configuration/tool_image_builder_test.go
@@ -25,6 +25,7 @@ import (
corev1 "k8s.io/api/core/v1"
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
cfgcm "github.com/apecloud/kubeblocks/pkg/configuration/config_manager"
"github.com/apecloud/kubeblocks/pkg/constant"
@@ -70,12 +71,12 @@ var _ = Describe("ToolsImageBuilderTest", func() {
ConfigSpecsBuildParams: []cfgcm.ConfigSpecMeta{{
ConfigSpecInfo: cfgcm.ConfigSpecInfo{
ConfigSpec: clusterComponent.ConfigTemplates[0],
- ReloadType: appsv1alpha1.TPLScriptType,
- FormatterConfig: appsv1alpha1.FormatterConfig{},
+ ReloadType: v1.TPLScriptType,
+ FormatterConfig: v1.FormatterConfig{},
},
- ToolsImageSpec: &appsv1alpha1.ToolsImageSpec{
+ ToolsImageSpec: &v1.ReloadToolsImage{
MountPoint: "/opt/images",
- ToolConfigs: []appsv1alpha1.ToolConfig{
+ ToolConfigs: []v1.ToolConfig{
{
Name: "test",
Image: "test_images",
diff --git a/pkg/controller/factory/builder.go b/pkg/controller/factory/builder.go
index 7f540c520fe..3bd12c05ffb 100644
--- a/pkg/controller/factory/builder.go
+++ b/pkg/controller/factory/builder.go
@@ -35,6 +35,7 @@ import (
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/rand"
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
dpv1alpha1 "github.com/apecloud/kubeblocks/apis/dataprotection/v1alpha1"
workloads "github.com/apecloud/kubeblocks/apis/workloads/v1alpha1"
@@ -431,7 +432,7 @@ func BuildCfgManagerContainer(sidecarRenderedParam *cfgcm.CfgManagerBuildParams,
return containerBuilder.GetObject(), nil
}
-func BuildCfgManagerToolsContainer(sidecarRenderedParam *cfgcm.CfgManagerBuildParams, component *component.SynthesizedComponent, toolsMetas []appsv1alpha1.ToolConfig, toolsMap map[string]cfgcm.ConfigSpecMeta) ([]corev1.Container, error) {
+func BuildCfgManagerToolsContainer(sidecarRenderedParam *cfgcm.CfgManagerBuildParams, component *component.SynthesizedComponent, toolsMetas []v1.ToolConfig, toolsMap map[string]cfgcm.ConfigSpecMeta) ([]corev1.Container, error) {
toolContainers := make([]corev1.Container, 0, len(toolsMetas))
for _, toolConfig := range toolsMetas {
toolContainerBuilder := builder.NewContainerBuilder(toolConfig.Name).
diff --git a/pkg/controller/factory/builder_test.go b/pkg/controller/factory/builder_test.go
index b48e3af5076..82a92354f3d 100644
--- a/pkg/controller/factory/builder_test.go
+++ b/pkg/controller/factory/builder_test.go
@@ -33,6 +33,7 @@ import (
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
workloads "github.com/apecloud/kubeblocks/apis/workloads/v1alpha1"
cfgcm "github.com/apecloud/kubeblocks/pkg/configuration/config_manager"
@@ -419,7 +420,7 @@ var _ = Describe("builder", func() {
Cluster: cluster,
ConfigLazyRenderedVolumes: make(map[string]corev1.VolumeMount),
}
- toolContainers := []appsv1alpha1.ToolConfig{
+ toolContainers := []v1.ToolConfig{
{Name: "test-tool", Image: "test-image", Command: []string{"sh"}},
}
diff --git a/pkg/controller/factory/suite_test.go b/pkg/controller/factory/suite_test.go
index 337e78c6f6f..154d51a7b12 100644
--- a/pkg/controller/factory/suite_test.go
+++ b/pkg/controller/factory/suite_test.go
@@ -40,6 +40,7 @@ import (
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
dpv1alpha1 "github.com/apecloud/kubeblocks/apis/dataprotection/v1alpha1"
intctrlutil "github.com/apecloud/kubeblocks/pkg/controllerutil"
@@ -100,6 +101,9 @@ var _ = BeforeSuite(func() {
err = appsv1alpha1.AddToScheme(scheme.Scheme)
Expect(err).NotTo(HaveOccurred())
+ err = appsv1.AddToScheme(scheme.Scheme)
+ Expect(err).NotTo(HaveOccurred())
+
err = dpv1alpha1.AddToScheme(scheme.Scheme)
Expect(err).NotTo(HaveOccurred())
diff --git a/pkg/controller/plan/prepare_test.go b/pkg/controller/plan/prepare_test.go
index 2215f75224e..d842f91b363 100644
--- a/pkg/controller/plan/prepare_test.go
+++ b/pkg/controller/plan/prepare_test.go
@@ -26,6 +26,7 @@ import (
corev1 "k8s.io/api/core/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
cfgcore "github.com/apecloud/kubeblocks/pkg/configuration/core"
"github.com/apecloud/kubeblocks/pkg/controller/component"
@@ -110,7 +111,7 @@ var _ = Describe("Prepare Test", func() {
createAllWorkloadTypesClusterDef()
testapps.CreateCustomizedObj(&testCtx, "config/envfrom-config.yaml", &corev1.ConfigMap{}, testCtx.UseDefaultNamespace())
- tpl := testapps.CreateCustomizedObj(&testCtx, "config/envfrom-constraint.yaml", &appsv1alpha1.ConfigConstraint{})
+ tpl := testapps.CreateCustomizedObj(&testCtx, "config/envfrom-constraint.yaml", &appsv1.ConfigConstraint{})
configSpecName = tpl.Name
pvcSpec := testapps.NewPVCSpec("1Gi")
diff --git a/pkg/controller/plan/suite_test.go b/pkg/controller/plan/suite_test.go
index 1447cbe84c1..60c6548ec75 100644
--- a/pkg/controller/plan/suite_test.go
+++ b/pkg/controller/plan/suite_test.go
@@ -38,6 +38,7 @@ import (
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
dpv1alpha1 "github.com/apecloud/kubeblocks/apis/dataprotection/v1alpha1"
intctrlutil "github.com/apecloud/kubeblocks/pkg/controllerutil"
@@ -100,6 +101,9 @@ var _ = BeforeSuite(func() {
err = appsv1alpha1.AddToScheme(scheme.Scheme)
Expect(err).NotTo(HaveOccurred())
+ err = appsv1.AddToScheme(scheme.Scheme)
+ Expect(err).NotTo(HaveOccurred())
+
err = dpv1alpha1.AddToScheme(scheme.Scheme)
Expect(err).NotTo(HaveOccurred())
diff --git a/pkg/controller/rsm2/reconciler_revision_update_test.go b/pkg/controller/rsm2/reconciler_revision_update_test.go
index c27fbb044ae..0ebd7386383 100644
--- a/pkg/controller/rsm2/reconciler_revision_update_test.go
+++ b/pkg/controller/rsm2/reconciler_revision_update_test.go
@@ -23,10 +23,11 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
+ corev1 "k8s.io/api/core/v1"
+
workloads "github.com/apecloud/kubeblocks/apis/workloads/v1alpha1"
"github.com/apecloud/kubeblocks/pkg/controller/builder"
"github.com/apecloud/kubeblocks/pkg/controller/kubebuilderx"
- corev1 "k8s.io/api/core/v1"
)
var _ = Describe("revision update reconciler test", func() {
diff --git a/pkg/controller/rsm2/reconciler_status_test.go b/pkg/controller/rsm2/reconciler_status_test.go
index 06766542886..20a2380d498 100644
--- a/pkg/controller/rsm2/reconciler_status_test.go
+++ b/pkg/controller/rsm2/reconciler_status_test.go
@@ -25,12 +25,13 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
- workloads "github.com/apecloud/kubeblocks/apis/workloads/v1alpha1"
- "github.com/apecloud/kubeblocks/pkg/controller/builder"
- "github.com/apecloud/kubeblocks/pkg/controller/kubebuilderx"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+
+ workloads "github.com/apecloud/kubeblocks/apis/workloads/v1alpha1"
+ "github.com/apecloud/kubeblocks/pkg/controller/builder"
+ "github.com/apecloud/kubeblocks/pkg/controller/kubebuilderx"
)
var _ = Describe("status reconciler test", func() {
diff --git a/pkg/controllerutil/config_util.go b/pkg/controllerutil/config_util.go
index 8a81a62bb38..a56f3818609 100644
--- a/pkg/controllerutil/config_util.go
+++ b/pkg/controllerutil/config_util.go
@@ -28,6 +28,7 @@ import (
corev1 "k8s.io/api/core/v1"
"sigs.k8s.io/controller-runtime/pkg/log"
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
"github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
"github.com/apecloud/kubeblocks/pkg/configuration/core"
"github.com/apecloud/kubeblocks/pkg/configuration/util"
@@ -50,7 +51,7 @@ type Result struct {
}
// MergeAndValidateConfigs merges and validates configuration files
-func MergeAndValidateConfigs(configConstraint v1alpha1.ConfigConstraintSpec, baseConfigs map[string]string, cmKey []string, updatedParams []core.ParamPairs) (map[string]string, error) {
+func MergeAndValidateConfigs(configConstraint appsv1.ConfigConstraintSpec, baseConfigs map[string]string, cmKey []string, updatedParams []core.ParamPairs) (map[string]string, error) {
var (
err error
fc = configConstraint.FormatterConfig
diff --git a/pkg/controllerutil/config_util_test.go b/pkg/controllerutil/config_util_test.go
index 78c8e2686e4..e5c98d8bb6a 100644
--- a/pkg/controllerutil/config_util_test.go
+++ b/pkg/controllerutil/config_util_test.go
@@ -31,6 +31,7 @@ import (
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
"github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
"github.com/apecloud/kubeblocks/pkg/configuration/core"
cfgutil "github.com/apecloud/kubeblocks/pkg/configuration/util"
@@ -302,21 +303,21 @@ var _ = Describe("config_util", func() {
Context("MergeAndValidateConfigs", func() {
It("Should succeed with no error", func() {
type args struct {
- configConstraint v1alpha1.ConfigConstraintSpec
+ configConstraint appsv1.ConfigConstraintSpec
baseCfg map[string]string
updatedParams []core.ParamPairs
cmKeys []string
}
configConstraintObj := testapps.NewCustomizedObj("resources/mysql-config-constraint.yaml",
- &v1alpha1.ConfigConstraint{}, func(cc *v1alpha1.ConfigConstraint) {
+ &appsv1.ConfigConstraint{}, func(cc *appsv1.ConfigConstraint) {
if ccContext, err := testdata.GetTestDataFileContent("cue_testdata/pg14.cue"); err == nil {
- cc.Spec.ConfigurationSchema = &v1alpha1.CustomParametersValidation{
+ cc.Spec.ConfigSchema = &appsv1.ConfigSchema{
CUE: string(ccContext),
}
}
- cc.Spec.FormatterConfig = &v1alpha1.FormatterConfig{
- Format: v1alpha1.Properties,
+ cc.Spec.FormatterConfig = &appsv1.FormatterConfig{
+ Format: appsv1.Properties,
}
})
diff --git a/pkg/controllerutil/suite_test.go b/pkg/controllerutil/suite_test.go
index 623368666a8..efb12623722 100644
--- a/pkg/controllerutil/suite_test.go
+++ b/pkg/controllerutil/suite_test.go
@@ -38,6 +38,7 @@ import (
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
"github.com/apecloud/kubeblocks/pkg/testutil"
viper "github.com/apecloud/kubeblocks/pkg/viperx"
@@ -99,6 +100,9 @@ var _ = BeforeSuite(func() {
err = appsv1alpha1.AddToScheme(scheme)
Expect(err).NotTo(HaveOccurred())
+ err = appsv1.AddToScheme(scheme)
+ Expect(err).NotTo(HaveOccurred())
+
k8sClient, err = client.New(cfg, client.Options{Scheme: scheme})
Expect(err).NotTo(HaveOccurred())
Expect(k8sClient).NotTo(BeNil())
diff --git a/pkg/generics/type.go b/pkg/generics/type.go
index 9e06f734651..9f33ede1c24 100644
--- a/pkg/generics/type.go
+++ b/pkg/generics/type.go
@@ -30,6 +30,7 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/client"
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
dpv1alpha1 "github.com/apecloud/kubeblocks/apis/dataprotection/v1alpha1"
extensionsv1alpha1 "github.com/apecloud/kubeblocks/apis/extensions/v1alpha1"
@@ -106,7 +107,7 @@ var OpsDefinitionSignature = func(_ appsv1alpha1.OpsDefinition, _ *appsv1alpha1.
}
var OpsRequestSignature = func(_ appsv1alpha1.OpsRequest, _ *appsv1alpha1.OpsRequest, _ appsv1alpha1.OpsRequestList, _ *appsv1alpha1.OpsRequestList) {
}
-var ConfigConstraintSignature = func(_ appsv1alpha1.ConfigConstraint, _ *appsv1alpha1.ConfigConstraint, _ appsv1alpha1.ConfigConstraintList, _ *appsv1alpha1.ConfigConstraintList) {
+var ConfigConstraintSignature = func(_ v1.ConfigConstraint, _ *v1.ConfigConstraint, _ v1.ConfigConstraintList, _ *v1.ConfigConstraintList) {
}
var BackupPolicyTemplateSignature = func(_ appsv1alpha1.BackupPolicyTemplate, _ *appsv1alpha1.BackupPolicyTemplate, _ appsv1alpha1.BackupPolicyTemplateList, _ *appsv1alpha1.BackupPolicyTemplateList) {
diff --git a/pkg/lorry/cronjobs/manager.go b/pkg/lorry/cronjobs/manager.go
index 439098c2b43..71113db3a74 100644
--- a/pkg/lorry/cronjobs/manager.go
+++ b/pkg/lorry/cronjobs/manager.go
@@ -24,8 +24,9 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
- "github.com/apecloud/kubeblocks/pkg/constant"
"github.com/spf13/viper"
+
+ "github.com/apecloud/kubeblocks/pkg/constant"
)
type Manager struct {
diff --git a/pkg/lorry/engines/dbmanager_mock.go b/pkg/lorry/engines/dbmanager_mock.go
index 65f95b46b44..cb26269347a 100644
--- a/pkg/lorry/engines/dbmanager_mock.go
+++ b/pkg/lorry/engines/dbmanager_mock.go
@@ -29,10 +29,11 @@ import (
context "context"
reflect "reflect"
- dcs "github.com/apecloud/kubeblocks/pkg/lorry/dcs"
- models "github.com/apecloud/kubeblocks/pkg/lorry/engines/models"
logr "github.com/go-logr/logr"
gomock "github.com/golang/mock/gomock"
+
+ dcs "github.com/apecloud/kubeblocks/pkg/lorry/dcs"
+ models "github.com/apecloud/kubeblocks/pkg/lorry/engines/models"
)
// MockDBManager is a mock of DBManager interface.
diff --git a/pkg/unstructured/config_object.go b/pkg/unstructured/config_object.go
index e13aa74947e..6f1a7630444 100644
--- a/pkg/unstructured/config_object.go
+++ b/pkg/unstructured/config_object.go
@@ -23,13 +23,13 @@ import (
"fmt"
"sync"
- appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
)
type ConfigObjectCreator = func(name string) ConfigObject
type ConfigObjectRegistry struct {
- objectCreator map[appsv1alpha1.CfgFileFormat]ConfigObjectCreator
+ objectCreator map[appsv1.CfgFileFormat]ConfigObjectCreator
}
var (
@@ -39,16 +39,16 @@ var (
func CfgObjectRegistry() *ConfigObjectRegistry {
ConfigRegistryOnce.Do(func() {
- configObjectRegistry = &ConfigObjectRegistry{objectCreator: make(map[appsv1alpha1.CfgFileFormat]ConfigObjectCreator)}
+ configObjectRegistry = &ConfigObjectRegistry{objectCreator: make(map[appsv1.CfgFileFormat]ConfigObjectCreator)}
})
return configObjectRegistry
}
-func (c *ConfigObjectRegistry) RegisterConfigCreator(format appsv1alpha1.CfgFileFormat, creator ConfigObjectCreator) {
+func (c *ConfigObjectRegistry) RegisterConfigCreator(format appsv1.CfgFileFormat, creator ConfigObjectCreator) {
c.objectCreator[format] = creator
}
-func (c *ConfigObjectRegistry) GetConfigObject(name string, format appsv1alpha1.CfgFileFormat) (ConfigObject, error) {
+func (c *ConfigObjectRegistry) GetConfigObject(name string, format appsv1.CfgFileFormat) (ConfigObject, error) {
creator, ok := c.objectCreator[format]
if !ok {
return nil, fmt.Errorf("not supported type[%s]", format)
@@ -56,7 +56,7 @@ func (c *ConfigObjectRegistry) GetConfigObject(name string, format appsv1alpha1.
return creator(name), nil
}
-func LoadConfig(name string, content string, format appsv1alpha1.CfgFileFormat) (ConfigObject, error) {
+func LoadConfig(name string, content string, format appsv1.CfgFileFormat) (ConfigObject, error) {
configObject, err := CfgObjectRegistry().GetConfigObject(name, format)
if err != nil {
return nil, err
diff --git a/pkg/unstructured/properties.go b/pkg/unstructured/properties.go
index f6447492efe..4980c62795c 100644
--- a/pkg/unstructured/properties.go
+++ b/pkg/unstructured/properties.go
@@ -25,7 +25,7 @@ import (
"github.com/magiconair/properties"
"github.com/spf13/cast"
- appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
)
type propertiesConfig struct {
@@ -36,7 +36,7 @@ type propertiesConfig struct {
const commentPrefix = "# "
func init() {
- CfgObjectRegistry().RegisterConfigCreator(appsv1alpha1.PropertiesPlus, func(name string) ConfigObject {
+ CfgObjectRegistry().RegisterConfigCreator(appsv1.PropertiesPlus, func(name string) ConfigObject {
return &propertiesConfig{name: name}
})
}
diff --git a/pkg/unstructured/properties_test.go b/pkg/unstructured/properties_test.go
index 010001d6ad4..89159bde266 100644
--- a/pkg/unstructured/properties_test.go
+++ b/pkg/unstructured/properties_test.go
@@ -24,7 +24,7 @@ import (
"github.com/stretchr/testify/assert"
- appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
)
func TestPropertiesFormat(t *testing.T) {
@@ -53,7 +53,7 @@ brokerMaxConnections=0
# The maximum number of connections per IP. If it exceeds, new connections are rejected.
brokerMaxConnectionsPerIp=0
`
- propsConfigObj, err := LoadConfig("props_test", propsContext, appsv1alpha1.PropertiesPlus)
+ propsConfigObj, err := LoadConfig("props_test", propsContext, appsv1.PropertiesPlus)
assert.Nil(t, err)
assert.EqualValues(t, propsConfigObj.Get("brokerDeduplicationProducerInactivityTimeoutMinutes"), "360")
@@ -70,7 +70,7 @@ brokerMaxConnectionsPerIp=0
dumpContext, err := propsConfigObj.Marshal()
assert.Nil(t, err)
- newObj, err := LoadConfig("props_test", dumpContext, appsv1alpha1.PropertiesPlus)
+ newObj, err := LoadConfig("props_test", dumpContext, appsv1.PropertiesPlus)
assert.Nil(t, err)
assert.EqualValues(t, newObj.GetAllParameters(), propsConfigObj.GetAllParameters())
@@ -84,7 +84,7 @@ brokerMaxConnectionsPerIp=0
}
func TestPropertiesEmpty(t *testing.T) {
- propsConfigObj, err := LoadConfig("props_test", "", appsv1alpha1.PropertiesPlus)
+ propsConfigObj, err := LoadConfig("props_test", "", appsv1.PropertiesPlus)
assert.Nil(t, err)
v, err := propsConfigObj.Marshal()
diff --git a/pkg/unstructured/redis_config.go b/pkg/unstructured/redis_config.go
index 52dc1f960aa..301efc230df 100644
--- a/pkg/unstructured/redis_config.go
+++ b/pkg/unstructured/redis_config.go
@@ -28,7 +28,7 @@ import (
"github.com/StudioSol/set"
"github.com/spf13/cast"
- appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
)
type redisConfig struct {
@@ -39,7 +39,7 @@ type redisConfig struct {
}
func init() {
- CfgObjectRegistry().RegisterConfigCreator(appsv1alpha1.RedisCfg, func(name string) ConfigObject {
+ CfgObjectRegistry().RegisterConfigCreator(appsv1.RedisCfg, func(name string) ConfigObject {
return &redisConfig{name: name}
})
}
diff --git a/pkg/unstructured/redis_config_test.go b/pkg/unstructured/redis_config_test.go
index 6422b289b86..2893e28a52f 100644
--- a/pkg/unstructured/redis_config_test.go
+++ b/pkg/unstructured/redis_config_test.go
@@ -26,12 +26,12 @@ import (
"github.com/stretchr/testify/require"
- appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
"github.com/apecloud/kubeblocks/test/testdata"
)
func TestRedisConfig(t *testing.T) {
- c, err := LoadConfig("test", "", appsv1alpha1.RedisCfg)
+ c, err := LoadConfig("test", "", appsv1.RedisCfg)
require.Nil(t, err)
tests := []struct {
@@ -96,7 +96,7 @@ func TestRedisConfigGetAllParameters(t *testing.T) {
}{{
name: "multi field update test",
fn: func() ConfigObject {
- c, _ := LoadConfig("test", "", appsv1alpha1.RedisCfg)
+ c, _ := LoadConfig("test", "", appsv1.RedisCfg)
_ = c.Update("port", "123")
_ = c.Update("a b", "123 234")
_ = c.Update("a c", "345")
@@ -114,7 +114,7 @@ func TestRedisConfigGetAllParameters(t *testing.T) {
}, {
name: "multi field update and delete test",
fn: func() ConfigObject {
- c, _ := LoadConfig("test", "", appsv1alpha1.RedisCfg)
+ c, _ := LoadConfig("test", "", appsv1.RedisCfg)
_ = c.Update("port", "123")
_ = c.Update("a b", "123 234")
_ = c.Update("a c", "345")
@@ -195,7 +195,7 @@ zset-max-listpack-value 64`
}}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
- config, err := LoadConfig(tt.name, tt.input, appsv1alpha1.RedisCfg)
+ config, err := LoadConfig(tt.name, tt.input, appsv1.RedisCfg)
if (err != nil) != tt.wantErr {
t.Errorf("Marshal() error = %v, wantErr %v", err, tt.wantErr)
return
diff --git a/pkg/unstructured/viper_wrap.go b/pkg/unstructured/viper_wrap.go
index fde0a8a68e2..8ed66ed8b86 100644
--- a/pkg/unstructured/viper_wrap.go
+++ b/pkg/unstructured/viper_wrap.go
@@ -29,24 +29,24 @@ import (
oviper "github.com/spf13/viper"
"gopkg.in/ini.v1"
- appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
)
type viperWrap struct {
*oviper.Viper
name string
- format appsv1alpha1.CfgFileFormat
+ format appsv1.CfgFileFormat
}
func init() {
- CfgObjectRegistry().RegisterConfigCreator(appsv1alpha1.Ini, createViper(appsv1alpha1.Ini))
- // CfgObjectRegistry().RegisterConfigCreator(appsv1alpha1.YAML, createViper(appsv1alpha1.YAML))
- CfgObjectRegistry().RegisterConfigCreator(appsv1alpha1.JSON, createViper(appsv1alpha1.JSON))
- CfgObjectRegistry().RegisterConfigCreator(appsv1alpha1.Dotenv, createViper(appsv1alpha1.Dotenv))
- CfgObjectRegistry().RegisterConfigCreator(appsv1alpha1.HCL, createViper(appsv1alpha1.HCL))
- CfgObjectRegistry().RegisterConfigCreator(appsv1alpha1.TOML, createViper(appsv1alpha1.TOML))
- CfgObjectRegistry().RegisterConfigCreator(appsv1alpha1.Properties, createViper(appsv1alpha1.Properties))
+ CfgObjectRegistry().RegisterConfigCreator(appsv1.Ini, createViper(appsv1.Ini))
+ // CfgObjectRegistry().RegisterConfigCreator(appsv1.YAML, createViper(appsv1.YAML))
+ CfgObjectRegistry().RegisterConfigCreator(appsv1.JSON, createViper(appsv1.JSON))
+ CfgObjectRegistry().RegisterConfigCreator(appsv1.Dotenv, createViper(appsv1.Dotenv))
+ CfgObjectRegistry().RegisterConfigCreator(appsv1.HCL, createViper(appsv1.HCL))
+ CfgObjectRegistry().RegisterConfigCreator(appsv1.TOML, createViper(appsv1.TOML))
+ CfgObjectRegistry().RegisterConfigCreator(appsv1.Properties, createViper(appsv1.Properties))
}
func (v *viperWrap) GetString(key string) (string, error) {
@@ -95,9 +95,9 @@ func (v viperWrap) Unmarshal(str string) error {
return v.ReadConfig(bytes.NewReader([]byte(str)))
}
-func newCfgViper(cfgType appsv1alpha1.CfgFileFormat) *oviper.Viper {
+func newCfgViper(cfgType appsv1.CfgFileFormat) *oviper.Viper {
defaultKeySep := DelimiterDot
- if cfgType == appsv1alpha1.Properties || cfgType == appsv1alpha1.Dotenv {
+ if cfgType == appsv1.Properties || cfgType == appsv1.Dotenv {
defaultKeySep = CfgDelimiterPlaceholder
}
// TODO config constraint support LoadOptions
@@ -109,7 +109,7 @@ func newCfgViper(cfgType appsv1alpha1.CfgFileFormat) *oviper.Viper {
return v
}
-func createViper(format appsv1alpha1.CfgFileFormat) ConfigObjectCreator {
+func createViper(format appsv1.CfgFileFormat) ConfigObjectCreator {
return func(name string) ConfigObject {
return &viperWrap{
name: name,
diff --git a/pkg/unstructured/viper_wrap_test.go b/pkg/unstructured/viper_wrap_test.go
index e5f883c5e03..a9fedc4aa4a 100644
--- a/pkg/unstructured/viper_wrap_test.go
+++ b/pkg/unstructured/viper_wrap_test.go
@@ -24,7 +24,7 @@ import (
"github.com/stretchr/testify/assert"
- appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
)
func TestIniFormat(t *testing.T) {
@@ -41,7 +41,7 @@ plugin-load = "rpl_semi_sync_master=semisync_master.so;rpl_semi_sync_slave=semis
port=3306
`
- iniConfigObj, err := LoadConfig("ini_test", iniContext, appsv1alpha1.Ini)
+ iniConfigObj, err := LoadConfig("ini_test", iniContext, appsv1.Ini)
assert.Nil(t, err)
assert.EqualValues(t, iniConfigObj.Get("mysqld.gtid_mode"), "OFF")
@@ -77,7 +77,7 @@ autovacuum_freeze_max_age = '100000000'
autovacuum_max_workers = '1'
autovacuum_naptime = '1min'
`
- propConfigObj, err := LoadConfig("prop_test", propertiesContext, appsv1alpha1.Properties)
+ propConfigObj, err := LoadConfig("prop_test", propertiesContext, appsv1.Properties)
assert.Nil(t, err)
assert.EqualValues(t, propConfigObj.Get("auto_explain.log_nested_statements"), "'True'")
@@ -107,7 +107,7 @@ func TestJSONFormat(t *testing.T) {
"type": "student"
}`
- jsonConfigObj, err := LoadConfig("json_test", jsonContext, appsv1alpha1.JSON)
+ jsonConfigObj, err := LoadConfig("json_test", jsonContext, appsv1.JSON)
assert.Nil(t, err)
assert.EqualValues(t, jsonConfigObj.Get("id"), "0001")
diff --git a/pkg/unstructured/xml_config.go b/pkg/unstructured/xml_config.go
index f56ff34c978..7b0495b15ea 100644
--- a/pkg/unstructured/xml_config.go
+++ b/pkg/unstructured/xml_config.go
@@ -26,7 +26,7 @@ import (
mxjv2 "github.com/clbanning/mxj/v2"
"github.com/spf13/cast"
- appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
)
type xmlConfig struct {
@@ -42,7 +42,7 @@ func init() {
// enable cast to int
mxjv2.CastValuesToInt(true)
- CfgObjectRegistry().RegisterConfigCreator(appsv1alpha1.XML, func(name string) ConfigObject {
+ CfgObjectRegistry().RegisterConfigCreator(appsv1.XML, func(name string) ConfigObject {
return &xmlConfig{name: name}
})
}
diff --git a/pkg/unstructured/xml_config_test.go b/pkg/unstructured/xml_config_test.go
index f2bf2fd731d..b90969c7fe8 100644
--- a/pkg/unstructured/xml_config_test.go
+++ b/pkg/unstructured/xml_config_test.go
@@ -24,7 +24,7 @@ import (
"github.com/stretchr/testify/assert"
- appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
)
func TestXMLFormat(t *testing.T) {
@@ -47,7 +47,7 @@ func TestXMLFormat(t *testing.T) {
`
- xmlConfigObj, err := LoadConfig("xml_test", xmlContext, appsv1alpha1.XML)
+ xmlConfigObj, err := LoadConfig("xml_test", xmlContext, appsv1.XML)
assert.Nil(t, err)
assert.EqualValues(t, xmlConfigObj.Get("profiles.default.max_threads"), 8)
@@ -64,7 +64,7 @@ func TestXMLFormat(t *testing.T) {
dumpContext, err := xmlConfigObj.Marshal()
assert.Nil(t, err)
- newObj, err := LoadConfig("xml_test", dumpContext, appsv1alpha1.XML)
+ newObj, err := LoadConfig("xml_test", dumpContext, appsv1.XML)
assert.Nil(t, err)
assert.EqualValues(t, newObj.GetAllParameters(), xmlConfigObj.GetAllParameters())
diff --git a/pkg/unstructured/yaml_config.go b/pkg/unstructured/yaml_config.go
index 9fc035fd4f0..a40ae637c45 100644
--- a/pkg/unstructured/yaml_config.go
+++ b/pkg/unstructured/yaml_config.go
@@ -26,7 +26,7 @@ import (
"github.com/spf13/cast"
"gopkg.in/yaml.v2"
- appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
)
type yamlConfig struct {
@@ -35,7 +35,7 @@ type yamlConfig struct {
}
func init() {
- CfgObjectRegistry().RegisterConfigCreator(appsv1alpha1.YAML, func(name string) ConfigObject {
+ CfgObjectRegistry().RegisterConfigCreator(appsv1.YAML, func(name string) ConfigObject {
return &yamlConfig{name: name}
})
}
diff --git a/pkg/unstructured/yaml_config_test.go b/pkg/unstructured/yaml_config_test.go
index c2eb20be02e..fee562b9a22 100644
--- a/pkg/unstructured/yaml_config_test.go
+++ b/pkg/unstructured/yaml_config_test.go
@@ -24,7 +24,7 @@ import (
"github.com/stretchr/testify/assert"
- appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
+ appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
"github.com/apecloud/kubeblocks/pkg/configuration/util"
"github.com/apecloud/kubeblocks/test/testdata"
)
@@ -44,7 +44,7 @@ spec:
name: postgresql-configuration
`
- yamlConfigObj, err := LoadConfig("yaml_test", yamlContext, appsv1alpha1.YAML)
+ yamlConfigObj, err := LoadConfig("yaml_test", yamlContext, appsv1.YAML)
assert.Nil(t, err)
assert.EqualValues(t, yamlConfigObj.Get("spec.clusterRef"), "pg")
@@ -65,7 +65,7 @@ func TestYAMLFormatForBadCase(t *testing.T) {
b, err := testdata.GetTestDataFileContent("config_encoding/prometheus.yaml")
assert.Nil(t, err)
- yamlConfigObj, err := LoadConfig("yaml_test", string(b), appsv1alpha1.YAML)
+ yamlConfigObj, err := LoadConfig("yaml_test", string(b), appsv1.YAML)
assert.Nil(t, err)
assert.NotNil(t, yamlConfigObj)
yamlConfigObj.GetAllParameters()
diff --git a/test/integration/controller_suite_test.go b/test/integration/controller_suite_test.go
index 4f741ef65a9..76fb2575dda 100644
--- a/test/integration/controller_suite_test.go
+++ b/test/integration/controller_suite_test.go
@@ -42,6 +42,7 @@ import (
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
+ v1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
dpv1alpha1 "github.com/apecloud/kubeblocks/apis/dataprotection/v1alpha1"
"github.com/apecloud/kubeblocks/controllers/apps"
@@ -158,7 +159,7 @@ func CreateSimpleConsensusMySQLClusterWithConfig(
By("Create a constraint obj")
constraint := testapps.CreateCustomizedObj(&testCtx,
mysqlConfigConstraintPath,
- &appsv1alpha1.ConfigConstraint{})
+ &v1.ConfigConstraint{})
mysqlVolumeMounts := []corev1.VolumeMount{
{
@@ -255,6 +256,9 @@ var _ = BeforeSuite(func() {
err = appsv1alpha1.AddToScheme(scheme.Scheme)
Expect(err).NotTo(HaveOccurred())
+ err = v1.AddToScheme(scheme.Scheme)
+ Expect(err).NotTo(HaveOccurred())
+
err = dpv1alpha1.AddToScheme(scheme.Scheme)
Expect(err).NotTo(HaveOccurred())
diff --git a/test/testdata/config/config-constraint.yaml b/test/testdata/config/config-constraint.yaml
index 0175a46546f..5220f227467 100644
--- a/test/testdata/config/config-constraint.yaml
+++ b/test/testdata/config/config-constraint.yaml
@@ -1,22 +1,19 @@
-apiVersion: apps.kubeblocks.io/v1alpha1
+apiVersion: apps.kubeblocks.io/v1
kind: ConfigConstraint
metadata:
name: mysql-tree-node-template-8.0
namespace: default
spec:
- # configmap reference
- tplRef: mysql-tree-node-template-8.0
-
- reloadOptions:
+ dynamicReloadAction:
unixSignalTrigger:
signal: SIGHUP
processName: mysqld
# top level mysql configuration type
- cfgSchemaTopLevelName: MysqlParameter
+ configSchemaTopLevelKey: MysqlParameter
# ConfigurationSchema that impose restrictions on engine parameter's rule
- configurationSchema:
+ configSchema:
# schema: auto generate from cue scripts
# example: ../../pkg/configuration/testdata/mysql_openapi.json
cue: |-
diff --git a/test/testdata/config/envfrom-constraint.yaml b/test/testdata/config/envfrom-constraint.yaml
index be37bc9acd6..59ee67a3242 100644
--- a/test/testdata/config/envfrom-constraint.yaml
+++ b/test/testdata/config/envfrom-constraint.yaml
@@ -1,4 +1,4 @@
-apiVersion: apps.kubeblocks.io/v1alpha1
+apiVersion: apps.kubeblocks.io/v1
kind: ConfigConstraint
metadata:
name: env-from-config-test
diff --git a/test/testdata/operations_config/config-constraint.yaml b/test/testdata/operations_config/config-constraint.yaml
index 0e90da045d9..779be55fb5f 100644
--- a/test/testdata/operations_config/config-constraint.yaml
+++ b/test/testdata/operations_config/config-constraint.yaml
@@ -1,10 +1,10 @@
-apiVersion: apps.kubeblocks.io/v1alpha1
+apiVersion: apps.kubeblocks.io/v1
kind: ConfigConstraint
metadata:
name: mysql-tree-node-template-8.0
spec:
# ConfigurationSchema that impose restrictions on engine parameter's rule
- configurationSchema:
+ configSchema:
# schema: auto generate from cue scripts
# example: ../../pkg/configuration/testdata/mysql_openapi.json
cue: |-
diff --git a/test/testdata/resources/mysql-config-constraint-not-validate.yaml b/test/testdata/resources/mysql-config-constraint-not-validate.yaml
index 92d4b657b71..232740e9e57 100644
--- a/test/testdata/resources/mysql-config-constraint-not-validate.yaml
+++ b/test/testdata/resources/mysql-config-constraint-not-validate.yaml
@@ -1,13 +1,8 @@
-apiVersion: apps.kubeblocks.io/v1alpha1
+apiVersion: apps.kubeblocks.io/v1
kind: ConfigConstraint
metadata:
name: mysql-tree-node-template-8.0
spec:
- # configmap reference
- tplRef: mysql-tree-node-template-8.0
-
- # cfgSchemaTopLevelName: MysqlParameter
-
# ConfigurationSchema that impose restrictions on engine parameter's rule
# configurationSchema:
# # schema: auto generate from cue scripts
@@ -22,10 +17,4 @@ spec:
formatterConfig:
format: ini
iniConfig:
- sectionName: mysqld
-
- # Immutable, if set to true, ensures that data stored in the ConfigMap cannot be updated (only object metadata can be modified).
- # If set to true, Configmap object referenced by TplRef will also be modified to immutable
- # Defaulted to true
- # It is recommended to turn this option on only during the development or testing phase.
- immutable: true
\ No newline at end of file
+ sectionName: mysqld
\ No newline at end of file
diff --git a/test/testdata/resources/mysql-config-constraint.yaml b/test/testdata/resources/mysql-config-constraint.yaml
index c807a641291..4c24bc59994 100644
--- a/test/testdata/resources/mysql-config-constraint.yaml
+++ b/test/testdata/resources/mysql-config-constraint.yaml
@@ -1,19 +1,19 @@
-apiVersion: apps.kubeblocks.io/v1alpha1
+apiVersion: apps.kubeblocks.io/v1
kind: ConfigConstraint
metadata:
name: mysql-tree-node-template-8.0
spec:
# configmap reference
- reloadOptions:
+ dynamicReloadAction:
unixSignalTrigger:
signal: SIGHUP
processName: mysqld
# top level mysql configuration type
- cfgSchemaTopLevelName: MysqlParameter
+ configSchemaTopLevelKey: MysqlParameter
# ConfigurationSchema that impose restrictions on engine parameter's rule
- configurationSchema:
+ configSchema:
# schema: auto generate from cue scripts
# example: ../../pkg/configuration/testdata/mysql_openapi.json
cue: |-
diff --git a/test/testdata/resources/mysql-consensus-config-constraint.yaml b/test/testdata/resources/mysql-consensus-config-constraint.yaml
index 5465ea78111..59908b695f9 100644
--- a/test/testdata/resources/mysql-consensus-config-constraint.yaml
+++ b/test/testdata/resources/mysql-consensus-config-constraint.yaml
@@ -1,4 +1,4 @@
-apiVersion: apps.kubeblocks.io/v1alpha1
+apiVersion: apps.kubeblocks.io/v1
kind: ConfigConstraint
metadata:
name: mysql8.0-config-constraints
@@ -11,18 +11,15 @@ metadata:
spec:
# configmap reference
# tplRef: mysql-3node-tpl-8.0
- reloadOptions:
+ dynamicReloadAction:
tplScriptTrigger:
scriptConfigMapRef: mysql-reload-script
-
-
-
# top level mysql configuration type
- cfgSchemaTopLevelName: MysqlParameter
+ configSchemaTopLevelKey: MysqlParameter
# ConfigurationSchema that impose restrictions on engine parameter's rule
- configurationSchema:
+ configSchema:
# schema: auto generate from mmmcue scripts
# example: ../../pkg/configuration/testdata/mysql_openapi.json
cue: |-