Skip to content

Commit 8a64e5f

Browse files
committed
🌱 Update golangc-lint to v1.53
Signed-off-by: Vince Prignano <vincepri@redhat.com>
1 parent a23f360 commit 8a64e5f

21 files changed

+215
-219
lines changed

.github/workflows/golangci-lint.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ jobs:
2222
- name: golangci-lint
2323
uses: golangci/golangci-lint-action@v3
2424
with:
25-
version: v1.52.1
25+
version: v1.53.3
2626
working-directory: ${{matrix.working-directory}}

.golangci.yml

+1-5
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ linters:
55
- asciicheck
66
- bidichk
77
- bodyclose
8-
- depguard
98
- dogsled
109
- dupl
1110
- errcheck
1211
- errchkjson
1312
- errorlint
1413
- exhaustive
1514
- exportloopref
15+
- ginkgolinter
1616
- goconst
1717
- gocritic
1818
- gocyclo
@@ -62,10 +62,6 @@ linters-settings:
6262
go: "1.20"
6363
stylecheck:
6464
go: "1.20"
65-
depguard:
66-
include-go-root: true
67-
packages:
68-
- io/ioutil # https://go.dev/doc/go1.16#ioutil
6965
revive:
7066
rules:
7167
# The following rules are recommended https://github.com/mgechev/revive#recommended-configuration

pkg/cache/cache_test.go

