Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.17](backport #36000) upgrade Go to 1.20.6 #36869

Merged
merged 6 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .go-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.19.12
1.20.6
8 changes: 4 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ linters-settings:

gosimple:
# Select the Go version to target. The default is '1.13'.
go: "1.19.12"
go: "1.20.6"

nakedret:
# make an issue if func has more lines of code than this setting and it has naked returns; default is 30
Expand All @@ -120,19 +120,19 @@ linters-settings:

staticcheck:
# Select the Go version to target. The default is '1.13'.
go: "1.19.12"
go: "1.20.6"
checks: ["all"]

stylecheck:
# Select the Go version to target. The default is '1.13'.
go: "1.19.12"
go: "1.20.6"
# Disabled:
# ST1005: error strings should not be capitalized
checks: ["all", "-ST1005"]

unused:
# Select the Go version to target. The default is '1.13'.
go: "1.19.12"
go: "1.20.6"

gosec:
excludes:
Expand Down
4 changes: 2 additions & 2 deletions auditbeat/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.19.12
FROM golang:1.20.6

RUN \
apt-get update \
Expand All @@ -11,7 +11,7 @@ RUN \
&& rm -rf /var/lib/apt/lists/*

# Use a virtualenv to avoid the PEP668 "externally managed environment" error caused by conflicts
# with the system Python installation. golang:1.19.10 uses Debian 12 which now enforces PEP668.
# with the system Python installation. golang:1.20.6 uses Debian 12 which now enforces PEP668.
ENV VIRTUAL_ENV=/opt/venv
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
Expand Down
21 changes: 21 additions & 0 deletions dev-tools/kubernetes/filebeat/Dockerfile.debug
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM golang:1.20.6 as builder

ENV PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/go/bin:/usr/local/go/bin

ENV CGO_ENABLED=0

RUN go install github.com/go-delve/delve/cmd/[email protected]

COPY build/filebeat-debugger /usr/share/filebeat/filebeat-debugger

FROM alpine:3.15

ENV PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/go/bin

WORKDIR /usr/share/filebeat

COPY --from=builder /go/bin/dlv /go/bin/dlv
COPY --from=builder /usr/share/filebeat/filebeat-debugger /usr/share/filebeat/filebeat-debugger

ENTRYPOINT ["dlv", "--headless", "--listen=:56268", "--api-version=2", "--log", "--log-output", "debugger", "exec", "/usr/share/filebeat/filebeat-debugger", "--"]
CMD [ "-e" ]
21 changes: 21 additions & 0 deletions dev-tools/kubernetes/heartbeat/Dockerfile.debug
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM golang:1.20.6 as builder

ENV PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/go/bin:/usr/local/go/bin

ENV CGO_ENABLED=0

RUN go install github.com/go-delve/delve/cmd/[email protected]

COPY build/heartbeat-debugger /usr/share/heartbeat/heartbeat-debugger

FROM alpine:3.16

ENV PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/go/bin

WORKDIR /usr/share/heartbeat

COPY --from=builder /go/bin/dlv /go/bin/dlv
COPY --from=builder /usr/share/heartbeat/heartbeat-debugger /usr/share/heartbeat/heartbeat-debugger

ENTRYPOINT ["dlv", "--headless", "--listen=:56268", "--api-version=2", "--log", "--log-output", "debugger", "exec", "/usr/share/heartbeat/heartbeat-debugger", "--"]
CMD [ "-e" ]
21 changes: 21 additions & 0 deletions dev-tools/kubernetes/metricbeat/Dockerfile.debug
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM golang:1.20.6 as builder

ENV PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/go/bin:/usr/local/go/bin

ENV CGO_ENABLED=0

RUN go install github.com/go-delve/delve/cmd/[email protected]

COPY build/metricbeat-debugger /usr/share/metricbeat/metricbeat-debugger

FROM alpine:3.15

ENV PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/go/bin

WORKDIR /usr/share/metricbeat

COPY --from=builder /go/bin/dlv /go/bin/dlv
COPY --from=builder /usr/share/metricbeat/metricbeat-debugger /usr/share/metricbeat/metricbeat-debugger

ENTRYPOINT ["dlv", "--headless", "--listen=:56268", "--api-version=2", "--log", "--log-output", "debugger", "exec", "/usr/share/metricbeat/metricbeat-debugger", "--"]
CMD [ "-e" ]
9 changes: 6 additions & 3 deletions dev-tools/mage/gotest.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

"github.com/magefile/mage/mg"
"github.com/magefile/mage/sh"
"github.com/pkg/errors"

Check failure on line 35 in dev-tools/mage/gotest.go

View workflow job for this annotation

GitHub Actions / lint (windows)

import of package `github.com/pkg/errors` is blocked because the module is in the blocked modules list. `errors` and `fmt` are recommended modules. This package is deprecated, use `fmt.Errorf` with `%!w(MISSING)` instead. (gomodguard)

"github.com/elastic/beats/v7/dev-tools/mage/gotool"
)
Expand Down Expand Up @@ -126,7 +126,7 @@
}

// GoTestIntegrationForModule executes the Go integration tests sequentially.
// Currently all test cases must be present under "./module" directory.
// Currently, all test cases must be present under "./module" directory.
//
// Motivation: previous implementation executed all integration tests at once,
// causing high CPU load, high memory usage and resulted in timeouts.
Expand Down Expand Up @@ -183,7 +183,7 @@

// InstallGoTestTools installs additional tools that are required to run unit and integration tests.
func InstallGoTestTools() {
gotool.Install(

Check failure on line 186 in dev-tools/mage/gotest.go

View workflow job for this annotation

GitHub Actions / lint (windows)

Error return value is not checked (errcheck)
gotool.Install.Package("gotest.tools/gotestsum"),
)
}
Expand Down Expand Up @@ -278,7 +278,7 @@
var goTestErr *exec.ExitError
if err != nil {
// Command ran.
exitErr, ok := err.(*exec.ExitError)

Check failure on line 281 in dev-tools/mage/gotest.go

View workflow job for this annotation

GitHub Actions / lint (windows)

type assertion on error will fail on wrapped errors. Use errors.As to check for specific errors (errorlint)
if !ok {
return errors.Wrap(err, "failed to execute go")
}
Expand All @@ -295,13 +295,16 @@
// Generate a HTML code coverage report.
var htmlCoverReport string
if params.CoverageProfileFile != "" {

htmlCoverReport = strings.TrimSuffix(params.CoverageProfileFile,
filepath.Ext(params.CoverageProfileFile)) + ".html"

coverToHTML := sh.RunCmd("go", "tool", "cover",
"-html="+params.CoverageProfileFile,
"-o", htmlCoverReport)
if err = coverToHTML(); err != nil {
return errors.Wrap(err, "failed to write HTML code coverage report")

if err := coverToHTML(); err != nil {
return fmt.Errorf("failed to write HTML code coverage report: %w", err)
}
}

Expand Down
20 changes: 10 additions & 10 deletions dev-tools/mage/gotest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,41 +210,41 @@ var wantTestAssertOutput = `(?sm:
Error Trace: gotest_test.go:\d+.*
Error: Should be true.*
Test: TestGoTest_Helper_AssertOutput/assert_fails.*
--- FAIL: TestGoTest_Helper_AssertOutput/assert_fails .*

=== FAIL: dev-tools/mage TestGoTest_Helper_AssertOutput/assert_with_message .*
gotest_test.go:\d+:.*
Error Trace: gotest_test.go:\d+.*
Error: Should be true.*
Test: TestGoTest_Helper_AssertOutput/assert_with_message.*
Messages: My message.*
--- FAIL: TestGoTest_Helper_AssertOutput/assert_with_message .*

=== FAIL: dev-tools/mage TestGoTest_Helper_AssertOutput/assert_with_messagef .*
gotest_test.go:\d+:.*
Error Trace: gotest_test.go:\d+.*
Error: Should be true.*
Test: TestGoTest_Helper_AssertOutput/assert_with_messagef.*
Messages: My message with arguments: 42.*
--- FAIL: TestGoTest_Helper_AssertOutput/assert_with_messagef .*

=== FAIL: dev-tools/mage TestGoTest_Helper_AssertOutput/require_fails .*
gotest_test.go:\d+:.*
Error Trace: gotest_test.go:\d+.*
Error: Should be true.*
Test: TestGoTest_Helper_AssertOutput/require_fails.*
--- FAIL: TestGoTest_Helper_AssertOutput/require_fails .*

=== FAIL: dev-tools/mage TestGoTest_Helper_AssertOutput/require_with_message .*
gotest_test.go:\d+:.*
Error Trace: gotest_test.go:\d+.*
Error: Should be true.*
Test: TestGoTest_Helper_AssertOutput/require_with_message.*
Messages: My message.*
--- FAIL: TestGoTest_Helper_AssertOutput/require_with_message .*

=== FAIL: dev-tools/mage TestGoTest_Helper_AssertOutput/require_with_messagef .*
gotest_test.go:\d+:.*
Error Trace: gotest_test.go:\d+.*
Error: Should be true.*
Test: TestGoTest_Helper_AssertOutput/require_with_messagef.*
Messages: My message with arguments: 42.*
--- FAIL: TestGoTest_Helper_AssertOutput/require_with_messagef .*

=== FAIL: dev-tools/mage TestGoTest_Helper_AssertOutput/equals_map .*
gotest_test.go:\d+:.*
Error Trace: gotest_test.go:\d+.*
Expand Down Expand Up @@ -306,17 +306,17 @@ var wantTestLogOutput = `(?sm:
gotest_test.go:\d+: printf style log message: 42.*
gotest_test.go:\d+: Log should fail.*
gotest_test.go:\d+: Log should fail with printf style log: 23.*
--- FAIL: TestGoTest_Helper_LogOutput/on_error.*

=== FAIL: dev-tools/mage TestGoTest_Helper_LogOutput/on_fatal.*
gotest_test.go:\d+: Log message should be printed.*
gotest_test.go:\d+: printf style log message: 42.*
gotest_test.go:\d+: Log should fail.*
--- FAIL: TestGoTest_Helper_LogOutput/on_fatal.*

=== FAIL: dev-tools/mage TestGoTest_Helper_LogOutput/on_fatalf.*
gotest_test.go:\d+: Log message should be printed.*
gotest_test.go:\d+: printf style log message: 42.*
gotest_test.go:\d+: Log should fail with printf style log: 42.*
--- FAIL: TestGoTest_Helper_LogOutput/on_fatalf.*

=== FAIL: dev-tools/mage TestGoTest_Helper_LogOutput/with_newlines.*
gotest_test.go:\d+: Log.*
message.*
Expand All @@ -336,7 +336,7 @@ var wantTestLogOutput = `(?sm:
style.*
log:.*
42.*
--- FAIL: TestGoTest_Helper_LogOutput/with_newlines.*

=== FAIL: dev-tools/mage TestGoTest_Helper_LogOutput.*
DONE 5 tests, 5 failures in.*
)`
Expand Down
8 changes: 4 additions & 4 deletions filebeat/input/syslog/format_check.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading