From f1b3a7da824012b12934d18b6e5f62759145863a Mon Sep 17 00:00:00 2001 From: Shivam Mukhade Date: Tue, 7 Sep 2021 16:14:31 +0530 Subject: [PATCH] [OpenShift] Add param to enable/disable servicemonitor This adds a param in TektonConfig & TektonPipeline to disable service monitor which is a part of TektonPipelines for OpenShift. Param will be added by default, user can change the value in TektonConfig to false to disable. Value is added in openshift extension and not in webhook as this is platform specific param. If invalid value is passed then default value is set for param to avoid installation failure. Users can pass valid values and change the param. Signed-off-by: Shivam Mukhade --- .../operator/v1alpha1/tektonconfig_defaults.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pkg/apis/operator/v1alpha1/tektonconfig_defaults.go b/pkg/apis/operator/v1alpha1/tektonconfig_defaults.go index 55ba1ec116..1895101b38 100644 --- a/pkg/apis/operator/v1alpha1/tektonconfig_defaults.go +++ b/pkg/apis/operator/v1alpha1/tektonconfig_defaults.go @@ -28,4 +28,20 @@ func (tc *TektonConfig) SetDefaults(ctx context.Context) { tc.Spec.Pipeline.PipelineProperties.setDefaults() setAddonDefaults(&tc.Spec.Addon.Params) + + // before adding webhook we had default value for pruner's keep as 1 + // but we expect user to define all values now otherwise webhook reject + // request so if a user has installed prev version and has not enabled + // pruner then `keep` will have a value 1 and after upgrading + // to newer version webhook will fail if keep has a value and + // other fields are not defined + // this handles that case by removing the default for keep if + // other pruner fields are not defined + if len(tc.Spec.Pruner.Resources) == 0 { + tc.Spec.Pruner.Keep = nil + tc.Spec.Pruner.Schedule = "" + } else if tc.Spec.Pruner.Schedule == "" { + tc.Spec.Pruner.Keep = nil + tc.Spec.Pruner.Resources = []string{} + } }