+15-15
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ var _ = Describe("Cache with transformers", func() {
193193
Expect(obj).NotTo(BeNil())
194194

195195
accessor, err := meta.Accessor(obj)
196-
Expect(err).To(BeNil())
196+
Expect(err).ToNot(HaveOccurred())
197197
annotations := accessor.GetAnnotations()
198198

199199
if _, exists := annotations["transformed"]; exists {
@@ -214,7 +214,7 @@ var _ = Describe("Cache with transformers", func() {
214214
obj := i.(runtime.Object)
215215
Expect(obj).NotTo(BeNil())
216216
accessor, err := meta.Accessor(obj)
217-
Expect(err).To(BeNil())
217+
Expect(err).ToNot(HaveOccurred())
218218

219219
annotations := accessor.GetAnnotations()
220220
if _, exists := annotations["transformed"]; exists {
@@ -401,15 +401,15 @@ var _ = Describe("Cache with selectors", func() {
401401
var sas corev1.ServiceAccountList
402402
err := informerCache.List(informerCacheCtx, &sas)
403403
Expect(err).NotTo(HaveOccurred())
404-
Expect(len(sas.Items)).To(Equal(1))
404+
Expect(sas.Items).To(HaveLen(1))
405405
Expect(sas.Items[0].Namespace).To(Equal(testNamespaceOne))
406406
})
407407

408408
It("Should list services and find exactly one in namespace "+testNamespaceTwo, func() {
409409
var svcs corev1.ServiceList
410410
err := informerCache.List(informerCacheCtx, &svcs)
411411
Expect(err).NotTo(HaveOccurred())
412-
Expect(len(svcs.Items)).To(Equal(1))
412+
Expect(svcs.Items).To(HaveLen(1))
413413
Expect(svcs.Items[0].Namespace).To(Equal(testNamespaceTwo))
414414
})
415415
})
@@ -618,7 +618,7 @@ func CacheTest(createCacheFunc func(config *rest.Config, opts cache.Options) (ca
618618
Expect(informerCache.List(context.Background(), outList2, client.InNamespace(testNamespaceOne))).To(Succeed())
619619

620620
By("verifying the pointer fields in pod have the same addresses")
621-
Expect(len(outList1.Items)).To(Equal(len(outList2.Items)))
621+
Expect(outList1.Items).To(HaveLen(len(outList2.Items)))
622622
sort.SliceStable(outList1.Items, func(i, j int) bool { return outList1.Items[i].Name <= outList1.Items[j].Name })
623623
sort.SliceStable(outList2.Items, func(i, j int) bool { return outList2.Items[i].Name <= outList2.Items[j].Name })
624624
for i := range outList1.Items {
@@ -798,7 +798,7 @@ func CacheTest(createCacheFunc func(config *rest.Config, opts cache.Options) (ca
798798
defer GinkgoRecover()
799799
Expect(namespacedCache.Start(informerCacheCtx)).To(Succeed())
800800
}()
801-
Expect(namespacedCache.WaitForCacheSync(informerCacheCtx)).NotTo(BeFalse())
801+
Expect(namespacedCache.WaitForCacheSync(informerCacheCtx)).To(BeTrue())
802802

803803
By("listing pods in all namespaces")
804804
out := &unstructured.UnstructuredList{}
@@ -893,7 +893,7 @@ func CacheTest(createCacheFunc func(config *rest.Config, opts cache.Options) (ca
893893
Expect(informerCache.List(context.Background(), outList2, client.InNamespace(testNamespaceOne))).To(Succeed())
894894

895895
By("verifying the pointer fields in pod have the same addresses")
896-
Expect(len(outList1.Items)).To(Equal(len(outList2.Items)))
896+
Expect(outList1.Items).To(HaveLen(len(outList2.Items)))
897897
sort.SliceStable(outList1.Items, func(i, j int) bool { return outList1.Items[i].GetName() <= outList1.Items[j].GetName() })
898898
sort.SliceStable(outList2.Items, func(i, j int) bool { return outList2.Items[i].GetName() <= outList2.Items[j].GetName() })
899899
for i := range outList1.Items {
@@ -940,7 +940,7 @@ func CacheTest(createCacheFunc func(config *rest.Config, opts cache.Options) (ca
940940
defer GinkgoRecover()
941941
Expect(m.Start(informerCacheCtx)).To(Succeed())
942942
}()
943-
Expect(m.WaitForCacheSync(informerCacheCtx)).NotTo(BeFalse())
943+
Expect(m.WaitForCacheSync(informerCacheCtx)).To(BeTrue())
944944

945945
By("should be able to fetch cluster scoped resource")
946946
node := &corev1.Node{}
@@ -1079,7 +1079,7 @@ func CacheTest(createCacheFunc func(config *rest.Config, opts cache.Options) (ca
10791079
defer GinkgoRecover()
10801080
Expect(namespacedCache.Start(informerCacheCtx)).To(Succeed())
10811081
}()
1082-
Expect(namespacedCache.WaitForCacheSync(informerCacheCtx)).NotTo(BeFalse())
1082+
Expect(namespacedCache.WaitForCacheSync(informerCacheCtx)).To(BeTrue())
10831083

10841084
By("listing pods in all namespaces")
10851085
out := &metav1.PartialObjectMetadataList{}
@@ -1179,7 +1179,7 @@ func CacheTest(createCacheFunc func(config *rest.Config, opts cache.Options) (ca
11791179
Expect(informerCache.List(context.Background(), outList2, client.InNamespace(testNamespaceOne))).To(Succeed())
11801180

11811181
By("verifying the pointer fields in pod have the same addresses")
1182-
Expect(len(outList1.Items)).To(Equal(len(outList2.Items)))
1182+
Expect(outList1.Items).To(HaveLen(len(outList2.Items)))
11831183
sort.SliceStable(outList1.Items, func(i, j int) bool { return outList1.Items[i].Name <= outList1.Items[j].Name })
11841184
sort.SliceStable(outList2.Items, func(i, j int) bool { return outList2.Items[i].Name <= outList2.Items[j].Name })
11851185
for i := range outList1.Items {
@@ -1238,7 +1238,7 @@ func CacheTest(createCacheFunc func(config *rest.Config, opts cache.Options) (ca
12381238
defer GinkgoRecover()
12391239
Expect(informer.Start(informerCacheCtx)).To(Succeed())
12401240
}()
1241-
Expect(informer.WaitForCacheSync(informerCacheCtx)).NotTo(BeFalse())
1241+
Expect(informer.WaitForCacheSync(informerCacheCtx)).To(BeTrue())
12421242

12431243
By("Checking with structured")
12441244
obtainedStructuredPodList := corev1.PodList{}
@@ -1415,7 +1415,7 @@ func CacheTest(createCacheFunc func(config *rest.Config, opts cache.Options) (ca
14151415
defer GinkgoRecover()
14161416
Expect(informer.Start(informerCacheCtx)).To(Succeed())
14171417
}()
1418-
Expect(informer.WaitForCacheSync(informerCacheCtx)).NotTo(BeFalse())
1418+
Expect(informer.WaitForCacheSync(informerCacheCtx)).To(BeTrue())
14191419

14201420
By("listing Pods with restartPolicyOnFailure")
14211421
listObj := &corev1.PodList{}
@@ -1484,7 +1484,7 @@ func CacheTest(createCacheFunc func(config *rest.Config, opts cache.Options) (ca
14841484
defer GinkgoRecover()
14851485
Expect(informer.Start(informerCacheCtx)).To(Succeed())
14861486
}()
1487-
Expect(informer.WaitForCacheSync(informerCacheCtx)).NotTo(BeFalse())
1487+
Expect(informer.WaitForCacheSync(informerCacheCtx)).To(BeTrue())
14881488

14891489
By("listing Namespaces with fixed indexer")
14901490
listObj := &corev1.NamespaceList{}
@@ -1574,7 +1574,7 @@ func CacheTest(createCacheFunc func(config *rest.Config, opts cache.Options) (ca
15741574
defer GinkgoRecover()
15751575
Expect(informer.Start(informerCacheCtx)).To(Succeed())
15761576
}()
1577-
Expect(informer.WaitForCacheSync(informerCacheCtx)).NotTo(BeFalse())
1577+
Expect(informer.WaitForCacheSync(informerCacheCtx)).To(BeTrue())
15781578

15791579
By("listing Pods with restartPolicyOnFailure")
15801580
listObj := &unstructured.UnstructuredList{}
@@ -1687,7 +1687,7 @@ func CacheTest(createCacheFunc func(config *rest.Config, opts cache.Options) (ca
16871687
defer GinkgoRecover()
16881688
Expect(informer.Start(informerCacheCtx)).To(Succeed())
16891689
}()
1690-
Expect(informer.WaitForCacheSync(informerCacheCtx)).NotTo(BeFalse())
1690+
Expect(informer.WaitForCacheSync(informerCacheCtx)).To(BeTrue())
16911691

16921692
By("listing Pods with restartPolicyOnFailure")
16931693
listObj := &metav1.PartialObjectMetadataList{}

pkg/cache/informer_cache_unit_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ var _ = Describe("ip.objectTypeForListObject", func() {
9393
&controllertest.UnconventionalListType{},
9494
&controllertest.UnconventionalListTypeList{},
9595
).AddToScheme(ip.scheme)
96-
Expect(err).To(BeNil())
96+
Expect(err).ToNot(HaveOccurred())
9797
})
9898

9999
By("calling objectTypeForListObject", func() {

pkg/certwatcher/certwatcher_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ var _ = Describe("CertWatcher", func() {
4242
var _ = Describe("certwatcher New", func() {
4343
It("should errors without cert/key", func() {
4444
_, err := certwatcher.New("", "")
45-
Expect(err).ToNot(BeNil())
45+
Expect(err).To(HaveOccurred())
4646
})
4747
})
4848

@@ -57,7 +57,7 @@ var _ = Describe("CertWatcher", func() {
5757
ctx, ctxCancel = context.WithCancel(context.Background())
5858

5959
err := writeCerts(certPath, keyPath, "127.0.0.1")
60-
Expect(err).To(BeNil())
60+
Expect(err).ToNot(HaveOccurred())
6161

6262
Eventually(func() error {
6363
for _, file := range []string{certPath, keyPath} {
@@ -72,7 +72,7 @@ var _ = Describe("CertWatcher", func() {
7272
}).Should(Succeed())
7373

7474
watcher, err = certwatcher.New(certPath, keyPath)
75-
Expect(err).To(BeNil())
75+
Expect(err).ToNot(HaveOccurred())
7676
})
7777

7878
startWatcher := func() (done <-chan struct{}) {
@@ -108,7 +108,7 @@ var _ = Describe("CertWatcher", func() {
108108
firstcert, _ := watcher.GetCertificate(nil)
109109

110110
err := writeCerts(certPath, keyPath, "192.168.0.1")
111-
Expect(err).To(BeNil())
111+
Expect(err).ToNot(HaveOccurred())
112112

113113
Eventually(func() bool {
114114
secondcert, _ := watcher.GetCertificate(nil)
@@ -157,7 +157,7 @@ var _ = Describe("CertWatcher", func() {
157157
return nil
158158
}, "4s").Should(Succeed())
159159

160-
Expect(os.Remove(keyPath)).To(BeNil())
160+
Expect(os.Remove(keyPath)).To(Succeed())
161161

162162
Eventually(func() error {
163163
readCertificateTotalAfter := testutil.ToFloat64(metrics.ReadCertificateTotal)

pkg/client/apiutil/restmapper_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func TestLazyRestMapperProvider(t *testing.T) {
110110

111111
mappings, err := lazyRestMapper.RESTMappings(schema.GroupKind{Group: "", Kind: "pod"}, "v1")
112112
g.Expect(err).NotTo(gmg.HaveOccurred())
113-
g.Expect(len(mappings)).To(gmg.Equal(1))
113+
g.Expect(mappings).To(gmg.HaveLen(1))
114114
g.Expect(mappings[0].GroupVersionKind.Kind).To(gmg.Equal("pod"))
115115
g.Expect(crt.GetRequestCount()).To(gmg.Equal(2))
116116

@@ -121,7 +121,7 @@ func TestLazyRestMapperProvider(t *testing.T) {
121121

122122
kinds, err := lazyRestMapper.KindsFor(schema.GroupVersionResource{Group: "authentication.k8s.io", Version: "v1", Resource: "tokenreviews"})
123123
g.Expect(err).NotTo(gmg.HaveOccurred())
124-
g.Expect(len(kinds)).To(gmg.Equal(1))
124+
g.Expect(kinds).To(gmg.HaveLen(1))
125125
g.Expect(kinds[0].Kind).To(gmg.Equal("TokenReview"))
126126
g.Expect(crt.GetRequestCount()).To(gmg.Equal(4))
127127

@@ -132,7 +132,7 @@ func TestLazyRestMapperProvider(t *testing.T) {
132132

133133
resources, err := lazyRestMapper.ResourcesFor(schema.GroupVersionResource{Group: "policy", Version: "v1", Resource: "poddisruptionbudgets"})
134134
g.Expect(err).NotTo(gmg.HaveOccurred())
135-
g.Expect(len(resources)).To(gmg.Equal(1))
135+
g.Expect(resources).To(gmg.HaveLen(1))
136136
g.Expect(resources[0].Resource).To(gmg.Equal("poddisruptionbudgets"))
137137
g.Expect(crt.GetRequestCount()).To(gmg.Equal(6))
138138
})

pkg/client/client_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ U5wwSivyi7vmegHKmblOzNVKA5qPO8zWzqBC
778778
Expect(actual.Labels["foo"]).To(Equal("bar"))
779779

780780
By("validating patch options were applied")
781-
Expect(testOption.applied).To(Equal(true))
781+
Expect(testOption.applied).To(BeTrue())
782782
})
783783
})
784784
})

0 commit comments

Comments
 (0)