I'm trying `upgrade-provider` and I'm getting this...
# package-authoring
b
I'm trying
upgrade-provider
and I'm getting this error
Copy code
$ ~/go/bin/upgrade-provider emailbob/pulumi-twingate --upstream-provider-name terraform-provider-twingate --upstream-provider-org Twingate
--- Set Up Environment ---
  - GOWORK=off
  - PULUMI_MISSING_DOCS_ERROR=true
  - PULUMI_EXTRA_MAPPING_ERROR=true
--- done ---
--- Discover Provider ---
...

- Upgrade Pulumi version in all places
  - ✓ Get Pulumi SDK version: v3.108.1
  - X /opt/homebrew/bin/go get <http://github.com/pulumi/pulumi/sdk/v3@v3.108.1|github.com/pulumi/pulumi/sdk/v3@v3.108.1>: exit status 1:
go: go.mod file not found in current directory or any parent directory.
	'go get' is no longer supported outside a module.
	To build and install a command, use 'go install' with a version,
	like 'go install <http://example.com/cmd@latest|example.com/cmd@latest>'
	For more information, see <https://golang.org/doc/go-get-install-deprecation>
	or run 'go help get' or 'go help install'.
This happens when I run it from the root and provider directory. The is currently in a test repo.
e
Does your provider build normally (outside of upgrade-provider)?
Looks like
upgrade-provider
might be assuming that GO modules are used (
go.mod
present)
b
Yes outside of
upgrade-prover
make tfgen , provider, and build_sdks all work
e
Do you have a go.mod ?
b
e
I seem to be hitting something else
Copy code
[1] t0yv0@Antons-MacBook-Pro> upgrade-provider emailbob/pulumi-twingate --upstream-provider-name terraform-provider-twingate --upstream-provider-org Twingate                                                                                                                                                                                                                                                       ~/code/pulumi-twingate
--- Set Up Environment --- 
  - GOWORK=off
  - PULUMI_MISSING_DOCS_ERROR=true
  - PULUMI_EXTRA_MAPPING_ERROR=true
--- done ---
--- Discover Provider --- 
  - Ensure Upstream Repo
    - Expected Location: /Users/t0yv0/code/pulumi-twingate
      - GetCwd: /Users/t0yv0/code/pulumi-twingate
    - Repo Exists
      - Stat
    - Validate Repository
      - git: /usr/bin/git status --short
  - Pull Default Branch
    - git: /usr/bin/git ls-remote --heads origin
    - Find default Branch: main
    - git: /usr/bin/git fetch
    - git: /usr/bin/git checkout main
    - git: /usr/bin/git pull origin
  - Get Repo Kind
    - /Users/t0yv0/code/pulumi-twingate/provider/go.mod: 12612 bytes read
    - Stat
    - Stat
  - Plan Provider Upgrade: 1.2.1 -> 2.1.1
    - Get Expected Target
      - From Upstream Releases
        - gh: /Users/t0yv0/bin/gh release list --repo=Twingate/terraform-provider-twingate --exclude-drafts --exclude-pre-releases
    - Set Current Upstream From Plain
      - Original Go Version of
        - git: /usr/bin/git show main:provider/go.mod
--- done ---
--- Plan Upgrade --- 
  - Planning Bridge Upgrade: v3.69.0 -> v3.77.0
    - git refs of
      - git: /usr/bin/git ls-remote --tags <https://github.com/pulumi/pulumi-terraform-bridge.git>
  - Planning Plugin SDK Upgrade: bridge v3.77.0 needs terraform-plugin-sdk v2.0.0-20240229143312-4f60ee4e2975
 -> Check if we should release a maintenance patch
    - gh: /Users/t0yv0/bin/gh repo view emailbob/pulumi-twingate --json=latestRelease
--- failed ---
error: parsing time "" as "2006-01-02T15:04:05Z07:00": cannot parse "" as "2006"
[1] t0yv0@Antons-MacBook-Pro> gh repo view emailbob/pulumi-twingate --json=latestRelease                                                                                                                                                                                                                                                                                                                            ~/code/pulumi-twingate
{
  "latestRelease": null
}
Looks like I needed to update my version of upgrade-provider
Now I'm getting this:
Copy code
~/code/upgrade-provider/upgrade-provider emailbob/pulumi-twingate --upstream-provider-name terraform-provider-twingate --upstream-provider-org Twingate                                                                                                                                                                                                                                   ~/code/pulumi-twingate
--- Set Up Environment --- 
  - GOWORK=off
  - PULUMI_MISSING_DOCS_ERROR=true
  - PULUMI_EXTRA_MAPPING_ERROR=true
