Skip to content

Commit 99face7

Browse files
Merge pull request openstack-k8s-operators#188 from gibizer/full-golangci-lint
Ensure golangci-lint runs on all files
2 parents de4c66c + d3ea905 commit 99face7

17 files changed

+59
-52
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,5 @@ repos:
5151
- repo: https://github.com/golangci/golangci-lint
5252
rev: v1.55.2
5353
hooks:
54-
- id: golangci-lint
54+
- id: golangci-lint-full
5555
args: ["-v"]

apis/memcached/v1beta1/webhook_suite_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ import (
2525
"testing"
2626
"time"
2727

28-
. "github.com/onsi/ginkgo/v2"
29-
. "github.com/onsi/gomega"
28+
. "github.com/onsi/ginkgo/v2" //revive:disable:dot-imports
29+
. "github.com/onsi/gomega" //revive:disable:dot-imports
3030

3131
admissionv1beta1 "k8s.io/api/admission/v1beta1"
3232
//+kubebuilder:scaffold:imports

apis/redis/v1beta1/webhook_suite_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ import (
2525
"testing"
2626
"time"
2727

28-
. "github.com/onsi/ginkgo/v2"
29-
. "github.com/onsi/gomega"
28+
. "github.com/onsi/ginkgo/v2" //revive:disable:dot-imports
29+
. "github.com/onsi/gomega" //revive:disable:dot-imports
3030

3131
admissionv1beta1 "k8s.io/api/admission/v1beta1"
3232
//+kubebuilder:scaffold:imports

controllers/memcached/suite_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import (
2020
"path/filepath"
2121
"testing"
2222

23-
. "github.com/onsi/ginkgo/v2"
24-
. "github.com/onsi/gomega"
23+
. "github.com/onsi/ginkgo/v2" //revive:disable:dot-imports
24+
. "github.com/onsi/gomega" //revive:disable:dot-imports
2525

2626
"k8s.io/client-go/kubernetes/scheme"
2727
"k8s.io/client-go/rest"

controllers/network/ipset_controller.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ func (r *IPSetReconciler) Reconcile(ctx context.Context, req ctrl.Request) (resu
148148
}
149149

150150
// SetupWithManager sets up the controller with the Manager.
151-
func (r *IPSetReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager) error {
151+
func (r *IPSetReconciler) SetupWithManager(_ context.Context, mgr ctrl.Manager) error {
152152
ipsetFN := handler.EnqueueRequestsFromMapFunc(func(ctx context.Context, o client.Object) []reconcile.Request {
153153
Log := r.GetLogger(ctx)
154154
result := []reconcile.Request{}
@@ -316,7 +316,6 @@ func (r *IPSetReconciler) getReservation(ctx context.Context, instance *networkv
316316
func (r *IPSetReconciler) patchReservation(
317317
ctx context.Context,
318318
helper *helper.Helper,
319-
ipset *networkv1.IPSet,
320319
name types.NamespacedName,
321320
labels map[string]string,
322321
spec networkv1.ReservationSpec,
@@ -381,7 +380,6 @@ func (r *IPSetReconciler) ensureReservation(
381380
reservation, _err = r.patchReservation(
382381
ctx,
383382
helper,
384-
ipset,
385383
reservationName,
386384
reservationLabels,
387385
reservationSpec,

controllers/rabbitmq/suite_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import (
2020
"path/filepath"
2121
"testing"
2222

23-
. "github.com/onsi/ginkgo/v2"
24-
. "github.com/onsi/gomega"
23+
. "github.com/onsi/ginkgo/v2" //revive:disable:dot-imports
24+
. "github.com/onsi/gomega" //revive:disable:dot-imports
2525

2626
"k8s.io/client-go/kubernetes/scheme"
2727
"k8s.io/client-go/rest"

controllers/rabbitmq/transporturl_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ func (r *TransportURLReconciler) findObjectsForSrc(ctx context.Context, src clie
362362
FieldSelector: fields.OneTermEqualSelector(field, src.GetName()),
363363
Namespace: src.GetNamespace(),
364364
}
365-
err := r.List(context.TODO(), crList, listOps)
365+
err := r.List(ctx, crList, listOps)
366366
if err != nil {
367367
return []reconcile.Request{}
368368
}

controllers/redis/redis_controller.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,11 @@ import (
2727
"k8s.io/client-go/kubernetes"
2828
"k8s.io/client-go/rest"
2929
ctrl "sigs.k8s.io/controller-runtime"
30+
"sigs.k8s.io/controller-runtime/pkg/builder"
3031
"sigs.k8s.io/controller-runtime/pkg/client"
32+
"sigs.k8s.io/controller-runtime/pkg/handler"
3133
"sigs.k8s.io/controller-runtime/pkg/log"
34+
"sigs.k8s.io/controller-runtime/pkg/predicate"
3235
"sigs.k8s.io/controller-runtime/pkg/reconcile"
3336

3437
"github.com/go-logr/logr"
@@ -407,11 +410,16 @@ func (r *Reconciler) SetupWithManager(mgr ctrl.Manager) error {
407410
Owns(&corev1.ServiceAccount{}).
408411
Owns(&rbacv1.Role{}).
409412
Owns(&rbacv1.RoleBinding{}).
413+
Watches(
414+
&corev1.Secret{},
415+
handler.EnqueueRequestsFromMapFunc(r.findObjectsForSrc),
416+
builder.WithPredicates(predicate.ResourceVersionChangedPredicate{}),
417+
).
410418
Complete(r)
411419
}
412420

413421
// findObjectsForSrc - returns a reconcile request if the object is referenced by a Redis CR
414-
func (r *Reconciler) findObjectsForSrc(src client.Object) []reconcile.Request {
422+
func (r *Reconciler) findObjectsForSrc(ctx context.Context, src client.Object) []reconcile.Request {
415423
requests := []reconcile.Request{}
416424

417425
for _, field := range allWatchFields {
@@ -420,7 +428,7 @@ func (r *Reconciler) findObjectsForSrc(src client.Object) []reconcile.Request {
420428
FieldSelector: fields.OneTermEqualSelector(field, src.GetName()),
421429
Namespace: src.GetNamespace(),
422430
}
423-
err := r.List(context.TODO(), crList, listOps)
431+
err := r.List(ctx, crList, listOps)
424432
if err != nil {
425433
return []reconcile.Request{}
426434
}

controllers/redis/suite_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import (
2020
"path/filepath"
2121
"testing"
2222

23-
. "github.com/onsi/ginkgo/v2"
24-
. "github.com/onsi/gomega"
23+
. "github.com/onsi/ginkgo/v2" //revive:disable:dot-imports
24+
. "github.com/onsi/gomega" //revive:disable:dot-imports
2525

2626
"k8s.io/client-go/kubernetes/scheme"
2727
"k8s.io/client-go/rest"

tests/functional/base_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"strings"
2222
"time"
2323

24-
. "github.com/onsi/gomega"
24+
. "github.com/onsi/gomega" //revive:disable:dot-imports
2525

2626
"github.com/google/uuid"
2727
corev1 "k8s.io/api/core/v1"
@@ -397,11 +397,11 @@ func IPSetConditionGetter(name types.NamespacedName) condition.Conditions {
397397
}
398398

399399
func TransportURLConditionGetter(name types.NamespacedName) condition.Conditions {
400-
instance := infra.GetTransportURL(name)
400+
instance := th.GetTransportURL(name)
401401
return instance.Status.Conditions
402402
}
403403

404-
func CreateLoadBalancerService(name types.NamespacedName, addDnsAnno bool) *corev1.Service {
404+
func CreateLoadBalancerService(name types.NamespacedName, addDNSAnno bool) *corev1.Service {
405405
svc := &corev1.Service{
406406
ObjectMeta: metav1.ObjectMeta{
407407
Name: name.Name,
@@ -430,7 +430,7 @@ func CreateLoadBalancerService(name types.NamespacedName, addDnsAnno bool) *core
430430
},
431431
}
432432

433-
if addDnsAnno {
433+
if addDNSAnno {
434434
svc.Annotations[networkv1.AnnotationHostnameKey] = fmt.Sprintf("%s.%s.svc", name.Name, name.Namespace)
435435
}
436436

@@ -486,8 +486,8 @@ func GetDefaultNetConfigSpec() map[string]interface{} {
486486
}
487487

488488
func GetSubnet1(name string) networkv1.Subnet {
489-
var gw string = "172.17.0.1"
490-
var vlan int = 20
489+
var gw = "172.17.0.1"
490+
var vlan = 20
491491
return networkv1.Subnet{
492492
Name: networkv1.NetNameStr(name),
493493
Cidr: "172.17.0.0/24",
@@ -506,8 +506,8 @@ func GetSubnet1(name string) networkv1.Subnet {
506506
}
507507

508508
func GetSubnet2(name string) networkv1.Subnet {
509-
var gw string = "172.18.0.1"
510-
var vlan int = 21
509+
var gw = "172.18.0.1"
510+
var vlan = 21
511511
return networkv1.Subnet{
512512
Name: networkv1.NetNameStr(name),
513513
Cidr: "172.18.0.0/24",
@@ -523,7 +523,7 @@ func GetSubnet2(name string) networkv1.Subnet {
523523
}
524524

525525
func GetSubnetWithWrongExcludeAddress() networkv1.Subnet {
526-
var vlan int = 20
526+
var vlan = 20
527527
return networkv1.Subnet{
528528
Name: subnet1,
529529
Cidr: "172.17.0.0/24",

0 commit comments

Comments
 (0)