Skip to content

Commit fd2a1f8

Browse files
committed
chore: Build with go 1.22
1 parent d7d561f commit fd2a1f8

23 files changed

+30
-30
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ env:
2020
E2E_SETUP_KIND: yes
2121
E2E_SETUP_KUBECTL: yes
2222
SUDO: sudo
23-
GO_VERSION: "^1.21"
24-
GOLANGCI_LINT_VERSION: "v1.54.2"
23+
GO_VERSION: "^1.22"
24+
GOLANGCI_LINT_VERSION: "v1.56.2"
2525

2626
jobs:
2727
ci-go-lint:

.github/workflows/govulncheck.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- cron: '0 0 * * 1'
77

88
env:
9-
GO_VERSION: "^1.21"
9+
GO_VERSION: "^1.22"
1010

1111
permissions:
1212
contents: read

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
run:
2-
deadline: 5m
2+
deadline: 10m
33

44
linters:
55
disable-all: true

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG GOVERSION=1.21
1+
ARG GOVERSION=1.22
22
ARG GOARCH
33
FROM golang:${GOVERSION} as builder
44
ARG GOARCH

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ OS ?= $(shell uname -s | tr A-Z a-z)
1616
ALL_ARCH = amd64 arm arm64 ppc64le s390x
1717
PKG = github.com/prometheus/common
1818
PROMETHEUS_VERSION = 2.46.0
19-
GO_VERSION = 1.21.8
19+
GO_VERSION = 1.22.2
2020
IMAGE = $(REGISTRY)/kube-state-metrics
2121
MULTI_ARCH_IMG = $(IMAGE)-$(ARCH)
2222
USER ?= $(shell id -u -n)

