Skip to content

Commit c83e05e

Browse files
authored
Merge pull request #2003 from kube-logging/chore/migrate-to-v2-golangci
chore: migrate to v2 golangci-lint
2 parents 1a256b6 + d483f54 commit c83e05e

Some content is hidden

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

47 files changed

+158
-154
lines changed

.golangci.yml

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,39 @@
1-
linters-settings:
2-
revive:
3-
min-confidence: 0.9
4-
gocyclo:
5-
min-complexity: 15
1+
version: "2"
2+
run:
3+
timeout: 10m
4+
allow-parallel-runners: true
65

6+
formatters:
7+
settings:
8+
gci:
9+
sections:
10+
- standard
11+
- default
12+
- prefix(github.com/kube-logging/logging-operator)
13+
goimports:
14+
local-prefixes:
15+
- github.com/kube-logging/logging-operator
16+
gofmt:
17+
simplify: true
18+
gofumpt:
19+
extra-rules: false
720

8-
issues:
9-
exclude-dirs:
10-
- .gen
11-
- client
12-
exclude:
13-
- if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
14-
- "`if` block ends with a `return` statement, so drop this `else` and outdent its block"
15-
- "missing the call to method parallel"
21+
linters:
22+
settings:
23+
misspell:
24+
locale: US
25+
revive:
26+
confidence: 0.9
27+
gocyclo:
28+
min-complexity: 15
29+
enable:
30+
- bodyclose
31+
- errcheck
32+
- ineffassign
33+
- misspell
34+
- nolintlint
35+
- revive
36+
- unconvert
37+
- unparam
38+
- unused
39+
- whitespace

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
CONTROLLER_GEN_VERSION := 0.17.2
99

1010
# renovate: datasource=github-releases depName=golangci/golangci-lint versioning=semver
11-
GOLANGCI_LINT_VERSION := 1.64.8
11+
GOLANGCI_LINT_VERSION := 2.0.2
1212

