Skip to content
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

GH-853: Allow deleting branding resource even on free tenants #875

Merged
merged 1 commit into from
Nov 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions internal/auth0/branding/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,16 +166,10 @@ func updateBranding(ctx context.Context, data *schema.ResourceData, meta interfa
func deleteBranding(ctx context.Context, _ *schema.ResourceData, meta interface{}) diag.Diagnostics {
api := meta.(*config.Config).GetAPI()

if err := checkForCustomDomains(ctx, api); err != nil {
if err == errNoCustomDomain {
return nil
if err := checkForCustomDomains(ctx, api); err == nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now aligned with the read logic found here

if err := checkForCustomDomains(ctx, api); err == nil {
where we skip reading the universal login template body if no custom domains are set on the tenant or if the tenant is a free tier tenant.

if err := api.Branding.DeleteUniversalLogin(ctx); err != nil {
return diag.FromErr(err)
}

return diag.FromErr(err)
}

if err := api.Branding.DeleteUniversalLogin(ctx); err != nil {
return diag.FromErr(err)
}

return nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you're inverting the if/else, shouldn't you be returning err?

Copy link
Contributor Author

@sergiught sergiught Nov 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we get no error it means we're not a free tier tenant and we have the ability to delete the universal login template data, otherwise we can't, so we shouldn't return the error in that case but allow for a successful deletion of the resource.

Please also check above: #875 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update: Ok with ignoring the errors for now because they would be unlikely and it is too difficult to identify the specific errors that we would want to keep or ignore. Especially provided that this is a deletion operation.

Expand Down