Skip to content

Commit

Permalink
Modifying attribute plan modifier (#303)
Browse files Browse the repository at this point in the history
  • Loading branch information
bendbennett committed Sep 1, 2022
1 parent 831e6aa commit 5fbbb26
Showing 1 changed file with 15 additions and 23 deletions.
38 changes: 15 additions & 23 deletions internal/planmodifiers/attribute.go
Expand Up @@ -180,42 +180,34 @@ func (r requiresReplaceIfValuesNotNullModifier) Modify(ctx context.Context, req

replace := false

additionalElems := map[string]attr.Value{}

for k, v := range configMap.Elems {
if _, ok := stateMap.Elems[k]; !ok {
if !v.IsNull() || v.IsUnknown() {
replace = true
break
}
for k, configValue := range configMap.Elems {
stateValue, ok := stateMap.Elems[k]

if !ok && configValue.IsNull() {
continue
}

if stateMap.Elems[k] != configMap.Elems[k] {
if !configValue.Equal(stateValue) {
replace = true
break
}

if v.IsNull() && !v.IsUnknown() {
additionalElems[k] = v
}
}

if replace {
resp.RequiresReplace = true
return
}

respPlan := resp.AttributePlan

pm, ok := respPlan.(types.Map)
if ok {
for k, v := range additionalElems {
pm.Elems[k] = v
}
}

resp.AttributePlan = pm
//respPlan := resp.AttributePlan
//
//pm, ok := respPlan.(types.Map)
//if ok {
// for k, v := range additionalElems {
// pm.Elems[k] = v
// }
//}
//
//resp.AttributePlan = pm
}

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

0 comments on commit 5fbbb26

Please sign in to comment.