9
9
10
10
buildv1alpha1 "github.com/shipwright-io/build/pkg/apis/build/v1alpha1"
11
11
"github.com/shipwright-io/build/pkg/config"
12
- "github.com/shipwright-io/build/pkg/ctxlog"
13
12
corev1 "k8s.io/api/core/v1"
14
13
"sigs.k8s.io/controller-runtime/pkg/controller"
15
14
"sigs.k8s.io/controller-runtime/pkg/event"
@@ -27,9 +26,8 @@ const (
27
26
28
27
// Add creates a new BuildRun_ttl_cleanup Controller and adds it to the Manager. The Manager will set fields on the Controller
29
28
// and Start it when the Manager is Started.
30
- func Add (ctx context.Context , c * config.Config , mgr manager.Manager ) error {
31
- ctx = ctxlog .NewContext (ctx , "buildrun-ttl-cleanup-controller" )
32
- return add (ctx , mgr , NewReconciler (c , mgr ), c .Controllers .BuildRun .MaxConcurrentReconciles )
29
+ func Add (_ context.Context , c * config.Config , mgr manager.Manager ) error {
30
+ return add (mgr , NewReconciler (c , mgr ), c .Controllers .BuildRun .MaxConcurrentReconciles )
33
31
}
34
32
35
33
// reconcileCompletedBuildRun returns true if the object has the required TTL parameters
@@ -58,7 +56,7 @@ func reconcileCompletedBuildRun(condition *buildv1alpha1.Condition, o *buildv1al
58
56
59
57
// reconcileAlreadyCompletedBuildRun returns true only if the TTL limit was introduced
60
58
// or if it was lowered as the object was completed before the update
61
- func reconcileAlreadyCompletedBuildRun (newCondition * buildv1alpha1.Condition , oldCondition * buildv1alpha1. Condition , n * buildv1alpha1.BuildRun , o * buildv1alpha1.BuildRun ) bool {
59
+ func reconcileAlreadyCompletedBuildRun (newCondition * buildv1alpha1.Condition , n * buildv1alpha1.BuildRun , o * buildv1alpha1.BuildRun ) bool {
62
60
if newCondition .Status == corev1 .ConditionTrue {
63
61
// check if a successful BuildRun has a TTL that was lowered or introduced
64
62
if (o .Spec .Retention == nil || o .Spec .Retention .TTLAfterSucceeded == nil ) && n .Spec .Retention != nil && n .Spec .Retention .TTLAfterSucceeded != nil {
@@ -81,7 +79,7 @@ func reconcileAlreadyCompletedBuildRun(newCondition *buildv1alpha1.Condition, ol
81
79
return false
82
80
}
83
81
84
- func add (ctx context. Context , mgr manager.Manager , r reconcile.Reconciler , maxConcurrentReconciles int ) error {
82
+ func add (mgr manager.Manager , r reconcile.Reconciler , maxConcurrentReconciles int ) error {
85
83
// Create the controller options
86
84
options := controller.Options {
87
85
Reconciler : r ,
@@ -128,7 +126,7 @@ func add(ctx context.Context, mgr manager.Manager, r reconcile.Reconciler, maxCo
128
126
129
127
// for objects that were already complete, check if the TTL was lowered or introduced
130
128
if oldCondition != nil && oldCondition .Status != corev1 .ConditionUnknown {
131
- return reconcileAlreadyCompletedBuildRun (newCondition , oldCondition , n , o )
129
+ return reconcileAlreadyCompletedBuildRun (newCondition , n , o )
132
130
}
133
131
134
132
return false
@@ -139,8 +137,5 @@ func add(ctx context.Context, mgr manager.Manager, r reconcile.Reconciler, maxCo
139
137
},
140
138
}
141
139
// Watch for changes to primary resource BuildRun
142
- if err = c .Watch (& source.Kind {Type : & buildv1alpha1.BuildRun {}}, & handler.EnqueueRequestForObject {}, predBuildRun ); err != nil {
143
- return err
144
- }
145
- return nil
140
+ return c .Watch (& source.Kind {Type : & buildv1alpha1.BuildRun {}}, & handler.EnqueueRequestForObject {}, predBuildRun )
146
141
}
0 commit comments