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

fix custom_domain domain missing issue #133

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.20

require (
github.com/hashicorp/terraform-plugin-docs v0.13.0
github.com/hashicorp/terraform-plugin-log v0.9.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.29.0
)

Expand Down Expand Up @@ -38,7 +39,6 @@ require (
github.com/hashicorp/terraform-exec v0.19.0 // indirect
github.com/hashicorp/terraform-json v0.17.1 // indirect
github.com/hashicorp/terraform-plugin-go v0.19.0 // indirect
github.com/hashicorp/terraform-plugin-log v0.9.0 // indirect
github.com/hashicorp/terraform-registry-address v0.2.2 // indirect
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect
Expand Down
4 changes: 2 additions & 2 deletions provider/resource_frontegg_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import (
"context"
"fmt"
"log"
"log/slog"

Check failure on line 6 in provider/resource_frontegg_user.go

View workflow job for this annotation

GitHub Actions / test (1.0.3)

package log/slog is not in GOROOT (/opt/hostedtoolcache/go/1.20.6/x64/src/log/slog)
"net/http"

"github.com/frontegg/terraform-provider-frontegg/internal/restclient"
Expand Down Expand Up @@ -92,7 +92,7 @@
}

func resourceFronteggUserSerialize(d *schema.ResourceData) fronteggUser {
log.Printf("role IDs: %#v", d.Get("role_ids").(*schema.Set).List())
slog.Debug("role IDs: %#v", d.Get("role_ids").(*schema.Set).List())
return fronteggUser{
Email: d.Get("email").(string),
Password: d.Get("password").(string),
Expand Down
14 changes: 11 additions & 3 deletions provider/resource_frontegg_workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"errors"
"fmt"
"log"
"github.com/hashicorp/terraform-plugin-log/tflog"
"reflect"
"regexp"
"strings"
Expand Down Expand Up @@ -1462,6 +1462,7 @@ func resourceFronteggWorkspaceUpdate(ctx context.Context, d *schema.ResourceData
}
}
if d.HasChange("custom_domain") {
tflog.Debug(ctx, "found custom_domain changes, recreating custom_domain")
clientHolder.ApiClient.Ignore404()
if err := clientHolder.ApiClient.Delete(ctx, fronteggCustomDomainURL, nil); err != nil {
return diag.FromErr(err)
Expand All @@ -1471,6 +1472,7 @@ func resourceFronteggWorkspaceUpdate(ctx context.Context, d *schema.ResourceData

customDomainErr := clientHolder.ApiClient.Post(ctx, fronteggCustomDomainURL, in, nil)
if customDomainErr != nil {
tflog.Debug(ctx, "custom domain failed to post")
diag.FromErr(customDomainErr)
}

Expand All @@ -1479,19 +1481,25 @@ func resourceFronteggWorkspaceUpdate(ctx context.Context, d *schema.ResourceData
err = retry.RetryContext(ctx, time.Minute, func() *retry.RetryError {
if err := clientHolder.ApiClient.Post(ctx, fronteggCustomDomainVerifyURL, nil, &out); err != nil {
if strings.Contains(err.Error(), "CName not found") {
tflog.Debug(ctx, "custom_domain cname not found")
return retry.RetryableError(err)
} else if strings.Contains(err.Error(), "Custom domain is missing") {
tflog.Debug(ctx, "custom_domain not found while validating")
return retry.RetryableError(err)
} else {
return retry.NonRetryableError(err)
}
}
if !out.Verified {
tflog.Debug(ctx, "custom_domain is not yet verified, retrying")
return retry.RetryableError(errors.New("domain not yet verified"))
} else {
return nil
}
})

if err != nil {
tflog.Debug(ctx, "Failed custom domain registration after retries")
return diag.FromErr(err)
}
}
Expand Down Expand Up @@ -1853,7 +1861,7 @@ func resourceFronteggWorkspaceUpdate(ctx context.Context, d *schema.ResourceData
// this is not an error.
switch len(out.Rows) {
case 0:
log.Printf("[DEBUG] no admin portal found, creating one with default config.")
tflog.Debug(ctx, "no admin portal found, creating one with default config.")
configuration = &adminPortal.Configuration
case 1:
adminPortal = out.Rows[0]
Expand Down Expand Up @@ -1893,7 +1901,7 @@ func resourceFronteggWorkspaceUpdate(ctx context.Context, d *schema.ResourceData
}

func resourceFronteggWorkspaceDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
log.Printf("[WARN] Cannot destroy workspace. Terraform will remove this resource from the " +
tflog.Warn(ctx, "Cannot destroy workspace. Terraform will remove this resource from the "+
"state file, but the workspace will remain in its last-applied state.")
return nil
}
Loading