Merge pull request #35437 from hashicorp/jbardin/providers-suggestion

add suggestion to run `terraform providers` on provider installation failure
pull/35443/head
James Bardin 2 years ago committed by GitHub
commit 208d13746d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -686,11 +686,12 @@ func (c *InitCommand) getProviders(ctx context.Context, config *configs.Config,
// the end, by checking ctx.Err().
default:
suggestion := fmt.Sprintf("\n\nTo see which modules are currently depending on %s and what versions are specified, run the following command:\n terraform providers", provider.ForDisplay())
diags = diags.Append(tfdiags.Sourceless(
tfdiags.Error,
"Failed to query available provider packages",
fmt.Sprintf("Could not retrieve the list of available versions for provider %s: %s",
provider.ForDisplay(), err,
fmt.Sprintf("Could not retrieve the list of available versions for provider %s: %s%s",
provider.ForDisplay(), err, suggestion,
),
))
}

@ -2939,6 +2939,10 @@ Error: Failed to query available provider packages
Could not retrieve the list of available versions for provider
hashicorp/test: no available releases match the given constraints 1.0.1,
1.0.2
To see which modules are currently depending on hashicorp/test and what
versions are specified, run the following command:
terraform providers
`
if diff := cmp.Diff(got, want); len(diff) > 0 {
t.Fatalf("wrong error message: \ngot:\n%s\nwant:\n%s\ndiff:\n%s", got, want, diff)

Loading…
Cancel
Save