Skip to content

Commit eb42392

Browse files
authored
Merge pull request #5531 from mboersma/bump-golangci-lint-1
Bump golangci-lint to v1.64.8
2 parents 85d64b9 + db29fb7 commit eb42392

File tree

12 files changed

+27
-25
lines changed

12 files changed

+27
-25
lines changed

.github/workflows/pr-golangci-lint.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ jobs:
3333
uses: golangci/golangci-lint-action@55c2c1448f86e01eaae002a5a3a9624417608d84 # tag=v6.5.2
3434
with:
3535
# update the version when updating golangci-lint
36-
version: v1.60.2
36+
version: v1.64.8
3737
args: --out-format=colored-line-number
3838
working-directory: ${{matrix.working-directory}}

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ linters:
4646
- revive # better version of golint
4747
- staticcheck # some of staticcheck's rules
4848
- stylecheck # another replacement for golint
49-
- tenv # using os.Setenv instead of t.Setenv in tests
5049
- thelper # test helpers not starting with t.Helper()
5150
- unconvert # unnecessary type conversions
5251
- unparam # unused function parameters
5352
- unused # unused constants, variables,functions, types
5453
- usestdlibvars # using variables/constants from the standard library
54+
- usetesting # reports uses of functions with replacement inside the testing package
5555
- whitespace # unnecessary newlines
5656

5757
linters-settings:

