From 0a17467625aed7641bd57af83c5f9ae1ccad1b3c Mon Sep 17 00:00:00 2001 From: Florian Stadler Date: Tue, 1 Oct 2024 13:12:08 +0200 Subject: [PATCH] Upgrade to Go 1.23 and golang.org/x to 0.21.0 (#278) This is necessary for upgrade-provider to detect new godebug directives like `tlskyber`. That godebug directive is used in pulumi-aws to work around an issue with AWS firewalls. Right now upgrade-provider fails when parsing the `go.mod` file because it doesn't know about the `tlskyber` directive. I verified this correctly works by executing an upstream check on the aws repo: ``` GH_TOKEN="$(gh auth token)" ./../upgrade-provider/bin/upgrade-provider "pulumi/pulumi-aws" --repo-path . --upstream-provider-name terraform-provider-aws --kind=check-upstream-version ``` Relates to https://github.com/pulumi/pulumi-aws/issues/4586 --- .github/workflows/ci.yml | 4 ++-- .github/workflows/release.yml | 4 ++-- README.md | 2 +- go.mod | 11 ++++++----- go.sum | 15 ++++++++++----- upgrade/http.go | 4 +++- upgrade/kind.go | 2 +- upgrade/migrations.go | 14 +++++++------- upgrade/upgrade_provider.go | 2 +- 9 files changed, 33 insertions(+), 25 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 047542b..565b89c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,6 @@ env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GOLANGCI_LINT_VERSION: v1.55.2 + GOLANGCI_LINT_VERSION: v1.61.0 name: Pull Request on: [pull_request] jobs: @@ -8,7 +8,7 @@ jobs: name: Build and Test strategy: matrix: - go-version: [1.21.x] + go-version: [1.23.x] runs-on: ubuntu-latest steps: - name: Install Go diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 94864b5..2049ecb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,10 +11,10 @@ jobs: uses: actions/checkout@v2 - name: Unshallow clone run: git fetch --prune --unshallow --tags - - name: Install Go 1.21 + - name: Install Go 1.23 uses: actions/setup-go@v2 with: - go-version: '1.21.x' + go-version: '1.23.x' - name: Goreleaser publish uses: goreleaser/goreleaser-action@v2 with: diff --git a/README.md b/README.md index be62fb1..b7f1db5 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ go install github.com/pulumi/upgrade-provider@main ## Requirements -- Go version `1.20` +- Go version `1.23` - `git` version `>=2.36.0` - [GitHub CLI](https://cli.github.com/) diff --git a/go.mod b/go.mod index d80cb45..23285b7 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/pulumi/upgrade-provider -go 1.21 +go 1.23 require ( github.com/Masterminds/semver/v3 v3.2.0 @@ -11,18 +11,19 @@ require ( github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.15.0 github.com/stretchr/testify v1.8.3 - golang.org/x/mod v0.12.0 - golang.org/x/tools v0.12.0 + golang.org/x/mod v0.21.0 + golang.org/x/tools v0.21.0 gopkg.in/yaml.v3 v3.0.1 ) require ( - github.com/google/go-cmp v0.5.9 // indirect + github.com/google/go-cmp v0.6.0 // indirect github.com/hexops/autogold v1.3.1 // indirect github.com/hexops/gotextdiff v1.0.3 // indirect github.com/hexops/valast v1.4.4 // indirect github.com/nightlyone/lockfile v1.0.0 // indirect github.com/rogpeppe/go-internal v1.11.0 // indirect + golang.org/x/sync v0.7.0 // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/ini.v1 v1.67.0 // indirect mvdan.cc/gofumpt v0.5.0 // indirect @@ -46,7 +47,7 @@ require ( github.com/spf13/cast v1.5.0 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/subosito/gotenv v1.4.2 // indirect - golang.org/x/sys v0.11.0 // indirect + golang.org/x/sys v0.20.0 // indirect golang.org/x/term v0.11.0 // indirect golang.org/x/text v0.12.0 // indirect ) diff --git a/go.sum b/go.sum index 9bd02c5..da743b4 100644 --- a/go.sum +++ b/go.sum @@ -113,8 +113,9 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= @@ -281,8 +282,9 @@ golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91 golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0= +golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -343,8 +345,9 @@ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -393,8 +396,9 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= +golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -471,8 +475,9 @@ golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc golang.org/x/tools v0.4.0/go.mod h1:UE5sM2OK9E/d67R0ANs2xJizIymRP5gJU295PvKXxjQ= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.8.0/go.mod h1:JxBZ99ISMI5ViVkT1tr6tdNmXeTrcpVSD3vZ1RsRdN4= -golang.org/x/tools v0.12.0 h1:YW6HUoUmYBpwSgyaGaZq1fHjrBjX1rlpZ54T6mu2kss= golang.org/x/tools v0.12.0/go.mod h1:Sc0INKfu04TlqNoRA1hgpFZbhYXHPr4V5DzpSBTPqQM= +golang.org/x/tools v0.21.0 h1:qc0xYgIbsSDt9EyWz05J5wfa7LOVW0YTLOXrqdLAWIw= +golang.org/x/tools v0.21.0/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/upgrade/http.go b/upgrade/http.go index 44017b8..6b042c3 100644 --- a/upgrade/http.go +++ b/upgrade/http.go @@ -29,7 +29,9 @@ type httpHandler interface { getHTTP(url string) ([]byte, error) } -var httpHandlerKey = struct{}{} +type httpContextKey struct{} + +var httpHandlerKey httpContextKey = httpContextKey{} type defaultHttpHandler struct { retryAttempts int diff --git a/upgrade/kind.go b/upgrade/kind.go index 9a3e4f7..29104e3 100644 --- a/upgrade/kind.go +++ b/upgrade/kind.go @@ -98,7 +98,7 @@ var getRepoKind = stepv2.Func11E("Get Repo Kind", func(ctx context.Context, repo if err != nil { return nil, fmt.Errorf("%s: %w", bridgeMissingMsg, err) } else if !ok { - return nil, fmt.Errorf(bridgeMissingMsg) + return nil, fmt.Errorf("%s", bridgeMissingMsg) } pf, ok, err := originalGoVersionOf(ctx, repo, filepath.Join("provider", "go.mod"), "github.com/pulumi/pulumi-terraform-bridge/pf") diff --git a/upgrade/migrations.go b/upgrade/migrations.go index c119f5c..b275b1e 100644 --- a/upgrade/migrations.go +++ b/upgrade/migrations.go @@ -24,7 +24,7 @@ const ( func AutoAliasingMigration(resourcesFilePath, providerName string) (bool, error) { // Create the AST by parsing src fset := token.NewFileSet() - file, err := parser.ParseFile(fset, resourcesFilePath, nil, parser.ParseComments) + file, err := parser.ParseFile(fset, resourcesFilePath, nil, parser.ParseComments|parser.SkipObjectResolution) if err != nil { return false, err } @@ -96,7 +96,7 @@ func AutoAliasingMigration(resourcesFilePath, providerName string) (bool, error) } c.InsertBefore(&ast.AssignStmt{ Tok: tok, - Lhs: []ast.Expr{&ast.Ident{Name: "err", Obj: &ast.Object{Kind: ast.Var, Name: "err"}}}, + Lhs: []ast.Expr{&ast.Ident{Name: "err"}}, Rhs: []ast.Expr{&ast.CallExpr{ Fun: &ast.SelectorExpr{ X: &ast.Ident{Name: "x"}, @@ -105,11 +105,11 @@ func AutoAliasingMigration(resourcesFilePath, providerName string) (bool, error) Args: []ast.Expr{ &ast.UnaryExpr{ Op: token.AND, - X: &ast.Ident{Name: "prov", Obj: &ast.Object{Kind: ast.Var, Name: "prov"}}, + X: &ast.Ident{Name: "prov"}, }, &ast.CallExpr{ Fun: &ast.SelectorExpr{ - X: &ast.Ident{Name: "prov", Obj: &ast.Object{Kind: ast.Var, Name: "prov"}}, + X: &ast.Ident{Name: "prov"}, Sel: &ast.Ident{Name: "GetMetadata"}, }, }, @@ -123,7 +123,7 @@ func AutoAliasingMigration(resourcesFilePath, providerName string) (bool, error) Sel: &ast.Ident{Name: "AssertNoErrorf"}, }, Args: []ast.Expr{ - &ast.Ident{Name: "err", Obj: &ast.Object{Kind: ast.Var, Name: "err"}}, + &ast.Ident{Name: "err"}, &ast.BasicLit{Kind: token.STRING, Value: "\"auto aliasing apply failed\""}, }, }}) @@ -140,7 +140,7 @@ func AutoAliasingMigration(resourcesFilePath, providerName string) (bool, error) Tok: token.VAR, Specs: []ast.Spec{ &ast.ValueSpec{ - Names: []*ast.Ident{{Name: "metadata", Obj: &ast.Object{Kind: ast.Var, Name: "metadata"}}}, + Names: []*ast.Ident{{Name: "metadata"}}, Type: &ast.ArrayType{Elt: &ast.Ident{Name: "byte // EMBED_DIRECTIVE_ANCHOR"}}, }, }, @@ -179,7 +179,7 @@ func AssertNoErrorMigration(resourcesFilePath, providerName string) (bool, error Sel: &ast.Ident{Name: "AssertNoErrorf"}, }, Args: []ast.Expr{ - &ast.Ident{Name: "err", Obj: &ast.Object{Kind: ast.Var, Name: "err"}}, + &ast.Ident{Name: "err"}, &ast.BasicLit{Kind: token.STRING, Value: "\"failed to apply auto token mapping\""}, }, }) diff --git a/upgrade/upgrade_provider.go b/upgrade/upgrade_provider.go index dcc9710..10c9b43 100644 --- a/upgrade/upgrade_provider.go +++ b/upgrade/upgrade_provider.go @@ -202,7 +202,7 @@ func UpgradeProvider(ctx context.Context, repoOrg, repoName string) (err error) return err } defer func() { - fmt.Printf("\n\n" + colorize.Warn("Major Version Updates are not fully automated!") + "\n") + fmt.Printf("\n\n%s\n", colorize.Warn("Major Version Updates are not fully automated!")) fmt.Printf("%s need to complete Step 11: Updating README.md and sdk/python/README.md "+ "in a follow up commit.\n", colorize.Bold("You")) fmt.Printf("Steps are listed at\n\t" +