Skip to content

Commit

Permalink
Make TestAccDefaultUniverseDomain_doesNotMatchExplicit independent fr…
Browse files Browse the repository at this point in the history
…om test credentials (hashicorp#10140)

[upstream:5989a16860b84d15ac84f0994cc31e27c0c59422]

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician committed Mar 7, 2024
1 parent 300da8f commit d0c41d0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .changelog/10140.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:none

```
6 changes: 3 additions & 3 deletions google/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -851,12 +851,12 @@ func ProviderConfigure(ctx context.Context, d *schema.ResourceData, p *schema.Pr
// Check if the user provided a value from the universe_domain field other than the default
if v, ok := d.GetOk("universe_domain"); ok && v.(string) != "googleapis.com" {
if config.UniverseDomain == "" {
return nil, diag.FromErr(fmt.Errorf("Universe domain '%s' supplied directly to Terraform with no matching universe domain in credentials. Credentials with no 'universe_domain' set are assumed to be in the default universe.", v))
return nil, diag.FromErr(fmt.Errorf("Universe domain mismatch: '%s' supplied directly to Terraform with no matching universe domain in credentials. Credentials with no 'universe_domain' set are assumed to be in the default universe.", v))
} else if v.(string) != config.UniverseDomain {
if _, err := os.Stat(config.Credentials); err == nil {
return nil, diag.FromErr(fmt.Errorf("'%s' does not match the universe domain '%s' already set in the credential file '%s'. The 'universe_domain' provider configuration can not be used to override the universe domain that is defined in the active credential. Set the 'universe_domain' provider configuration when universe domain information is not already available in the credential, e.g. when authenticating with a JWT token.", v, config.UniverseDomain, config.Credentials))
return nil, diag.FromErr(fmt.Errorf("Universe domain mismatch: '%s' does not match the universe domain '%s' already set in the credential file '%s'. The 'universe_domain' provider configuration can not be used to override the universe domain that is defined in the active credential. Set the 'universe_domain' provider configuration when universe domain information is not already available in the credential, e.g. when authenticating with a JWT token.", v, config.UniverseDomain, config.Credentials))
} else {
return nil, diag.FromErr(fmt.Errorf("'%s' does not match the universe domain '%s' supplied directly to Terraform. The 'universe_domain' provider configuration can not be used to override the universe domain that is defined in the active credential. Set the 'universe_domain' provider configuration when universe domain information is not already available in the credential, e.g. when authenticating with a JWT token.", v, config.UniverseDomain))
return nil, diag.FromErr(fmt.Errorf("Universe domain mismatch: '%s' does not match the universe domain '%s' supplied directly to Terraform. The 'universe_domain' provider configuration can not be used to override the universe domain that is defined in the active credential. Set the 'universe_domain' provider configuration when universe domain information is not already available in the credential, e.g. when authenticating with a JWT token.", v, config.UniverseDomain))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion google/provider/universe/universe_domain_compute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func TestAccDefaultUniverseDomain_doesNotMatchExplicit(t *testing.T) {
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccUniverseDomain_basic_disk(universeDomainFake),
ExpectError: regexp.MustCompile("supplied directly to Terraform with no matching universe domain in credentials"),
ExpectError: regexp.MustCompile("Universe domain mismatch"),
},
},
})
Expand Down

0 comments on commit d0c41d0

Please sign in to comment.