Skip to content

Commit 7340583

Browse files
pratap0007tekton-robot
authored andcommitted
Update TektonConfig CR's addon params to remove cluster tasks params
Cluster tasks have been deprecated and removed, previous version of TektonConfig CR's addon params have the clusterTasks and communityClusterTasks params and need to remove it from the TektonConfig's addon params this removes the cluster tasks params from TektonConfig's addon params and updates it Signed-off-by: Shiv Verma <shverma@redhat.com>'
1 parent 30442eb commit 7340583

File tree

7 files changed

+38
-15
lines changed

7 files changed

+38
-15
lines changed

pkg/apis/operator/v1alpha1/const.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ const (
3333
ProfileLite = "lite"
3434

3535
// Addon Params
36-
// Keeping ClusterTasksParams and CommunityClusterTasks params for backward compatibility
37-
// will be removed from next operator api release
38-
ClusterTasksParam = "clusterTasks"
39-
CommunityClusterTasks = "communityClusterTasks"
4036
PipelineTemplatesParam = "pipelineTemplates"
4137
ResolverTasks = "resolverTasks"
4238
ResolverStepActions = "resolverStepActions"
@@ -113,10 +109,6 @@ var (
113109
}
114110

115111
AddonParams = map[string]ParamValue{
116-
// Keeping ClusterTasks and CommunityClusterTasks params
117-
// for backward compatibility and will be removed in next operator api release
118-
ClusterTasksParam: defaultParamValue,
119-
CommunityClusterTasks: defaultParamValue,
120112
PipelineTemplatesParam: defaultParamValue,
121113
ResolverTasks: defaultParamValue,
122114
ResolverStepActions: defaultParamValue,

pkg/apis/operator/v1alpha1/tektonaddon_default_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func Test_AddonSetDefaults_DefaultParamsWithValues(t *testing.T) {
3939
}
4040

4141
ta.SetDefaults(context.TODO())
42-
assert.Equal(t, 5, len(ta.Spec.Params))
42+
assert.Equal(t, 3, len(ta.Spec.Params))
4343

4444
params := ParseParams(ta.Spec.Params)
4545
value, ok := params[PipelineTemplatesParam]
@@ -70,7 +70,7 @@ func Test_AddonSetDefaults_ResolverTaskIsFalse(t *testing.T) {
7070
}
7171

7272
ta.SetDefaults(context.TODO())
73-
assert.Equal(t, 5, len(ta.Spec.Params))
73+
assert.Equal(t, 3, len(ta.Spec.Params))
7474

7575
params := ParseParams(ta.Spec.Params)
7676
value, ok := params[ResolverTasks]
@@ -101,7 +101,7 @@ func Test_AddonSetDefaults_ResolverStepActions(t *testing.T) {
101101
}
102102

103103
ta.SetDefaults(context.TODO())
104-
assert.Equal(t, 5, len(ta.Spec.Params))
104+
assert.Equal(t, 3, len(ta.Spec.Params))
105105

106106
params := ParseParams(ta.Spec.Params)
107107
value, ok := params[ResolverStepActions]

pkg/apis/operator/v1alpha1/tektonaddon_validation.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ func validateAddonParams(params []Param, pathToParams string) *apis.FieldError {
4848
var errs *apis.FieldError
4949

5050
for i, p := range params {
51+
// Todo: Remove this in next operator release
52+
if p.Name == "clusterTasks" || p.Name == "communityClusterTasks" {
53+
continue
54+
}
5155
paramValue, ok := AddonParams[p.Name]
5256
if !ok {
5357
errs = errs.Also(apis.ErrInvalidKeyName(p.Name, pathToParams))

pkg/apis/operator/v1alpha1/tektonconfig_default_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func Test_SetDefaults_Addon_Params(t *testing.T) {
8989
t.Setenv("PLATFORM", "openshift")
9090

9191
tc.SetDefaults(context.TODO())
92-
if len(tc.Spec.Addon.Params) != 5 {
92+
if len(tc.Spec.Addon.Params) != 3 {
9393
t.Error("Setting default failed for TektonConfig (spec.addon.params)")
9494
}
9595
}

pkg/reconciler/shared/tektonconfig/upgrade/pre_upgrade.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,30 @@ func upgradePipelineProperties(ctx context.Context, logger *zap.SugaredLogger, k
7575
}
7676
return nil
7777
}
78+
79+
// previous version of the TektonConfig CR's addon params has cluster task params to manage the cluster tasks
80+
// and cluster tasks have been deprecated and removed so need to remove the clusterTasks and communityClusterTasks
81+
// params from TektonConfig's addon params and this removes the cluster tasks params and updates TektonConfig's addon params
82+
// Todo: remove this in the next operator release
83+
func removeDeprecatedAddonParams(ctx context.Context, logger *zap.SugaredLogger, k8sClient kubernetes.Interface, operatorClient versioned.Interface, restConfig *rest.Config) error {
84+
tcCR, err := operatorClient.OperatorV1alpha1().TektonConfigs().Get(ctx, v1alpha1.ConfigResourceName, metav1.GetOptions{})
85+
if err != nil {
86+
if apierrs.IsNotFound(err) {
87+
return nil
88+
}
89+
return err
90+
}
91+
92+
updatedParams := []v1alpha1.Param{}
93+
for _, p := range tcCR.Spec.Addon.Params {
94+
if p.Name == "clusterTasks" || p.Name == "communityClusterTasks" {
95+
continue
96+
}
97+
updatedParams = append(updatedParams, p)
98+
}
99+
100+
// update the Tekton config's addon params
101+
tcCR.Spec.Addon.Params = updatedParams
102+
_, err = operatorClient.OperatorV1alpha1().TektonConfigs().Update(ctx, tcCR, metav1.UpdateOptions{})
103+
return err
104+
}

pkg/reconciler/shared/tektonconfig/upgrade/upgrade.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ var (
3333
// pre upgrade functions
3434
preUpgradeFunctions = []upgradeFunc{
3535
resetTektonConfigConditions, // upgrade #1: removes conditions from TektonConfig CR, clears outdated conditions
36-
upgradePipelineProperties, // update default value of enable-step-actions from false to true
36+
upgradePipelineProperties, // upgrade #2: update default value of enable-step-actions from false to true
37+
// Todo: Remove the removeDeprecatedAddonParams upgrade function in next operator release
38+
removeDeprecatedAddonParams, // upgrade #3: remove the deprecated cluster task params from TektonConfig CR's addon params
3739
}
3840

3941
// post upgrade functions

test/e2e/common/00_tektonconfigdeployment_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,6 @@ func (s *TektonConfigTestSuite) Test05_DisableAndEnableAddons() {
349349
// disable addons and update
350350
tc := s.getCurrentConfig(timeout)
351351
tc.Spec.Addon.Params = []v1alpha1.Param{
352-
{Name: v1alpha1.ClusterTasksParam, Value: "false"},
353-
{Name: v1alpha1.CommunityClusterTasks, Value: "false"},
354352
{Name: v1alpha1.PipelineTemplatesParam, Value: "false"},
355353
}
356354
_, err := s.clients.TektonConfig().Update(context.TODO(), tc, metav1.UpdateOptions{})

0 commit comments

Comments
 (0)