Skip to content

Commit f9a3a9e

Browse files
committed
Update golangci-lint and Go version for lint workflow
1 parent f7558d0 commit f9a3a9e

File tree

7 files changed

+38
-20
lines changed

7 files changed

+38
-20
lines changed

.github/workflows/golangci-lint.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77
# Remove all permissions from GITHUB_TOKEN except metadata.
88
permissions: {}
99

10+
env:
11+
GO_VERSION: 1.18.4
12+
1013
jobs:
1114
golangci:
1215
name: lint
@@ -21,9 +24,9 @@ jobs:
2124
- uses: actions/checkout@v3
2225
- uses: actions/setup-go@v3
2326
with:
24-
go-version: 1.17
27+
go-version: ${{ env.GO_VERSION }}
2528
- name: golangci-lint
2629
uses: golangci/[email protected]
2730
with:
28-
version: v1.44.0
31+
version: v1.47.1
2932
working-directory: ${{matrix.working-directory}}

.golangci.yml

+26-4
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,28 @@ linters:
4343
- whitespace
4444

4545
linters-settings:
46+
revive:
47+
rules:
48+
- name: context-keys-type
49+
disabled: true
50+
- name: errorf
51+
disabled: true
52+
- name: time-naming
53+
disabled: true
54+
- name: unexported-return
55+
disabled: true
56+
- name: unhandled-error
57+
disabled: true
58+
- name: var-declaration
59+
disabled: true
60+
- name: modifies-value-receiver
61+
disabled: true
62+
- name: range-val-address
63+
disabled: true
64+
- name: string-of-int
65+
disabled: true
66+
- name: time-equal
67+
disabled: true
4668
godot:
4769
# declarations - for top level declaration comments (default);
4870
# toplevel - for top level comments;
@@ -138,13 +160,13 @@ linters-settings:
138160
- pkg: sigs.k8s.io/cluster-api/test/infrastructure/docker/exp/api/v1beta1
139161
alias: infraexpv1
140162
nolintlint:
141-
allow-unused: false
163+
allow-unused: true # TODO(oscr) Set to false when revive linter is fully enabled again.
142164
allow-leading-space: false
143165
require-specific: true
144166
staticcheck:
145-
go: "1.17"
167+
go: "1.18"
146168
stylecheck:
147-
go: "1.17"
169+
go: "1.18"
148170
gosec:
149171
excludes:
150172
- G307 # Deferring unsafe method "Close" on type "\*os.File"
@@ -167,7 +189,7 @@ linters-settings:
167189
- whyNoLint
168190
- wrapperFunc
169191
unused:
170-
go: "1.17"
192+
go: "1.18"
171193
issues:
172194
max-same-issues: 0
173195
max-issues-per-linter: 0

controllers/remote/cluster_cache_reconciler_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func TestClusterCacheReconciler(t *testing.T) {
4545

4646
// createAndWatchCluster creates a new cluster and ensures the clusterCacheTracker has a clusterAccessor for it
4747
createAndWatchCluster := func(clusterName string, testNamespace *corev1.Namespace, g *WithT) {
48-
t.Log(fmt.Sprintf("Creating a cluster %q", clusterName))
48+
t.Logf("Creating a cluster %q", clusterName)
4949
testCluster := &clusterv1.Cluster{
5050
ObjectMeta: metav1.ObjectMeta{
5151
Name: clusterName,
@@ -136,7 +136,7 @@ func TestClusterCacheReconciler(t *testing.T) {
136136
defer teardown(t, g, testNamespace)
137137

138138
for _, clusterName := range []string{"cluster-1", "cluster-2", "cluster-3"} {
139-
t.Log(fmt.Sprintf("Deleting cluster %q", clusterName))
139+
t.Logf("Deleting cluster %q", clusterName)
140140
obj := &clusterv1.Cluster{
141141
ObjectMeta: metav1.ObjectMeta{
142142
Namespace: testNamespace.Name,
@@ -145,7 +145,7 @@ func TestClusterCacheReconciler(t *testing.T) {
145145
}
146146
g.Expect(k8sClient.Delete(ctx, obj)).To(Succeed())
147147

148-
t.Log(fmt.Sprintf("Checking cluster %q's clusterAccessor is removed", clusterName))
148+
t.Logf("Checking cluster %q's clusterAccessor is removed", clusterName)
149149
g.Eventually(func() bool { return cct.clusterAccessorExists(util.ObjectKey(obj)) }, timeout).Should(BeFalse())
150150
}
151151
})

internal/controllers/topology/cluster/patches/template.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func (t *requestItemBuilder) WithHolder(object client.Object, fieldPath string)
6262
}
6363

6464
// uuidGenerator is defined as a package variable to enable changing it during testing.
65-
var uuidGenerator func() types.UID = uuid.NewUUID
65+
var uuidGenerator = uuid.NewUUID
6666

6767
// Build builds a GeneratePatchesRequestItem.
6868
func (t *requestItemBuilder) Build() (*runtimehooksv1.GeneratePatchesRequestItem, error) {

internal/webhooks/cluster_test.go

+2-5
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ func TestClusterDefaultNamespaces(t *testing.T) {
4747
},
4848
}
4949
webhook := &Cluster{}
50-
tFunc := util.CustomDefaultValidateTest(ctx, c, webhook)
51-
52-
t.Run("for Cluster", tFunc)
50+
t.Run("for Cluster", util.CustomDefaultValidateTest(ctx, c, webhook))
5351
g.Expect(webhook.Default(ctx, c)).To(Succeed())
5452

5553
g.Expect(c.Spec.InfrastructureRef.Namespace).To(Equal(c.Namespace))
@@ -351,8 +349,7 @@ func TestClusterDefaultTopologyVersion(t *testing.T) {
351349

352350
// Create the webhook and add the fakeClient as its client.
353351
webhook := &Cluster{Client: fakeClient}
354-
tFunc := util.CustomDefaultValidateTest(ctx, c, webhook)
355-
t.Run("for Cluster", tFunc)
352+
t.Run("for Cluster", util.CustomDefaultValidateTest(ctx, c, webhook))
356353
g.Expect(webhook.Default(ctx, c)).To(Succeed())
357354

358355
g.Expect(c.Spec.Topology.Version).To(HavePrefix("v"))

internal/webhooks/clusterclass_test.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,7 @@ func TestClusterClassDefaultNamespaces(t *testing.T) {
7777

7878
// Create the webhook and add the fakeClient as its client.
7979
webhook := &ClusterClass{Client: fakeClient}
80-
tFunc := util.CustomDefaultValidateTest(ctx, in, webhook)
81-
82-
t.Run("for ClusterClass", tFunc)
80+
t.Run("for ClusterClass", util.CustomDefaultValidateTest(ctx, in, webhook))
8381

8482
g := NewWithT(t)
8583
g.Expect(webhook.Default(ctx, in)).To(Succeed())

util/container/image.go

-2
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@ limitations under the License.
1818
package container
1919

2020
import (
21-
2221
// Import the crypto sha256 algorithm for the docker image parser to work
2322
_ "crypto/sha256"
24-
2523
// Import the crypto/sha512 algorithm for the docker image parser to work with 384 and 512 sha hashes
2624
_ "crypto/sha512"
2725
"fmt"

0 commit comments

Comments
 (0)