api/v1beta1/azurecluster_validation_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ func TestResourceGroupInvalid(t *testing.T) {
483483
g := NewWithT(t)
484484
err := validateResourceGroup(testCase.resourceGroup,
485485
field.NewPath("spec").Child("networkSpec").Child("vnet").Child("resourceGroup"))
486-
g.Expect(err).NotTo(BeNil())
486+
g.Expect(err).To(HaveOccurred())
487487
g.Expect(err.Type).To(Equal(field.ErrorTypeInvalid))
488488
g.Expect(err.Field).To(Equal("spec.networkSpec.vnet.resourceGroup"))
489489
g.Expect(err.BadValue).To(BeEquivalentTo(testCase.resourceGroup))
@@ -743,7 +743,7 @@ func TestSubnetNameInvalid(t *testing.T) {
743743
g := NewWithT(t)
744744
err := validateSubnetName(testCase.subnetName,
745745
field.NewPath("spec").Child("networkSpec").Child("subnets").Index(0).Child("name"))
746-
g.Expect(err).NotTo(BeNil())
746+
g.Expect(err).To(HaveOccurred())
747747
g.Expect(err.Type).To(Equal(field.ErrorTypeInvalid))
748748
g.Expect(err.Field).To(Equal("spec.networkSpec.subnets[0].name"))
749749
g.Expect(err.BadValue).To(BeEquivalentTo(testCase.subnetName))

azure/scope/machinepool_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1700,7 +1700,7 @@ func TestBootstrapDataChanges(t *testing.T) {
17001700

17011701
spec := s.ScaleSetSpec(ctx)
17021702
sSpec := spec.(*scalesets.ScaleSetSpec)
1703-
g.Expect(sSpec.ShouldPatchCustomData).To(Equal(false))
1703+
g.Expect(sSpec.ShouldPatchCustomData).To(BeFalse())
17041704

17051705
amp.Annotations[azure.CustomDataHashAnnotation] = "old"
17061706

@@ -1710,7 +1710,7 @@ func TestBootstrapDataChanges(t *testing.T) {
17101710

17111711
spec = s.ScaleSetSpec(ctx)
17121712
sSpec = spec.(*scalesets.ScaleSetSpec)
1713-
g.Expect(sSpec.ShouldPatchCustomData).To(Equal(true))
1713+
g.Expect(sSpec.ShouldPatchCustomData).To(BeTrue())
17141714
}
17151715

17161716
func sha256Hash(text string) []byte {

controllers/asosecret_controller_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ import (
3939
)
4040

4141
func TestASOSecretReconcile(t *testing.T) {
42-
os.Setenv("AZURE_CLIENT_ID", "fooClient") //nolint:tenv // we want to use os.Setenv here instead of t.Setenv
43-
os.Setenv("AZURE_CLIENT_SECRET", "fooSecret") //nolint:tenv // we want to use os.Setenv here instead of t.Setenv
44-
os.Setenv("AZURE_TENANT_ID", "fooTenant") //nolint:tenv // we want to use os.Setenv here instead of t.Setenv
45-
os.Setenv("AZURE_SUBSCRIPTION_ID", "fooSubscription") //nolint:tenv // we want to use os.Setenv here instead of t.Setenv
42+
os.Setenv("AZURE_CLIENT_ID", "fooClient") //nolint:gosec,usetesting // we want to use os.Setenv here instead of t.Setenv
43+
os.Setenv("AZURE_CLIENT_SECRET", "fooSecret") //nolint:gosec,usetesting // we want to use os.Setenv here instead of t.Setenv
44+
os.Setenv("AZURE_TENANT_ID", "fooTenant") //nolint:gosec,usetesting // we want to use os.Setenv here instead of t.Setenv
45+
os.Setenv("AZURE_SUBSCRIPTION_ID", "fooSubscription") //nolint:gosec,usetesting // we want to use os.Setenv here instead of t.Setenv
4646

4747
scheme := runtime.NewScheme()
4848
_ = clusterv1.AddToScheme(scheme)

controllers/helpers_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,9 @@ func TestGetCloudProviderConfig(t *testing.T) {
165165
},
166166
}
167167

168-
os.Setenv("AZURE_CLIENT_ID", "fooClient") //nolint:tenv // we want to use os.Setenv here instead of t.Setenv
169-
os.Setenv("AZURE_CLIENT_SECRET", "fooSecret") //nolint:tenv // we want to use os.Setenv here instead of t.Setenv
170-
os.Setenv("AZURE_TENANT_ID", "fooTenant") //nolint:tenv // we want to use os.Setenv here instead of t.Setenv
168+
os.Setenv("AZURE_CLIENT_ID", "fooClient") //nolint:gosec,usetesting // we want to use os.Setenv here instead of t.Setenv
169+
os.Setenv("AZURE_CLIENT_SECRET", "fooSecret") //nolint:gosec,usetesting // we want to use os.Setenv here instead of t.Setenv
170+
os.Setenv("AZURE_TENANT_ID", "fooTenant") //nolint:gosec,usetesting // we want to use os.Setenv here instead of t.Setenv
171171

172172
for name, tc := range cases {
173173
t.Run(name, func(t *testing.T) {

test/e2e/azure_privatecluster.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func AzurePrivateClusterSpec(ctx context.Context, inputGetter func() AzurePrivat
9999
Consistently(func() error {
100100
ns := &corev1.Namespace{}
101101
return publicClusterProxy.GetClient().Get(ctx, client.ObjectKey{Name: kubesystem}, ns)
102-
}, "5s", "100ms").Should(BeNil(), "Failed to assert public API server stability")
102+
}, "5s", "100ms").Should(Succeed(), "Failed to assert public API server stability")
103103

104104
// **************
105105
// Get the Client ID for the user assigned identity
@@ -113,10 +113,10 @@ func AzurePrivateClusterSpec(ctx context.Context, inputGetter func() AzurePrivat
113113
userID = "cloud-provider-user-identity"
114114
}
115115
resourceID := fmt.Sprintf("/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ManagedIdentity/userAssignedIdentities/%s", subscriptionID, identityRG, userID)
116-
os.Setenv("UAMI_CLIENT_ID", getClientIDforMSI(resourceID))
116+
Expect(os.Setenv("UAMI_CLIENT_ID", getClientIDforMSI(resourceID))).To(Succeed())
117117

118-
os.Setenv("CLUSTER_IDENTITY_NAME", "cluster-identity-user-assigned")
119-
os.Setenv("CLUSTER_IDENTITY_NAMESPACE", input.Namespace.Name)
118+
Expect(os.Setenv("CLUSTER_IDENTITY_NAME", "cluster-identity-user-assigned")).To(Succeed())
119+
Expect(os.Setenv("CLUSTER_IDENTITY_NAMESPACE", input.Namespace.Name)).To(Succeed())
120120
// *************
121121

122122
By("Creating a private workload cluster")

test/e2e/azure_selfhosted.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,11 @@ func SelfHostedSpec(ctx context.Context, inputGetter func() SelfHostedSpecInput)
132132
Consistently(func() error {
133133
ns := &corev1.Namespace{}
134134
return input.BootstrapClusterProxy.GetClient().Get(ctx, client.ObjectKey{Name: kubesystem}, ns)
135-
}, "5s", "100ms").Should(BeNil(), "Failed to assert bootstrap API server stability")
135+
}, "5s", "100ms").Should(Succeed(), "Failed to assert bootstrap API server stability")
136136
Consistently(func() error {
137137
ns := &corev1.Namespace{}
138138
return selfHostedClusterProxy.GetClient().Get(ctx, client.ObjectKey{Name: kubesystem}, ns)
139-
}, "5s", "100ms").Should(BeNil(), "Failed to assert self-hosted API server stability")
139+
}, "5s", "100ms").Should(Succeed(), "Failed to assert self-hosted API server stability")
140140

141141
By("Moving the cluster to self hosted")
142142
clusterctl.Move(ctx, clusterctl.MoveInput{
@@ -218,11 +218,11 @@ func SelfHostedSpec(ctx context.Context, inputGetter func() SelfHostedSpecInput)
218218
Consistently(func() error {
219219
ns := &corev1.Namespace{}
220220
return input.BootstrapClusterProxy.GetClient().Get(ctx, client.ObjectKey{Name: kubesystem}, ns)
221-
}, "5s", "100ms").Should(BeNil(), "Failed to assert bootstrap API server stability")
221+
}, "5s", "100ms").Should(Succeed(), "Failed to assert bootstrap API server stability")
222222
Consistently(func() error {
223223
ns := &corev1.Namespace{}
224224
return selfHostedClusterProxy.GetClient().Get(ctx, client.ObjectKey{Name: kubesystem}, ns)
225-
}, "5s", "100ms").Should(BeNil(), "Failed to assert self-hosted API server stability")
225+
}, "5s", "100ms").Should(Succeed(), "Failed to assert self-hosted API server stability")
226226

