Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌱 Update golangc-lint to v1.53 #2398

Merged
merged 1 commit into from Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Expand Up @@ -22,5 +22,5 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.52.1
version: v1.53.3
working-directory: ${{matrix.working-directory}}
6 changes: 1 addition & 5 deletions .golangci.yml
Expand Up @@ -5,14 +5,14 @@ linters:
- asciicheck
- bidichk
- bodyclose
- depguard
- dogsled
- dupl
- errcheck
- errchkjson
- errorlint
- exhaustive
- exportloopref
- ginkgolinter
- goconst
- gocritic
- gocyclo
Expand Down Expand Up @@ -62,10 +62,6 @@ linters-settings:
go: "1.20"
stylecheck:
go: "1.20"
depguard:
include-go-root: true
packages:
- io/ioutil # https://go.dev/doc/go1.16#ioutil
revive:
rules:
# The following rules are recommended https://github.com/mgechev/revive#recommended-configuration
Expand Down
30 changes: 15 additions & 15 deletions pkg/cache/cache_test.go
Expand Up @@ -193,7 +193,7 @@ var _ = Describe("Cache with transformers", func() {
Expect(obj).NotTo(BeNil())

accessor, err := meta.Accessor(obj)
Expect(err).To(BeNil())
Expect(err).ToNot(HaveOccurred())
annotations := accessor.GetAnnotations()

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

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

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

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

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

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

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

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

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

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

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

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

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

By("listing Pods with restartPolicyOnFailure")
listObj := &metav1.PartialObjectMetadataList{}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cache/informer_cache_unit_test.go
Expand Up @@ -93,7 +93,7 @@ var _ = Describe("ip.objectTypeForListObject", func() {
&controllertest.UnconventionalListType{},
&controllertest.UnconventionalListTypeList{},
).AddToScheme(ip.scheme)
Expect(err).To(BeNil())
Expect(err).ToNot(HaveOccurred())
})

By("calling objectTypeForListObject", func() {
Expand Down
10 changes: 5 additions & 5 deletions pkg/certwatcher/certwatcher_test.go
Expand Up @@ -42,7 +42,7 @@ var _ = Describe("CertWatcher", func() {
var _ = Describe("certwatcher New", func() {
It("should errors without cert/key", func() {
_, err := certwatcher.New("", "")
Expect(err).ToNot(BeNil())
Expect(err).To(HaveOccurred())
})
})

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

err := writeCerts(certPath, keyPath, "127.0.0.1")
Expect(err).To(BeNil())
Expect(err).ToNot(HaveOccurred())

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

watcher, err = certwatcher.New(certPath, keyPath)
Expect(err).To(BeNil())
Expect(err).ToNot(HaveOccurred())
})

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

err := writeCerts(certPath, keyPath, "192.168.0.1")
Expect(err).To(BeNil())
Expect(err).ToNot(HaveOccurred())

Eventually(func() bool {
secondcert, _ := watcher.GetCertificate(nil)
Expand Down Expand Up @@ -157,7 +157,7 @@ var _ = Describe("CertWatcher", func() {
return nil
}, "4s").Should(Succeed())

Expect(os.Remove(keyPath)).To(BeNil())
Expect(os.Remove(keyPath)).To(Succeed())

Eventually(func() error {
readCertificateTotalAfter := testutil.ToFloat64(metrics.ReadCertificateTotal)
Expand Down
6 changes: 3 additions & 3 deletions pkg/client/apiutil/restmapper_test.go
Expand Up @@ -110,7 +110,7 @@ func TestLazyRestMapperProvider(t *testing.T) {

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

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

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

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

resources, err := lazyRestMapper.ResourcesFor(schema.GroupVersionResource{Group: "policy", Version: "v1", Resource: "poddisruptionbudgets"})
g.Expect(err).NotTo(gmg.HaveOccurred())
g.Expect(len(resources)).To(gmg.Equal(1))
g.Expect(resources).To(gmg.HaveLen(1))
g.Expect(resources[0].Resource).To(gmg.Equal("poddisruptionbudgets"))
g.Expect(crt.GetRequestCount()).To(gmg.Equal(6))
})
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/client_test.go
Expand Up @@ -778,7 +778,7 @@ U5wwSivyi7vmegHKmblOzNVKA5qPO8zWzqBC
Expect(actual.Labels["foo"]).To(Equal("bar"))

By("validating patch options were applied")
Expect(testOption.applied).To(Equal(true))
Expect(testOption.applied).To(BeTrue())
})
})
})
Expand Down