Skip to content

Commit 302680d

Browse files
authored
bump go and deps (#352)
1 parent 1c8a322 commit 302680d

File tree

38 files changed

+204
-201
lines changed

38 files changed

+204
-201
lines changed

.github/workflows/build-and-upload.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
- name: Set up Go 1.x
6767
uses: actions/setup-go@v4
6868
with:
69-
go-version: ~1.22.7
69+
go-version: '>1.25'
7070
cache: false
7171

7272
- name: Configure AWS Credentials
@@ -158,7 +158,7 @@ jobs:
158158
- name: Set up Go 1.x
159159
uses: actions/setup-go@v4
160160
with:
161-
go-version: '>1.22'
161+
go-version: '>1.25'
162162
cache: true
163163

164164
- name: Configure AWS Credentials
@@ -285,7 +285,7 @@ jobs:
285285
- name: Set up Go 1.x
286286
uses: actions/setup-go@v4
287287
with:
288-
go-version: '>1.22'
288+
go-version: '>1.25'
289289
cache: true
290290

291291
- name: Configure AWS Credentials

.github/workflows/pr-build-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
- name: Set up Go
4848
uses: actions/setup-go@v5
4949
with:
50-
go-version: "~1.24.4"
50+
go-version: "~1.25.5"
5151

5252
- name: Cache tools
5353
uses: actions/cache@v4

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# syntax=docker/dockerfile:1.4
2-
FROM --platform=$BUILDPLATFORM golang:1.24 AS builder
2+
FROM --platform=$BUILDPLATFORM golang:1.25 AS builder
33

44
# Set build arguments early
55
ARG TARGETARCH

Makefile

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,14 @@ $(CONTROLLER_GEN): $(LOCALBIN)
195195
test -s $(LOCALBIN)/controller-gen && $(LOCALBIN)/controller-gen --version | grep -q $(CONTROLLER_TOOLS_VERSION) || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)
196196

197197
.PHONY: goimports
198-
goimports:
199-
@echo $(ALL_SRC) | xargs -n 10 $(LOCALBIN)/goimports -w -local $(CW_AGENT_OPERATOR_IMPORT_PATH) || GOBIN=$(LOCALBIN) go install golang.org/x/tools/cmd/goimports
198+
goimports: $(LOCALBIN)
199+
@test -s $(LOCALBIN)/goimports || GOBIN=$(LOCALBIN) go install golang.org/x/tools/cmd/goimports@latest
200+
@echo $(ALL_SRC) | xargs -n 10 $(LOCALBIN)/goimports -w -local $(CW_AGENT_OPERATOR_IMPORT_PATH)
200201

201202
.PHONY: impi
202-
impi:
203-
@echo $(ALL_SRC) | xargs -n 10 $(LOCALBIN)/impi --local $(CW_AGENT_OPERATOR_IMPORT_PATH) --scheme stdThirdPartyLocal || GOBIN=$(LOCALBIN) go install github.com/pavius/impi/cmd/[email protected]
203+
impi: $(LOCALBIN)
204+
@test -s $(LOCALBIN)/impi || GOBIN=$(LOCALBIN) go install github.com/pavius/impi/cmd/[email protected]
205+
@echo $(ALL_SRC) | xargs -n 10 $(LOCALBIN)/impi --local $(CW_AGENT_OPERATOR_IMPORT_PATH) --scheme stdThirdPartyLocal
204206
@echo "Check import order/grouping finished"
205207

206208
.PHONY: lint
@@ -237,7 +239,10 @@ checklicense: install-addlicense
237239

238240
.PHONY: golangci-lint
239241
golangci-lint: ## Download golangci-lint locally if necessary.
240-
$(call go-get-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))
242+
# $(call go-get-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))
243+
#Install from source for golangci-lint is not recommended based on https://golangci-lint.run/usage/install/#install-from-source so using binary
244+
#installation
245+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s -- -b $(LOCALBIN) v2.4.0
241246

242247
.PHONY: envtest
243248
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.

apis/v1alpha1/collector_webhook.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,15 +328,16 @@ func checkAutoscalerSpec(autoscaler *AutoscalerSpec) error {
328328
}
329329

330330
// pod metrics target only support value and averageValue.
331-
if metric.Pods.Target.Type == autoscalingv2.AverageValueMetricType {
331+
switch metric.Pods.Target.Type {
332+
case autoscalingv2.AverageValueMetricType:
332333
if val, ok := metric.Pods.Target.AverageValue.AsInt64(); !ok || val < int64(1) {
333334
return fmt.Errorf("the OpenTelemetry Spec autoscale configuration is incorrect, average value should be greater than 0")
334335
}
335-
} else if metric.Pods.Target.Type == autoscalingv2.ValueMetricType {
336+
case autoscalingv2.ValueMetricType:
336337
if val, ok := metric.Pods.Target.Value.AsInt64(); !ok || val < int64(1) {
337338
return fmt.Errorf("the OpenTelemetry Spec autoscale configuration is incorrect, value should be greater than 0")
338339
}
339-
} else {
340+
default:
340341
return fmt.Errorf("the OpenTelemetry Spec autoscale configuration is incorrect, invalid pods target type")
341342
}
342343
}