--- done ---
--- Discover Provider --- 
  - Ensure Upstream Repo
    - Expected Location: /Users/t0yv0/code/pulumi-twingate
      - GetCwd: /Users/t0yv0/code/pulumi-twingate
    - Repo Exists
      - Stat
    - Validate Repository
      - git: /usr/bin/git status --short
  - Pull Default Branch
    - git: /usr/bin/git ls-remote --heads origin
    - Find default Branch: main
    - git: /usr/bin/git fetch
    - git: /usr/bin/git checkout main
    - git: /usr/bin/git pull origin
  - Get Repo Kind
    - /Users/t0yv0/code/pulumi-twingate/provider/go.mod: 12612 bytes read
    - Stat
    - Stat
  - Plan Provider Upgrade: 1.2.1 -> 2.1.1
    - Get Expected Target
      - From Upstream Releases
        - gh: /Users/t0yv0/bin/gh release list --repo=Twingate/terraform-provider-twingate --exclude-drafts --exclude-pre-releases
    - Set Current Upstream From Plain
      - Original Go Version of
        - git: /usr/bin/git show main:provider/go.mod
--- done ---
--- Plan Upgrade --- 
  - Planning Bridge Upgrade: v3.69.0 -> v3.77.0
    - git refs of
      - git: /usr/bin/git ls-remote --tags <https://github.com/pulumi/pulumi-terraform-bridge.git>
  - Planning Plugin SDK Upgrade: bridge v3.77.0 needs terraform-plugin-sdk v2.0.0-20240229143312-4f60ee4e2975
  - Check if we should release a maintenance patch
    - gh: /Users/t0yv0/bin/gh repo view emailbob/pulumi-twingate --json=latestRelease
--- done ---
--- Planning Java Gen Version Update --- 
  - Fetching latest Java Gen: 0.9.9
    - Latest Release Version: of pulumi/pulumi-java: 0.9.9
      - gh: /Users/t0yv0/bin/gh repo view pulumi/pulumi-java --json=latestRelease
    - Stat
    - Upgrading Java Gen Version: 0.0.0 -> 0.9.9
--- done ---
error: This is a major version update (v1 -> v2), but --major was not passed
Copy code
git rev-parse HEAD                                                                                                                                                                                                                                                                                                                                                                    ~/code/pulumi-twingate
6534f3dd065d39f17111d39f885a41c9c7e103d4
Perhaps I should start from a different commit to repro? Thank you
b
To get around the major version error pass in
--target-version v1.2.1
This is strange I have 4 instances of go.mod
Copy code
find . -type f -name 'go.mod'
./provider/go.mod
./sdk/nodejs/node_modules/@pulumi/pulumi/tests/automation/data/testproj/go.mod
./sdk/go.mod
./examples/go.mod
After I run:
~/go/bin/upgrade-provider emailbob/pulumi-twingate --upstream-provider-name terraform-provider-twingate --upstream-provider-org Twingate  --target-version v1.2.1
errors with:
Copy code
go: go.mod file not found in current directory or any parent directory.
	'go get' is no longer supported outside a module.
	To build and install a command, use 'go install' with a version,
	like 'go install <http://example.com/cmd@latest|example.com/cmd@latest>'
	For more information, see <https://golang.org/doc/go-get-install-deprecation>
	or run 'go help get' or 'go help install'.
