Skip to content

Commit 044dde7

Browse files
Fix new golangci-lint findings
1 parent 45f2308 commit 044dde7

File tree

7 files changed

+19
-37
lines changed

7 files changed

+19
-37
lines changed

cmd/git/main.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -529,11 +529,7 @@ func writeErrorResults(failure *shpgit.ErrorResult) (err error) {
529529
return err
530530
}
531531

532-
if err = os.WriteFile(flagValues.resultFileErrorReason, []byte(failure.Reason.String()), 0666); err != nil {
533-
return err
534-
}
535-
536-
return nil
532+
return os.WriteFile(flagValues.resultFileErrorReason, []byte(failure.Reason.String()), 0666)
537533
}
538534

539535
func cleanURL() string {

cmd/waiter/main.go

-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ func newDoneCmd() *cobra.Command {
107107
func main() {
108108
if err := rootCmd.Execute(); err != nil {
109109
log.Fatalf("[ERROR] %v\n", err)
110-
os.Exit(1)
111110
}
112111
os.Exit(0)
113112
}

pkg/reconciler/buildlimitcleanup/controller.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99

1010
buildv1alpha1 "github.com/shipwright-io/build/pkg/apis/build/v1alpha1"
1111
"github.com/shipwright-io/build/pkg/config"
12-
"github.com/shipwright-io/build/pkg/ctxlog"
1312
corev1 "k8s.io/api/core/v1"
1413
"k8s.io/apimachinery/pkg/types"
1514
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -29,11 +28,10 @@ const (
2928

3029
// Add creates a new build_limit_cleanup Controller and adds it to the Manager. The Manager will set fields on the Controller
3130
// and Start it when the Manager is Started
32-
func Add(ctx context.Context, c *config.Config, mgr manager.Manager) error {
33-
ctx = ctxlog.NewContext(ctx, "build-limit-cleanup-controller")
34-
return add(ctx, mgr, NewReconciler(c, mgr), c.Controllers.Build.MaxConcurrentReconciles)
31+
func Add(_ context.Context, c *config.Config, mgr manager.Manager) error {
32+
return add(mgr, NewReconciler(c, mgr), c.Controllers.Build.MaxConcurrentReconciles)
3533
}
36-
func add(ctx context.Context, mgr manager.Manager, r reconcile.Reconciler, maxConcurrentReconciles int) error {
34+
func add(mgr manager.Manager, r reconcile.Reconciler, maxConcurrentReconciles int) error {
3735
// Create the controller options
3836
options := controller.Options{
3937
Reconciler: r,

pkg/reconciler/buildrun/controller.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,18 @@ import (
2525

2626
buildv1alpha1 "github.com/shipwright-io/build/pkg/apis/build/v1alpha1"
2727
"github.com/shipwright-io/build/pkg/config"
28-
"github.com/shipwright-io/build/pkg/ctxlog"
2928
)
3029

3130
type setOwnerReferenceFunc func(owner, object metav1.Object, scheme *runtime.Scheme) error
3231

3332
// Add creates a new BuildRun Controller and adds it to the Manager. The Manager will set fields on the Controller
3433
// and Start it when the Manager is Started.
35-
func Add(ctx context.Context, c *config.Config, mgr manager.Manager) error {
36-
ctx = ctxlog.NewContext(ctx, "buildrun-controller")
37-
return add(ctx, mgr, NewReconciler(c, mgr, controllerutil.SetControllerReference), c.Controllers.BuildRun.MaxConcurrentReconciles)
34+
func Add(_ context.Context, c *config.Config, mgr manager.Manager) error {
35+
return add(mgr, NewReconciler(c, mgr, controllerutil.SetControllerReference), c.Controllers.BuildRun.MaxConcurrentReconciles)
3836
}
3937

4038
// add adds a new Controller to mgr with r as the reconcile.Reconciler
41-
func add(ctx context.Context, mgr manager.Manager, r reconcile.Reconciler, maxConcurrentReconciles int) error {
39+
func add(mgr manager.Manager, r reconcile.Reconciler, maxConcurrentReconciles int) error {
4240
// Create the controller options
4341
options := controller.Options{
4442
Reconciler: r,

pkg/reconciler/buildrunttlcleanup/controller.go

+6-11
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99

1010
buildv1alpha1 "github.com/shipwright-io/build/pkg/apis/build/v1alpha1"
1111
"github.com/shipwright-io/build/pkg/config"
12-
"github.com/shipwright-io/build/pkg/ctxlog"
1312
corev1 "k8s.io/api/core/v1"
1413
"sigs.k8s.io/controller-runtime/pkg/controller"
1514
"sigs.k8s.io/controller-runtime/pkg/event"
@@ -27,9 +26,8 @@ const (
2726

2827
// Add creates a new BuildRun_ttl_cleanup Controller and adds it to the Manager. The Manager will set fields on the Controller
2928
// 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)
3331
}
3432

3533
// reconcileCompletedBuildRun returns true if the object has the required TTL parameters
@@ -58,7 +56,7 @@ func reconcileCompletedBuildRun(condition *buildv1alpha1.Condition, o *buildv1al
5856

5957
// reconcileAlreadyCompletedBuildRun returns true only if the TTL limit was introduced
6058
// 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 {
6260
if newCondition.Status == corev1.ConditionTrue {
6361
// check if a successful BuildRun has a TTL that was lowered or introduced
6462
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
8179
return false
8280
}
8381

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 {
8583
// Create the controller options
8684
options := controller.Options{
8785
Reconciler: r,
@@ -128,7 +126,7 @@ func add(ctx context.Context, mgr manager.Manager, r reconcile.Reconciler, maxCo
128126

129127
// for objects that were already complete, check if the TTL was lowered or introduced
130128
if oldCondition != nil && oldCondition.Status != corev1.ConditionUnknown {
131-
return reconcileAlreadyCompletedBuildRun(newCondition, oldCondition, n, o)
129+
return reconcileAlreadyCompletedBuildRun(newCondition, n, o)
132130
}
133131

134132
return false
@@ -139,8 +137,5 @@ func add(ctx context.Context, mgr manager.Manager, r reconcile.Reconciler, maxCo
139137
},
140138
}
141139
// 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)
146141
}

pkg/reconciler/buildstrategy/controller.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,16 @@ import (
1515

1616
buildv1alpha1 "github.com/shipwright-io/build/pkg/apis/build/v1alpha1"
1717
"github.com/shipwright-io/build/pkg/config"
18-
"github.com/shipwright-io/build/pkg/ctxlog"
1918
)
2019

2120
// Add creates a new BuildStrategy Controller and adds it to the Manager. The Manager will set fields on the Controller
2221
// and Start it when the Manager is Started.
23-
func Add(ctx context.Context, c *config.Config, mgr manager.Manager) error {
24-
ctx = ctxlog.NewContext(ctx, "buildstrategy-controller")
25-
return add(ctx, mgr, NewReconciler(c, mgr), c.Controllers.BuildStrategy.MaxConcurrentReconciles)
22+
func Add(_ context.Context, c *config.Config, mgr manager.Manager) error {
23+
return add(mgr, NewReconciler(c, mgr), c.Controllers.BuildStrategy.MaxConcurrentReconciles)
2624
}
2725

2826
// add adds a new Controller to mgr with r as the reconcile.Reconciler
29-
func add(ctx context.Context, mgr manager.Manager, r reconcile.Reconciler, maxConcurrentReconciles int) error {
27+
func add(mgr manager.Manager, r reconcile.Reconciler, maxConcurrentReconciles int) error {
3028
// Create the controller options
3129
options := controller.Options{
3230
Reconciler: r,

pkg/reconciler/clusterbuildstrategy/controller.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,16 @@ import (
1515

1616
buildv1alpha1 "github.com/shipwright-io/build/pkg/apis/build/v1alpha1"
1717
"github.com/shipwright-io/build/pkg/config"
18-
"github.com/shipwright-io/build/pkg/ctxlog"
1918
)
2019

2120
// Add creates a new ClusterBuildStrategy Controller and adds it to the Manager. The Manager will set fields on the Controller
2221
// and Start it when the Manager is Started.
23-
func Add(ctx context.Context, c *config.Config, mgr manager.Manager) error {
24-
ctx = ctxlog.NewContext(ctx, "clusterbuildstrategy-controller")
25-
return add(ctx, mgr, NewReconciler(c, mgr), c.Controllers.ClusterBuildStrategy.MaxConcurrentReconciles)
22+
func Add(_ context.Context, c *config.Config, mgr manager.Manager) error {
23+
return add(mgr, NewReconciler(c, mgr), c.Controllers.ClusterBuildStrategy.MaxConcurrentReconciles)
2624
}
2725

2826
// add adds a new Controller to mgr with r as the reconcile.Reconciler
29-
func add(ctx context.Context, mgr manager.Manager, r reconcile.Reconciler, maxConcurrentReconciles int) error {
27+
func add(mgr manager.Manager, r reconcile.Reconciler, maxConcurrentReconciles int) error {
3028
// Create the controller options
3129
options := controller.Options{
3230
Reconciler: r,

0 commit comments

Comments
 (0)