Skip to content

Commit eb04b7c

Browse files
committed
chore: enable the modernize analyzer and apply it
golangci-lint gains the modernize analyzer, and the tree is updated to satisfy it. The changes are mechanical: range-over-int loops, slices and maps helpers in place of hand-written loops, min and max builtins, and new(x) in place of a local variable taken by address. persistentVolumeModePointer went with them. It wrapped new(mode) for a single caller, which the inline analyzer flags. Signed-off-by: Bence Csati <bence.csati@axoflow.com>
1 parent 3add201 commit eb04b7c

106 files changed

Lines changed: 322 additions & 335 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.golangci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ linters:
3636
- errcheck
3737
- ineffassign
3838
- misspell
39+
- modernize
3940
- nolintlint
4041
- revive
4142
- gocyclo

e2e/common/setup/loggingoperator.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func LoggingOperator(t *testing.T, c common.Cluster, opts ...LoggingOperatorOpti
8787
}
8888
actionConfig := new(action.Configuration)
8989

90-
if err := actionConfig.Init(restClientGetter, opt.Namespace, "memory", func(format string, v ...interface{}) {
90+
if err := actionConfig.Init(restClientGetter, opt.Namespace, "memory", func(format string, v ...any) {
9191
t.Logf(format, v...)
9292
}); err != nil {
9393
t.Fatalf("helm action config init: %s", err)
@@ -129,29 +129,29 @@ func LoggingOperator(t *testing.T, c common.Cluster, opts ...LoggingOperatorOpti
129129
t.Fatalf("kind load images: %s", err)
130130
}
131131

132-
_, err = installer.Run(chartReq, map[string]interface{}{
132+
_, err = installer.Run(chartReq, map[string]any{
133133
"nameOverride": opt.NameOverride,
134-
"image": map[string]interface{}{
134+
"image": map[string]any{
135135
"repository": loggingOperatorImage.repository,
136136
"tag": loggingOperatorImage.tag,
137137
"pullPolicy": corev1.PullNever,
138138
},
139-
"testReceiver": map[string]interface{}{
139+
"testReceiver": map[string]any{
140140
"enabled": true,
141141
},
142-
"volumes": []map[string]interface{}{
142+
"volumes": []map[string]any{
143143
{
144144
"name": "coverage-data",
145145
"emptyDir": map[string]string{},
146146
},
147147
},
148-
"volumeMounts": []map[string]interface{}{
148+
"volumeMounts": []map[string]any{
149149
{
150150
"mountPath": "/covdatafiles",
151151
"name": "coverage-data",
152152
},
153153
},
154-
"env": []map[string]interface{}{
154+
"env": []map[string]any{
155155
{
156156
"name": "GOCOVERDIR",
157157
"value": "/covdatafiles",

e2e/fluentd-aggregator/fluentd_aggregator_test.go

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"os/exec"
2222
"path/filepath"
2323
"regexp"
24+
"slices"
2425
"strings"
2526
"testing"
2627
"time"
@@ -412,11 +413,9 @@ func TestFluentdAggregator_ConfigChecks(t *testing.T) {
412413
return false
413414
}
414415
if logging.Status.ProblemsCount > 0 {
415-
for _, problem := range logging.Status.Problems {
416-
if configCheckFailure.MatchString(problem) {
417-
t.Logf("Found the problem in Logging status: %v", logging.Status)
418-
return true
419-
}
416+
if slices.ContainsFunc(logging.Status.Problems, configCheckFailure.MatchString) {
417+
t.Logf("Found the problem in Logging status: %v", logging.Status)
418+
return true
420419
}
421420
}
422421
t.Logf("Waiting for the problem to appear in Logging status: %v", logging.Status.Problems)
@@ -433,11 +432,9 @@ func TestFluentdAggregator_ConfigChecks(t *testing.T) {
433432
return false
434433
}
435434
if logging.Status.ProblemsCount > 0 {
436-
for _, problem := range logging.Status.Problems {
437-
if configCheckFailure.MatchString(problem) {
438-
t.Logf("Waiting for the problem to be cleared in Logging status: %v", logging.Status.Problems)
439-
return false
440-
}
435+
if slices.ContainsFunc(logging.Status.Problems, configCheckFailure.MatchString) {
436+
t.Logf("Waiting for the problem to be cleared in Logging status: %v", logging.Status.Problems)
437+
return false
441438
}
442439
}
443440
t.Logf("Problem cleared in Logging status: %v", logging.Status)

pkg/sdk/extensions/api/v1alpha1/eventtailer_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ import (
2727

2828
// +name:"EventTailer"
2929
// +weight:"200"
30-
type _hugoEventTailer = interface{} //nolint:deadcode,unused
30+
type _hugoEventTailer = any //nolint:deadcode,unused
3131

3232
// +name:"EventTailer"
3333
// +version:"v1alpha1"
3434
// +description:"Eventtailer's main goal is to listen kubernetes events and transmit their changes to stdout. This way the logging-operator is able to process them."
35-
type _metaEventTailer = interface{} //nolint:deadcode,unused
35+
type _metaEventTailer = any //nolint:deadcode,unused
3636

3737
// EventTailerSpec defines the desired state of EventTailer
3838
type EventTailerSpec struct {

pkg/sdk/extensions/api/v1alpha1/hosttailer_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ import (
2626

2727
// +name:"HostTailer"
2828
// +weight:"200"
29-
type _hugoHostTailer = interface{} //nolint:deadcode,unused
29+
type _hugoHostTailer = any //nolint:deadcode,unused
3030

3131
// +name:"HostTailer"
3232
// +version:"v1alpha1"
3333
// +description:"HostTailer's main goal is to tail custom files and transmit their changes to stdout. This way the logging-operator is able to process them."
34-
type _metaHostTailer = interface{} //nolint:deadcode,unused
34+
type _metaHostTailer = any //nolint:deadcode,unused
3535

3636
// HostTailerSpec defines the desired state of HostTailer
3737
type HostTailerSpec struct {

pkg/sdk/extensions/extensionsconfig/config_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ func TestFluentBitConfigFilePath(t *testing.T) {
9696
},
9797
}
9898
for _, tt := range tests {
99-
tt := tt
10099
t.Run(tt.name, func(t *testing.T) {
101100
if got := fluentBitConfigFilePath(tt.args.image, tt.args.filePath); !reflect.DeepEqual(got, tt.want) {
102101
t.Errorf("FluentBitConfigFilePath() = %v, want %v", got, tt.want)

pkg/sdk/logging/api/v1alpha1/clusterflow_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ import (
2222

2323
// +name:"ClusterFlow"
2424
// +weight:"200"
25-
type _hugoClusterFlow interface{} //nolint:deadcode,unused
25+
type _hugoClusterFlow any //nolint:deadcode,unused
2626

2727
// +name:"ClusterFlow"
2828
// +version:"v1alpha1"
2929
// +description:"ClusterFlow is the Schema for the clusterflows API"
30-
type _metaClusterFlow interface{} //nolint:deadcode,unused
30+
type _metaClusterFlow any //nolint:deadcode,unused
3131

3232
// +kubebuilder:object:root=true
3333
// +kubebuilder:resource:categories=logging-all

pkg/sdk/logging/api/v1alpha1/clusteroutput_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ import (
2222

2323
// +name:"ClusterOutput"
2424
// +weight:"200"
25-
type _hugoClusterOutput interface{} //nolint:deadcode,unused
25+
type _hugoClusterOutput any //nolint:deadcode,unused
2626

2727
// +name:"ClusterOutput"
2828
// +version:"v1alpha1"
2929
// +description:"ClusterOutput is the Schema for the clusteroutputs API"
30-
type _metaClusterOutput interface{} //nolint:deadcode,unused
30+
type _metaClusterOutput any //nolint:deadcode,unused
3131

3232
// +kubebuilder:object:root=true
3333
// +kubebuilder:resource:categories=logging-all

pkg/sdk/logging/api/v1alpha1/output_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ import (
2222

2323
// +name:"OutputSpec"
2424
// +weight:"200"
25-
type _hugoOutputSpec interface{} //nolint:deadcode,unused
25+
type _hugoOutputSpec any //nolint:deadcode,unused
2626

2727
// +name:"OutputSpec"
2828
// +version:"v1alpha1"
2929
// +description:"OutputSpec defines the desired state of Output"
30-
type _metaOutputSpec interface{} //nolint:deadcode,unused
30+
type _metaOutputSpec any //nolint:deadcode,unused
3131

3232
// OutputSpec defines the desired state of Output
3333
type OutputSpec struct {

pkg/sdk/logging/api/v1beta1/clusterflow_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ import (
2020

2121
// +name:"ClusterFlow"
2222
// +weight:"200"
23-
type _hugoClusterFlow interface{} //nolint:deadcode,unused
23+
type _hugoClusterFlow any //nolint:deadcode,unused
2424

2525
// +name:"ClusterFlow"
2626
// +version:"v1beta1"
2727
// +description:"ClusterFlow is the Schema for the clusterflows API"
28-
type _metaClusterFlow interface{} //nolint:deadcode,unused
28+
type _metaClusterFlow any //nolint:deadcode,unused
2929

3030
// +kubebuilder:object:root=true
3131
// +kubebuilder:resource:categories=logging-all

0 commit comments

Comments
 (0)