Skip to content

Commit

Permalink
chore: rebase main
Browse files Browse the repository at this point in the history
  • Loading branch information
sophon-zt committed Nov 15, 2024
1 parent 9a48472 commit 46049c9
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 318 deletions.
3 changes: 0 additions & 3 deletions controllers/apps/componentdefinition_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,6 @@ func (r *ComponentDefinitionReconciler) deletionHandler(rctx intctrlutil.Request
recordEvent, &appsv1.ComponentList{}); res != nil || err != nil {
return res, err
}
if err := appsconfig.DeleteConfigMapFinalizer(r.Client, rctx, cmpd); err != nil {
return &ctrl.Result{}, err
}
return nil, nil
}
}
Expand Down
8 changes: 4 additions & 4 deletions controllers/apps/transformer_component_tls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"

appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
"github.com/apecloud/kubeblocks/pkg/configuration/core"
parametersv1alpha1 "github.com/apecloud/kubeblocks/apis/parameters/v1alpha1"
configcore "github.com/apecloud/kubeblocks/pkg/configuration/core"
"github.com/apecloud/kubeblocks/pkg/constant"
"github.com/apecloud/kubeblocks/pkg/controller/component"
"github.com/apecloud/kubeblocks/pkg/controller/graph"
Expand Down Expand Up @@ -185,11 +185,11 @@ var _ = Describe("TLS self-signed cert function", func() {
Eventually(testapps.ClusterReconciled(&testCtx, clusterKey)).Should(BeTrue())
Eventually(testapps.GetClusterPhase(&testCtx, clusterKey)).Should(Equal(appsv1.CreatingClusterPhase))
cfgKey := client.ObjectKey{
Name: core.GenerateComponentConfigurationName(clusterObj.Name, defaultCompName),
Name: configcore.GenerateComponentParameterName(clusterObj.Name, defaultCompName),
Namespace: testCtx.DefaultNamespace,
}
hasTLSSettings := func() bool {
conf := &appsv1alpha1.Configuration{}
conf := &parametersv1alpha1.ComponentParameter{}
Expect(k8sClient.Get(ctx, cfgKey, conf)).Should(Succeed())
item := &conf.Spec.ConfigItemDetails[0]
if item.Payload.Data == nil {
Expand Down
33 changes: 16 additions & 17 deletions pkg/controller/builder/builder_parameter.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package builder
import (
appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
parametersv1alpha1 "github.com/apecloud/kubeblocks/apis/parameters/v1alpha1"
intctrlutil "github.com/apecloud/kubeblocks/pkg/controllerutil"
)

type ParameterBuilder struct {
Expand All @@ -38,29 +37,29 @@ func (c *ParameterBuilder) ClusterRef(clusterName string) *ParameterBuilder {
}

func (c *ParameterBuilder) SetComponentParameters(component string, parameters appsv1.ComponentParameters) *ParameterBuilder {
componentSpec := intctrlutil.GetParameter(&c.get().Spec, component)
if componentSpec != nil {
componentSpec.Parameters = parameters
return c
}
c.get().Spec.ComponentParameters = append(c.get().Spec.ComponentParameters, parametersv1alpha1.ComponentParametersSpec{
ComponentName: component,
Parameters: parameters,
})
componentSpec := safeGetComponentSpec(&c.get().Spec, component)
componentSpec.Parameters = parameters
return c
}

func (c *ParameterBuilder) AddCustomTemplate(component string, tpl string, customTemplates appsv1.ConfigTemplateExtension) *ParameterBuilder {
componentSpec := intctrlutil.GetParameter(&c.get().Spec, component)
if componentSpec == nil {
c.get().Spec.ComponentParameters = append(c.get().Spec.ComponentParameters, parametersv1alpha1.ComponentParametersSpec{
ComponentName: component,
})
}
componentSpec = intctrlutil.GetParameter(&c.get().Spec, component)
componentSpec := safeGetComponentSpec(&c.get().Spec, component)
if componentSpec.CustomTemplates == nil {
componentSpec.CustomTemplates = make(map[string]appsv1.ConfigTemplateExtension)
}
componentSpec.CustomTemplates[tpl] = customTemplates
return c
}

func safeGetComponentSpec(spec *parametersv1alpha1.ParameterSpec, component string) *parametersv1alpha1.ComponentParametersSpec {
for i, parameter := range spec.ComponentParameters {
if parameter.ComponentName == component {
return &spec.ComponentParameters[i]
}
}
var size = len(spec.ComponentParameters)
spec.ComponentParameters = append(spec.ComponentParameters, parametersv1alpha1.ComponentParametersSpec{
ComponentName: component,
})
return &spec.ComponentParameters[size]
}
2 changes: 1 addition & 1 deletion pkg/controller/configuration/config_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func handleInjectEnv(ctx context.Context,
return err
}
for _, obj := range envObjs {
if err = intctrlutil.IgnoreIsAlreadyExists(cli.Create(ctx, obj)); err != nil {
if err = intctrlutil.IgnoreIsAlreadyExists(cli.Create(ctx, obj, inDataContext())); err != nil {
return err
}
}
Expand Down
4 changes: 0 additions & 4 deletions pkg/controller/configuration/parameter_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ var _ = Describe("resource Fetcher", func() {
// clusterObj, _, _ = newAllFieldsClusterObj(compDefObj, false)
})

AfterEach(func() {
DeferCleanup()
})

Context("ClassifyParamsFromConfigTemplate", func() {
It("Should succeed with no error with one paramDef", func() {
parameters := appsv1.ComponentParameters{
Expand Down
2 changes: 0 additions & 2 deletions pkg/controller/configuration/template_render.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ func RenderTemplate(resourceCtx *ResourceCtx,
for _, tpl := range tpls {
configCMName := core.GetComponentCfgName(cluster.Name, synthesizedComponent.Name, tpl.Name)
if configCM, err = generateConfigMapFromTemplate(cluster, synthesizedComponent, tplBuilder, configCMName, tpl, resourceCtx.Context, reconcileCtx.Client, nil); err != nil {
}
if err != nil {
return nil, err
}
if err = intctrlutil.SetOwnerReference(comp, configCM); err != nil {
Expand Down
Loading

0 comments on commit 46049c9

Please sign in to comment.