From 7d181b7a752fd0689686a1a3db081108646715d8 Mon Sep 17 00:00:00 2001 From: Sven Rebhan <36194019+srebhan@users.noreply.github.com> Date: Tue, 25 Feb 2025 00:46:57 +0100 Subject: [PATCH] chore: Update go to v1.24.0 (#16549) --- .circleci/config.yml | 2 +- .github/workflows/readme-linter.yml | 2 +- .golangci.yml | 7 ++----- Makefile | 4 ++-- config/config_test.go | 18 ++++-------------- go.mod | 2 +- plugins/inputs/beanstalkd/beanstalkd.go | 2 +- scripts/ci.docker | 2 +- scripts/installgo_linux.sh | 4 ++-- scripts/installgo_mac.sh | 6 +++--- scripts/installgo_windows.sh | 2 +- 11 files changed, 19 insertions(+), 32 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index af5aac8cb..12c3b7c5c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,7 +8,7 @@ executors: working_directory: '/go/src/github.com/influxdata/telegraf' resource_class: large docker: - - image: 'quay.io/influxdb/telegraf-ci:1.23.5' + - image: 'quay.io/influxdb/telegraf-ci:1.24.0' environment: GOFLAGS: -p=4 mac: diff --git a/.github/workflows/readme-linter.yml b/.github/workflows/readme-linter.yml index 0f4bb2081..26f1b0ebc 100644 --- a/.github/workflows/readme-linter.yml +++ b/.github/workflows/readme-linter.yml @@ -11,7 +11,7 @@ jobs: steps: - uses: actions/setup-go@v5 with: - go-version: '1.23.5' + go-version: '1.24.0' - uses: actions/checkout@v4 with: fetch-depth: 0 diff --git a/.golangci.yml b/.golangci.yml index a4cbf4c25..5688790f7 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -352,13 +352,10 @@ linters-settings: - suite-thelper - useless-assert usetesting: - # Enable/disable `os.CreateTemp("", ...)` detections. - # Default: true os-create-temp: false - # Enable/disable `os.MkdirTemp()` detections. - # Default: true os-mkdir-temp: false - + context-background: false + context-todo: false issues: # List of regexps of issue texts to exclude. diff --git a/Makefile b/Makefile index 77dd7a69d..7da2c6653 100644 --- a/Makefile +++ b/Makefile @@ -257,8 +257,8 @@ plugins/parsers/influx/machine.go: plugins/parsers/influx/machine.go.rl .PHONY: ci ci: - docker build -t quay.io/influxdb/telegraf-ci:1.23.5 - < scripts/ci.docker - docker push quay.io/influxdb/telegraf-ci:1.23.5 + docker build -t quay.io/influxdb/telegraf-ci:1.24.0 - < scripts/ci.docker + docker push quay.io/influxdb/telegraf-ci:1.24.0 .PHONY: install install: $(buildbin) diff --git a/config/config_test.go b/config/config_test.go index 893c31220..1662f6635 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -42,28 +42,18 @@ import ( func TestReadBinaryFile(t *testing.T) { // Create a temporary binary file using the Telegraf tool custom_builder to pass as a config - wd, err := os.Getwd() - require.NoError(t, err) - t.Cleanup(func() { - err := os.Chdir(wd) - require.NoError(t, err) - }) - - err = os.Chdir("../") - require.NoError(t, err) + t.Chdir("..") tmpdir := t.TempDir() binaryFile := filepath.Join(tmpdir, "custom_builder") cmd := exec.Command("go", "build", "-o", binaryFile, "./tools/custom_builder") + var outb, errb bytes.Buffer cmd.Stdout = &outb cmd.Stderr = &errb - err = cmd.Run() + require.NoErrorf(t, cmd.Run(), "stdout: %s, stderr: %s", outb.String(), errb.String()) - require.NoErrorf(t, err, "stdout: %s, stderr: %s", outb.String(), errb.String()) c := config.NewConfig() - err = c.LoadConfig(binaryFile) - require.Error(t, err) - require.ErrorContains(t, err, "provided config is not a TOML file") + require.ErrorContains(t, c.LoadConfig(binaryFile), "provided config is not a TOML file") } func TestConfig_LoadSingleInputWithEnvVars(t *testing.T) { diff --git a/go.mod b/go.mod index 644a038e4..c24446806 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/influxdata/telegraf -go 1.23.0 +go 1.24.0 godebug x509negativeserial=1 diff --git a/plugins/inputs/beanstalkd/beanstalkd.go b/plugins/inputs/beanstalkd/beanstalkd.go index fb7f1e066..1623f0935 100644 --- a/plugins/inputs/beanstalkd/beanstalkd.go +++ b/plugins/inputs/beanstalkd/beanstalkd.go @@ -165,7 +165,7 @@ func (b *Beanstalkd) gatherTubeStats(connection *textproto.Conn, tube string, ac } func runQuery(connection *textproto.Conn, cmd string, result interface{}) error { - requestID, err := connection.Cmd(cmd) + requestID, err := connection.Cmd("%s", cmd) if err != nil { return err } diff --git a/scripts/ci.docker b/scripts/ci.docker index 0c9d29f90..462ebf499 100644 --- a/scripts/ci.docker +++ b/scripts/ci.docker @@ -1,4 +1,4 @@ -FROM golang:1.23.5 +FROM golang:1.24.0 RUN chmod -R 755 "$GOPATH" diff --git a/scripts/installgo_linux.sh b/scripts/installgo_linux.sh index 0d7bd5f4a..6ab89ac7c 100644 --- a/scripts/installgo_linux.sh +++ b/scripts/installgo_linux.sh @@ -2,10 +2,10 @@ set -eux -GO_VERSION="1.23.5" +GO_VERSION="1.24.0" GO_ARCH="linux-amd64" # from https://go.dev/dl -GO_VERSION_SHA="cbcad4a6482107c7c7926df1608106c189417163428200ce357695cc7e01d091" +GO_VERSION_SHA="dea9ca38a0b852a74e81c26134671af7c0fbe65d81b0dc1c5bfe22cf7d4c8858" # Download Go and verify Go tarball setup_go () { diff --git a/scripts/installgo_mac.sh b/scripts/installgo_mac.sh index bba5cfada..2a352d2f8 100644 --- a/scripts/installgo_mac.sh +++ b/scripts/installgo_mac.sh @@ -3,9 +3,9 @@ set -eux ARCH=$(uname -m) -GO_VERSION="1.23.5" -GO_VERSION_SHA_arm64="047bfce4fbd0da6426bd30cd19716b35a466b1c15a45525ce65b9824acb33285" # from https://go.dev/dl -GO_VERSION_SHA_amd64="d8b310b0b6bd6a630307579165cfac8a37571483c7d6804a10dd73bbefb0827f" # from https://go.dev/dl +GO_VERSION="1.24.0" +GO_VERSION_SHA_arm64="fd9cfb5dd6c75a347cfc641a253f0db1cebaca16b0dd37965351c6184ba595e4" # from https://go.dev/dl +GO_VERSION_SHA_amd64="7af054e5088b68c24b3d6e135e5ca8d91bbd5a05cb7f7f0187367b3e6e9e05ee" # from https://go.dev/dl if [ "$ARCH" = 'arm64' ]; then GO_ARCH="darwin-arm64" diff --git a/scripts/installgo_windows.sh b/scripts/installgo_windows.sh index c5d4cfda1..9b9203a85 100644 --- a/scripts/installgo_windows.sh +++ b/scripts/installgo_windows.sh @@ -2,7 +2,7 @@ set -eux -GO_VERSION="1.23.5" +GO_VERSION="1.24.0" setup_go () { choco upgrade golang --allow-downgrade --version=${GO_VERSION}