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

Only set RequiresReplace if value has changed and config is non-null #203

Closed
wants to merge 1 commit into from
Closed
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: 8 additions & 4 deletions tfsdk/attribute_plan_modification.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ type RequiresReplaceModifier struct{}

// Modify sets RequiresReplace on the response to true.
func (r RequiresReplaceModifier) Modify(ctx context.Context, req ModifyAttributePlanRequest, resp *ModifyAttributePlanResponse) {
resp.RequiresReplace = true
if req.AttributePlan != req.AttributeState && req.AttributeConfig != nil {
resp.RequiresReplace = true
}
}

// Description returns a human-readable description of the plan modifier.
Expand Down Expand Up @@ -103,9 +105,11 @@ type RequiresReplaceIfModifier struct {
// Modify sets RequiresReplace on the response to true if the conditional
// RequiresReplaceIfFunc returns true.
func (r RequiresReplaceIfModifier) Modify(ctx context.Context, req ModifyAttributePlanRequest, resp *ModifyAttributePlanResponse) {
res, diags := r.f(ctx, req.AttributeState, req.AttributeConfig, req.AttributePath)
resp.Diagnostics.Append(diags...)
resp.RequiresReplace = res
if req.AttributePlan != req.AttributeState && req.AttributeConfig != nil {
res, diags := r.f(ctx, req.AttributeState, req.AttributeConfig, req.AttributePath)
resp.Diagnostics.Append(diags...)
resp.RequiresReplace = res
}
}

// Description returns a human-readable description of the plan modifier.
Expand Down