pulumi / upgrade-provider

A tool to automate provider upgrades on your local machine
6 stars 1 forks source link

When there is an update errors with 'go get' is no longer supported outside a module #258

Closed twingate-blee closed 4 months ago

twingate-blee commented 5 months ago

What happened?

upgrade-provider script errors when there is an update. When I update everything manually and run it works fine output of "No actions needed"

Run upgrade-provider "$REPO" --kind="$KIND" ${TBV:+--target-bridge-version="$TBV"} ${REV:+--pr-reviewers="$REV"} ${DESC:+--pr-description="$DESC"} ${PREF:+--pr-title-prefix="$PREF"} ${PUV:+--target-pulumi-version="$PUV"} ${JV:+--java-version="$JV"}
---- Update Repository ----
- Update Plugin SDK
 Update TF Plugin SDK Fork: updated
 /opt/hostedtoolcache/go/1.21.8/x64/bin/go mod tidy: done
- Upgrade Bridge Version
 /opt/hostedtoolcache/go/1.21.8/x64/bin/go get github.com/pulumi/pulumi-terraform...: done
 /opt/hostedtoolcache/go/1.21.8/x64/bin/go get github.com/hashicorp/terraform-plu...: done
 /opt/hostedtoolcache/go/1.21.8/x64/bin/go get github.com/hashicorp/terraform-plu...: done
 /opt/hostedtoolcache/go/1.21.8/x64/bin/go mod tidy: done
- Upgrade Pf Version
 /opt/hostedtoolcache/go/1.21.8/x64/bin/go get github.com/pulumi/pulumi-terraform...: done
 /opt/hostedtoolcache/go/1.21.8/x64/bin/go mod tidy: done
- Upgrade Pulumi version in all places
 Get Pulumi SDK version: v3.111.1
 /opt/hostedtoolcache/go/1.21.8/x64/bin/go get github.com/pulumi/pulumi/sdk/v3@v3...: 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 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'.

Error: Process completed with exit code 1.

Example

Errors when using github action

name: Upgrade provider
on:
  workflow_dispatch: {}
  issues:
    types:
    - opened
  schedule:
    - cron: '0 5 * * *'

permissions:
  contents: write

env:
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
  upgrade_provider:
    name: upgrade-provider
    runs-on: ubuntu-latest
    steps:
    - name: Call upgrade provider action
      uses: pulumi/pulumi-upgrade-provider-action@main
      with:
        kind: all

Or command line

~/go/bin/upgrade-provider /pulumi- --upstream-provider-name terraform-provider- twingate --upstream-provider-org --allow-missing-docs --remove-plugins

Output of pulumi about

CLI Version 3.109.0 Go Version go1.22.0 Go Compiler gc

Host OS darwin Version 14.4 Arch x86_64

Backend Name pulumi.com

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

iwahbe commented 5 months ago

Hey @twingate-blee. Thanks for reporting this to us.

mikhailshilkov commented 5 months ago

@iwahbe Any diagnosis of what is going on in this case?

iwahbe commented 4 months ago

@twingate-blee As I understand it, this error only shows up when upgrade-provider is run via pulumi/pulumi-upgrade-provider-action. We haven't seen this in any of our providers (all of which use pulumi/pulumi-upgrade-provider-action.

Is this still happening? Is the repo public (so I can see the logs)?

twingate-blee commented 4 months ago

This is no longer happening but I'm getting other errors.

I was finally able to get this to successfully run by passing --kind provider

Any other option passed to --kind gives me various errors.

For example running with --kind code I get the error below.

./resources.go:174:18: duplicate field name MetadataInfo in struct literal
make: *** [tfgen] Error 1

I already have MetadataInfo and when running the command it adds MetadataInfo again to resource.go. Below is the duplicate it adds

, MetadataInfo:

        // These are new API's that you may opt to use to automatically compute resource
        // tokens, and apply auto aliasing for full backwards compatibility.  For more
        // information, please reference:
        // https://pkg.go.dev/github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge#ProviderInfo.ComputeTokens
        tfbridge.NewProviderMetadata(metadata),
iwahbe commented 4 months ago

Thanks for responding. I'm glad go get is no longer failing. Did you ever figure out why the failure was happening?

The --kind code looks like a much more straightforward error. I'll take a look.

iwahbe commented 4 months ago

I opened https://github.com/pulumi/upgrade-provider/issues/260 to track the MetadataInfo bug.