Skip to content

Commit 7c52b2c

Browse files
[chore] Update golangci to 8.0.0 (#1237)
* [chore] Update golangci to 8.0.0 Signed-off-by: Andreas Gerstmayr <[email protected]> * update version Signed-off-by: Andreas Gerstmayr <[email protected]> --------- Signed-off-by: Andreas Gerstmayr <[email protected]>
1 parent 6660126 commit 7c52b2c

File tree

8 files changed

+83
-94
lines changed

8 files changed

+83
-94
lines changed

.github/workflows/continuous-integration.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ jobs:
7575
persist-credentials: false
7676

7777
- name: Lint
78-
uses: golangci/golangci-lint-action@55c2c1448f86e01eaae002a5a3a9624417608d84 # v6.5.1
78+
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
7979
with:
8080
args: -v
81-
version: v1.64.8
82-
81+
version: v2.2.1

.golangci.yaml

Lines changed: 40 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,45 @@
1-
run:
2-
timeout: 5m
3-
4-
# all available settings of specific linters
5-
linters-settings:
6-
# Disable goheader for now, we can introduce this later
7-
# goheader:
8-
# template-path: header.txt
9-
goimports:
10-
local-prefixes: github.com/grafana/tempo-operator
11-
misspell:
12-
locale: US
13-
govet:
14-
disable-all: true
15-
revive:
16-
rules:
17-
- name: exported
18-
arguments:
19-
- disableStutteringCheck
20-
1+
version: "2"
212
linters:
223
enable:
23-
# Disable for now, we can introduce this later
24-
# - goheader
25-
- goimports
26-
- misspell
27-
- gosec
28-
- govet
294
- exhaustive
305
- godot
31-
- unparam
6+
- gosec
7+
- govet
8+
- misspell
329
- revive
33-
34-
issues:
35-
exclude-use-default: false
36-
# Excluding configuration per-path, per-linter, per-text and per-source
37-
exclude-rules:
38-
# Exclude some linters from running on tests files.
39-
- path: _test\.go
40-
linters:
41-
- gosec
42-
43-
# TODO (andreasgerstmayr): remove once we remove ComponentConfiguration
44-
# https://github.com/kubernetes-sigs/kubebuilder/issues/3457
45-
# https://github.com/kubernetes-sigs/controller-runtime/issues/895
46-
- path: cmd/root.go
47-
text: "SA1019: options.AndFrom is deprecated"
48-
- path: cmd/root.go
49-
text: "SA1019: ctrl.ConfigFile is deprecated"
50-
- path: apis/config/v1alpha1/projectconfig_types.go
51-
text: 'SA1019: "sigs.k8s.io/controller-runtime/pkg/config/v1alpha1" is deprecated'
10+
- unparam
11+
settings:
12+
misspell:
13+
locale: US
14+
revive:
15+
rules:
16+
- name: exported
17+
arguments:
18+
- disableStutteringCheck
19+
exclusions:
20+
generated: lax
21+
rules:
22+
- path: _test\.go
23+
linters:
24+
- gosec
25+
- linters:
26+
- staticcheck
27+
text: "(QF1001|QF1003|QF1008)"
28+
paths:
29+
- third_party$
30+
- builtin$
31+
- examples$
32+
formatters:
33+
enable:
34+
- gofmt
35+
- goimports
36+
settings:
37+
goimports:
38+
local-prefixes:
39+
- github.com/grafana/tempo-operator
40+
exclusions:
41+
generated: lax
42+
paths:
43+
- third_party$
44+
- builtin$
45+
- examples$

cmd/gather/config/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ func NewConfig(scheme *runtime.Scheme) (Config, error) {
5959

6060
clusterClient, err := client.New(config, client.Options{Scheme: scheme})
6161
if err != nil {
62-
return Config{}, fmt.Errorf("creating the Kubernetes client: %w\n", err)
62+
return Config{}, fmt.Errorf("creating the Kubernetes client: %w", err)
6363
}
6464

6565
clientset, err := kubernetes.NewForConfig(config)
6666
if err != nil {
67-
return Config{}, fmt.Errorf("creating the Kubernetes clienset: %w\n", err)
67+
return Config{}, fmt.Errorf("creating the Kubernetes clienset: %w", err)
6868
}
6969

7070
return Config{

internal/controller/tempo/internal/management/state/state_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"path/filepath"
88
"testing"
99

10-
"github.com/grafana/tempo-operator/api/tempo/v1alpha1"
1110
tempov1alpha1 "github.com/grafana/tempo-operator/api/tempo/v1alpha1"
1211
"github.com/grafana/tempo-operator/internal/controller/tempo/internal/management/state"
1312

@@ -35,7 +34,7 @@ func TestMain(m *testing.M) {
3534
os.Exit(1)
3635
}
3736

38-
if err := v1alpha1.AddToScheme(testScheme); err != nil {
37+
if err := tempov1alpha1.AddToScheme(testScheme); err != nil {
3938
fmt.Printf("failed to register scheme: %v", err)
4039
os.Exit(1)
4140
}

internal/controller/tempo/tempostack_controller_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
networkingv1 "k8s.io/api/networking/v1"
1515
rbacv1 "k8s.io/api/rbac/v1"
1616
apierrors "k8s.io/apimachinery/pkg/api/errors"
17-
k8serrors "k8s.io/apimachinery/pkg/api/errors"
1817
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1918
"k8s.io/apimachinery/pkg/types"
2019
"k8s.io/client-go/tools/record"
@@ -935,10 +934,10 @@ func TestOpenShiftMode_finalizer(t *testing.T) {
935934
// the cluster role should be deleted
936935
err = k8sClient.Get(context.Background(), types.NamespacedName{Name: fmt.Sprintf("tempo-%s-gateway-%s", tempoName, namespaceName), Namespace: "default"}, gatewayClusterRole)
937936
require.Error(t, err)
938-
assert.True(t, k8serrors.IsNotFound(err))
937+
assert.True(t, apierrors.IsNotFound(err))
939938
err = k8sClient.Get(context.Background(), types.NamespacedName{Name: fmt.Sprintf("tempo-%s-gateway-%s", tempoName, namespaceName), Namespace: "default"}, gatewayClusterRoleBinding)
940939
require.Error(t, err)
941-
assert.True(t, k8serrors.IsNotFound(err))
940+
assert.True(t, apierrors.IsNotFound(err))
942941
}
943942

944943
func TestReconcileManifestsValidateModes(t *testing.T) {

internal/handlers/gateway/oidc_secret_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func TestGetTenantSecrets(t *testing.T) {
104104

105105
for _, tc := range tt {
106106
t.Run(tc.name, func(t *testing.T) {
107-
tc.tempo.Namespace = strings.Replace(tc.name, " ", "-", -1)
107+
tc.tempo.Namespace = strings.ReplaceAll(tc.name, " ", "-")
108108
_ = createNamespace(t, tc.tempo.Namespace)
109109

110110
if tc.clientID != nil {

internal/status/components_test.go

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"github.com/stretchr/testify/require"
99

1010
corev1 "k8s.io/api/core/v1"
11-
v1 "k8s.io/api/core/v1"
1211
apierrors "k8s.io/apimachinery/pkg/api/errors"
1312
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1413
"k8s.io/apimachinery/pkg/runtime/schema"
@@ -43,14 +42,14 @@ func TestSetComponentsStatus_WhenListReturnError_ReturnError(t *testing.T) {
4342
if tc.componentNotFound == componentName {
4443
return nil, apierrors.NewNotFound(schema.GroupResource{}, "something wasn't found")
4544
}
46-
pods := v1.PodList{
47-
Items: []v1.Pod{
45+
pods := corev1.PodList{
46+
Items: []corev1.Pod{
4847
{
4948
ObjectMeta: metav1.ObjectMeta{
5049
Name: "pod-a",
5150
},
52-
Status: v1.PodStatus{
53-
Phase: v1.PodPending,
51+
Status: corev1.PodStatus{
52+
Phase: corev1.PodPending,
5453
},
5554
},
5655
},
@@ -68,22 +67,22 @@ func TestSetComponentsStatus_WhenSomePodPending(t *testing.T) {
6867
k := &statusClientStub{}
6968

7069
k.GetPodsComponentStub = func(ctx context.Context, componentName string, stack v1alpha1.TempoStack) (*corev1.PodList, error) {
71-
pods := v1.PodList{
72-
Items: []v1.Pod{
70+
pods := corev1.PodList{
71+
Items: []corev1.Pod{
7372
{
7473
ObjectMeta: metav1.ObjectMeta{
7574
Name: "pod-a",
7675
},
77-
Status: v1.PodStatus{
78-
Phase: v1.PodPending,
76+
Status: corev1.PodStatus{
77+
Phase: corev1.PodPending,
7978
},
8079
},
8180
{
8281
ObjectMeta: metav1.ObjectMeta{
8382
Name: "pod-b",
8483
},
85-
Status: v1.PodStatus{
86-
Phase: v1.PodRunning,
84+
Status: corev1.PodStatus{
85+
Phase: corev1.PodRunning,
8786
},
8887
},
8988
},
@@ -136,22 +135,22 @@ func TestSetComponentsStatus_WhenSomePodFailed(t *testing.T) {
136135
k := &statusClientStub{}
137136

138137
k.GetPodsComponentStub = func(ctx context.Context, componentName string, stack v1alpha1.TempoStack) (*corev1.PodList, error) {
139-
pods := v1.PodList{
140-
Items: []v1.Pod{
138+
pods := corev1.PodList{
139+
Items: []corev1.Pod{
141140
{
142141
ObjectMeta: metav1.ObjectMeta{
143142
Name: "pod-a",
144143
},
145-
Status: v1.PodStatus{
146-
Phase: v1.PodFailed,
144+
Status: corev1.PodStatus{
145+
Phase: corev1.PodFailed,
147146
},
148147
},
149148
{
150149
ObjectMeta: metav1.ObjectMeta{
151150
Name: "pod-b",
152151
},
153-
Status: v1.PodStatus{
154-
Phase: v1.PodRunning,
152+
Status: corev1.PodStatus{
153+
Phase: corev1.PodRunning,
155154
},
156155
},
157156
},
@@ -204,22 +203,22 @@ func TestSetComponentsStatus_WhenSomePodUnknow(t *testing.T) {
204203
k := &statusClientStub{}
205204

206205
k.GetPodsComponentStub = func(ctx context.Context, componentName string, stack v1alpha1.TempoStack) (*corev1.PodList, error) {
207-
pods := v1.PodList{
208-
Items: []v1.Pod{
206+
pods := corev1.PodList{
207+
Items: []corev1.Pod{
209208
{
210209
ObjectMeta: metav1.ObjectMeta{
211210
Name: "pod-a",
212211
},
213-
Status: v1.PodStatus{
214-
Phase: v1.PodUnknown,
212+
Status: corev1.PodStatus{
213+
Phase: corev1.PodUnknown,
215214
},
216215
},
217216
{
218217
ObjectMeta: metav1.ObjectMeta{
219218
Name: "pod-b",
220219
},
221-
Status: v1.PodStatus{
222-
Phase: v1.PodRunning,
220+
Status: corev1.PodStatus{
221+
Phase: corev1.PodRunning,
223222
},
224223
},
225224
},
@@ -272,22 +271,22 @@ func TestSetComponentsStatus_WhenAllReady(t *testing.T) {
272271
k := &statusClientStub{}
273272

274273
k.GetPodsComponentStub = func(ctx context.Context, componentName string, stack v1alpha1.TempoStack) (*corev1.PodList, error) {
275-
pods := v1.PodList{
276-
Items: []v1.Pod{
274+
pods := corev1.PodList{
275+
Items: []corev1.Pod{
277276
{
278277
ObjectMeta: metav1.ObjectMeta{
279278
Name: "pod-a",
280279
},
281-
Status: v1.PodStatus{
282-
Phase: v1.PodRunning,
280+
Status: corev1.PodStatus{
281+
Phase: corev1.PodRunning,
283282
},
284283
},
285284
{
286285
ObjectMeta: metav1.ObjectMeta{
287286
Name: "pod-b",
288287
},
289-
Status: v1.PodStatus{
290-
Phase: v1.PodRunning,
288+
Status: corev1.PodStatus{
289+
Phase: corev1.PodRunning,
291290
},
292291
},
293292
},

internal/webhooks/tempomonolithic_webhook.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
1717

1818
configv1alpha1 "github.com/grafana/tempo-operator/api/config/v1alpha1"
19-
"github.com/grafana/tempo-operator/api/tempo/v1alpha1"
2019
tempov1alpha1 "github.com/grafana/tempo-operator/api/tempo/v1alpha1"
2120
"github.com/grafana/tempo-operator/internal/handlers/storage"
2221
"github.com/grafana/tempo-operator/internal/status"
@@ -48,16 +47,16 @@ func (v *monolithicValidator) ValidateCreate(ctx context.Context, obj runtime.Ob
4847

4948
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
5049
func (v *monolithicValidator) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) {
51-
oldTempo, ok := oldObj.(*v1alpha1.TempoMonolithic)
50+
oldTempo, ok := oldObj.(*tempov1alpha1.TempoMonolithic)
5251
if !ok {
5352
return nil, apierrors.NewBadRequest(fmt.Sprintf("expected a TempoMonolithic object but got %T", oldObj))
5453
}
55-
newTempo, ok := newObj.(*v1alpha1.TempoMonolithic)
54+
newTempo, ok := newObj.(*tempov1alpha1.TempoMonolithic)
5655
if !ok {
5756
return nil, apierrors.NewBadRequest(fmt.Sprintf("expected a TempoMonolithic object but got %T", newObj))
5857
}
5958
if newTempo.GetDeletionTimestamp() != nil &&
60-
controllerutil.ContainsFinalizer(oldTempo, v1alpha1.TempoFinalizer) && !controllerutil.ContainsFinalizer(newTempo, v1alpha1.TempoFinalizer) {
59+
controllerutil.ContainsFinalizer(oldTempo, tempov1alpha1.TempoFinalizer) && !controllerutil.ContainsFinalizer(newTempo, tempov1alpha1.TempoFinalizer) {
6160
// Do not validate if the specs are the same and only finalizer was removed
6261
// This is to avoid a situation when kubectl delete -f file.yaml is run and the file contains
6362
// Tempo CR and custom SA or storage secret. The reconcile loop will remove the finalizer and trigger the webhook which would fail.
@@ -181,7 +180,7 @@ func (v *monolithicValidator) validateMultitenancy(ctx context.Context, tempo te
181180

182181
multitenancyBase := field.NewPath("spec", "multitenancy")
183182

184-
if tempo.Spec.Multitenancy != nil && tempo.Spec.Multitenancy.Mode == v1alpha1.ModeOpenShift {
183+
if tempo.Spec.Multitenancy != nil && tempo.Spec.Multitenancy.Mode == tempov1alpha1.ModeOpenShift {
185184
err := validateGatewayOpenShiftModeRBAC(ctx, v.client)
186185
if err != nil {
187186
return field.ErrorList{field.Invalid(
@@ -267,7 +266,7 @@ func (v *monolithicValidator) validateServiceAccount(ctx context.Context, tempo
267266
return nil
268267
}
269268

270-
if tempo.Spec.Multitenancy.IsGatewayEnabled() && tempo.Spec.Multitenancy.Mode == v1alpha1.ModeOpenShift {
269+
if tempo.Spec.Multitenancy.IsGatewayEnabled() && tempo.Spec.Multitenancy.Mode == tempov1alpha1.ModeOpenShift {
271270
return field.ErrorList{field.Invalid(
272271
field.NewPath("spec").Child("serviceAccount"),
273272
tempo.Spec.ServiceAccount,
@@ -295,9 +294,9 @@ func (v *monolithicValidator) validateExtraConfig(tempo tempov1alpha1.TempoMonol
295294
return nil
296295
}
297296

298-
func (v *monolithicValidator) validateConflictWithTempoStack(ctx context.Context, tempo v1alpha1.TempoMonolithic) field.ErrorList {
297+
func (v *monolithicValidator) validateConflictWithTempoStack(ctx context.Context, tempo tempov1alpha1.TempoMonolithic) field.ErrorList {
299298
return validateTempoNameConflict(func() error {
300-
stack := &v1alpha1.TempoStack{}
299+
stack := &tempov1alpha1.TempoStack{}
301300
return v.client.Get(ctx, types.NamespacedName{Namespace: tempo.Namespace, Name: tempo.Name}, stack)
302301
},
303302
tempo.Name, "TempoMonolithic", "TempoStack",

0 commit comments

Comments
 (0)