./sdk/go.mod
is deleted
Copy code
find . -type f -name 'go.mod'
./provider/go.mod
./sdk/nodejs/node_modules/@pulumi/pulumi/tests/automation/data/testproj/go.mod
./examples/go.mod
e
Trying again
Copy code
/Users/t0yv0/code/upgrade-provider/upgrade-provider emailbob/pulumi-twingate --upstream-provider-name terraform-provider-twingate --upstream-provider-org Twingate --target-version v1.2.1
```
Copy code
--- failed ---
error: exit status 1:
go: <http://github.com/emailbob/pulumi-twingate/sdk/go/twingate|github.com/emailbob/pulumi-twingate/sdk/go/twingate> imports
        <http://github.com/pulumi/pulumi/sdk/v3/go/pulumi|github.com/pulumi/pulumi/sdk/v3/go/pulumi> imports
        <http://github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin|github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin> tested by
        <http://github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin.test|github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin.test> imports
        <http://pgregory.net/rapid|pgregory.net/rapid> loaded from <http://pgregory.net/rapid@v0.5.5|pgregory.net/rapid@v0.5.5>,
        but go 1.16 would select v0.6.1
go: <http://github.com/emailbob/pulumi-twingate/sdk/go/twingate|github.com/emailbob/pulumi-twingate/sdk/go/twingate> imports
        <http://github.com/pulumi/pulumi/sdk/v3/go/pulumi|github.com/pulumi/pulumi/sdk/v3/go/pulumi> imports
        <http://github.com/pulumi/pulumi/sdk/v3/go/common/util/cmdutil|github.com/pulumi/pulumi/sdk/v3/go/common/util/cmdutil> imports
        <http://github.com/uber/jaeger-client-go|github.com/uber/jaeger-client-go> imports
        <http://github.com/uber/jaeger-client-go/utils|github.com/uber/jaeger-client-go/utils> tested by
        <http://github.com/uber/jaeger-client-go/utils.test|github.com/uber/jaeger-client-go/utils.test> imports
        <http://github.com/stretchr/testify/mock|github.com/stretchr/testify/mock> imports
        <http://github.com/stretchr/objx|github.com/stretchr/objx> loaded from <http://github.com/stretchr/objx@v0.1.0|github.com/stretchr/objx@v0.1.0>,
        but go 1.16 would select v0.5.0

To upgrade to the versions selected by go 1.16:
        go mod tidy -go=1.16 && go mod tidy -go=1.17
If reproducibility with go 1.16 is not needed:
        go mod tidy -compat=1.17
For other options, see:
        <https://golang.org/doc/modules/pruning>
go: <http://github.com/emailbob/pulumi-twingate/sdk/go/twingate|github.com/emailbob/pulumi-twingate/sdk/go/twingate> imports
        <http://github.com/pulumi/pulumi/sdk/v3/go/pulumi|github.com/pulumi/pulumi/sdk/v3/go/pulumi> imports
        <http://github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin|github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin> tested by
        <http://github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin.test|github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin.test> imports
        <http://pgregory.net/rapid|pgregory.net/rapid> loaded from <http://pgregory.net/rapid@v0.5.5|pgregory.net/rapid@v0.5.5>,
        but go 1.16 would select v0.6.1
go: <http://github.com/emailbob/pulumi-twingate/sdk/go/twingate|github.com/emailbob/pulumi-twingate/sdk/go/twingate> imports
        <http://github.com/pulumi/pulumi/sdk/v3/go/pulumi|github.com/pulumi/pulumi/sdk/v3/go/pulumi> imports
        <http://github.com/pulumi/pulumi/sdk/v3/go/common/util/cmdutil|github.com/pulumi/pulumi/sdk/v3/go/common/util/cmdutil> imports
        <http://github.com/uber/jaeger-client-go|github.com/uber/jaeger-client-go> imports
        <http://github.com/uber/jaeger-client-go/utils|github.com/uber/jaeger-client-go/utils> tested by
        <http://github.com/uber/jaeger-client-go/utils.test|github.com/uber/jaeger-client-go/utils.test> imports
        <http://github.com/stretchr/testify/mock|github.com/stretchr/testify/mock> imports
        <http://github.com/stretchr/objx|github.com/stretchr/objx> loaded from <http://github.com/stretchr/objx@v0.1.0|github.com/stretchr/objx@v0.1.0>,
        but go 1.16 would select v0.5.0
Still a different failure for me
Copy code
go version                                                                                                                                                         ~/code/pulumi-twingate
go version go1.21.5 darwin/amd64
The
./sdk/nodejs/node_modules/@pulumi/pulumi/tests/automation/data/testproj/go.mod
instance is a bit unexpected, it's under node_modules so some testdata accidentally got published into p/p node SDK, which is not great, perhaps we have an unexpected interaction with that? Try cleaning
git clean -fxd
before running upgrade-provider, that should remove node_modules
Hmm, trying to fix
sdk/go.mod
I ran into really annoying behavior where my edits are wiped out. Logged https://github.com/pulumi/upgrade-provider/issues/257 - this is definitely something very unhelpful.
b
Thanks for creating the ticket. Is there any manual work around or should I just avoid running
upgrade-provider
for now?
e
It sounds like if you put your edits on origin/main then it will respect them as a workaround for 257. However you might be having a slightly different issue. I still wasn't quite able to get into the same state as you're reporting where it complains that go.mod is not found