internal/store/clusterrole.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func clusterRoleMetricFamilies(allowAnnotationsList, allowLabelsList []string) [
9191
metric.Gauge,
9292
basemetrics.ALPHA,
9393
"",
94-
wrapClusterRoleFunc(func(r *rbacv1.ClusterRole) *metric.Family {
94+
wrapClusterRoleFunc(func(_ *rbacv1.ClusterRole) *metric.Family {
9595
return &metric.Family{
9696
Metrics: []*metric.Metric{{
9797
LabelKeys: []string{},

internal/store/configmap.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func configMapMetricFamilies(allowAnnotationsList, allowLabelsList []string) []g
8787
metric.Gauge,
8888
basemetrics.STABLE,
8989
"",
90-
wrapConfigMapFunc(func(c *v1.ConfigMap) *metric.Family {
90+
wrapConfigMapFunc(func(_ *v1.ConfigMap) *metric.Family {
9191
return &metric.Family{
9292
Metrics: []*metric.Metric{{
9393
LabelKeys: []string{},

internal/store/endpoint.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func endpointMetricFamilies(allowAnnotationsList, allowLabelsList []string) []ge
4848
metric.Gauge,
4949
basemetrics.STABLE,
5050
"",
51-
wrapEndpointFunc(func(e *v1.Endpoints) *metric.Family {
51+
wrapEndpointFunc(func(_ *v1.Endpoints) *metric.Family {
5252
return &metric.Family{
5353
Metrics: []*metric.Metric{
5454
{

internal/store/job.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func jobMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generat
9494
metric.Gauge,
9595
basemetrics.STABLE,
9696
"",
97-
wrapJobFunc(func(j *v1batch.Job) *metric.Family {
97+
wrapJobFunc(func(_ *v1batch.Job) *metric.Family {
9898
return &metric.Family{
9999
Metrics: []*metric.Metric{
100100
{

internal/store/mutatingwebhookconfiguration.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ var (
4141
metric.Gauge,
4242
basemetrics.ALPHA,
4343
"",
44-
wrapMutatingWebhookConfigurationFunc(func(mwc *admissionregistrationv1.MutatingWebhookConfiguration) *metric.Family {
44+
wrapMutatingWebhookConfigurationFunc(func(_ *admissionregistrationv1.MutatingWebhookConfiguration) *metric.Family {
4545
return &metric.Family{
4646
Metrics: []*metric.Metric{
4747
{

internal/store/role.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func roleMetricFamilies(allowAnnotationsList, allowLabelsList []string) []genera
9191
metric.Gauge,
9292
basemetrics.ALPHA,
9393
"",
94-
wrapRoleFunc(func(r *rbacv1.Role) *metric.Family {
94+
wrapRoleFunc(func(_ *rbacv1.Role) *metric.Family {
9595
return &metric.Family{
9696
Metrics: []*metric.Metric{{
9797
LabelKeys: []string{},

internal/store/secret.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func secretMetricFamilies(allowAnnotationsList, allowLabelsList []string) []gene
4848
metric.Gauge,
4949
basemetrics.STABLE,
5050
"",
51-
wrapSecretFunc(func(s *v1.Secret) *metric.Family {
51+
wrapSecretFunc(func(_ *v1.Secret) *metric.Family {
5252
return &metric.Family{
5353
Metrics: []*metric.Metric{
5454
{

internal/store/validatingwebhookconfiguration.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ var (
4141
metric.Gauge,
4242
basemetrics.ALPHA,
4343
"",
44-
wrapValidatingWebhookConfigurationFunc(func(vwc *admissionregistrationv1.ValidatingWebhookConfiguration) *metric.Family {
44+
wrapValidatingWebhookConfigurationFunc(func(_ *admissionregistrationv1.ValidatingWebhookConfiguration) *metric.Family {
4545
return &metric.Family{
4646
Metrics: []*metric.Metric{
4747
{

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
func main() {
2828
opts := options.NewOptions()
2929
cmd := options.InitCommand
30-
cmd.Run = func(cmd *cobra.Command, args []string) {
30+
cmd.Run = func(_ *cobra.Command, _ []string) {
3131
internal.RunKubeStateMetricsWrapper(opts)
3232
}
3333
opts.AddFlags(cmd)

pkg/app/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ func buildMetricsServer(m *metricshandler.MetricsHandler, durationObserver prome
403403
mux.Handle(metricsPath, promhttp.InstrumentHandlerDuration(durationObserver, m))
404404

405405
// Add healthzPath
406-
mux.HandleFunc(healthzPath, func(w http.ResponseWriter, r *http.Request) {
406+
mux.HandleFunc(healthzPath, func(w http.ResponseWriter, _ *http.Request) {
407407
w.WriteHeader(http.StatusOK)
408408
w.Write([]byte(http.StatusText(http.StatusOK)))
409409
})

pkg/app/server_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func BenchmarkKubeStateMetrics(b *testing.B) {
100100
// This test is not suitable to be compared in terms of time, as it includes
101101
// a one second wait. Use for memory allocation comparisons, profiling, ...
102102
handler := metricshandler.New(&options.Options{}, kubeClient, builder, false)
103-
b.Run("GenerateMetrics", func(b *testing.B) {
103+
b.Run("GenerateMetrics", func(_ *testing.B) {
104104
handler.ConfigureSharding(ctx, 0, 1)
105105

106106
// Wait for caches to fill

pkg/metrics_store/metrics_store_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func (f *metricFamily) ByteSlice() []byte {
4141
}
4242

4343
func TestObjectsSameNameDifferentNamespaces(t *testing.T) {
44-
serviceIDS := []string{"a", "b"}
44+
serviceIDs := []string{"a", "b"}
4545

4646
genFunc := func(obj interface{}) []metric.FamilyInterface {
4747
o, err := meta.Accessor(obj)
@@ -65,7 +65,7 @@ func TestObjectsSameNameDifferentNamespaces(t *testing.T) {
6565

6666
ms := NewMetricsStore([]string{"Information about service."}, genFunc)
6767

68-
for _, id := range serviceIDS {
68+
for _, id := range serviceIDs {
6969
s := v1.Service{
7070
ObjectMeta: metav1.ObjectMeta{
7171
Name: "service",
@@ -88,7 +88,7 @@ func TestObjectsSameNameDifferentNamespaces(t *testing.T) {
8888
}
8989
m := w.String()
9090

91-
for _, id := range serviceIDS {
91+
for _, id := range serviceIDs {
9292
if !strings.Contains(m, fmt.Sprintf("uid=\"%v\"", id)) {
9393
t.Fatalf("expected to find metric with uid %v", id)
9494
}

pkg/metrics_store/metrics_writer_test.go

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

239239
// TestWriteAllWithEmptyStores checks that nothing is printed if no metrics exist for metric families.
240240
func TestWriteAllWithEmptyStores(t *testing.T) {
241-
genFunc := func(obj interface{}) []metric.FamilyInterface {
241+
genFunc := func(_ interface{}) []metric.FamilyInterface {
242242
mf1 := metric.Family{
243243
Name: "kube_service_info_1",
244244
Metrics: []*metric.Metric{},

pkg/options/options.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func NewOptions() *Options {
8383
func (o *Options) AddFlags(cmd *cobra.Command) {
8484
o.cmd = cmd
8585

86-
completionCommand.SetHelpFunc(func(cmd *cobra.Command, args []string) {
86+
completionCommand.SetHelpFunc(func(_ *cobra.Command, _ []string) {
8787
if shellPath, ok := os.LookupEnv("SHELL"); ok {
8888
shell := shellPath[strings.LastIndex(shellPath, "/")+1:]
8989
fmt.Println(FetchLoadInstructions(shell))
@@ -97,7 +97,7 @@ func (o *Options) AddFlags(cmd *cobra.Command) {
9797
versionCommand := &cobra.Command{
9898
Use: "version",
9999
Short: "Print version information.",
100-
Run: func(cmd *cobra.Command, args []string) {
100+
Run: func(_ *cobra.Command, _ []string) {
101101
fmt.Printf("%s\n", version.Print("kube-state-metrics"))
102102
klog.FlushAndExit(klog.ExitFlushTimeout, 0)
103103
},

tests/e2e/discovery_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func TestVariableVKsDiscoveryAndResolution(t *testing.T) {
9797
klog.InfoS("started KSM")
9898

9999
// Wait for port 8080 to come up.
100-
err = wait.PollUntilContextTimeout(context.TODO(), 1*time.Second, 20*time.Second, true, func(ctx context.Context) (bool, error) {
100+
err = wait.PollUntilContextTimeout(context.TODO(), 1*time.Second, 20*time.Second, true, func(_ context.Context) (bool, error) {
101101
conn, err := net.Dial("tcp", "localhost:8080")
102102
if err != nil {
103103
return false, nil
@@ -140,7 +140,7 @@ func TestVariableVKsDiscoveryAndResolution(t *testing.T) {
140140
// Wait for the metric to be available.
141141
ch := make(chan bool, 1)
142142
klog.InfoS("waiting for metrics to become available")
143-
err = wait.PollUntilContextTimeout(context.TODO(), discovery.Interval, PopulateTimeout, true, func(ctx context.Context) (bool, error) {
143+
err = wait.PollUntilContextTimeout(context.TODO(), discovery.Interval, PopulateTimeout, true, func(_ context.Context) (bool, error) {
144144
out, err := exec.Command("curl", "localhost:8080/metrics").Output()
145145
if err != nil {
146146
return false, err

tests/e2e/hot-reload-kubeconfig_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func TestKubeConfigHotReload(t *testing.T) {
7474
go internal.RunKubeStateMetricsWrapper(opts)
7575

7676
// Wait for port 8080 to come up.
77-
err = wait.PollUntilContextTimeout(context.TODO(), 1*time.Second, 20*time.Second, true, func(ctx context.Context) (bool, error) {
77+
err = wait.PollUntilContextTimeout(context.TODO(), 1*time.Second, 20*time.Second, true, func(_ context.Context) (bool, error) {
7878
conn, err := net.Dial("tcp", "localhost:8080")
7979
if err != nil {
8080
return false, nil
@@ -108,7 +108,7 @@ func TestKubeConfigHotReload(t *testing.T) {
108108

109109
// Wait for port 8080 to come up.
110110
ch := make(chan bool, 1)
111-
err = wait.PollUntilContextTimeout(context.TODO(), 1*time.Second, 20*time.Second, true, func(ctx context.Context) (bool, error) {
111+
err = wait.PollUntilContextTimeout(context.TODO(), 1*time.Second, 20*time.Second, true, func(_ context.Context) (bool, error) {
112112
conn, err := net.Dial("tcp", "localhost:8080")
113113
if err != nil {
114114
return false, nil

tests/e2e/hot-reload_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func TestConfigHotReload(t *testing.T) {
6565
go internal.RunKubeStateMetricsWrapper(opts)
6666

6767
// Wait for port 8080 to come up.
68-
err = wait.PollUntilContextTimeout(context.TODO(), 1*time.Second, 20*time.Second, true, func(ctx context.Context) (bool, error) {
68+
err = wait.PollUntilContextTimeout(context.TODO(), 1*time.Second, 20*time.Second, true, func(_ context.Context) (bool, error) {
6969
conn, err := net.Dial("tcp", "localhost:8080")
7070
if err != nil {
7171
return false, nil
@@ -89,7 +89,7 @@ func TestConfigHotReload(t *testing.T) {
8989

9090
// Wait for port 8080 to come up.
9191
ch := make(chan bool, 1)
92-
err = wait.PollUntilContextTimeout(context.TODO(), 1*time.Second, 20*time.Second, true, func(ctx context.Context) (bool, error) {
92+
err = wait.PollUntilContextTimeout(context.TODO(), 1*time.Second, 20*time.Second, true, func(_ context.Context) (bool, error) {
9393
conn, err := net.Dial("tcp", "localhost:8080")
9494
if err != nil {
9595
return false, nil

tests/e2e/main_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ func getLabelsDocumentation() (map[string][]string, error) {
154154
// Match wildcard patterns for dynamic labels such as label_CRONJOB_LABEL
155155
patternRe := regexp.MustCompile(`_[A-Z_]+`)
156156

157-
err := filepath.WalkDir("../../docs", func(p string, d fs.DirEntry, err error) error {
157+
err := filepath.WalkDir("../../docs", func(p string, d fs.DirEntry, _ error) error {
158158

159159
if d.IsDir() || !fileRe.MatchString(d.Name()) {
160160
// Ignore the entry

0 commit comments

Comments
 (0)