Skip to content

Commit 7524785

Browse files
authored
bump golang to 1.23.6 & linter updates (#6526)
Signed-off-by: Zbynek Roubalik <[email protected]>
1 parent d1eb176 commit 7524785

28 files changed

+33
-90
lines changed

.devcontainer/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
44
#-------------------------------------------------------------------------------------------------------------
55

6-
FROM golang:1.23.4
6+
FROM golang:1.23.6
77

88
# Avoid warnings by switching to noninteractive
99
ENV DEBIAN_FRONTEND=noninteractive

.github/workflows/main-build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
id-token: write # needed for signing the images with GitHub OIDC Token **not production ready**
1717

1818
# keda-tools is built from github.com/test-tools/tools/Dockerfile
19-
container: ghcr.io/kedacore/keda-tools:1.23.3
19+
container: ghcr.io/kedacore/keda-tools:1.23.6
2020
steps:
2121
- name: Check out code
2222
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4

.github/workflows/pr-e2e.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
triage:
1111
runs-on: ubuntu-latest
1212
name: Comment evaluate
13-
container: ghcr.io/kedacore/keda-tools:1.23.3
13+
container: ghcr.io/kedacore/keda-tools:1.23.6
1414
outputs:
1515
run-e2e: ${{ startsWith(github.event.comment.body,'/run-e2e') && steps.checkUserMember.outputs.isTeamMember == 'true' }}
1616
pr_num: ${{ steps.parser.outputs.pr_num }}
@@ -69,7 +69,7 @@ jobs:
6969
needs: triage
7070
runs-on: ubuntu-latest
7171
name: Build images
72-
container: ghcr.io/kedacore/keda-tools:1.23.3
72+
container: ghcr.io/kedacore/keda-tools:1.23.6
7373
if: needs.triage.outputs.run-e2e == 'true'
7474
steps:
7575
- name: Set status in-progress
@@ -149,7 +149,7 @@ jobs:
149149
needs: [triage, build-test-images]
150150
runs-on: e2e
151151
name: Execute e2e tests
152-
container: ghcr.io/kedacore/keda-tools:1.23.3
152+
container: ghcr.io/kedacore/keda-tools:1.23.6
153153
if: needs.triage.outputs.run-e2e == 'true'
154154
steps:
155155
- name: Set status in-progress

.github/workflows/pr-validation.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
validate:
1111
name: validate - ${{ matrix.name }}
1212
runs-on: ${{ matrix.runner }}
13-
container: ghcr.io/kedacore/keda-tools:1.23.3
13+
container: ghcr.io/kedacore/keda-tools:1.23.6
1414
strategy:
1515
matrix:
1616
include:
@@ -80,7 +80,7 @@ jobs:
8080
pull-requests: read # for dorny/paths-filter to read pull requests
8181
name: validate-dockerfiles - ${{ matrix.name }}
8282
runs-on: ${{ matrix.runner }}
83-
container: ghcr.io/kedacore/keda-tools:1.23.3
83+
container: ghcr.io/kedacore/keda-tools:1.23.6
8484
strategy:
8585
matrix:
8686
include:
@@ -114,7 +114,7 @@ jobs:
114114
pull-requests: read # for dorny/paths-filter to read pull requests
115115
name: Validate dev-container - ${{ matrix.name }}
116116
runs-on: ${{ matrix.runner }}
117-
container: ghcr.io/kedacore/keda-tools:1.23.3
117+
container: ghcr.io/kedacore/keda-tools:1.23.6
118118
strategy:
119119
matrix:
120120
include:
@@ -151,7 +151,7 @@ jobs:
151151
with:
152152
go-version: "1.23"
153153
- name: Get golangci
154-
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.61.0
154+
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.63.4
155155
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
156156

157157
trivy-scan:

.github/workflows/release-build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
id-token: write # needed for signing the images with GitHub OIDC Token **not production ready**
1818

1919
# keda-tools is built from github.com/test-tools/tools/Dockerfile
20-
container: ghcr.io/kedacore/keda-tools:1.23.3
20+
container: ghcr.io/kedacore/keda-tools:1.23.6
2121
steps:
2222
- name: Check out code
2323
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4

.github/workflows/static-analysis-codeql.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
codeQl:
1818
name: Analyze CodeQL Go
1919
runs-on: ubuntu-latest
20-
container: ghcr.io/kedacore/keda-tools:1.23.3
20+
container: ghcr.io/kedacore/keda-tools:1.23.6
2121
if: (github.actor != 'dependabot[bot]')
2222
steps:
2323
- name: Checkout repository

.github/workflows/template-main-e2e-test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
name: Run e2e test
99
runs-on: ARM64
1010
# keda-tools is built from github.com/test-tools/tools/Dockerfile
11-
container: ghcr.io/kedacore/keda-tools:1.23.3
11+
container: ghcr.io/kedacore/keda-tools:1.23.6
1212
concurrency: e2e-tests
1313
steps:
1414
- name: Check out code

.golangci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ linters:
2727
- unconvert
2828
- ineffassign
2929
- staticcheck
30-
- exportloopref
30+
- copyloopvar
3131
- depguard
3232
- dogsled
3333
- errcheck

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ For more installation options visit the [pre-commits](https://pre-commit.com).
164164

165165
Before running pre-commit, you must install the [golangci-lint](https://golangci-lint.run/) tool as a static check tool for golang code (contains a series of linter)
166166
```shell script
167-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.59.1
167+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.63.4
168168
# or
169169
brew install golangci/tap/golangci-lint
170170
```

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the manager binary
2-
FROM --platform=$BUILDPLATFORM ghcr.io/kedacore/keda-tools:1.23.4 AS builder
2+
FROM --platform=$BUILDPLATFORM ghcr.io/kedacore/keda-tools:1.23.6 AS builder
33

44
ARG BUILD_VERSION=main
55
ARG GIT_COMMIT=HEAD

Dockerfile.adapter

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the adapter binary
2-
FROM --platform=$BUILDPLATFORM ghcr.io/kedacore/keda-tools:1.23.4 AS builder
2+
FROM --platform=$BUILDPLATFORM ghcr.io/kedacore/keda-tools:1.23.6 AS builder
33

44
ARG BUILD_VERSION=main
55
ARG GIT_COMMIT=HEAD

Dockerfile.webhooks

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the manager binary
2-
FROM --platform=$BUILDPLATFORM ghcr.io/kedacore/keda-tools:1.23.4 AS builder
2+
FROM --platform=$BUILDPLATFORM ghcr.io/kedacore/keda-tools:1.23.6 AS builder
33

44
ARG BUILD_VERSION=main
55
ARG GIT_COMMIT=HEAD

apis/keda/v1alpha1/scaledjob_types_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ func TestScaledJob(t *testing.T) {
7373
}
7474

7575
for _, test := range tests {
76-
test := test
7776
t.Run(test.name, func(t *testing.T) {
7877
scaledJob := &ScaledJob{
7978
Spec: ScaledJobSpec{

apis/keda/v1alpha1/scaledobject_types.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -257,18 +257,18 @@ func (so *ScaledObject) GetHPAMaxReplicas() int32 {
257257
// checkReplicaCountBoundsAreValid checks that Idle/Min/Max ReplicaCount defined in ScaledObject are correctly specified
258258
// i.e. that Min is not greater than Max or Idle greater or equal to Min
259259
func CheckReplicaCountBoundsAreValid(scaledObject *ScaledObject) error {
260-
min := int32(0)
260+
minReplicas := int32(0)
261261
if scaledObject.Spec.MinReplicaCount != nil {
262-
min = *scaledObject.GetHPAMinReplicas()
262+
minReplicas = *scaledObject.GetHPAMinReplicas()
263263
}
264-
max := scaledObject.GetHPAMaxReplicas()
264+
maxReplicas := scaledObject.GetHPAMaxReplicas()
265265

266-
if min > max {
267-
return fmt.Errorf("MinReplicaCount=%d must be less than MaxReplicaCount=%d", min, max)
266+
if minReplicas > maxReplicas {
267+
return fmt.Errorf("MinReplicaCount=%d must be less than MaxReplicaCount=%d", minReplicas, maxReplicas)
268268
}
269269

270-
if scaledObject.Spec.IdleReplicaCount != nil && *scaledObject.Spec.IdleReplicaCount >= min {
271-
return fmt.Errorf("IdleReplicaCount=%d must be less than MinReplicaCount=%d", *scaledObject.Spec.IdleReplicaCount, min)
270+
if scaledObject.Spec.IdleReplicaCount != nil && *scaledObject.Spec.IdleReplicaCount >= minReplicas {
271+
return fmt.Errorf("IdleReplicaCount=%d must be less than MinReplicaCount=%d", *scaledObject.Spec.IdleReplicaCount, minReplicas)
272272
}
273273

274274
return nil

apis/keda/v1alpha1/scaledobject_webhook.go

+2
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ func validateWorkload(so *ScaledObject, action string, dryRun bool) (admission.W
180180
return nil, nil
181181
}
182182

183+
//nolint:unparam
183184
func verifyReplicaCount(incomingSo *ScaledObject, action string, _ bool) error {
184185
err := CheckReplicaCountBoundsAreValid(incomingSo)
185186
if err != nil {
@@ -189,6 +190,7 @@ func verifyReplicaCount(incomingSo *ScaledObject, action string, _ bool) error {
189190
return nil
190191
}
191192

193+
//nolint:unparam
192194
func verifyFallback(incomingSo *ScaledObject, action string, _ bool) error {
193195
err := CheckFallbackValid(incomingSo)
194196
if err != nil {

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/kedacore/keda/v2
22

3-
go 1.23.4
3+
go 1.23.6
44

55
require (
66
cloud.google.com/go/compute/metadata v0.6.0

pkg/scalers/beanstalkd_scaler_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ func TestBeanstalkdGetMetricSpecForScaling(t *testing.T) {
190190

191191
func TestGetTubeStats(t *testing.T) {
192192
for _, testData := range testTubeStatsTestData {
193-
testData := testData
194193
yamlData, err := yaml.Marshal(testData.response)
195194
if err != nil {
196195
t.Fatal(err)

pkg/scalers/datadog_scaler.go

+2-12
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"io"
88
"net/http"
99
"regexp"
10+
"slices"
1011
"strconv"
1112
"strings"
1213
"time"
@@ -564,7 +565,7 @@ func (s *datadogScaler) getQueryResult(ctx context.Context) (float64, error) {
564565
return AvgFloatFromSlice(results), nil
565566
default:
566567
// Aggregate Results - default Max value:
567-
return MaxFloatFromSlice(results), nil
568+
return slices.Max(results), nil
568569
}
569570
}
570571

@@ -674,17 +675,6 @@ func (s *datadogScaler) GetMetricsAndActivity(ctx context.Context, metricName st
674675
return []external_metrics.ExternalMetricValue{metric}, num > s.metadata.activationQueryValue, nil
675676
}
676677

677-
// MaxFloatFromSlice finds the largest value in a slice of floats
678-
func MaxFloatFromSlice(results []float64) float64 {
679-
max := results[0]
680-
for _, result := range results {
681-
if result > max {
682-
max = result
683-
}
684-
}
685-
return max
686-
}
687-
688678
// AvgFloatFromSlice finds the average value in a slice of floats
689679
func AvgFloatFromSlice(results []float64) float64 {
690680
total := 0.0

pkg/scalers/datadog_scaler_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package scalers
22

33
import (
44
"context"
5+
"slices"
56
"testing"
67

78
"github.com/go-logr/logr"
@@ -48,7 +49,7 @@ func TestMaxFloatFromSlice(t *testing.T) {
4849
input := []float64{1.0, 2.0, 3.0, 4.0}
4950
expectedOutput := float64(4.0)
5051

51-
output := MaxFloatFromSlice(input)
52+
output := slices.Max(input)
5253

5354
assertEqual(t, output, expectedOutput)
5455
}

pkg/scalers/ibmmq_scaler.go

+2-14
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"io"
99
"net/http"
1010
"net/url"
11+
"slices"
1112

1213
"github.com/go-logr/logr"
1314
v2 "k8s.io/api/autoscaling/v2"
@@ -211,7 +212,7 @@ func calculateDepth(depths []int64, operation string) int64 {
211212
case avgOperation:
212213
return avgDepths(depths)
213214
case maxOperation:
214-
return maxDepths(depths)
215+
return slices.Max(depths)
215216
default:
216217
return 0
217218
}
@@ -232,19 +233,6 @@ func avgDepths(depths []int64) int64 {
232233
return sumDepths(depths) / int64(len(depths))
233234
}
234235

235-
func maxDepths(depths []int64) int64 {
236-
if len(depths) == 0 {
237-
return 0
238-
}
239-
max := depths[0]
240-
for _, depth := range depths[1:] {
241-
if depth > max {
242-
max = depth
243-
}
244-
}
245-
return max
246-
}
247-
248236
func (s *ibmmqScaler) GetMetricSpecForScaling(context.Context) []v2.MetricSpec {
249237
metricName := kedautil.NormalizeString(fmt.Sprintf("ibmmq-%s", s.metadata.QueueName[0]))
250238
externalMetric := &v2.ExternalMetricSource{

pkg/scalers/openstack_metrics_scaler_test.go

-3
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ func TestOpenstackMetricsGetMetricsForSpecScaling(t *testing.T) {
107107
}
108108

109109
for _, testData := range testCases {
110-
testData := testData
111110
meta, err := parseOpenstackMetricMetadata(&scalersconfig.ScalerConfig{ResolvedEnv: testData.resolvedEnv, TriggerMetadata: testData.metadataTestData.metadata, AuthParams: testData.authMetadataTestData.authMetadata, TriggerIndex: testData.triggerIndex}, logr.Discard())
112111

113112
if err != nil {
@@ -144,7 +143,6 @@ func TestOpenstackMetricsGetMetricsForSpecScalingInvalidMetaData(t *testing.T) {
144143
}
145144

146145
for _, testData := range testCases {
147-
testData := testData
148146
t.Run(testData.name, func(pt *testing.T) {
149147
_, err := parseOpenstackMetricMetadata(&scalersconfig.ScalerConfig{ResolvedEnv: testData.resolvedEnv, TriggerMetadata: testData.metadataTestData.metadata, AuthParams: testData.authMetadataTestData.authMetadata, TriggerIndex: testData.triggerIndex}, logr.Discard())
150148
assert.NotNil(t, err)
@@ -163,7 +161,6 @@ func TestOpenstackMetricAuthenticationInvalidAuthMetadata(t *testing.T) {
163161
}
164162

165163
for _, testData := range testCases {
166-
testData := testData
167164
t.Run(testData.name, func(ptr *testing.T) {
168165
_, err := parseOpenstackMetricAuthenticationMetadata(&scalersconfig.ScalerConfig{ResolvedEnv: testData.resolvedEnv, TriggerMetadata: testData.metadataTestData.metadata, AuthParams: testData.authMetadataTestData.authMetadata, TriggerIndex: testData.triggerIndex})
169166
assert.NotNil(t, err)

pkg/scalers/openstack_swift_scaler_test.go

-3
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ func TestOpenstackSwiftGetMetricSpecForScaling(t *testing.T) {
104104
}
105105

106106
for _, testData := range testCases {
107-
testData := testData
108107
meta, err := parseOpenstackSwiftMetadata(&scalersconfig.ScalerConfig{ResolvedEnv: testData.resolvedEnv, TriggerMetadata: testData.metadataTestData.metadata, AuthParams: testData.authMetadataTestData.authMetadata, TriggerIndex: testData.scaledIndex})
109108
if err != nil {
110109
t.Fatal("Could not parse metadata:", err)
@@ -135,7 +134,6 @@ func TestParseOpenstackSwiftMetadataForInvalidCases(t *testing.T) {
135134
}
136135

137136
for _, testData := range testCases {
138-
testData := testData
139137
t.Run(testData.name, func(pt *testing.T) {
140138
_, err := parseOpenstackSwiftMetadata(&scalersconfig.ScalerConfig{ResolvedEnv: testData.resolvedEnv, TriggerMetadata: testData.metadataTestData.metadata, AuthParams: testData.authMetadataTestData.authMetadata, TriggerIndex: testData.scaledIndex})
141139
assert.NotNil(t, err)
@@ -155,7 +153,6 @@ func TestParseOpenstackSwiftAuthenticationMetadataForInvalidCases(t *testing.T)
155153
}
156154

157155
for _, testData := range testCases {
158-
testData := testData
159156
t.Run(testData.name, func(pt *testing.T) {
160157
_, err := parseOpenstackSwiftAuthenticationMetadata(&scalersconfig.ScalerConfig{ResolvedEnv: testData.resolvedEnv, TriggerMetadata: testData.metadataTestData.metadata, AuthParams: testData.authMetadataTestData.authMetadata, TriggerIndex: testData.scaledIndex})
161158
assert.NotNil(t, err)

pkg/scalers/rabbitmq_scaler_test.go

-2
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,6 @@ func TestGetQueueInfo(t *testing.T) {
371371
}
372372

373373
for _, testData := range allTestData {
374-
testData := testData
375374
vhost, path := getVhostAndPathFromURL(testData.urlPath, testData.extraMetadata["vhostName"])
376375
var apiStub = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
377376
expectedPath := fmt.Sprintf("%s/api/queues%s/evaluate_trials", path, vhost)
@@ -512,7 +511,6 @@ func TestGetQueueInfoWithRegex(t *testing.T) {
512511
}
513512

514513
for _, testData := range allTestData {
515-
testData := testData
516514
vhost, path := getVhostAndPathFromURL(testData.urlPath, testData.extraMetadata["vhostName"])
517515
var apiStub = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
518516
expectedPath := fmt.Sprintf("%s/api/queues%s?page=1&use_regex=true&pagination=false&name=%%5Eevaluate_trials%%24&page_size=100", path, vhost)

pkg/scalers/redis_streams_scaler_test.go

-3
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ func TestParseRedisStreamsMetadata(t *testing.T) {
4747
}
4848

4949
for _, tc := range testCasesPending {
50-
tc := tc
5150
t.Run(tc.name, func(te *testing.T) {
5251
m, err := parseRedisStreamsMetadata(&scalersconfig.ScalerConfig{TriggerMetadata: tc.metadata, ResolvedEnv: tc.resolvedEnv, AuthParams: tc.authParams})
5352
assert.Nil(t, err)
@@ -97,7 +96,6 @@ func TestParseRedisStreamsMetadata(t *testing.T) {
9796
}
9897

9998
for _, tc := range testCasesLag {
100-
tc := tc
10199
t.Run(tc.name, func(te *testing.T) {
102100
m, err := parseRedisStreamsMetadata(&scalersconfig.ScalerConfig{TriggerMetadata: tc.metadata, ResolvedEnv: tc.resolvedEnv, AuthParams: tc.authParams})
103101
assert.Nil(t, err)
@@ -158,7 +156,6 @@ func TestParseRedisStreamsMetadataForInvalidCases(t *testing.T) {
158156
}
159157

160158
for _, tc := range testCases {
161-
tc := tc
162159
t.Run(tc.name, func(te *testing.T) {
163160
_, err := parseRedisStreamsMetadata(&scalersconfig.ScalerConfig{TriggerMetadata: tc.metadata, ResolvedEnv: tc.resolvedEnv, AuthParams: map[string]string{}})
164161
assert.NotNil(t, err)

0 commit comments

Comments
 (0)