Skip to content

Commit

Permalink
Upgrade to Go 1.23 and golang.org/x to 0.21.0 (#278)
Browse files Browse the repository at this point in the history
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 pulumi/pulumi-aws#4586
  • Loading branch information
flostadler authored Oct 1, 2024
1 parent f87b5b3 commit 0a17467
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 25 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
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:
build:
name: Build and Test
strategy:
matrix:
go-version: [1.21.x]
go-version: [1.23.x]
runs-on: ubuntu-latest
steps:
- name: Install Go
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/)

Expand Down
11 changes: 6 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
)
15 changes: 10 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down
4 changes: 3 additions & 1 deletion upgrade/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion upgrade/kind.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
14 changes: 7 additions & 7 deletions upgrade/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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"},
Expand All @@ -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"},
},
},
Expand All @@ -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\""},
},
}})
Expand All @@ -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"}},
},
},
Expand Down Expand Up @@ -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\""},
},
})
Expand Down
2 changes: 1 addition & 1 deletion upgrade/upgrade_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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" +
Expand Down

0 comments on commit 0a17467

Please sign in to comment.