-
Notifications
You must be signed in to change notification settings - Fork 164
chore: migrate tfe_oauth_client to framework #1661
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
chore: migrate tfe_oauth_client to framework #1661
Conversation
df31b92
to
1a58dc0
Compare
1a58dc0
to
ba098cb
Compare
Optional: true, | ||
Default: true, | ||
|
||
"organization_scoped": schema.BoolAttribute{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think these last three attributes should require replacement. For example when testing with the previous sdk, switching the value from organization_scoped from true to false causes an update-in-place. Whereas with this change, it forces a replacement and it causes the error Provider produced inconsistent result after apply
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, thanks! Updated in a6d5a36.
e6ef965
to
a6d5a36
Compare
func TestAccTFEOAuthClientDataSource_missingOrgWithName(t *testing.T) { | ||
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int() | ||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccTFEOAuthClientDataSourcePreCheck(t) }, | ||
ProtoV5ProviderFactories: testAccMuxedProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccTFEOAuthClientDataSourceConfig_missingOrgWithName(rInt), | ||
ExpectError: regexp.MustCompile("all of `name,organization` must"), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestAccTFEOAuthClientDataSource_missingOrgWithServiceProvider(t *testing.T) { | ||
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int() | ||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccTFEOAuthClientDataSourcePreCheck(t) }, | ||
ProtoV5ProviderFactories: testAccMuxedProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccTFEOAuthClientDataSourceConfig_missingOrgWithServiceProvider(rInt), | ||
ExpectError: regexp.MustCompile("all of `organization,service_provider` must be"), | ||
ExpectError: regexp.MustCompile("Invalid Attribute Combination"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed these tests since we are now defaulting organization to the provider config.
7b65e2a
to
9352b04
Compare
oc, err = d.config.Client.OAuthClients.Read(ctx, id) | ||
if err != nil && errors.Is(err, tfe.ErrResourceNotFound) { | ||
tflog.Debug(ctx, fmt.Sprintf("OAuth client %s no longer exists", id)) | ||
resp.State.RemoveResource(ctx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This removeResource
check is only applicable to resource. If you run into the "resource not found" error when accessing a data source, it means that you passed the wrong id and no resource is associated with that client id. So I think here we just want to do:
oc, err = d.config.Client.OAuthClients.Read(ctx, id)
if err != nil {
resp.Diagnostics.AddError("Error reading OAuth client", err.Error())
return
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in b2339ec.
9352b04
to
b2339ec
Compare
Description
This PR migrates the
tfe_oauth_client
resource and data source to the provider framework.Acceptance tests that made use of any of the above also needed to be switched to the muxed provider factory.
Testing plan
Output from acceptance tests