Merge pull request #28684 from hashicorp/radditude/org-read-error
backend/remote: clearer error when we fail to read the organization
This commit is contained in:
commit
dc71cd4495
|
@ -321,15 +321,16 @@ func (b *Remote) Configure(obj cty.Value) tfdiags.Diagnostics {
|
|||
entitlements, err := b.client.Organizations.Entitlements(context.Background(), b.organization)
|
||||
if err != nil {
|
||||
if err == tfe.ErrResourceNotFound {
|
||||
err = fmt.Errorf("organization %s does not exist", b.organization)
|
||||
err = fmt.Errorf("organization %q at host %s not found.\n\n"+
|
||||
"Please ensure that the organization and hostname are correct "+
|
||||
"and that your API token for %s is valid.",
|
||||
b.organization, b.hostname, b.hostname)
|
||||
}
|
||||
diags = diags.Append(tfdiags.AttributeValue(
|
||||
tfdiags.Error,
|
||||
"Failed to read organization entitlements",
|
||||
fmt.Sprintf(
|
||||
`The "remote" backend encountered an unexpected error while reading the `+
|
||||
`organization settings: %s.`, err,
|
||||
),
|
||||
fmt.Sprintf("Failed to read organization %q at host %s", b.organization, b.hostname),
|
||||
fmt.Sprintf("The \"remote\" backend encountered an unexpected error while reading the "+
|
||||
"organization settings: %s", err),
|
||||
cty.Path{cty.GetAttrStep{Name: "organization"}},
|
||||
))
|
||||
return diags
|
||||
|
|
|
@ -55,7 +55,7 @@ func TestRemote_config(t *testing.T) {
|
|||
"prefix": cty.NullVal(cty.String),
|
||||
}),
|
||||
}),
|
||||
confErr: "organization nonexisting does not exist",
|
||||
confErr: "organization \"nonexisting\" at host app.terraform.io not found",
|
||||
},
|
||||
"with_an_unknown_host": {
|
||||
config: cty.ObjectVal(map[string]cty.Value{
|
||||
|
|
Loading…
Reference in New Issue