chore: Update to go1.20.1 (#12679)

This commit is contained in:
Joshua Powers 2023-02-16 02:52:36 -07:00 committed by GitHub
parent 0244614b71
commit 9c79277405
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 33 additions and 15 deletions

View File

@ -8,7 +8,7 @@ executors:
working_directory: '/go/src/github.com/influxdata/telegraf' working_directory: '/go/src/github.com/influxdata/telegraf'
resource_class: large resource_class: large
docker: docker:
- image: 'quay.io/influxdb/telegraf-ci:1.20' - image: 'quay.io/influxdb/telegraf-ci:1.20.1'
environment: environment:
GOFLAGS: -p=4 GOFLAGS: -p=4
mac: mac:

View File

@ -241,8 +241,8 @@ plugins/parsers/influx/machine.go: plugins/parsers/influx/machine.go.rl
.PHONY: ci .PHONY: ci
ci: ci:
docker build -t quay.io/influxdb/telegraf-ci:1.20 - < scripts/ci.docker docker build -t quay.io/influxdb/telegraf-ci:1.20.1 - < scripts/ci.docker
docker push quay.io/influxdb/telegraf-ci:1.20 docker push quay.io/influxdb/telegraf-ci:1.20.1
.PHONY: install .PHONY: install
install: $(buildbin) install: $(buildbin)

2
go.mod
View File

@ -1,6 +1,6 @@
module github.com/influxdata/telegraf module github.com/influxdata/telegraf
go 1.19 go 1.20
require ( require (
cloud.google.com/go/bigquery v1.45.0 cloud.google.com/go/bigquery v1.45.0

View File

@ -708,7 +708,7 @@ func TestParseTimestampInvalid(t *testing.T) {
name: "layout not matching time", name: "layout not matching time",
format: "rfc3339", format: "rfc3339",
timestamp: "09.07.2019 00:11:00", timestamp: "09.07.2019 00:11:00",
expected: "cannot parse \"09.07.2019 00:11:00\" as \"2006\"", expected: "parsing time \"09.07.2019 00:11:00\" as \"2006-01-02T15:04:05Z07:00\": cannot parse",
}, },
{ {
name: "unix wrong type", name: "unix wrong type",

View File

@ -1,4 +1,4 @@
FROM golang:1.20 FROM golang:1.20.1
RUN chmod -R 755 "$GOPATH" RUN chmod -R 755 "$GOPATH"

View File

@ -2,10 +2,10 @@
set -eux set -eux
GO_VERSION="1.20" GO_VERSION="1.20.1"
GO_ARCH="linux-amd64" GO_ARCH="linux-amd64"
# from https://golang.org/dl # from https://golang.org/dl
GO_VERSION_SHA="5a9ebcc65c1cce56e0d2dc616aff4c4cedcfbda8cc6f0288cc08cda3b18dcbf1" GO_VERSION_SHA="000a5b1fca4f75895f78befeb2eecf10bfff3c428597f3f1e69133b63b911b02"
# Download Go and verify Go tarball # Download Go and verify Go tarball
setup_go () { setup_go () {

View File

@ -3,9 +3,9 @@
set -eux set -eux
ARCH=$(uname -m) ARCH=$(uname -m)
GO_VERSION="1.20" GO_VERSION="1.20.1"
GO_VERSION_SHA_arm64="32864d6fe888714ca7b421b5997269c7f6349d7e2675c3a399133e521787608b" # from https://golang.org/dl GO_VERSION_SHA_arm64="f1a8e06c7f1ba1c008313577f3f58132eb166a41ceb95ce6e9af30bc5a3efca4" # from https://golang.org/dl
GO_VERSION_SHA_amd64="777025500f62d14bb5a4923072cd97431887961d24de08433a60c2fe1120531d" # from https://golang.org/dl GO_VERSION_SHA_amd64="a300a45e801ab459f3008aae5bb9efbe9a6de9bcd12388f5ca9bbd14f70236de" # from https://golang.org/dl
if [ "$ARCH" = 'arm64' ]; then if [ "$ARCH" = 'arm64' ]; then
GO_ARCH="darwin-arm64" GO_ARCH="darwin-arm64"

View File

@ -2,7 +2,7 @@
set -eux set -eux
GO_VERSION="1.20" GO_VERSION="1.20.1"
setup_go () { setup_go () {
choco upgrade golang --allow-downgrade --version=${GO_VERSION} choco upgrade golang --allow-downgrade --version=${GO_VERSION}

View File

@ -9,6 +9,7 @@ import (
"regexp" "regexp"
"strings" "strings"
"github.com/coreos/go-semver/semver"
"golang.org/x/net/html" "golang.org/x/net/html"
) )
@ -43,6 +44,12 @@ func removeZeroPatch(version string) string {
return version return version
} }
// removePatch cleans version from "1.20.1" to "1.20" (think go.mod entry)
func removePatch(version string) string {
verInfo := semver.New(version)
return fmt.Sprintf("%d.%d", verInfo.Major, verInfo.Minor)
}
// findHash will search the downloads table for the hashes matching the artifacts list // findHash will search the downloads table for the hashes matching the artifacts list
func findHashes(body io.Reader, version string) (map[string]string, error) { func findHashes(body io.Reader, version string) (map[string]string, error) {
version = removeZeroPatch(version) version = removeZeroPatch(version)
@ -107,6 +114,10 @@ func findHashes(body io.Reader, version string) (map[string]string, error) {
// Reached end of table // Reached end of table
if tokenType == html.EndTagToken && htmlTokens.Token().Data == "table" { if tokenType == html.EndTagToken && htmlTokens.Token().Data == "table" {
if len(hashes) == 0 {
return nil, fmt.Errorf("could not find version %q on downloads page", version)
}
return nil, fmt.Errorf("only found %d hashes expected %d: %v", len(hashes), len(artifacts), hashes) return nil, fmt.Errorf("only found %d hashes expected %d: %v", len(hashes), len(artifacts), hashes)
} }
} }
@ -130,13 +141,15 @@ func main() {
if strings.HasPrefix(version, "v") { if strings.HasPrefix(version, "v") {
version = strings.TrimLeft(version, "v") version = strings.TrimLeft(version, "v")
} }
zeroPatchVersion := removeZeroPatch(version)
hashes, err := getHashes(version) hashes, err := getHashes(version)
if err != nil { if err != nil {
log.Panic(err) log.Fatal(err)
} }
zeroPatchVersion := removeZeroPatch(version)
noPatchVersion := removePatch(version)
files := []FileInfo{ files := []FileInfo{
{ {
FileName: ".circleci/config.yml", FileName: ".circleci/config.yml",
@ -146,7 +159,12 @@ func main() {
{ {
FileName: ".github/workflows/golangci-lint.yml", FileName: ".github/workflows/golangci-lint.yml",
Regex: `(go-version).*`, Regex: `(go-version).*`,
Replace: fmt.Sprintf("$1: '%s'", zeroPatchVersion), Replace: fmt.Sprintf("$1: '%s'", noPatchVersion),
},
{
FileName: "go.mod",
Regex: `(go)\s(\d.\d*)`,
Replace: fmt.Sprintf("$1 %s", noPatchVersion),
}, },
{ {
FileName: "Makefile", FileName: "Makefile",