Skip to content

Commit

Permalink
Handle upgrade from older version which has pruner defaults
Browse files Browse the repository at this point in the history
Before webhook we had default value for pruner's keep as 1
but we expect user to define all values now 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

Signed-off-by: Shivam Mukhade <[email protected]>
  • Loading branch information
Shivam Mukhade committed Sep 6, 2021
1 parent 8ceeabb commit a0a6c6e
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 @@ -26,4 +26,20 @@ func (tc *TektonConfig) SetDefaults(ctx context.Context) {
}

tc.Spec.Pipeline.PipelineProperties.setDefaults()

// before webhook we had default value for pruner's keep as 1
// but we expect user to define all values now
// 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 a0a6c6e

Please sign in to comment.