From 20613deef827cc8cecffbd877a5bd1b36bbba45d Mon Sep 17 00:00:00 2001 From: Stefan Bueringer Date: Mon, 18 Jul 2022 13:57:57 +0200 Subject: [PATCH] Bump golangci-lint to v1.47.0 --- .github/workflows/golangci-lint.yml | 2 +- .golangci.yml | 5 +++++ controllers/remote/cluster_cache_reconciler_test.go | 6 +++--- internal/webhooks/cluster_test.go | 7 ++----- internal/webhooks/clusterclass_test.go | 4 +--- util/container/image.go | 2 -- 6 files changed, 12 insertions(+), 14 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 5f21bfad46a5..cea76e42aff4 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -25,5 +25,5 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v3.2.0 with: - version: v1.44.0 + version: v1.47.0 working-directory: ${{matrix.working-directory}} diff --git a/.golangci.yml b/.golangci.yml index 186f12cc0217..d8c4c28c6462 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -265,6 +265,11 @@ issues: - gocritic text: "deferInLoop: Possible resource leak, 'defer' is called in the 'for' loop" path: _test\.go + # We want to keep the ANCHOR_END comments, gci would somehow drop them. + - linters: + - gci + text: "File is not `gci`-ed with -skip-generated -s standard,default" + path: .*condition_types.go run: timeout: 10m diff --git a/controllers/remote/cluster_cache_reconciler_test.go b/controllers/remote/cluster_cache_reconciler_test.go index b818bcfe765f..c9567cbf0cd7 100644 --- a/controllers/remote/cluster_cache_reconciler_test.go +++ b/controllers/remote/cluster_cache_reconciler_test.go @@ -45,7 +45,7 @@ func TestClusterCacheReconciler(t *testing.T) { // createAndWatchCluster creates a new cluster and ensures the clusterCacheTracker has a clusterAccessor for it createAndWatchCluster := func(clusterName string, testNamespace *corev1.Namespace, g *WithT) { - t.Log(fmt.Sprintf("Creating a cluster %q", clusterName)) + t.Logf("Creating a cluster %q", clusterName) testCluster := &clusterv1.Cluster{ ObjectMeta: metav1.ObjectMeta{ Name: clusterName, @@ -136,7 +136,7 @@ func TestClusterCacheReconciler(t *testing.T) { defer teardown(t, g, testNamespace) for _, clusterName := range []string{"cluster-1", "cluster-2", "cluster-3"} { - t.Log(fmt.Sprintf("Deleting cluster %q", clusterName)) + t.Logf("Deleting cluster %q", clusterName) obj := &clusterv1.Cluster{ ObjectMeta: metav1.ObjectMeta{ Namespace: testNamespace.Name, @@ -145,7 +145,7 @@ func TestClusterCacheReconciler(t *testing.T) { } g.Expect(k8sClient.Delete(ctx, obj)).To(Succeed()) - t.Log(fmt.Sprintf("Checking cluster %q's clusterAccessor is removed", clusterName)) + t.Logf("Checking cluster %q's clusterAccessor is removed", clusterName) g.Eventually(func() bool { return cct.clusterAccessorExists(util.ObjectKey(obj)) }, timeout).Should(BeFalse()) } }) diff --git a/internal/webhooks/cluster_test.go b/internal/webhooks/cluster_test.go index c8033aed6394..b06be6dd37c8 100644 --- a/internal/webhooks/cluster_test.go +++ b/internal/webhooks/cluster_test.go @@ -47,9 +47,7 @@ func TestClusterDefaultNamespaces(t *testing.T) { }, } webhook := &Cluster{} - tFunc := util.CustomDefaultValidateTest(ctx, c, webhook) - - t.Run("for Cluster", tFunc) + t.Run("for Cluster", util.CustomDefaultValidateTest(ctx, c, webhook)) g.Expect(webhook.Default(ctx, c)).To(Succeed()) g.Expect(c.Spec.InfrastructureRef.Namespace).To(Equal(c.Namespace)) @@ -351,8 +349,7 @@ func TestClusterDefaultTopologyVersion(t *testing.T) { // Create the webhook and add the fakeClient as its client. webhook := &Cluster{Client: fakeClient} - tFunc := util.CustomDefaultValidateTest(ctx, c, webhook) - t.Run("for Cluster", tFunc) + t.Run("for Cluster", util.CustomDefaultValidateTest(ctx, c, webhook)) g.Expect(webhook.Default(ctx, c)).To(Succeed()) g.Expect(c.Spec.Topology.Version).To(HavePrefix("v")) diff --git a/internal/webhooks/clusterclass_test.go b/internal/webhooks/clusterclass_test.go index a7c827cb7900..278448870501 100644 --- a/internal/webhooks/clusterclass_test.go +++ b/internal/webhooks/clusterclass_test.go @@ -77,9 +77,7 @@ func TestClusterClassDefaultNamespaces(t *testing.T) { // Create the webhook and add the fakeClient as its client. webhook := &ClusterClass{Client: fakeClient} - tFunc := util.CustomDefaultValidateTest(ctx, in, webhook) - - t.Run("for ClusterClass", tFunc) + t.Run("for ClusterClass", util.CustomDefaultValidateTest(ctx, in, webhook)) g := NewWithT(t) g.Expect(webhook.Default(ctx, in)).To(Succeed()) diff --git a/util/container/image.go b/util/container/image.go index fa11667596f3..4da11c508d42 100644 --- a/util/container/image.go +++ b/util/container/image.go @@ -18,10 +18,8 @@ limitations under the License. package container import ( - // Import the crypto sha256 algorithm for the docker image parser to work _ "crypto/sha256" - // Import the crypto/sha512 algorithm for the docker image parser to work with 384 and 512 sha hashes _ "crypto/sha512" "fmt"