Skip to content

Commit

Permalink
refactor: render debug output using a Go-syntax representation of the…
Browse files Browse the repository at this point in the history
… value
  • Loading branch information
Integralist committed Oct 19, 2023
1 parent eb26fc3 commit 5fed5a7
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion internal/provider/resources/servicevcl/process_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"

"github.com/integralist/terraform-provider-fastly-framework/internal/helpers"
"github.com/integralist/terraform-provider-fastly-framework/internal/provider/data"
"github.com/integralist/terraform-provider-fastly-framework/internal/provider/models"
Expand Down Expand Up @@ -72,7 +73,7 @@ func (r *Resource) Create(ctx context.Context, req resource.CreateRequest, resp
// Save the planned changes into Terraform state.
resp.Diagnostics.Append(resp.State.Set(ctx, &plan)...)

tflog.Trace(ctx, "Create", map[string]any{"state": fmt.Sprintf("%+v", plan)})
tflog.Trace(ctx, "Create", map[string]any{"state": fmt.Sprintf("%#v", plan)})
}

func createService(
Expand Down
3 changes: 2 additions & 1 deletion internal/provider/resources/servicevcl/process_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-log/tflog"

"github.com/integralist/terraform-provider-fastly-framework/internal/provider/models"
)

Expand Down Expand Up @@ -55,5 +56,5 @@ func (r *Resource) Delete(ctx context.Context, req resource.DeleteRequest, resp
}
}

tflog.Trace(ctx, "Delete", map[string]any{"state": fmt.Sprintf("%+v", state)})
tflog.Trace(ctx, "Delete", map[string]any{"state": fmt.Sprintf("%#v", state)})
}
3 changes: 2 additions & 1 deletion internal/provider/resources/servicevcl/process_read.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"

"github.com/integralist/terraform-provider-fastly-framework/internal/helpers"
"github.com/integralist/terraform-provider-fastly-framework/internal/provider/data"
"github.com/integralist/terraform-provider-fastly-framework/internal/provider/models"
Expand Down Expand Up @@ -95,7 +96,7 @@ func (r *Resource) Read(ctx context.Context, req resource.ReadRequest, resp *res
// Save the updated state data back into Terraform state.
resp.Diagnostics.Append(resp.State.Set(ctx, &state)...)

tflog.Trace(ctx, "Read", map[string]any{"state": fmt.Sprintf("%+v", state)})
tflog.Trace(ctx, "Read", map[string]any{"state": fmt.Sprintf("%#v", state)})
}

func readSettings(ctx context.Context, state *models.ServiceVCL, resp *resource.ReadResponse, api helpers.API) error {
Expand Down
3 changes: 2 additions & 1 deletion internal/provider/resources/servicevcl/process_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"

"github.com/integralist/terraform-provider-fastly-framework/internal/helpers"
"github.com/integralist/terraform-provider-fastly-framework/internal/provider/data"
"github.com/integralist/terraform-provider-fastly-framework/internal/provider/interfaces"
Expand Down Expand Up @@ -98,7 +99,7 @@ func (r *Resource) Update(ctx context.Context, req resource.UpdateRequest, resp
// Save the planned changes into Terraform state.
resp.Diagnostics.Append(resp.State.Set(ctx, &plan)...)

tflog.Trace(ctx, "Update", map[string]any{"state": fmt.Sprintf("%+v", plan)})
tflog.Trace(ctx, "Update", map[string]any{"state": fmt.Sprintf("%#v", plan)})
}

func updateServiceSettings(ctx context.Context, plan *models.ServiceVCL, diags diag.Diagnostics, api helpers.API) error {
Expand Down
3 changes: 2 additions & 1 deletion internal/provider/resources/servicevcl/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-go/tftypes"
"github.com/hashicorp/terraform-plugin-log/tflog"

"github.com/integralist/terraform-provider-fastly-framework/internal/helpers"
"github.com/integralist/terraform-provider-fastly-framework/internal/provider/interfaces"
"github.com/integralist/terraform-provider-fastly-framework/internal/provider/resources/domain"
Expand Down Expand Up @@ -150,7 +151,7 @@ func (r *Resource) ImportState(ctx context.Context, req resource.ImportStateRequ
var state map[string]tftypes.Value
err := resp.State.Raw.As(&state)
if err == nil {
tflog.Debug(ctx, "ImportState", map[string]any{"state": fmt.Sprintf("%+v", state)})
tflog.Debug(ctx, "ImportState", map[string]any{"state": fmt.Sprintf("%#v", state)})
}
}

Expand Down

0 comments on commit 5fed5a7

Please sign in to comment.