Skip to content

Commit

Permalink
fix: Set TektonConfig Pruner
Browse files Browse the repository at this point in the history
Starting in Tekton Operator v0.58.0, TektonConfig objects must set a
value for `keep` or `keepSince` if the pruner is enabled [1].
If Shipwright bootstraps the TektonConfig object and does not set a
value for `.spec.pruner.keep` (or `.keepSince`), it risks failing to
reconcile the TektonConfig instance or worse [2].

Fixing by setting the `keep` value to match the Tekton operator
default.

Fixes #231

[1] tektoncd/operator#410
[2] tektoncd/operator#2450
  • Loading branch information
adambkaplan committed Dec 11, 2024
1 parent cc83aee commit 3b310b3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/tekton/tekton.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ func IsTektonConfigPresent(ctx context.Context, client tektonoperatorclientv1alp
// CreateTektonConfigWithProfileAndTargetNamespace creates a TektonConfig object with the given
// profile and target namespace for Tekton components.
func CreateTektonConfigWithProfileAndTargetNamespace(ctx context.Context, client tektonoperatorclientv1alpha1.OperatorV1alpha1Interface, profile string, targetNamepsace string) (*tektonoperatorv1alpha1.TektonConfig, error) {
// If creating a TektonConfig, enable the pruner with default keep of 100
// This matches the Tekton operator default
keep := uint(100)
tektonConfig := &tektonoperatorv1alpha1.TektonConfig{
ObjectMeta: metav1.ObjectMeta{
Name: "config",
Expand All @@ -111,6 +114,10 @@ func CreateTektonConfigWithProfileAndTargetNamespace(ctx context.Context, client
CommonSpec: tektonoperatorv1alpha1.CommonSpec{
TargetNamespace: targetNamepsace,
},
Pruner: tektonoperatorv1alpha1.Prune{
Disabled: false,
Keep: &keep,
},
},
}
return client.TektonConfigs().Create(ctx, tektonConfig, metav1.CreateOptions{})
Expand Down
2 changes: 2 additions & 0 deletions pkg/tekton/tekton_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ func TestReconcileTekton(t *testing.T) {
g.Expect(tektonConfig.Name).To(o.Equal("config"))
g.Expect(tektonConfig.Spec.Profile).To(o.Equal("lite"))
g.Expect(tektonConfig.Spec.TargetNamespace).To(o.Equal("tekton-pipelines"))
g.Expect(tektonConfig.Spec.Pruner.Disabled).To(o.Equal(false))
g.Expect(tektonConfig.Spec.Pruner.Keep).NotTo(o.BeNil())
}
})
}
Expand Down

0 comments on commit 3b310b3

Please sign in to comment.