Skip to content

Commit efaafae

Browse files
Update dependency golangci/golangci-lint to v2.3.0 (#3649)
* Update dependency golangci/golangci-lint to v2.3.0 | datasource | package | from | to | | ----------- | ---------------------- | ------ | ------ | | github-tags | golangci/golangci-lint | v2.2.2 | v2.3.0 | Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Fix noctx lint errors --------- Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Ciara Stacke <[email protected]>
1 parent 1c55846 commit efaafae

File tree

9 files changed

+45
-23
lines changed

9 files changed

+45
-23
lines changed

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
4141
with:
4242
working-directory: ${{ matrix.directory }}
43-
version: v2.2.2 # renovate: datasource=github-tags depName=golangci/golangci-lint
43+
version: v2.3.0 # renovate: datasource=github-tags depName=golangci/golangci-lint
4444

4545
njs-lint:
4646
name: NJS Lint

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ repos:
3939
- javascript
4040

4141
- repo: https://github.com/golangci/golangci-lint
42-
rev: v2.2.2
42+
rev: v2.3.0
4343
hooks:
4444
- id: golangci-lint-full
4545
name: golangci-lint-root

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ GO_LINKER_FLAGS = $(GO_LINKER_FLAGS_OPTIMIZATIONS) $(GO_LINKER_FlAGS_VARS)
2323

2424
# tools versions
2525
# renovate: datasource=github-tags depName=golangci/golangci-lint
26-
GOLANGCI_LINT_VERSION = v2.2.2
26+
GOLANGCI_LINT_VERSION = v2.3.0
2727
# renovate: datasource=docker depName=kindest/node
2828
KIND_K8S_VERSION = v1.33.2
2929
# renovate: datasource=github-tags depName=norwoodj/helm-docs

internal/controller/nginx/agent/grpc/grpc.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ func NewServer(
7575

7676
// Start is a runnable that starts the gRPC server for communicating with the nginx agent.
7777
func (g *Server) Start(ctx context.Context) error {
78-
listener, err := net.Listen("tcp", fmt.Sprintf(":%d", g.port))
78+
var lc net.ListenConfig
79+
listener, err := lc.Listen(ctx, "tcp", fmt.Sprintf(":%d", g.port))
7980
if err != nil {
8081
return err
8182
}

tests/framework/collector.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package framework
22

33
import (
4+
"context"
45
"fmt"
56
"os/exec"
67

@@ -17,18 +18,20 @@ const (
1718

1819
// InstallCollector installs the otel-collector.
1920
func InstallCollector() ([]byte, error) {
21+
ctx := context.Background()
2022
repoAddArgs := []string{
2123
"repo",
2224
"add",
2325
"open-telemetry",
2426
"https://open-telemetry.github.io/opentelemetry-helm-charts",
2527
}
2628

27-
if output, err := exec.Command("helm", repoAddArgs...).CombinedOutput(); err != nil {
29+
if output, err := exec.CommandContext(ctx, "helm", repoAddArgs...).CombinedOutput(); err != nil {
2830
return output, err
2931
}
3032

31-
if output, err := exec.Command(
33+
if output, err := exec.CommandContext(
34+
ctx,
3235
"helm",
3336
"repo",
3437
"update",
@@ -47,7 +50,7 @@ func InstallCollector() ([]byte, error) {
4750
"--wait",
4851
}
4952

50-
return exec.Command("helm", args...).CombinedOutput()
53+
return exec.CommandContext(ctx, "helm", args...).CombinedOutput()
5154
}
5255

5356
// UninstallCollector uninstalls the otel-collector.
@@ -57,7 +60,7 @@ func UninstallCollector(resourceManager ResourceManager) ([]byte, error) {
5760
"--namespace", CollectorNamespace,
5861
}
5962

60-
output, err := exec.Command("helm", args...).CombinedOutput()
63+
output, err := exec.CommandContext(context.Background(), "helm", args...).CombinedOutput()
6164
if err != nil {
6265
return output, err
6366
}

tests/framework/ngf.go

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,12 @@ type InstallationConfig struct {
4242
func InstallGatewayAPI(apiVersion string) ([]byte, error) {
4343
apiPath := fmt.Sprintf("%s/v%s/standard-install.yaml", gwInstallBasePath, apiVersion)
4444

45-
if output, err := exec.Command("kubectl", "apply", "-f", apiPath).CombinedOutput(); err != nil {
45+
cmd := exec.CommandContext(
46+
context.Background(),
47+
"kubectl", "apply", "-f", apiPath,
48+
)
49+
output, err := cmd.CombinedOutput()
50+
if err != nil {
4651
return output, err
4752
}
4853

@@ -53,7 +58,7 @@ func InstallGatewayAPI(apiVersion string) ([]byte, error) {
5358
func UninstallGatewayAPI(apiVersion string) ([]byte, error) {
5459
apiPath := fmt.Sprintf("%s/v%s/standard-install.yaml", gwInstallBasePath, apiVersion)
5560

56-
output, err := exec.Command("kubectl", "delete", "-f", apiPath).CombinedOutput()
61+
output, err := exec.CommandContext(context.Background(), "kubectl", "delete", "-f", apiPath).CombinedOutput()
5762
if err != nil && !strings.Contains(string(output), "not found") {
5863
return output, err
5964
}
@@ -84,7 +89,7 @@ func InstallNGF(cfg InstallationConfig, extraArgs ...string) ([]byte, error) {
8489

8590
GinkgoWriter.Printf("Installing NGF with command: helm %v\n", strings.Join(fullArgs, " "))
8691

87-
return exec.Command("helm", fullArgs...).CombinedOutput()
92+
return exec.CommandContext(context.Background(), "helm", fullArgs...).CombinedOutput()
8893
}
8994

9095
// CreateLicenseSecret creates the NGINX Plus JWT secret.
@@ -127,7 +132,12 @@ func CreateLicenseSecret(k8sClient client.Client, namespace, filename string) er
127132
// UpgradeNGF upgrades NGF. CRD upgrades assume the chart is local.
128133
func UpgradeNGF(cfg InstallationConfig, extraArgs ...string) ([]byte, error) {
129134
crdPath := filepath.Join(cfg.ChartPath, "crds") + "/"
130-
if output, err := exec.Command("kubectl", "apply", "-f", crdPath).CombinedOutput(); err != nil {
135+
cmd := exec.CommandContext(
136+
context.Background(),
137+
"kubectl", "apply", "-f", crdPath,
138+
)
139+
output, err := cmd.CombinedOutput()
140+
if err != nil {
131141
return output, err
132142
}
133143

@@ -152,7 +162,7 @@ func UpgradeNGF(cfg InstallationConfig, extraArgs ...string) ([]byte, error) {
152162

153163
GinkgoWriter.Printf("Upgrading NGF with command: helm %v\n", strings.Join(fullArgs, " "))
154164

155-
return exec.Command("helm", fullArgs...).CombinedOutput()
165+
return exec.CommandContext(context.Background(), "helm", fullArgs...).CombinedOutput()
156166
}
157167

158168
// UninstallNGF uninstalls NGF.
@@ -161,7 +171,7 @@ func UninstallNGF(cfg InstallationConfig, k8sClient client.Client) ([]byte, erro
161171
"uninstall", cfg.ReleaseName, "--namespace", cfg.Namespace,
162172
}
163173

164-
output, err := exec.Command("helm", args...).CombinedOutput()
174+
output, err := exec.CommandContext(context.Background(), "helm", args...).CombinedOutput()
165175
if err != nil && !strings.Contains(string(output), "release: not found") {
166176
return output, err
167177
}

tests/framework/portforward.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package framework
22

33
import (
44
"bytes"
5+
"context"
56
"fmt"
67
"log/slog"
78
"net/http"
@@ -49,9 +50,10 @@ func PortForward(config *rest.Config, namespace, podName string, ports []string,
4950

5051
go func() {
5152
for {
53+
ctx := context.Background()
5254
if err := forward(); err != nil {
53-
slog.Error("error forwarding ports", "error", err)
54-
slog.Info("retrying port forward in 1s...")
55+
slog.ErrorContext(ctx, "error forwarding ports", "error", err)
56+
slog.InfoContext(ctx, "retrying port forward in 1s...")
5557
}
5658

5759
select {

tests/framework/prometheus.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ func InstallPrometheus(
3939
rm ResourceManager,
4040
cfg PrometheusConfig,
4141
) (PrometheusInstance, error) {
42-
output, err := exec.Command(
42+
ctx := context.Background()
43+
output, err := exec.CommandContext(
44+
ctx,
4345
"helm",
4446
"repo",
4547
"add",
@@ -50,7 +52,8 @@ func InstallPrometheus(
5052
return PrometheusInstance{}, fmt.Errorf("failed to add Prometheus helm repo: %w; output: %s", err, string(output))
5153
}
5254

53-
output, err = exec.Command(
55+
output, err = exec.CommandContext(
56+
ctx,
5457
"helm",
5558
"repo",
5659
"update",
@@ -62,7 +65,8 @@ func InstallPrometheus(
6265
scrapeInterval := fmt.Sprintf("%ds", int(cfg.ScrapeInterval.Seconds()))
6366

6467
//nolint:gosec
65-
output, err = exec.Command(
68+
output, err = exec.CommandContext(
69+
ctx,
6670
"helm",
6771
"install",
6872
prometheusReleaseName,
@@ -110,7 +114,8 @@ func InstallPrometheus(
110114

111115
// UninstallPrometheus uninstalls Prometheus from the cluster.
112116
func UninstallPrometheus(rm ResourceManager) error {
113-
output, err := exec.Command(
117+
output, err := exec.CommandContext(
118+
context.Background(),
114119
"helm",
115120
"uninstall",
116121
prometheusReleaseName,
@@ -208,7 +213,7 @@ func (ins *PrometheusInstance) QueryWithCtx(ctx context.Context, query string) (
208213
}
209214

210215
if len(warnings) > 0 {
211-
slog.Info(
216+
slog.InfoContext(context.Background(),
212217
"Prometheus query returned warnings",
213218
"query", query,
214219
"warnings", warnings,
@@ -240,7 +245,7 @@ func (ins *PrometheusInstance) QueryRangeWithCtx(ctx context.Context,
240245
}
241246

242247
if len(warnings) > 0 {
243-
slog.Info(
248+
slog.InfoContext(context.Background(),
244249
"Prometheus range query returned warnings",
245250
"query", query,
246251
"range", promRange,

tests/framework/results.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package framework
22

33
import (
4+
"context"
45
"encoding/csv"
56
"fmt"
67
"io"
@@ -77,7 +78,7 @@ func generatePNG(resultsDir, inputFilename, outputFilename, configFilename strin
7778
gnuplotCfg := filepath.Join(filepath.Dir(pwd), "scripts", configFilename)
7879

7980
files := fmt.Sprintf("inputfile='%s';outputfile='%s'", inputFilename, outputFilename)
80-
cmd := exec.Command("gnuplot", "-e", files, "-c", gnuplotCfg)
81+
cmd := exec.CommandContext(context.Background(), "gnuplot", "-e", files, "-c", gnuplotCfg)
8182
cmd.Dir = resultsDir
8283

8384
output, err := cmd.CombinedOutput()

0 commit comments

Comments
 (0)