Skip to content

Commit

Permalink
resource_redirect/create: Explicitly disable 'merge' functionality.
Browse files Browse the repository at this point in the history
This way, new resources will be solely managed by TerraForm and not
be ('accidentally') rolled up into other pre-existing redirects
which may or may not be managed outside of Terraform
  • Loading branch information
Freeaqingme committed Apr 3, 2024
1 parent b8f4b22 commit 359ac69
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion internal/provider/resource_redirect.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/hashicorp/terraform-plugin-log/tflog"
"io"
"net/http"
"strings"
"time"

"github.com/hashicorp/go-cty/cty"
"github.com/hashicorp/terraform-plugin-log/tflog"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
Expand Down Expand Up @@ -113,6 +113,8 @@ func redirectTypeValidator(i interface{}, _ cty.Path) diag.Diagnostics {
// https://redirect.pizza/docs#tag/Redirects/operation/createRedirect
func resourceRedirectCreate(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
data := hydrateHttpPersistData(d)
merge := false // Do not use the merge functionality for resources managed by Terraform
data.Merge = &merge
reqBody, _ := json.Marshal(data)

apiClientData := meta.(*apiClient)
Expand Down Expand Up @@ -264,6 +266,7 @@ type httpPersistData struct {
KeepQueryString bool `json:"keep_query_string"`
Tracking bool `json:"tracking"`
Tags []string `json:"tags"`
Merge *bool `json:"merge,omitempty"`
}

func hydrateHttpPersistData(d *schema.ResourceData) *httpPersistData {
Expand Down

0 comments on commit 359ac69

Please sign in to comment.