apis/v1alpha1/instrumentation_webhook.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -207,32 +207,32 @@ func (w InstrumentationWebhook) defaulter(r *Instrumentation) error {
207207

208208
func (w InstrumentationWebhook) validate(r *Instrumentation) (admission.Warnings, error) {
209209
var warnings []string
210-
switch r.Spec.Sampler.Type {
210+
switch r.Spec.Type {
211211
case "":
212212
warnings = append(warnings, "sampler type not set")
213213
case TraceIDRatio, ParentBasedTraceIDRatio:
214-
if r.Spec.Sampler.Argument != "" {
215-
rate, err := strconv.ParseFloat(r.Spec.Sampler.Argument, 64)
214+
if r.Spec.Argument != "" {
215+
rate, err := strconv.ParseFloat(r.Spec.Argument, 64)
216216
if err != nil {
217-
return warnings, fmt.Errorf("spec.sampler.argument is not a number: %s", r.Spec.Sampler.Argument)
217+
return warnings, fmt.Errorf("spec.sampler.argument is not a number: %s", r.Spec.Argument)
218218
}
219219
if rate < 0 || rate > 1 {
220-
return warnings, fmt.Errorf("spec.sampler.argument should be in rage [0..1]: %s", r.Spec.Sampler.Argument)
220+
return warnings, fmt.Errorf("spec.sampler.argument should be in rage [0..1]: %s", r.Spec.Argument)
221221
}
222222
}
223223
case JaegerRemote, ParentBasedJaegerRemote:
224224
// value is a comma separated list of endpoint, pollingIntervalMs, initialSamplingRate
225225
// Example: `endpoint=http://localhost:14250,pollingIntervalMs=5000,initialSamplingRate=0.25`
226-
if r.Spec.Sampler.Argument != "" {
227-
err := validateJaegerRemoteSamplerArgument(r.Spec.Sampler.Argument)
226+
if r.Spec.Argument != "" {
227+
err := validateJaegerRemoteSamplerArgument(r.Spec.Argument)
228228

229229
if err != nil {
230-
return warnings, fmt.Errorf("spec.sampler.argument is not a valid argument for sampler %s: %w", r.Spec.Sampler.Type, err)
230+
return warnings, fmt.Errorf("spec.sampler.argument is not a valid argument for sampler %s: %w", r.Spec.Type, err)
231231
}
232232
}
233233
case AlwaysOn, AlwaysOff, ParentBasedAlwaysOn, ParentBasedAlwaysOff, XRaySampler:
234234
default:
235-
return warnings, fmt.Errorf("spec.sampler.type is not valid: %s", r.Spec.Sampler.Type)
235+
return warnings, fmt.Errorf("spec.sampler.type is not valid: %s", r.Spec.Type)
236236
}
237237

238238
// validate env vars

cmd/amazon-cloudwatch-agent-target-allocator/collector/collector_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,20 +159,20 @@ func Test_closeChannel(t *testing.T) {
159159
tests := []struct {
160160
description string
161161
isCloseChannel bool
162-
timeoutSeconds time.Duration
162+
timeout time.Duration
163163
}{
164164
{
165165
// event is triggered by channel closing.
166166
description: "close_channel",
167167
isCloseChannel: true,
168168
// channel should be closed before this timeout occurs
169-
timeoutSeconds: 10 * time.Second,
169+
timeout: 10 * time.Second,
170170
},
171171
{
172172
// event triggered by timeout.
173173
description: "watcher_timeout",
174174
isCloseChannel: false,
175-
timeoutSeconds: 0 * time.Second,
175+
timeout: 0 * time.Second,
176176
},
177177
}
178178

@@ -190,7 +190,7 @@ func Test_closeChannel(t *testing.T) {
190190

191191
go func(watcher watch.Interface) {
192192
defer wg.Done()
193-
ctx, cancel := context.WithTimeout(context.Background(), tc.timeoutSeconds)
193+
ctx, cancel := context.WithTimeout(context.Background(), tc.timeout)
194194
defer cancel()
195195
if msg := runWatch(ctx, &kubeClient, watcher.ResultChan(), map[string]*allocation.Collector{}, func(colMap map[string]*allocation.Collector) {}); msg != "" {
196196
terminated = true

cmd/amazon-cloudwatch-agent-target-allocator/config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ func Load() (*Config, string, error) {
207207
// ValidateConfig validates the cli and file configs together.
208208
func ValidateConfig(config *Config) error {
209209
scrapeConfigsPresent := config.PromConfig != nil && len(config.PromConfig.ScrapeConfigs) > 0
210-
if !(config.PrometheusCR.Enabled || scrapeConfigsPresent) {
210+
if !config.PrometheusCR.Enabled && !scrapeConfigsPresent {
211211
return fmt.Errorf("at least one scrape config must be defined, or Prometheus CR watching must be enabled")
212212
}
213213
return nil

cmd/amazon-cloudwatch-agent-target-allocator/server/server_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,37 +1044,37 @@ func generateTestingCerts() (caBundlePath, caCertPath, caKeyPath, clientCertPath
10441044
if err != nil {
10451045
return "", "", "", "", "", fmt.Errorf("error creating temp CA cert file: %w", err)
10461046
}
1047-
defer caCertFile.Close()
1047+
defer func() { _ = caCertFile.Close() }()
10481048

10491049
caKeyFile, err := os.CreateTemp(tempDir, "ca-key-*.key")
10501050
if err != nil {
10511051
return "", "", "", "", "", fmt.Errorf("error creating temp CA key file: %w", err)
10521052
}
1053-
defer caKeyFile.Close()
1053+
defer func() { _ = caKeyFile.Close() }()
10541054

10551055
serverCertFile, err := os.CreateTemp(tempDir, "server-cert-*.crt")
10561056
if err != nil {
10571057
return "", "", "", "", "", fmt.Errorf("error creating temp server cert file: %w", err)
10581058
}
1059-
defer serverCertFile.Close()
1059+
defer func() { _ = serverCertFile.Close() }()
10601060

10611061
serverKeyFile, err := os.CreateTemp(tempDir, "server-key-*.key")
10621062
if err != nil {
10631063
return "", "", "", "", "", fmt.Errorf("error creating temp server key file: %w", err)
10641064
}
1065-
defer serverKeyFile.Close()
1065+
defer func() { _ = serverKeyFile.Close() }()
10661066

10671067
clientCertFile, err := os.CreateTemp(tempDir, "client-cert-*.crt")
10681068
if err != nil {
10691069
return "", "", "", "", "", fmt.Errorf("error creating temp client cert file: %w", err)
10701070
}
1071-
defer clientCertFile.Close()
1071+
defer func() { _ = clientCertFile.Close() }()
10721072

10731073
clientKeyFile, err := os.CreateTemp(tempDir, "client-key-*.key")
10741074
if err != nil {
10751075
return "", "", "", "", "", fmt.Errorf("error creating temp client key file: %w", err)
10761076
}
1077-
defer clientKeyFile.Close()
1077+
defer func() { _ = clientKeyFile.Close() }()
10781078

10791079
// Write the CA, server, and client certificates and keys to their respective files
10801080
caCertPEMBlock := &pem.Block{Type: "CERTIFICATE", Bytes: caCertBytes}
@@ -1150,7 +1150,7 @@ func createMismatchedClientCert() (caPath string, tlsConfig *tls.Config, err err
11501150
if err != nil {
11511151
return "", nil, err
11521152
}
1153-
defer caFile.Close()
1153+
defer func() { _ = caFile.Close() }()
11541154
err = pem.Encode(caFile, &pem.Block{Type: "CERTIFICATE", Bytes: caBytes})
11551155
if err != nil {
11561156
return "", nil, err
@@ -1161,7 +1161,7 @@ func createMismatchedClientCert() (caPath string, tlsConfig *tls.Config, err err
11611161
if err != nil {
11621162
return "", nil, err
11631163
}
1164-
defer clientCertFile.Close()
1164+
defer func() { _ = clientCertFile.Close() }()
11651165
err = pem.Encode(clientCertFile, &pem.Block{Type: "CERTIFICATE", Bytes: clientCertBytes})
11661166
if err != nil {
11671167
return "", nil, err
@@ -1172,7 +1172,7 @@ func createMismatchedClientCert() (caPath string, tlsConfig *tls.Config, err err
11721172
if err != nil {
11731173
return "", nil, err
11741174
}
1175-
defer clientKeyFile.Close()
1175+
defer func() { _ = clientKeyFile.Close() }()
11761176
clientKeyBytes, err := x509.MarshalECPrivateKey(clientKey)
11771177
if err != nil {
11781178
return "", nil, err

cmd/amazon-cloudwatch-agent-target-allocator/target/discovery.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,6 @@ func getScrapeConfigHash(jobToScrapeConfig map[string]*config.ScrapeConfig) (has
140140
return nil, err
141141
}
142142
}
143-
yamlEncoder.Close()
143+
_ = yamlEncoder.Close()
144144
return hash, err
145145
}

0 commit comments

Comments
 (0)