1313
# renovate: datasource=go depName=github.com/vladopajic/go-test-coverage/v2 versioning=semver
1414
GO_TEST_COVERAGE_VERSION := 2.13.0
@@ -284,7 +284,7 @@ ${ENVTEST_BINARY_ASSETS}_${ENVTEST_K8S_VERSION}: | ${SETUP_ENVTEST} ${ENVTEST_BI
284284
${GOLANGCI_LINT}: ${GOLANGCI_LINT}_${GOLANGCI_LINT_VERSION}_${GOVERSION} | ${BIN}
285285
ln -sf $(notdir $<) $@
286286

287-
${GOLANGCI_LINT}_${GOLANGCI_LINT_VERSION}_${GOVERSION}: IMPORT_PATH := github.com/golangci/golangci-lint/cmd/golangci-lint
287+
${GOLANGCI_LINT}_${GOLANGCI_LINT_VERSION}_${GOVERSION}: IMPORT_PATH := github.com/golangci/golangci-lint/v2/cmd/golangci-lint
288288
${GOLANGCI_LINT}_${GOLANGCI_LINT_VERSION}_${GOVERSION}: VERSION := v${GOLANGCI_LINT_VERSION}
289289
${GOLANGCI_LINT}_${GOLANGCI_LINT_VERSION}_${GOVERSION}: | ${BIN}
290290
${go_install_binary}

controllers/extensions/eventtailer_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func (r *EventTailerReconciler) Reconcile(ctx context.Context, req ctrl.Request)
5656

5757
eventTailer := loggingextensionsv1alpha1.EventTailer{}
5858

59-
if err := r.Client.Get(ctx, req.NamespacedName, &eventTailer); err != nil {
59+
if err := r.Get(ctx, req.NamespacedName, &eventTailer); err != nil {
6060
if apierrors.IsNotFound(err) {
6161
return reconcile.Result{}, nil
6262
}

controllers/extensions/hosttailer_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func (r *HostTailerReconciler) Reconcile(ctx context.Context, req ctrl.Request)
5454

5555
hosttailer := loggingextensionsv1alpha1.HostTailer{}
5656

57-
if err := r.Client.Get(ctx, req.NamespacedName, &hosttailer); err != nil {
57+
if err := r.Get(ctx, req.NamespacedName, &hosttailer); err != nil {
5858
if apierrors.IsNotFound(err) {
5959
return reconcile.Result{}, nil
6060
}

controllers/logging/logging_controller.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func (r *LoggingReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
111111
log.V(1).Info("reconciling")
112112

113113
var logging loggingv1beta1.Logging
114-
if err := r.Client.Get(ctx, req.NamespacedName, &logging); err != nil {
114+
if err := r.Get(ctx, req.NamespacedName, &logging); err != nil {
115115
// If object is not found, return without error.
116116
// Created objects are automatically garbage collected.
117117
// For additional cleanup logic use finalizers.
@@ -120,14 +120,14 @@ func (r *LoggingReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
120120

121121
var missingCRDs []string
122122

123-
if err := r.Client.List(ctx, &v1.ServiceMonitorList{}); err == nil {
123+
if err := r.List(ctx, &v1.ServiceMonitorList{}); err == nil {
124124
//nolint:staticcheck
125125
ctx = context.WithValue(ctx, resources.ServiceMonitorKey, true)
126126
} else {
127127
missingCRDs = append(missingCRDs, "ServiceMonitor")
128128
}
129129

130-
if err := r.Client.List(ctx, &v1.PrometheusRuleList{}); err == nil {
130+
if err := r.List(ctx, &v1.PrometheusRuleList{}); err == nil {
131131
//nolint:staticcheck
132132
ctx = context.WithValue(ctx, resources.PrometheusRuleKey, true)
133133
} else {
@@ -384,7 +384,7 @@ func (r *LoggingReconciler) syslogNGConfigFinalizer(ctx context.Context, logging
384384

385385
func (r *LoggingReconciler) dynamicDefaults(ctx context.Context, log logr.Logger, syslogNGSpec *loggingv1beta1.SyslogNGSpec) {
386386
nodes := corev1.NodeList{}
387-
if err := r.Client.List(ctx, &nodes); err != nil {
387+
if err := r.List(ctx, &nodes); err != nil {
388388
log.Error(err, "listing nodes")
389389
}
390390
if syslogNGSpec != nil && syslogNGSpec.MaxConnections == 0 {

controllers/logging/loggingroute_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ type LoggingRouteReconciler struct {
4949
// Reconcile routes between logging domains
5050
func (r *LoggingRouteReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
5151
var loggingRoute loggingv1beta1.LoggingRoute
52-
if err := r.Client.Get(ctx, req.NamespacedName, &loggingRoute); err != nil {
52+
if err := r.Get(ctx, req.NamespacedName, &loggingRoute); err != nil {
5353
return reconcile.Result{}, client.IgnoreNotFound(err)
5454
}
5555

controllers/logging/telemetry_controller_controller.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func (r *TelemetryControllerReconciler) Reconcile(ctx context.Context, req ctrl.
5353
log := r.Log.WithValues("telemetry-controller", req.Name)
5454

5555
var logging loggingv1beta1.Logging
56-
if err := r.Client.Get(ctx, req.NamespacedName, &logging); err != nil {
56+
if err := r.Get(ctx, req.NamespacedName, &logging); err != nil {
5757
return reconcile.Result{}, client.IgnoreNotFound(err)
5858
}
5959

@@ -100,11 +100,11 @@ func (r *TelemetryControllerReconciler) createTelemetryControllerResources(logge
100100
func (r *TelemetryControllerReconciler) finalizeLoggingForTelemetryController(ctx context.Context, logger logr.Logger, logging *loggingv1beta1.Logging, objectsToCreate *[]client.Object) error {
101101
logger.Info("Finalizing Telemetry controller resources")
102102

103-
if logging.ObjectMeta.DeletionTimestamp.IsZero() {
103+
if logging.DeletionTimestamp.IsZero() {
104104
if !controllerutil.ContainsFinalizer(logging, TelemetryControllerFinalizer) {
105105
r.Log.Info("adding telemetrycontroller finalizer")
106106
controllerutil.AddFinalizer(logging, TelemetryControllerFinalizer)
107-
if err := r.Client.Update(ctx, logging); err != nil {
107+
if err := r.Update(ctx, logging); err != nil {
108108
return err
109109
}
110110
}
@@ -117,7 +117,7 @@ func (r *TelemetryControllerReconciler) finalizeLoggingForTelemetryController(ct
117117

118118
r.Log.Info("removing telemetrycontroller finalizer")
119119
controllerutil.RemoveFinalizer(logging, TelemetryControllerFinalizer)
120-
if err := r.Client.Update(ctx, logging); err != nil {
120+
if err := r.Update(ctx, logging); err != nil {
121121
return err
122122
}
123123
}
@@ -130,11 +130,11 @@ func (r *TelemetryControllerReconciler) deployTelemetryControllerResources(ctx c
130130
logger.Info("Deploying Telemetry controller resources")
131131

132132
for _, objectToCreate := range *objectsToCreate {
133-
if err := r.Client.Get(ctx, client.ObjectKeyFromObject(objectToCreate), objectToCreate); err != nil {
133+
if err := r.Get(ctx, client.ObjectKeyFromObject(objectToCreate), objectToCreate); err != nil {
134134
if !apierrors.IsNotFound(err) {
135135
return err
136136
}
137-
if err := r.Client.Create(ctx, objectToCreate); err != nil {
137+
if err := r.Create(ctx, objectToCreate); err != nil {
138138
return err
139139
}
140140
logger.Info("Created object", "object", objectToCreate.GetName())
@@ -150,7 +150,7 @@ func (r *TelemetryControllerReconciler) deleteTelemetryControllerResources(ctx c
150150
logger.Info("Logging resource is being deleted, deleting Telemetry controller resources")
151151

152152
for _, obj := range *objectsToCreate {
153-
if err := r.Client.Delete(ctx, obj); err != nil {
153+
if err := r.Delete(ctx, obj); err != nil {
154154
return client.IgnoreNotFound(err)
155155
}
156156
logger.Info("Deleted object", "object", obj.GetName())
@@ -164,7 +164,7 @@ func (r *TelemetryControllerReconciler) isAggregatorReady(ctx context.Context, l
164164

165165
podName := fmt.Sprintf("%s-fluentd-0", logging.Name)
166166
pod := &corev1.Pod{}
167-
err := r.Client.Get(ctx, client.ObjectKey{Name: podName, Namespace: logging.Spec.ControlNamespace}, pod)
167+
err := r.Get(ctx, client.ObjectKey{Name: podName, Namespace: logging.Spec.ControlNamespace}, pod)
168168
if err != nil {
169169
if apierrors.IsNotFound(err) {
170170
return fmt.Errorf("aggregator pod: %s not found", podName)

docs/configuration/crds/v1beta1/fluentd_types.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ ExtraVolume defines the fluentd extra volumes
228228

229229
## FluentdScaling
230230

231-
FluentdScaling enables configuring the scaling behaviour of the fluentd statefulset
231+
FluentdScaling enables configuring the scaling behavior of the fluentd statefulset
232232

233233
### drain (FluentdDrainConfig, optional) {#fluentdscaling-drain}
234234

docs/configuration/plugins/filters/elasticsearch_genid.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ You can specify keys which are record in events for hash generation seed. This p
6464

6565
### separator (string, optional) {#elasticsearchgenid-separator}
6666

67-
You can specify separator charactor to creating seed for hash generation.
67+
You can specify separator character to creating seed for hash generation.
6868

6969

7070
### use_entire_record (bool, optional) {#elasticsearchgenid-use_entire_record}

docs/configuration/plugins/filters/parser.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ If true, keep time field in the record.
127127

128128
### keys (string, optional) {#parse section-keys}
129129

130-
Names for fields on each line. (seperated by coma)
130+
Names for fields on each line. (separated by coma)
131131

132132

133133
### label_delimiter (string, optional) {#parse section-label_delimiter}

0 commit comments

Comments
 (0)