Skip to content

Commit be5ad8d

Browse files
committed
Fix lint errors reported by golang-lint
More fixes for various lint errors reported by revive and other linters. These are enough to make golang-lint pass
1 parent aa94403 commit be5ad8d

File tree

10 files changed

+26
-25
lines changed

10 files changed

+26
-25
lines changed

apis/memcached/v1beta1/memcached_webhook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func (r *Memcached) ValidateCreate() (admission.Warnings, error) {
8585
}
8686

8787
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
88-
func (r *Memcached) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
88+
func (r *Memcached) ValidateUpdate(_ runtime.Object) (admission.Warnings, error) {
8989
memcachedlog.Info("validate update", "name", r.Name)
9090

9191
// TODO(user): fill in your validation logic upon object update.

apis/network/v1beta1/common_webhook.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const (
3838
)
3939

4040
func getNetConfig(
41-
c client.Client,
41+
_ client.Client,
4242
obj metav1.Object,
4343
) (*NetConfig, error) {
4444
// check if NetConfig is available
@@ -62,7 +62,7 @@ func getNetConfig(
6262
}
6363

6464
func getIPSets(
65-
c client.Client,
65+
_ client.Client,
6666
obj metav1.Object,
6767
) (*IPSetList, error) {
6868
// check if IPSet is available

apis/network/v1beta1/dnsmasq_webhook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func (r *DNSMasq) ValidateCreate() (admission.Warnings, error) {
7979
}
8080

8181
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
82-
func (r *DNSMasq) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
82+
func (r *DNSMasq) ValidateUpdate(_ runtime.Object) (admission.Warnings, error) {
8383
dnsmasqlog.Info("validate update", "name", r.Name)
8484

8585
// TODO(user): fill in your validation logic upon object update.

apis/network/v1beta1/ipset_webhook_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ package v1beta1
1919
import (
2020
"testing"
2121

22-
. "github.com/onsi/gomega"
22+
. "github.com/onsi/gomega" //revive:disable:dot-imports
2323
apierrors "k8s.io/apimachinery/pkg/api/errors"
2424
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2525
"k8s.io/apimachinery/pkg/util/validation/field"
@@ -448,7 +448,7 @@ func TestIPSetUpdateValidation(t *testing.T) {
448448
g := NewWithT(t)
449449
basePath := field.NewPath("spec")
450450

451-
new := &IPSet{
451+
newCfg := &IPSet{
452452
ObjectMeta: metav1.ObjectMeta{
453453
Namespace: "foo",
454454
},
@@ -459,12 +459,12 @@ func TestIPSetUpdateValidation(t *testing.T) {
459459

460460
allErrs := valiateIPSetNetwork(tt.newSpec.Networks, basePath, &tt.n)
461461
if len(allErrs) > 0 {
462-
err = apierrors.NewInvalid(GroupVersion.WithKind("IPSet").GroupKind(), new.Name, allErrs)
462+
err = apierrors.NewInvalid(GroupVersion.WithKind("IPSet").GroupKind(), newCfg.Name, allErrs)
463463
}
464464

465465
allErrs = valiateIPSetChanged(tt.newSpec.Networks, tt.oldSpec.Networks, basePath)
466466
if len(allErrs) > 0 {
467-
err = apierrors.NewInvalid(GroupVersion.WithKind("IPSet").GroupKind(), new.Name, allErrs)
467+
err = apierrors.NewInvalid(GroupVersion.WithKind("IPSet").GroupKind(), newCfg.Name, allErrs)
468468
}
469469

470470
if tt.expectErr {

apis/network/v1beta1/netconfig_webhook.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,8 @@ func valiateUniqElement(
265265
}
266266

267267
// CIDRs must be uniq, while its possible to have same CIDR on different VLANs, we exlude this config
268+
//
269+
//lint:ignore U1000 valiateUniqCIDR
268270
func valiateUniqCIDR(
269271
netCIDRs map[int]map[string]field.Path,
270272
vlan *int,

apis/network/v1beta1/netconfig_webhook_test.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ package v1beta1
1919
import (
2020
"testing"
2121

22-
. "github.com/onsi/gomega"
22+
. "github.com/onsi/gomega" //revive:disable:dot-imports
2323
apierrors "k8s.io/apimachinery/pkg/api/errors"
2424
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2525
"k8s.io/apimachinery/pkg/util/validation/field"
@@ -1554,10 +1554,9 @@ func TestNetConfigValidation(t *testing.T) {
15541554
basePath := field.NewPath("spec")
15551555

15561556
if tt.expectErr {
1557-
g.Expect(len(valiateNetworks(tt.c.Spec.Networks, basePath))).Should(BeNumerically(">", 0))
1557+
g.Expect(valiateNetworks(tt.c.Spec.Networks, basePath)).ShouldNot(BeEmpty())
15581558
} else {
1559-
g.Expect(len(valiateNetworks(tt.c.Spec.Networks, basePath))).Should(BeNumerically("==", 0))
1560-
1559+
g.Expect(valiateNetworks(tt.c.Spec.Networks, basePath)).Should(BeEmpty())
15611560
}
15621561
})
15631562
}
@@ -1781,7 +1780,7 @@ func TestNetConfigUpdateValidation(t *testing.T) {
17811780
g := NewWithT(t)
17821781
basePath := field.NewPath("spec")
17831782

1784-
new := &NetConfig{
1783+
newCfg := &NetConfig{
17851784
ObjectMeta: metav1.ObjectMeta{
17861785
Namespace: "foo",
17871786
},
@@ -1792,12 +1791,12 @@ func TestNetConfigUpdateValidation(t *testing.T) {
17921791

17931792
allErrs := valiateNetworks(tt.newSpec.Networks, basePath)
17941793
if len(allErrs) > 0 {
1795-
err = apierrors.NewInvalid(GroupVersion.WithKind("NetConfig").GroupKind(), new.Name, allErrs)
1794+
err = apierrors.NewInvalid(GroupVersion.WithKind("NetConfig").GroupKind(), newCfg.Name, allErrs)
17961795
}
17971796

17981797
allErrs = valiateNetworksChanged(tt.newSpec.Networks, tt.oldSpec.Networks, basePath)
17991798
if len(allErrs) > 0 {
1800-
err = apierrors.NewInvalid(GroupVersion.WithKind("NetConfig").GroupKind(), new.Name, allErrs)
1799+
err = apierrors.NewInvalid(GroupVersion.WithKind("NetConfig").GroupKind(), newCfg.Name, allErrs)
18011800
}
18021801

18031802
if tt.expectErr {

apis/network/v1beta1/reservation_webhook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func (r *Reservation) ValidateCreate() (admission.Warnings, error) {
6161
}
6262

6363
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
64-
func (r *Reservation) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
64+
func (r *Reservation) ValidateUpdate(_ runtime.Object) (admission.Warnings, error) {
6565
reservationlog.Info("validate update", "name", r.Name)
6666

6767
// TODO(user): fill in your validation logic upon object update.

apis/redis/v1beta1/redis_webhook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func (r *Redis) ValidateCreate() (admission.Warnings, error) {
8585
}
8686

8787
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
88-
func (r *Redis) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
88+
func (r *Redis) ValidateUpdate(_ runtime.Object) (admission.Warnings, error) {
8989
redislog.Info("validate update", "name", r.Name)
9090

9191
// TODO(user): fill in your validation logic upon object update.

tests/functional/ipset_controller_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ var _ = Describe("IPSet controller", func() {
7474
Namespace: namespace,
7575
}
7676

77-
DeferCleanup(func(ctx SpecContext) {
77+
DeferCleanup(func(_ SpecContext) {
7878
th.DeleteInstance(ipset)
7979
th.DeleteInstance(netCfg)
8080
}, NodeTimeout(timeout))
@@ -115,7 +115,7 @@ var _ = Describe("IPSet controller", func() {
115115
Namespace: namespace,
116116
}
117117

118-
DeferCleanup(func(ctx SpecContext) {
118+
DeferCleanup(func(_ SpecContext) {
119119
th.DeleteInstance(ipset)
120120
th.DeleteInstance(netCfg)
121121
}, NodeTimeout(timeout))
@@ -155,7 +155,7 @@ var _ = Describe("IPSet controller", func() {
155155
Namespace: namespace,
156156
}
157157

158-
DeferCleanup(func(ctx SpecContext) {
158+
DeferCleanup(func(_ SpecContext) {
159159
th.DeleteInstance(ipset)
160160
th.DeleteInstance(netCfg)
161161
}, NodeTimeout(timeout))
@@ -195,7 +195,7 @@ var _ = Describe("IPSet controller", func() {
195195
Namespace: namespace,
196196
}
197197

198-
DeferCleanup(func(ctx SpecContext) {
198+
DeferCleanup(func(_ SpecContext) {
199199
th.DeleteInstance(ipset)
200200
th.DeleteInstance(netCfg)
201201
}, NodeTimeout(timeout))
@@ -248,7 +248,7 @@ var _ = Describe("IPSet controller", func() {
248248
Namespace: namespace,
249249
}
250250

251-
DeferCleanup(func(ctx SpecContext) {
251+
DeferCleanup(func(_ SpecContext) {
252252
th.DeleteInstance(ipset)
253253
th.DeleteInstance(netCfg)
254254
}, NodeTimeout(timeout))
@@ -291,7 +291,7 @@ var _ = Describe("IPSet controller", func() {
291291
Namespace: namespace,
292292
}
293293

294-
DeferCleanup(func(ctx SpecContext) {
294+
DeferCleanup(func(_ SpecContext) {
295295
th.DeleteInstance(ipset)
296296
th.DeleteInstance(netCfg)
297297
}, NodeTimeout(timeout))

tests/functional/netconfig_webhook_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ var _ = Describe("NetConfig webhook", func() {
3939
})
4040

4141
It("should have created a NetConfig", func() {
42-
Eventually(func(g Gomega) {
42+
Eventually(func(_ Gomega) {
4343
GetNetConfig(netConfigName)
4444
}, timeout, interval).Should(Succeed())
4545
})
@@ -84,7 +84,7 @@ var _ = Describe("NetConfig webhook", func() {
8484

8585
It("should not be possible to delete the NetConfig", func() {
8686
netcfg := &networkv1.NetConfig{}
87-
Eventually(func(g Gomega) {
87+
Eventually(func(_ Gomega) {
8888
netcfg = GetNetConfig(netConfigName)
8989
}, timeout, interval).Should(Succeed())
9090

0 commit comments

Comments
 (0)