Skip to content

Commit

Permalink
Add copyloovar linter and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
periklis committed Oct 8, 2024
1 parent ae5db7f commit 318fcb5
Show file tree
Hide file tree
Showing 40 changed files with 5 additions and 95 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ jobs:
- name: Lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.54.2
args: --timeout=4m
version: v1.61.0
args: --timeout=5m
working-directory: ./operator
- name: Check prometheus rules
working-directory: ./operator
Expand Down
3 changes: 3 additions & 0 deletions operator/.golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# golangci.com configuration
# https://github.com/golangci/golangci/wiki/Configuration
linters-settings:
copyloopvar:
check-alias: true
gci:
sections:
- standard
Expand All @@ -23,6 +25,7 @@ linters-settings:
linters:
enable-all: false
enable:
- copyloopvar
- errcheck # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases
- gci # Gci controls Go package import order and makes it always deterministic
#- err113 # checks that errors are wrapped according to go 1.13 error wrapping tools
Expand Down
2 changes: 0 additions & 2 deletions operator/apis/loki/v1beta1/alertingrule_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ func TestConvertToV1_AlertingRule(t *testing.T) {
}

for _, tc := range tt {
tc := tc
t.Run(tc.desc, func(t *testing.T) {
t.Parallel()
dst := v1.AlertingRule{}
Expand Down Expand Up @@ -306,7 +305,6 @@ func TestConvertFromV1_AlertingRule(t *testing.T) {
}

for _, tc := range tt {
tc := tc
t.Run(tc.desc, func(t *testing.T) {
t.Parallel()

Expand Down
2 changes: 0 additions & 2 deletions operator/apis/loki/v1beta1/lokistack_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,6 @@ func TestConvertToV1_LokiStack(t *testing.T) {
}

for _, tc := range tt {
tc := tc
t.Run(tc.desc, func(t *testing.T) {
t.Parallel()
dst := v1.LokiStack{}
Expand Down Expand Up @@ -1256,7 +1255,6 @@ func TestConvertFromV1_LokiStack(t *testing.T) {
}

for _, tc := range tt {
tc := tc
t.Run(tc.desc, func(t *testing.T) {
t.Parallel()

Expand Down
2 changes: 0 additions & 2 deletions operator/apis/loki/v1beta1/recordingrule_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ func TestConvertToV1_RecordingRule(t *testing.T) {
}

for _, tc := range tt {
tc := tc
t.Run(tc.desc, func(t *testing.T) {
t.Parallel()
dst := v1.RecordingRule{}
Expand Down Expand Up @@ -234,7 +233,6 @@ func TestConvertFromV1_RecordingRule(t *testing.T) {
}

for _, tc := range tt {
tc := tc
t.Run(tc.desc, func(t *testing.T) {
t.Parallel()

Expand Down
2 changes: 0 additions & 2 deletions operator/apis/loki/v1beta1/rulerconfig_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,6 @@ func TestConvertToV1_RulerConfig(t *testing.T) {
}

for _, tc := range tt {
tc := tc
t.Run(tc.desc, func(t *testing.T) {
t.Parallel()
dst := v1.RulerConfig{}
Expand Down Expand Up @@ -1027,7 +1026,6 @@ func TestConvertFromV1_RulerConfig(t *testing.T) {
}

for _, tc := range tt {
tc := tc
t.Run(tc.desc, func(t *testing.T) {
t.Parallel()
dst := v1beta1.RulerConfig{}
Expand Down
1 change: 0 additions & 1 deletion operator/controllers/loki/certrotation_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ func TestCertRotationController_ExpiryRetryAfter(t *testing.T) {
},
}
for _, tc := range tt {
tc := tc
t.Run(tc.desc, func(t *testing.T) {
t.Parallel()
require.Equal(t, tc.wantDuration, expiryRetryAfter(tc.refresh))
Expand Down
2 changes: 0 additions & 2 deletions operator/internal/certrotation/rotation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ func TestSignerRotation_NeedNewCertificate(t *testing.T) {
},
}
for _, tc := range tt {
tc := tc
t.Run(tc.desc, func(t *testing.T) {
t.Parallel()
c := signerRotation{Clock: nowFn}
Expand Down Expand Up @@ -272,7 +271,6 @@ func TestCertificateRotation_NeedNewCertificate(t *testing.T) {
},
}
for _, tc := range tt {
tc := tc
t.Run(tc.desc, func(t *testing.T) {
t.Parallel()
rawCA, err := tc.signerFn()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ func TestGetOptions_PruneServiceCAAnnotations_ForTenantMode(t *testing.T) {
}

for _, tc := range tt {
tc := tc
t.Run(string(tc.mode), func(t *testing.T) {
opts, err := GetOptions(context.TODO(), k, req, tc.mode)
require.NoError(t, err)
Expand Down
3 changes: 0 additions & 3 deletions operator/internal/handlers/internal/gateway/modes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ func TestValidateModes_StaticMode(t *testing.T) {
},
}
for _, tst := range table {
tst := tst
t.Run(tst.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -434,7 +433,6 @@ func TestValidateModes_DynamicMode(t *testing.T) {
},
}
for _, tst := range table {
tst := tst
t.Run(tst.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -533,7 +531,6 @@ func TestValidateModes_OpenshiftLoggingMode(t *testing.T) {
},
}
for _, tst := range table {
tst := tst
t.Run(tst.name, func(t *testing.T) {
t.Parallel()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ func TestExtractOIDCSecret(t *testing.T) {
},
}
for _, tst := range table {
tst := tst
t.Run(tst.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -185,7 +184,6 @@ func TestCheckKeyIsPresent(t *testing.T) {
},
}
for _, tst := range table {
tst := tst
t.Run(tst.name, func(t *testing.T) {
t.Parallel()

Expand Down
1 change: 0 additions & 1 deletion operator/internal/handlers/internal/rules/secrets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ func TestExtractRulerSecret(t *testing.T) {
},
}
for _, tst := range table {
tst := tst
t.Run(tst.name, func(t *testing.T) {
t.Parallel()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ func TestCheckValidConfigMap(t *testing.T) {
},
}
for _, tst := range table {
tst := tst
t.Run(tst.name, func(t *testing.T) {
t.Parallel()

Expand Down
9 changes: 0 additions & 9 deletions operator/internal/handlers/internal/storage/secrets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ func TestHashSecretData(t *testing.T) {
}

for _, tc := range tt {
tc := tc

t.Run(tc.desc, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -254,7 +252,6 @@ func TestAzureExtract(t *testing.T) {
},
}
for _, tst := range table {
tst := tst
t.Run(tst.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -348,7 +345,6 @@ func TestGCSExtract(t *testing.T) {
},
}
for _, tst := range table {
tst := tst
t.Run(tst.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -596,7 +592,6 @@ func TestS3Extract(t *testing.T) {
},
}
for _, tst := range table {
tst := tst
t.Run(tst.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -664,7 +659,6 @@ func TestS3Extract_S3ForcePathStyle(t *testing.T) {
}

for _, tc := range tt {
tc := tc
t.Run(tc.desc, func(t *testing.T) {
t.Parallel()
options, err := extractS3ConfigSecret(tc.secret, lokiv1.CredentialModeStatic)
Expand Down Expand Up @@ -731,7 +725,6 @@ func TestS3Extract_WithOpenShiftTokenCCOAuth(t *testing.T) {
},
}
for _, tst := range table {
tst := tst
t.Run(tst.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -887,7 +880,6 @@ func TestSwiftExtract(t *testing.T) {
},
}
for _, tst := range table {
tst := tst
t.Run(tst.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -965,7 +957,6 @@ func TestAlibabaCloudExtract(t *testing.T) {
},
}
for _, tst := range table {
tst := tst
t.Run(tst.name, func(t *testing.T) {
t.Parallel()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,6 @@ func TestAllowStructuredMetadata(t *testing.T) {
}

for _, tc := range tt {
tc := tc
t.Run(tc.desc, func(t *testing.T) {
t.Parallel()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ func TestGetTLSSecurityProfile(t *testing.T) {
k.StatusStub = func() client.StatusWriter { return sw }

for _, tc := range tc {
tc := tc
t.Run(tc.desc, func(t *testing.T) {
t.Parallel()

Expand Down
7 changes: 0 additions & 7 deletions operator/internal/manifests/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ func TestApplyTLSSettings_OverrideDefaults(t *testing.T) {
}

for _, tc := range tc {
tc := tc
t.Run(tc.desc, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -258,7 +257,6 @@ func TestBuildAll_WithFeatureGates_ServiceMonitors(t *testing.T) {
}

for _, tst := range table {
tst := tst
t.Run(tst.desc, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -319,7 +317,6 @@ func TestBuildAll_WithFeatureGates_OpenShift_ServingCertsService(t *testing.T) {
}

for _, tst := range table {
tst := tst
t.Run(tst.desc, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -594,7 +591,6 @@ func TestBuildAll_WithFeatureGates_GRPCEncryption(t *testing.T) {
}

for _, tst := range table {
tst := tst
t.Run(tst.desc, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -750,7 +746,6 @@ func TestBuildAll_WithFeatureGates_RestrictedPodSecurityStandard(t *testing.T) {
}

for _, tst := range table {
tst := tst
t.Run(tst.desc, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -867,7 +862,6 @@ func TestBuildAll_WithFeatureGates_LokiStackGateway(t *testing.T) {
},
}
for _, tst := range table {
tst := tst
t.Run(tst.desc, func(t *testing.T) {
t.Parallel()
err := ApplyDefaultSettings(&tst.BuildOptions)
Expand Down Expand Up @@ -921,7 +915,6 @@ func TestBuildAll_WithFeatureGates_LokiStackAlerts(t *testing.T) {
},
}
for _, tst := range table {
tst := tst
t.Run(tst.desc, func(t *testing.T) {
t.Parallel()
err := ApplyDefaultSettings(&tst.BuildOptions)
Expand Down
8 changes: 0 additions & 8 deletions operator/internal/manifests/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,6 @@ func TestConfigOptions_GossipRingConfig(t *testing.T) {
},
}
for _, tc := range tt {
tc := tc
t.Run(tc.desc, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -429,7 +428,6 @@ func TestConfigOptions_RetentionConfig(t *testing.T) {
}

for _, tc := range tt {
tc := tc
t.Run(tc.desc, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -520,7 +518,6 @@ func TestConfigOptions_RulerAlertManager(t *testing.T) {
}

for _, tc := range tt {
tc := tc
t.Run(tc.desc, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -640,7 +637,6 @@ func TestConfigOptions_RulerAlertManager_UserOverride(t *testing.T) {
}

for _, tc := range tt {
tc := tc
t.Run(tc.desc, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -771,7 +767,6 @@ func TestConfigOptions_RulerOverrides_OCPApplicationTenant(t *testing.T) {
}

for _, tc := range tt {
tc := tc
t.Run(tc.desc, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -980,7 +975,6 @@ func TestConfigOptions_RulerOverrides(t *testing.T) {
}

for _, tc := range tt {
tc := tc
t.Run(tc.desc, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -1205,7 +1199,6 @@ func TestConfigOptions_RulerOverrides_OCPUserWorkloadOnlyEnabled(t *testing.T) {
}

for _, tc := range tt {
tc := tc
t.Run(tc.desc, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -1299,7 +1292,6 @@ func TestConfigOptions_Replication(t *testing.T) {
}

for _, tc := range tt {
tc := tc
t.Run(tc.desc, func(t *testing.T) {
t.Parallel()

Expand Down
Loading

0 comments on commit 318fcb5

Please sign in to comment.