Skip to content

Commit f0f9898

Browse files
authored
Merge pull request #2643 from mrueg/golangci-v2
chore: Migrate to golangci-lint v2
2 parents a0d9835 + 0c029b6 commit f0f9898

28 files changed

+99
-88
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ env:
2121
E2E_SETUP_KUBECTL: yes
2222
SUDO: sudo
2323
GO_VERSION: "^1.24"
24-
GOLANGCI_LINT_VERSION: "v1.64.6"
24+
GOLANGCI_LINT_VERSION: "v2.0.2"
2525

2626
jobs:
2727
ci-go-lint:

.golangci.yml

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
run:
2-
timeout: 10m
3-
1+
version: "2"
42
linters:
5-
disable-all: true
3+
default: none
64
enable:
75
- gocritic
86
- gocyclo
9-
- gofmt
10-
- goimports
117
- gosec
12-
- gosimple
138
- govet
149
- ineffassign
1510
- misspell
@@ -18,22 +13,37 @@ linters:
1813
- staticcheck
1914
- unconvert
2015
- unused
21-
22-
linters-settings:
23-
goimports:
24-
local-prefixes: k8s.io/kube-state-metrics,k8s.io/kube-state-metrics/v2
25-
16+
exclusions:
17+
generated: lax
18+
rules:
19+
- linters:
20+
- promlinter
21+
path: _test\.go
22+
- linters:
23+
- gosec
24+
text: 'G104:'
25+
- linters:
26+
- revive
27+
text: 'package-comments:'
28+
paths:
29+
- third_party$
30+
- builtin$
31+
- examples$
2632
issues:
27-
exclude-use-default: false
28-
exclude-rules:
29-
# We don't check metrics naming in the tests.
30-
- path: _test\.go
31-
linters:
32-
- promlinter
33-
# TODO(mrueg) Improve error handling
34-
- text: "G104:"
35-
linters:
36-
- gosec
37-
- text: "package-comments:"
38-
linters:
39-
- revive
33+
max-issues-per-linter: 0
34+
max-same-issues: 0
35+
formatters:
36+
enable:
37+
- gofmt
38+
- goimports
39+
settings:
40+
goimports:
41+
local-prefixes:
42+
- k8s.io/kube-state-metrics
43+
- k8s.io/kube-state-metrics/v2
44+
exclusions:
45+
generated: lax
46+
paths:
47+
- third_party$
48+
- builtin$
49+
- examples$

internal/store/clusterrole.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func clusterRoleMetricFamilies(allowAnnotationsList, allowLabelsList []string) [
131131
"",
132132
wrapClusterRoleFunc(func(r *rbacv1.ClusterRole) *metric.Family {
133133
return &metric.Family{
134-
Metrics: resourceVersionMetric(r.ObjectMeta.ResourceVersion),
134+
Metrics: resourceVersionMetric(r.ResourceVersion),
135135
}
136136
}),
137137
),

internal/store/clusterrolebinding.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ func clusterRoleBindingMetricFamilies(allowAnnotationsList, allowLabelsList []st
133133
"",
134134
wrapClusterRoleBindingFunc(func(r *rbacv1.ClusterRoleBinding) *metric.Family {
135135
return &metric.Family{
136-
Metrics: resourceVersionMetric(r.ObjectMeta.ResourceVersion),
136+
Metrics: resourceVersionMetric(r.ResourceVersion),
137137
}
138138
}),
139139
),

internal/store/configmap.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ func configMapMetricFamilies(allowAnnotationsList, allowLabelsList []string) []g
127127
"",
128128
wrapConfigMapFunc(func(c *v1.ConfigMap) *metric.Family {
129129
return &metric.Family{
130-
Metrics: resourceVersionMetric(c.ObjectMeta.ResourceVersion),
130+
Metrics: resourceVersionMetric(c.ResourceVersion),
131131
}
132132
}),
133133
),

internal/store/cronjob.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ func cronJobMetricFamilies(allowAnnotationsList, allowLabelsList []string) []gen
273273
"",
274274
wrapCronJobFunc(func(j *batchv1.CronJob) *metric.Family {
275275
return &metric.Family{
276-
Metrics: resourceVersionMetric(j.ObjectMeta.ResourceVersion),
276+
Metrics: resourceVersionMetric(j.ResourceVersion),
277277
}
278278
}),
279279
),
@@ -358,7 +358,7 @@ func getNextScheduledTime(schedule string, lastScheduleTime *metav1.Time, create
358358

359359
sched, err := cron.ParseStandard(schedule)
360360
if err != nil {
361-
return time.Time{}, fmt.Errorf("Failed to parse cron job schedule '%s': %w", schedule, err)
361+
return time.Time{}, fmt.Errorf("failed to parse cron job schedule '%s': %w", schedule, err)
362362
}
363363
if !lastScheduleTime.IsZero() {
364364
return sched.Next(lastScheduleTime.Time), nil

internal/store/daemonset.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ func daemonSetMetricFamilies(allowAnnotationsList, allowLabelsList []string) []g
217217
{
218218
LabelKeys: []string{},
219219
LabelValues: []string{},
220-
Value: float64(d.ObjectMeta.Generation),
220+
Value: float64(d.Generation),
221221
},
222222
},
223223
}

internal/store/deployment.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ func deploymentMetricFamilies(allowAnnotationsList, allowLabelsList []string) []
277277
return &metric.Family{
278278
Metrics: []*metric.Metric{
279279
{
280-
Value: float64(d.ObjectMeta.Generation),
280+
Value: float64(d.Generation),
281281
},
282282
},
283283
}

internal/store/horizontalpodautoscaler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func createHPAMetaDataGeneration() generator.FamilyGenerator {
134134
return &metric.Family{
135135
Metrics: []*metric.Metric{
136136
{
137-
Value: float64(a.ObjectMeta.Generation),
137+
Value: float64(a.Generation),
138138
},
139139
},
140140
}

internal/store/ingress.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ func ingressMetricFamilies(allowAnnotationsList, allowLabelsList []string) []gen
140140
"",
141141
wrapIngressFunc(func(i *networkingv1.Ingress) *metric.Family {
142142
return &metric.Family{
143-
Metrics: resourceVersionMetric(i.ObjectMeta.ResourceVersion),
143+
Metrics: resourceVersionMetric(i.ResourceVersion),
144144
}
145145
}),
146146
),

0 commit comments

Comments
 (0)