From 5fbbb26b4345c09108f030f1c1a0cd5e8604f3c3 Mon Sep 17 00:00:00 2001 From: Benjamin Bennett Date: Thu, 1 Sep 2022 17:23:09 +0100 Subject: [PATCH] Modifying attribute plan modifier (#303) --- internal/planmodifiers/attribute.go | 38 ++++++++++++----------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/internal/planmodifiers/attribute.go b/internal/planmodifiers/attribute.go index 43d0e550..baddc592 100644 --- a/internal/planmodifiers/attribute.go +++ b/internal/planmodifiers/attribute.go @@ -180,25 +180,17 @@ 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 { @@ -206,16 +198,16 @@ func (r requiresReplaceIfValuesNotNullModifier) Modify(ctx context.Context, req 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.