Skip to content

Commit

Permalink
[OpenShift] Add param to enable/disable servicemonitor
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Shivam Mukhade authored and tekton-robot committed Sep 13, 2021
1 parent 2ff75eb commit 0467af4
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pkg/apis/operator/v1alpha1/tektonconfig_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
}
}

0 comments on commit 0467af4

Please sign in to comment.