227227
By("Moving the cluster back to bootstrap")
228228
clusterctl.Move(ctx, clusterctl.MoveInput{

test/e2e/azure_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ var _ = Describe("Workload cluster creation", func() {
916916
Context("Creating an AKS cluster using ClusterClass [Managed Kubernetes]", func() {
917917
It("with a single control plane node and 1 node", func() {
918918
// Use default as the clusterclass name so test infra can find the clusterclass template
919-
os.Setenv("CLUSTER_CLASS_NAME", "default")
919+
Expect(os.Setenv("CLUSTER_CLASS_NAME", "default")).To(Succeed())
920920

921921
// Use "cc" as spec name because NAT gateway pip name exceeds limit.
922922
clusterName = getClusterName(clusterNamePrefix, "cc")

test/e2e/capi_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ var _ = Describe("Running the Cluster API E2E tests", func() {
198198
identityName := e2eConfig.GetVariable(AzureUserIdentity)
199199
identity, err := identityClient.Get(ctx, identityRG, identityName, nil)
200200
Expect(err).NotTo(HaveOccurred())
201-
os.Setenv("AZURE_CLIENT_ID_CLOUD_PROVIDER", *identity.Properties.ClientID)
201+
Expect(os.Setenv("AZURE_CLIENT_ID_CLOUD_PROVIDER", *identity.Properties.ClientID)).To(Succeed())
202202
})
203203

204204
Context("upgrade from an old version of v1beta1 to current, and scale workload clusters created in the old version", func() {

test/e2e/helpers.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,9 @@ func describeEvents(ctx context.Context, clientset *kubernetes.Clientset, namesp
372372
fmt.Fprintf(w, "%s\t%s\t%s\t%s/%s\t%s\n", e.LastTimestamp, e.Type, e.Reason,
373373
strings.ToLower(e.InvolvedObject.Kind), e.InvolvedObject.Name, e.Message)
374374
}
375-
w.Flush()
375+
if err = w.Flush(); err != nil {
376+
b.WriteString(err.Error())
377+
}
376378
}
377379
}
378380
return b.String()

util/system/namespace_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func TestGetNamespace(t *testing.T) {
4444
for _, c := range cases {
4545
t.Run(c.Name, func(t *testing.T) {
4646
g := gomega.NewWithT(t)
47-
os.Setenv(NamespaceEnvVarName, c.PodNamespace) //nolint:tenv // leave it as is
47+
os.Setenv(NamespaceEnvVarName, c.PodNamespace) //nolint:gosec,usetesting // leave it as is
4848
defer os.Unsetenv(NamespaceEnvVarName)
4949
g.Expect(GetManagerNamespace()).To(gomega.Equal(c.Expected))
5050
})

0 commit comments

Comments
 (0)