diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 5f21bfad46a5..0599ba3557f6 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -21,9 +21,9 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 with: - go-version: 1.17 + go-version: 1.18.4 - name: golangci-lint uses: golangci/golangci-lint-action@v3.2.0 with: - version: v1.44.0 + version: v1.47.1 working-directory: ${{matrix.working-directory}} diff --git a/.golangci.yml b/.golangci.yml index 186f12cc0217..1d52f2729a6a 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -43,6 +43,28 @@ linters: - whitespace linters-settings: + revive: + rules: + - name: context-keys-type + disabled: true + - name: errorf + disabled: true + - name: time-naming + disabled: true + - name: unexported-return + disabled: true + - name: unhandled-error + disabled: true + - name: var-declaration + disabled: true + - name: modifies-value-receiver + disabled: true + - name: range-val-address + disabled: true + - name: string-of-int + disabled: true + - name: time-equal + disabled: true godot: # declarations - for top level declaration comments (default); # toplevel - for top level comments; 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/controllers/topology/cluster/patches/template.go b/internal/controllers/topology/cluster/patches/template.go index b156145c3010..831e03fe45df 100644 --- a/internal/controllers/topology/cluster/patches/template.go +++ b/internal/controllers/topology/cluster/patches/template.go @@ -62,7 +62,7 @@ func (t *requestItemBuilder) WithHolder(object client.Object, fieldPath string) } // uuidGenerator is defined as a package variable to enable changing it during testing. -var uuidGenerator func() types.UID = uuid.NewUUID +var uuidGenerator = uuid.NewUUID // Build builds a GeneratePatchesRequestItem. func (t *requestItemBuilder) Build() (*runtimehooksv1.GeneratePatchesRequestItem, error) { 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"