mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
Structured Plan Renderer: Refactor Primitive and Sensitive value processing (#32476)
* refactor sensitive and primitive values to match patterns used elsewhere * goimports * address comments * fix tests * also use %q for map keys
This commit is contained in:
parent
46ab53d651
commit
a086453783
@ -71,7 +71,11 @@ func (renderer mapRenderer) Render(change Change, indent int, opts RenderOpts) s
|
||||
comma = ","
|
||||
}
|
||||
|
||||
buf.WriteString(fmt.Sprintf("%s%s \"%s\"%-*s = %s%s\n", change.indent(indent+1), format.DiffActionSymbol(element.action), key, renderer.maximumKeyLen-len(key), "", element.Render(indent+1, elementOpts), comma))
|
||||
// When we add padding for the keys, we want the length to be an
|
||||
// additional 2 characters, as we are going to add quotation marks ("")
|
||||
// around the key when it is rendered.
|
||||
keyLenWithOffset := renderer.maximumKeyLen + 2
|
||||
buf.WriteString(fmt.Sprintf("%s%s %-*q = %s%s\n", change.indent(indent+1), format.DiffActionSymbol(element.action), keyLenWithOffset, key, element.Render(indent+1, elementOpts), comma))
|
||||
}
|
||||
|
||||
if unchangedElements > 0 {
|
||||
|
@ -3,46 +3,60 @@ package change
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/zclconf/go-cty/cty"
|
||||
|
||||
"github.com/hashicorp/terraform/internal/plans"
|
||||
)
|
||||
|
||||
func Primitive(before, after *string) Renderer {
|
||||
func Primitive(before, after interface{}, ctype cty.Type) Renderer {
|
||||
return &primitiveRenderer{
|
||||
before: before,
|
||||
after: after,
|
||||
ctype: ctype,
|
||||
}
|
||||
}
|
||||
|
||||
type primitiveRenderer struct {
|
||||
NoWarningsRenderer
|
||||
|
||||
before *string
|
||||
after *string
|
||||
before interface{}
|
||||
after interface{}
|
||||
ctype cty.Type
|
||||
}
|
||||
|
||||
func (renderer primitiveRenderer) Render(result Change, indent int, opts RenderOpts) string {
|
||||
var beforeValue, afterValue string
|
||||
func (renderer primitiveRenderer) Render(change Change, indent int, opts RenderOpts) string {
|
||||
beforeValue := renderPrimitiveValue(renderer.before, renderer.ctype)
|
||||
afterValue := renderPrimitiveValue(renderer.after, renderer.ctype)
|
||||
|
||||
if renderer.before != nil {
|
||||
beforeValue = *renderer.before
|
||||
} else {
|
||||
beforeValue = "[dark_gray]null[reset]"
|
||||
}
|
||||
|
||||
if renderer.after != nil {
|
||||
afterValue = *renderer.after
|
||||
} else {
|
||||
afterValue = "[dark_gray]null[reset]"
|
||||
}
|
||||
|
||||
switch result.action {
|
||||
switch change.action {
|
||||
case plans.Create:
|
||||
return fmt.Sprintf("%s%s", afterValue, result.forcesReplacement())
|
||||
return fmt.Sprintf("%s%s", afterValue, change.forcesReplacement())
|
||||
case plans.Delete:
|
||||
return fmt.Sprintf("%s%s%s", beforeValue, result.nullSuffix(opts.overrideNullSuffix), result.forcesReplacement())
|
||||
return fmt.Sprintf("%s%s%s", beforeValue, change.nullSuffix(opts.overrideNullSuffix), change.forcesReplacement())
|
||||
case plans.NoOp:
|
||||
return fmt.Sprintf("%s%s", beforeValue, result.forcesReplacement())
|
||||
return fmt.Sprintf("%s%s", beforeValue, change.forcesReplacement())
|
||||
default:
|
||||
return fmt.Sprintf("%s [yellow]->[reset] %s%s", beforeValue, afterValue, result.forcesReplacement())
|
||||
return fmt.Sprintf("%s [yellow]->[reset] %s%s", beforeValue, afterValue, change.forcesReplacement())
|
||||
}
|
||||
}
|
||||
|
||||
func renderPrimitiveValue(value interface{}, t cty.Type) string {
|
||||
switch value.(type) {
|
||||
case nil:
|
||||
return "[dark_gray]null[reset]"
|
||||
}
|
||||
|
||||
switch {
|
||||
case t == cty.String:
|
||||
return fmt.Sprintf("%q", value.(string))
|
||||
case t == cty.Bool:
|
||||
if value.(bool) {
|
||||
return "true"
|
||||
}
|
||||
return "false"
|
||||
case t == cty.Number:
|
||||
return fmt.Sprintf("%g", value)
|
||||
default:
|
||||
panic("unrecognized primitive type: " + t.FriendlyName())
|
||||
}
|
||||
}
|
||||
|
@ -6,15 +6,12 @@ import (
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/mitchellh/colorstring"
|
||||
"github.com/zclconf/go-cty/cty"
|
||||
|
||||
"github.com/hashicorp/terraform/internal/plans"
|
||||
)
|
||||
|
||||
func TestRenderers(t *testing.T) {
|
||||
strptr := func(in string) *string {
|
||||
return &in
|
||||
}
|
||||
|
||||
colorize := colorstring.Colorize{
|
||||
Colors: colorstring.DefaultColors,
|
||||
Disable: true,
|
||||
@ -27,21 +24,21 @@ func TestRenderers(t *testing.T) {
|
||||
}{
|
||||
"primitive_create": {
|
||||
change: Change{
|
||||
renderer: Primitive(nil, strptr("1")),
|
||||
renderer: Primitive(nil, 1.0, cty.Number),
|
||||
action: plans.Create,
|
||||
},
|
||||
expected: "1",
|
||||
},
|
||||
"primitive_delete": {
|
||||
change: Change{
|
||||
renderer: Primitive(strptr("1"), nil),
|
||||
renderer: Primitive(1.0, nil, cty.Number),
|
||||
action: plans.Delete,
|
||||
},
|
||||
expected: "1 -> null",
|
||||
},
|
||||
"primitive_delete_override": {
|
||||
change: Change{
|
||||
renderer: Primitive(strptr("1"), nil),
|
||||
renderer: Primitive(1.0, nil, cty.Number),
|
||||
action: plans.Delete,
|
||||
},
|
||||
opts: RenderOpts{overrideNullSuffix: true},
|
||||
@ -49,28 +46,28 @@ func TestRenderers(t *testing.T) {
|
||||
},
|
||||
"primitive_update_to_null": {
|
||||
change: Change{
|
||||
renderer: Primitive(strptr("1"), nil),
|
||||
renderer: Primitive(1.0, nil, cty.Number),
|
||||
action: plans.Update,
|
||||
},
|
||||
expected: "1 -> null",
|
||||
},
|
||||
"primitive_update_from_null": {
|
||||
change: Change{
|
||||
renderer: Primitive(nil, strptr("1")),
|
||||
renderer: Primitive(nil, 1.0, cty.Number),
|
||||
action: plans.Update,
|
||||
},
|
||||
expected: "null -> 1",
|
||||
},
|
||||
"primitive_update": {
|
||||
change: Change{
|
||||
renderer: Primitive(strptr("0"), strptr("1")),
|
||||
renderer: Primitive(0.0, 1.0, cty.Number),
|
||||
action: plans.Update,
|
||||
},
|
||||
expected: "0 -> 1",
|
||||
},
|
||||
"primitive_update_replace": {
|
||||
change: Change{
|
||||
renderer: Primitive(strptr("0"), strptr("1")),
|
||||
renderer: Primitive(0.0, 1.0, cty.Number),
|
||||
action: plans.Update,
|
||||
replace: true,
|
||||
},
|
||||
@ -78,16 +75,23 @@ func TestRenderers(t *testing.T) {
|
||||
},
|
||||
"sensitive_update": {
|
||||
change: Change{
|
||||
renderer: Sensitive("0", "1", true, true),
|
||||
action: plans.Update,
|
||||
renderer: Sensitive(Change{
|
||||
renderer: Primitive(0.0, 1.0, cty.Number),
|
||||
action: plans.Update,
|
||||
}, true, true),
|
||||
action: plans.Update,
|
||||
},
|
||||
expected: "(sensitive)",
|
||||
},
|
||||
"sensitive_update_replace": {
|
||||
change: Change{
|
||||
renderer: Sensitive("0", "1", true, true),
|
||||
action: plans.Update,
|
||||
replace: true,
|
||||
renderer: Sensitive(Change{
|
||||
renderer: Primitive(0.0, 1.0, cty.Number),
|
||||
action: plans.Update,
|
||||
replace: true,
|
||||
}, true, true),
|
||||
action: plans.Update,
|
||||
replace: true,
|
||||
},
|
||||
expected: "(sensitive) # forces replacement",
|
||||
},
|
||||
@ -101,7 +105,7 @@ func TestRenderers(t *testing.T) {
|
||||
"computed_update": {
|
||||
change: Change{
|
||||
renderer: Computed(Change{
|
||||
renderer: Primitive(strptr("0"), nil),
|
||||
renderer: Primitive(0.0, nil, cty.Number),
|
||||
action: plans.Delete,
|
||||
}),
|
||||
action: plans.Update,
|
||||
@ -119,7 +123,7 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: Object(map[string]Change{
|
||||
"attribute_one": {
|
||||
renderer: Primitive(nil, strptr("0")),
|
||||
renderer: Primitive(nil, 0.0, cty.Number),
|
||||
action: plans.Create,
|
||||
},
|
||||
}),
|
||||
@ -142,7 +146,7 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: Object(map[string]Change{
|
||||
"attribute_one": {
|
||||
renderer: Primitive(strptr("0"), nil),
|
||||
renderer: Primitive(0.0, nil, cty.Number),
|
||||
action: plans.Delete,
|
||||
},
|
||||
}),
|
||||
@ -165,7 +169,7 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: NestedObject(map[string]Change{
|
||||
"attribute_one": {
|
||||
renderer: Primitive(strptr("0"), nil),
|
||||
renderer: Primitive(0.0, nil, cty.Number),
|
||||
action: plans.Delete,
|
||||
},
|
||||
}),
|
||||
@ -181,7 +185,7 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: Object(map[string]Change{
|
||||
"attribute_one": {
|
||||
renderer: Primitive(nil, strptr("0")),
|
||||
renderer: Primitive(nil, 0.0, cty.Number),
|
||||
action: plans.Create,
|
||||
},
|
||||
}),
|
||||
@ -197,7 +201,7 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: Object(map[string]Change{
|
||||
"attribute_one": {
|
||||
renderer: Primitive(strptr("0"), strptr("1")),
|
||||
renderer: Primitive(0.0, 1.0, cty.Number),
|
||||
action: plans.Update,
|
||||
},
|
||||
}),
|
||||
@ -213,7 +217,7 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: Object(map[string]Change{
|
||||
"attribute_one": {
|
||||
renderer: Primitive(strptr("0"), strptr("1")),
|
||||
renderer: Primitive(0.0, 1.0, cty.Number),
|
||||
action: plans.Update,
|
||||
},
|
||||
}),
|
||||
@ -230,7 +234,7 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: Object(map[string]Change{
|
||||
"attribute_one": {
|
||||
renderer: Primitive(strptr("0"), nil),
|
||||
renderer: Primitive(0.0, nil, cty.Number),
|
||||
action: plans.Delete,
|
||||
},
|
||||
}),
|
||||
@ -246,15 +250,15 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: Object(map[string]Change{
|
||||
"attribute_one": {
|
||||
renderer: Primitive(strptr("0"), strptr("1")),
|
||||
renderer: Primitive(0.0, 1.0, cty.Number),
|
||||
action: plans.Update,
|
||||
},
|
||||
"attribute_two": {
|
||||
renderer: Primitive(strptr("0"), strptr("0")),
|
||||
renderer: Primitive(0.0, 0.0, cty.Number),
|
||||
action: plans.NoOp,
|
||||
},
|
||||
"attribute_three": {
|
||||
renderer: Primitive(nil, strptr("1")),
|
||||
renderer: Primitive(nil, 1.0, cty.Number),
|
||||
action: plans.Create,
|
||||
},
|
||||
}),
|
||||
@ -272,8 +276,11 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: Object(map[string]Change{
|
||||
"attribute_one": {
|
||||
renderer: Sensitive(nil, 1, false, true),
|
||||
action: plans.Create,
|
||||
renderer: Sensitive(Change{
|
||||
renderer: Primitive(nil, 1.0, cty.Number),
|
||||
action: plans.Create,
|
||||
}, false, true),
|
||||
action: plans.Create,
|
||||
},
|
||||
}),
|
||||
action: plans.Update,
|
||||
@ -288,8 +295,11 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: Object(map[string]Change{
|
||||
"attribute_one": {
|
||||
renderer: Sensitive(nil, 1, false, true),
|
||||
action: plans.Update,
|
||||
renderer: Sensitive(Change{
|
||||
renderer: Primitive(0.0, 1.0, cty.Number),
|
||||
action: plans.Update,
|
||||
}, true, true),
|
||||
action: plans.Update,
|
||||
},
|
||||
}),
|
||||
action: plans.Update,
|
||||
@ -304,8 +314,11 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: Object(map[string]Change{
|
||||
"attribute_one": {
|
||||
renderer: Sensitive(nil, 1, false, true),
|
||||
action: plans.Delete,
|
||||
renderer: Sensitive(Change{
|
||||
renderer: Primitive(0.0, nil, cty.Number),
|
||||
action: plans.Delete,
|
||||
}, true, false),
|
||||
action: plans.Delete,
|
||||
},
|
||||
}),
|
||||
action: plans.Update,
|
||||
@ -337,7 +350,7 @@ func TestRenderers(t *testing.T) {
|
||||
renderer: Object(map[string]Change{
|
||||
"attribute_one": {
|
||||
renderer: Computed(Change{
|
||||
renderer: Primitive(strptr("1"), nil),
|
||||
renderer: Primitive(1.0, nil, cty.Number),
|
||||
action: plans.Delete,
|
||||
}),
|
||||
action: plans.Update,
|
||||
@ -355,15 +368,15 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: Object(map[string]Change{
|
||||
"attribute_one": {
|
||||
renderer: Primitive(strptr("1"), strptr("2")),
|
||||
renderer: Primitive(1.0, 2.0, cty.Number),
|
||||
action: plans.Update,
|
||||
},
|
||||
"attribute:two": {
|
||||
renderer: Primitive(strptr("2"), strptr("3")),
|
||||
renderer: Primitive(2.0, 3.0, cty.Number),
|
||||
action: plans.Update,
|
||||
},
|
||||
"attribute_six": {
|
||||
renderer: Primitive(strptr("3"), strptr("4")),
|
||||
renderer: Primitive(3.0, 4.0, cty.Number),
|
||||
action: plans.Update,
|
||||
},
|
||||
}),
|
||||
@ -388,7 +401,7 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: Map(map[string]Change{
|
||||
"element_one": {
|
||||
renderer: Primitive(nil, strptr("new")),
|
||||
renderer: Primitive(nil, "new", cty.String),
|
||||
action: plans.Create,
|
||||
},
|
||||
}),
|
||||
@ -396,7 +409,7 @@ func TestRenderers(t *testing.T) {
|
||||
},
|
||||
expected: `
|
||||
{
|
||||
+ "element_one" = new
|
||||
+ "element_one" = "new"
|
||||
}
|
||||
`,
|
||||
},
|
||||
@ -411,7 +424,7 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: Map(map[string]Change{
|
||||
"element_one": {
|
||||
renderer: Primitive(strptr("old"), nil),
|
||||
renderer: Primitive("old", nil, cty.String),
|
||||
action: plans.Delete,
|
||||
},
|
||||
}),
|
||||
@ -419,7 +432,7 @@ func TestRenderers(t *testing.T) {
|
||||
},
|
||||
expected: `
|
||||
{
|
||||
- "element_one" = old
|
||||
- "element_one" = "old"
|
||||
} -> null
|
||||
`,
|
||||
},
|
||||
@ -427,7 +440,7 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: Map(map[string]Change{
|
||||
"element_one": {
|
||||
renderer: Primitive(nil, strptr("new")),
|
||||
renderer: Primitive(nil, "new", cty.String),
|
||||
action: plans.Create,
|
||||
},
|
||||
}),
|
||||
@ -435,7 +448,7 @@ func TestRenderers(t *testing.T) {
|
||||
},
|
||||
expected: `
|
||||
{
|
||||
+ "element_one" = new
|
||||
+ "element_one" = "new"
|
||||
}
|
||||
`,
|
||||
},
|
||||
@ -443,7 +456,7 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: Map(map[string]Change{
|
||||
"element_one": {
|
||||
renderer: Primitive(strptr("old"), strptr("new")),
|
||||
renderer: Primitive("old", "new", cty.String),
|
||||
action: plans.Update,
|
||||
},
|
||||
}),
|
||||
@ -451,7 +464,7 @@ func TestRenderers(t *testing.T) {
|
||||
},
|
||||
expected: `
|
||||
{
|
||||
~ "element_one" = old -> new
|
||||
~ "element_one" = "old" -> "new"
|
||||
}
|
||||
`,
|
||||
},
|
||||
@ -459,7 +472,7 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: Map(map[string]Change{
|
||||
"element_one": {
|
||||
renderer: Primitive(strptr("old"), nil),
|
||||
renderer: Primitive("old", nil, cty.String),
|
||||
action: plans.Delete,
|
||||
},
|
||||
}),
|
||||
@ -467,7 +480,7 @@ func TestRenderers(t *testing.T) {
|
||||
},
|
||||
expected: `
|
||||
{
|
||||
- "element_one" = old -> null
|
||||
- "element_one" = "old" -> null
|
||||
}
|
||||
`,
|
||||
},
|
||||
@ -475,7 +488,7 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: Map(map[string]Change{
|
||||
"element_one": {
|
||||
renderer: Primitive(strptr("old"), strptr("new")),
|
||||
renderer: Primitive("old", "new", cty.String),
|
||||
action: plans.Update,
|
||||
},
|
||||
}),
|
||||
@ -484,7 +497,7 @@ func TestRenderers(t *testing.T) {
|
||||
},
|
||||
expected: `
|
||||
{ # forces replacement
|
||||
~ "element_one" = old -> new
|
||||
~ "element_one" = "old" -> "new"
|
||||
}
|
||||
`,
|
||||
},
|
||||
@ -492,15 +505,15 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: Map(map[string]Change{
|
||||
"element_one": {
|
||||
renderer: Primitive(nil, strptr("new")),
|
||||
renderer: Primitive(nil, "new", cty.String),
|
||||
action: plans.Create,
|
||||
},
|
||||
"element_two": {
|
||||
renderer: Primitive(strptr("old"), strptr("old")),
|
||||
renderer: Primitive("old", "old", cty.String),
|
||||
action: plans.NoOp,
|
||||
},
|
||||
"element_three": {
|
||||
renderer: Primitive(strptr("old"), strptr("new")),
|
||||
renderer: Primitive("old", "new", cty.String),
|
||||
action: plans.Update,
|
||||
},
|
||||
}),
|
||||
@ -508,8 +521,8 @@ func TestRenderers(t *testing.T) {
|
||||
},
|
||||
expected: `
|
||||
{
|
||||
+ "element_one" = new
|
||||
~ "element_three" = old -> new
|
||||
+ "element_one" = "new"
|
||||
~ "element_three" = "old" -> "new"
|
||||
# (1 unchanged element hidden)
|
||||
}
|
||||
`,
|
||||
@ -518,8 +531,11 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: Map(map[string]Change{
|
||||
"element_one": {
|
||||
renderer: Sensitive(nil, 1, false, true),
|
||||
action: plans.Create,
|
||||
renderer: Sensitive(Change{
|
||||
renderer: Primitive(nil, 1.0, cty.Number),
|
||||
action: plans.Create,
|
||||
}, false, true),
|
||||
action: plans.Create,
|
||||
},
|
||||
}),
|
||||
action: plans.Update,
|
||||
@ -534,8 +550,11 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: Map(map[string]Change{
|
||||
"element_one": {
|
||||
renderer: Sensitive(0, 1, true, true),
|
||||
action: plans.Update,
|
||||
renderer: Sensitive(Change{
|
||||
renderer: Primitive(0.0, 1.0, cty.Number),
|
||||
action: plans.Update,
|
||||
}, true, true),
|
||||
action: plans.Update,
|
||||
},
|
||||
}),
|
||||
action: plans.Update,
|
||||
@ -550,8 +569,11 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: Map(map[string]Change{
|
||||
"element_one": {
|
||||
renderer: Sensitive(0, 0, true, false),
|
||||
action: plans.Update,
|
||||
renderer: Sensitive(Change{
|
||||
renderer: Primitive(0.0, 0.0, cty.Number),
|
||||
action: plans.NoOp,
|
||||
}, true, false),
|
||||
action: plans.Update,
|
||||
},
|
||||
}),
|
||||
action: plans.Update,
|
||||
@ -568,8 +590,11 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: Map(map[string]Change{
|
||||
"element_one": {
|
||||
renderer: Sensitive(0, nil, true, false),
|
||||
action: plans.Delete,
|
||||
renderer: Sensitive(Change{
|
||||
renderer: Primitive(0.0, nil, cty.Number),
|
||||
action: plans.Delete,
|
||||
}, true, false),
|
||||
action: plans.Delete,
|
||||
},
|
||||
}),
|
||||
action: plans.Update,
|
||||
@ -601,7 +626,7 @@ func TestRenderers(t *testing.T) {
|
||||
renderer: Map(map[string]Change{
|
||||
"element_one": {
|
||||
renderer: Computed(Change{
|
||||
renderer: Primitive(strptr("1"), nil),
|
||||
renderer: Primitive(1.0, nil, cty.Number),
|
||||
action: plans.Delete,
|
||||
}),
|
||||
action: plans.Update,
|
||||
@ -626,7 +651,7 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: List([]Change{
|
||||
{
|
||||
renderer: Primitive(nil, strptr("1")),
|
||||
renderer: Primitive(nil, 1.0, cty.Number),
|
||||
action: plans.Create,
|
||||
},
|
||||
}),
|
||||
@ -649,7 +674,7 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: List([]Change{
|
||||
{
|
||||
renderer: Primitive(strptr("1"), nil),
|
||||
renderer: Primitive(1.0, nil, cty.Number),
|
||||
action: plans.Delete,
|
||||
},
|
||||
}),
|
||||
@ -665,7 +690,7 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: List([]Change{
|
||||
{
|
||||
renderer: Primitive(nil, strptr("1")),
|
||||
renderer: Primitive(nil, 1.0, cty.Number),
|
||||
action: plans.Create,
|
||||
},
|
||||
}),
|
||||
@ -681,7 +706,7 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: List([]Change{
|
||||
{
|
||||
renderer: Primitive(strptr("0"), strptr("1")),
|
||||
renderer: Primitive(0.0, 1.0, cty.Number),
|
||||
action: plans.Update,
|
||||
},
|
||||
}),
|
||||
@ -697,11 +722,11 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: List([]Change{
|
||||
{
|
||||
renderer: Primitive(strptr("0"), nil),
|
||||
renderer: Primitive(0.0, nil, cty.Number),
|
||||
action: plans.Delete,
|
||||
},
|
||||
{
|
||||
renderer: Primitive(nil, strptr("1")),
|
||||
renderer: Primitive(nil, 1.0, cty.Number),
|
||||
action: plans.Create,
|
||||
},
|
||||
}),
|
||||
@ -718,7 +743,7 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: List([]Change{
|
||||
{
|
||||
renderer: Primitive(strptr("0"), nil),
|
||||
renderer: Primitive(0.0, nil, cty.Number),
|
||||
action: plans.Delete,
|
||||
},
|
||||
}),
|
||||
@ -734,7 +759,7 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: List([]Change{
|
||||
{
|
||||
renderer: Primitive(strptr("0"), strptr("1")),
|
||||
renderer: Primitive(0.0, 1.0, cty.Number),
|
||||
action: plans.Update,
|
||||
},
|
||||
}),
|
||||
@ -751,23 +776,23 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: NestedList([]Change{
|
||||
{
|
||||
renderer: Primitive(strptr("0"), strptr("0")),
|
||||
renderer: Primitive(0.0, 0.0, cty.Number),
|
||||
action: plans.NoOp,
|
||||
},
|
||||
{
|
||||
renderer: Primitive(strptr("1"), strptr("1")),
|
||||
renderer: Primitive(1.0, 1.0, cty.Number),
|
||||
action: plans.NoOp,
|
||||
},
|
||||
{
|
||||
renderer: Primitive(strptr("2"), strptr("5")),
|
||||
renderer: Primitive(2.0, 5.0, cty.Number),
|
||||
action: plans.Update,
|
||||
},
|
||||
{
|
||||
renderer: Primitive(strptr("3"), strptr("3")),
|
||||
renderer: Primitive(3.0, 3.0, cty.Number),
|
||||
action: plans.NoOp,
|
||||
},
|
||||
{
|
||||
renderer: Primitive(strptr("4"), strptr("4")),
|
||||
renderer: Primitive(4.0, 4.0, cty.Number),
|
||||
action: plans.NoOp,
|
||||
},
|
||||
}),
|
||||
@ -784,23 +809,23 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: List([]Change{
|
||||
{
|
||||
renderer: Primitive(strptr("0"), strptr("0")),
|
||||
renderer: Primitive(0.0, 0.0, cty.Number),
|
||||
action: plans.NoOp,
|
||||
},
|
||||
{
|
||||
renderer: Primitive(strptr("1"), strptr("1")),
|
||||
renderer: Primitive(1.0, 1.0, cty.Number),
|
||||
action: plans.NoOp,
|
||||
},
|
||||
{
|
||||
renderer: Primitive(strptr("2"), strptr("5")),
|
||||
renderer: Primitive(2.0, 5.0, cty.Number),
|
||||
action: plans.Update,
|
||||
},
|
||||
{
|
||||
renderer: Primitive(strptr("3"), strptr("3")),
|
||||
renderer: Primitive(3.0, 3.0, cty.Number),
|
||||
action: plans.NoOp,
|
||||
},
|
||||
{
|
||||
renderer: Primitive(strptr("4"), strptr("4")),
|
||||
renderer: Primitive(4.0, 4.0, cty.Number),
|
||||
action: plans.NoOp,
|
||||
},
|
||||
}),
|
||||
@ -820,8 +845,11 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: List([]Change{
|
||||
{
|
||||
renderer: Sensitive(nil, 1, false, true),
|
||||
action: plans.Create,
|
||||
renderer: Sensitive(Change{
|
||||
renderer: Primitive(nil, 1.0, cty.Number),
|
||||
action: plans.Create,
|
||||
}, false, true),
|
||||
action: plans.Create,
|
||||
},
|
||||
}),
|
||||
action: plans.Update,
|
||||
@ -836,8 +864,11 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: List([]Change{
|
||||
{
|
||||
renderer: Sensitive(1, nil, true, false),
|
||||
action: plans.Delete,
|
||||
renderer: Sensitive(Change{
|
||||
renderer: Primitive(1.0, nil, cty.Number),
|
||||
action: plans.Delete,
|
||||
}, true, false),
|
||||
action: plans.Delete,
|
||||
},
|
||||
}),
|
||||
action: plans.Update,
|
||||
@ -852,8 +883,11 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: List([]Change{
|
||||
{
|
||||
renderer: Sensitive(nil, 1, false, true),
|
||||
action: plans.Update,
|
||||
renderer: Sensitive(Change{
|
||||
renderer: Primitive(0.0, 1.0, cty.Number),
|
||||
action: plans.Update,
|
||||
}, true, true),
|
||||
action: plans.Update,
|
||||
},
|
||||
}),
|
||||
action: plans.Update,
|
||||
@ -868,8 +902,11 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: List([]Change{
|
||||
{
|
||||
renderer: Sensitive(1, 1, false, true),
|
||||
action: plans.Update,
|
||||
renderer: Sensitive(Change{
|
||||
renderer: Primitive(1.0, 1.0, cty.Number),
|
||||
action: plans.NoOp,
|
||||
}, false, true),
|
||||
action: plans.Update,
|
||||
},
|
||||
}),
|
||||
action: plans.Update,
|
||||
@ -903,7 +940,7 @@ func TestRenderers(t *testing.T) {
|
||||
renderer: List([]Change{
|
||||
{
|
||||
renderer: Computed(Change{
|
||||
renderer: Primitive(strptr("0"), nil),
|
||||
renderer: Primitive(0.0, nil, cty.Number),
|
||||
action: plans.Delete,
|
||||
}),
|
||||
action: plans.Update,
|
||||
@ -928,7 +965,7 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: Set([]Change{
|
||||
{
|
||||
renderer: Primitive(nil, strptr("1")),
|
||||
renderer: Primitive(nil, 1.0, cty.Number),
|
||||
action: plans.Create,
|
||||
},
|
||||
}),
|
||||
@ -951,7 +988,7 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: Set([]Change{
|
||||
{
|
||||
renderer: Primitive(strptr("1"), nil),
|
||||
renderer: Primitive(1.0, nil, cty.Number),
|
||||
action: plans.Delete,
|
||||
},
|
||||
}),
|
||||
@ -967,7 +1004,7 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: Set([]Change{
|
||||
{
|
||||
renderer: Primitive(nil, strptr("1")),
|
||||
renderer: Primitive(nil, 1.0, cty.Number),
|
||||
action: plans.Create,
|
||||
},
|
||||
}),
|
||||
@ -983,7 +1020,7 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: Set([]Change{
|
||||
{
|
||||
renderer: Primitive(strptr("0"), strptr("1")),
|
||||
renderer: Primitive(0.0, 1.0, cty.Number),
|
||||
action: plans.Update,
|
||||
},
|
||||
}),
|
||||
@ -999,11 +1036,11 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: Set([]Change{
|
||||
{
|
||||
renderer: Primitive(strptr("0"), nil),
|
||||
renderer: Primitive(0.0, nil, cty.Number),
|
||||
action: plans.Delete,
|
||||
},
|
||||
{
|
||||
renderer: Primitive(nil, strptr("1")),
|
||||
renderer: Primitive(nil, 1.0, cty.Number),
|
||||
action: plans.Create,
|
||||
},
|
||||
}),
|
||||
@ -1020,7 +1057,7 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: Set([]Change{
|
||||
{
|
||||
renderer: Primitive(strptr("0"), nil),
|
||||
renderer: Primitive(0.0, nil, cty.Number),
|
||||
action: plans.Delete,
|
||||
},
|
||||
}),
|
||||
@ -1036,7 +1073,7 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: Set([]Change{
|
||||
{
|
||||
renderer: Primitive(strptr("0"), strptr("1")),
|
||||
renderer: Primitive(0.0, 1.0, cty.Number),
|
||||
action: plans.Update,
|
||||
},
|
||||
}),
|
||||
@ -1053,23 +1090,23 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: Set([]Change{
|
||||
{
|
||||
renderer: Primitive(strptr("0"), strptr("0")),
|
||||
renderer: Primitive(0.0, 0.0, cty.Number),
|
||||
action: plans.NoOp,
|
||||
},
|
||||
{
|
||||
renderer: Primitive(strptr("1"), strptr("1")),
|
||||
renderer: Primitive(1.0, 1.0, cty.Number),
|
||||
action: plans.NoOp,
|
||||
},
|
||||
{
|
||||
renderer: Primitive(strptr("2"), strptr("5")),
|
||||
renderer: Primitive(2.0, 5.0, cty.Number),
|
||||
action: plans.Update,
|
||||
},
|
||||
{
|
||||
renderer: Primitive(strptr("3"), strptr("3")),
|
||||
renderer: Primitive(3.0, 3.0, cty.Number),
|
||||
action: plans.NoOp,
|
||||
},
|
||||
{
|
||||
renderer: Primitive(strptr("4"), strptr("4")),
|
||||
renderer: Primitive(4.0, 4.0, cty.Number),
|
||||
action: plans.NoOp,
|
||||
},
|
||||
}),
|
||||
@ -1086,8 +1123,11 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: Set([]Change{
|
||||
{
|
||||
renderer: Sensitive(nil, 1, false, true),
|
||||
action: plans.Create,
|
||||
renderer: Sensitive(Change{
|
||||
renderer: Primitive(nil, 1.0, cty.Number),
|
||||
action: plans.Create,
|
||||
}, false, true),
|
||||
action: plans.Create,
|
||||
},
|
||||
}),
|
||||
action: plans.Update,
|
||||
@ -1102,8 +1142,11 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: Set([]Change{
|
||||
{
|
||||
renderer: Sensitive(1, nil, true, false),
|
||||
action: plans.Delete,
|
||||
renderer: Sensitive(Change{
|
||||
renderer: Primitive(1.0, nil, cty.Number),
|
||||
action: plans.Delete,
|
||||
}, false, true),
|
||||
action: plans.Delete,
|
||||
},
|
||||
}),
|
||||
action: plans.Update,
|
||||
@ -1118,8 +1161,11 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: Set([]Change{
|
||||
{
|
||||
renderer: Sensitive(nil, 1, false, true),
|
||||
action: plans.Update,
|
||||
renderer: Sensitive(Change{
|
||||
renderer: Primitive(0.0, 1.0, cty.Number),
|
||||
action: plans.Update,
|
||||
}, true, true),
|
||||
action: plans.Update,
|
||||
},
|
||||
}),
|
||||
action: plans.Update,
|
||||
@ -1134,8 +1180,11 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: Set([]Change{
|
||||
{
|
||||
renderer: Sensitive(1, 2, false, true),
|
||||
action: plans.Update,
|
||||
renderer: Sensitive(Change{
|
||||
renderer: Primitive(1.0, 2.0, cty.Number),
|
||||
action: plans.Update,
|
||||
}, false, true),
|
||||
action: plans.Update,
|
||||
},
|
||||
}),
|
||||
action: plans.Update,
|
||||
@ -1169,7 +1218,7 @@ func TestRenderers(t *testing.T) {
|
||||
renderer: Set([]Change{
|
||||
{
|
||||
renderer: Computed(Change{
|
||||
renderer: Primitive(strptr("0"), nil),
|
||||
renderer: Primitive(0.0, nil, cty.Number),
|
||||
action: plans.Delete,
|
||||
}),
|
||||
action: plans.Update,
|
||||
@ -1196,11 +1245,11 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: Block(map[string]Change{
|
||||
"string": {
|
||||
renderer: Primitive(nil, strptr("\"root\"")),
|
||||
renderer: Primitive(nil, "root", cty.String),
|
||||
action: plans.Create,
|
||||
},
|
||||
"boolean": {
|
||||
renderer: Primitive(nil, strptr("true")),
|
||||
renderer: Primitive(nil, true, cty.Bool),
|
||||
action: plans.Create,
|
||||
},
|
||||
}, map[string][]Change{
|
||||
@ -1208,7 +1257,7 @@ func TestRenderers(t *testing.T) {
|
||||
{
|
||||
renderer: Block(map[string]Change{
|
||||
"string": {
|
||||
renderer: Primitive(nil, strptr("\"one\"")),
|
||||
renderer: Primitive(nil, "one", cty.String),
|
||||
action: plans.Create,
|
||||
},
|
||||
}, nil),
|
||||
@ -1219,7 +1268,7 @@ func TestRenderers(t *testing.T) {
|
||||
{
|
||||
renderer: Block(map[string]Change{
|
||||
"string": {
|
||||
renderer: Primitive(nil, strptr("\"two\"")),
|
||||
renderer: Primitive(nil, "two", cty.String),
|
||||
action: plans.Create,
|
||||
},
|
||||
}, nil),
|
||||
@ -1247,11 +1296,11 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: Block(map[string]Change{
|
||||
"string": {
|
||||
renderer: Primitive(nil, strptr("\"root\"")),
|
||||
renderer: Primitive(nil, "root", cty.String),
|
||||
action: plans.Create,
|
||||
},
|
||||
"boolean": {
|
||||
renderer: Primitive(nil, strptr("true")),
|
||||
renderer: Primitive(nil, true, cty.Bool),
|
||||
action: plans.Create,
|
||||
},
|
||||
}, map[string][]Change{
|
||||
@ -1259,7 +1308,7 @@ func TestRenderers(t *testing.T) {
|
||||
{
|
||||
renderer: Block(map[string]Change{
|
||||
"string": {
|
||||
renderer: Primitive(nil, strptr("\"one\"")),
|
||||
renderer: Primitive(nil, "one", cty.String),
|
||||
action: plans.Create,
|
||||
},
|
||||
}, nil),
|
||||
@ -1270,7 +1319,7 @@ func TestRenderers(t *testing.T) {
|
||||
{
|
||||
renderer: Block(map[string]Change{
|
||||
"string": {
|
||||
renderer: Primitive(nil, strptr("\"two\"")),
|
||||
renderer: Primitive(nil, "two", cty.String),
|
||||
action: plans.Create,
|
||||
},
|
||||
}, nil),
|
||||
@ -1298,11 +1347,11 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: Block(map[string]Change{
|
||||
"string": {
|
||||
renderer: Primitive(nil, strptr("\"root\"")),
|
||||
renderer: Primitive(nil, "root", cty.String),
|
||||
action: plans.Create,
|
||||
},
|
||||
"boolean": {
|
||||
renderer: Primitive(strptr("false"), strptr("true")),
|
||||
renderer: Primitive(false, true, cty.Bool),
|
||||
action: plans.Update,
|
||||
},
|
||||
}, map[string][]Change{
|
||||
@ -1310,7 +1359,7 @@ func TestRenderers(t *testing.T) {
|
||||
{
|
||||
renderer: Block(map[string]Change{
|
||||
"string": {
|
||||
renderer: Primitive(nil, strptr("\"one\"")),
|
||||
renderer: Primitive(nil, "one", cty.String),
|
||||
action: plans.NoOp,
|
||||
},
|
||||
}, nil),
|
||||
@ -1321,7 +1370,7 @@ func TestRenderers(t *testing.T) {
|
||||
{
|
||||
renderer: Block(map[string]Change{
|
||||
"string": {
|
||||
renderer: Primitive(nil, strptr("\"two\"")),
|
||||
renderer: Primitive(nil, "two", cty.String),
|
||||
action: plans.Create,
|
||||
},
|
||||
}, nil),
|
||||
@ -1346,11 +1395,11 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: Block(map[string]Change{
|
||||
"string": {
|
||||
renderer: Primitive(strptr("\"root\""), nil),
|
||||
renderer: Primitive("root", nil, cty.String),
|
||||
action: plans.Delete,
|
||||
},
|
||||
"boolean": {
|
||||
renderer: Primitive(strptr("true"), nil),
|
||||
renderer: Primitive(true, nil, cty.Bool),
|
||||
action: plans.Delete,
|
||||
},
|
||||
}, map[string][]Change{
|
||||
@ -1358,7 +1407,7 @@ func TestRenderers(t *testing.T) {
|
||||
{
|
||||
renderer: Block(map[string]Change{
|
||||
"string": {
|
||||
renderer: Primitive(strptr("\"one\""), nil),
|
||||
renderer: Primitive("one", nil, cty.String),
|
||||
action: plans.Delete,
|
||||
},
|
||||
}, nil),
|
||||
@ -1369,7 +1418,7 @@ func TestRenderers(t *testing.T) {
|
||||
{
|
||||
renderer: Block(map[string]Change{
|
||||
"string": {
|
||||
renderer: Primitive(strptr("\"two\""), nil),
|
||||
renderer: Primitive("two", nil, cty.String),
|
||||
action: plans.Delete,
|
||||
},
|
||||
}, nil),
|
||||
@ -1397,11 +1446,11 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: Block(map[string]Change{
|
||||
"string": {
|
||||
renderer: Primitive(strptr("\"root\""), nil),
|
||||
renderer: Primitive("root", nil, cty.String),
|
||||
action: plans.Delete,
|
||||
},
|
||||
"boolean": {
|
||||
renderer: Primitive(strptr("true"), nil),
|
||||
renderer: Primitive(true, nil, cty.Bool),
|
||||
action: plans.Delete,
|
||||
},
|
||||
}, map[string][]Change{
|
||||
@ -1409,7 +1458,7 @@ func TestRenderers(t *testing.T) {
|
||||
{
|
||||
renderer: Block(map[string]Change{
|
||||
"string": {
|
||||
renderer: Primitive(strptr("\"one\""), nil),
|
||||
renderer: Primitive("one", nil, cty.String),
|
||||
action: plans.Delete,
|
||||
},
|
||||
}, nil),
|
||||
@ -1420,7 +1469,7 @@ func TestRenderers(t *testing.T) {
|
||||
{
|
||||
renderer: Block(map[string]Change{
|
||||
"string": {
|
||||
renderer: Primitive(strptr("\"two\""), nil),
|
||||
renderer: Primitive("two", nil, cty.String),
|
||||
action: plans.Delete,
|
||||
},
|
||||
}, nil),
|
||||
@ -1457,15 +1506,15 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: Block(map[string]Change{
|
||||
"attribute_one": {
|
||||
renderer: Primitive(strptr("1"), strptr("2")),
|
||||
renderer: Primitive(1.0, 2.0, cty.Number),
|
||||
action: plans.Update,
|
||||
},
|
||||
"attribute:two": {
|
||||
renderer: Primitive(strptr("2"), strptr("3")),
|
||||
renderer: Primitive(2.0, 3.0, cty.Number),
|
||||
action: plans.Update,
|
||||
},
|
||||
"attribute_six": {
|
||||
renderer: Primitive(strptr("3"), strptr("4")),
|
||||
renderer: Primitive(3.0, 4.0, cty.Number),
|
||||
action: plans.Update,
|
||||
},
|
||||
}, map[string][]Change{
|
||||
@ -1473,7 +1522,7 @@ func TestRenderers(t *testing.T) {
|
||||
{
|
||||
renderer: Block(map[string]Change{
|
||||
"string": {
|
||||
renderer: Primitive(strptr("\"one\""), strptr("\"four\"")),
|
||||
renderer: Primitive("one", "four", cty.String),
|
||||
action: plans.Update,
|
||||
},
|
||||
}, nil),
|
||||
@ -1484,7 +1533,7 @@ func TestRenderers(t *testing.T) {
|
||||
{
|
||||
renderer: Block(map[string]Change{
|
||||
"string": {
|
||||
renderer: Primitive(strptr("\"two\""), strptr("\"three\"")),
|
||||
renderer: Primitive("two", "three", cty.String),
|
||||
action: plans.Update,
|
||||
},
|
||||
}, nil),
|
||||
@ -1513,11 +1562,11 @@ func TestRenderers(t *testing.T) {
|
||||
change: Change{
|
||||
renderer: Block(map[string]Change{
|
||||
"id": {
|
||||
renderer: Primitive(strptr("\"root\""), strptr("\"root\"")),
|
||||
renderer: Primitive("root", "root", cty.String),
|
||||
action: plans.NoOp,
|
||||
},
|
||||
"boolean": {
|
||||
renderer: Primitive(strptr("false"), strptr("false")),
|
||||
renderer: Primitive(false, false, cty.Bool),
|
||||
action: plans.NoOp,
|
||||
},
|
||||
}, map[string][]Change{
|
||||
@ -1525,7 +1574,7 @@ func TestRenderers(t *testing.T) {
|
||||
{
|
||||
renderer: Block(map[string]Change{
|
||||
"string": {
|
||||
renderer: Primitive(strptr("\"one\""), strptr("\"one\"")),
|
||||
renderer: Primitive("one", "one", cty.String),
|
||||
action: plans.NoOp,
|
||||
},
|
||||
}, nil),
|
||||
@ -1536,7 +1585,7 @@ func TestRenderers(t *testing.T) {
|
||||
{
|
||||
renderer: Block(map[string]Change{
|
||||
"string": {
|
||||
renderer: Primitive(strptr("\"two\""), strptr("\"two\"")),
|
||||
renderer: Primitive("two", "two", cty.String),
|
||||
action: plans.NoOp,
|
||||
},
|
||||
}, nil),
|
||||
@ -1558,11 +1607,11 @@ func TestRenderers(t *testing.T) {
|
||||
renderer: TypeChange(Change{
|
||||
renderer: Map(map[string]Change{
|
||||
"element_one": {
|
||||
renderer: Primitive(strptr("0"), nil),
|
||||
renderer: Primitive(0.0, nil, cty.Number),
|
||||
action: plans.Delete,
|
||||
},
|
||||
"element_two": {
|
||||
renderer: Primitive(strptr("1"), nil),
|
||||
renderer: Primitive(1.0, nil, cty.Number),
|
||||
action: plans.Delete,
|
||||
},
|
||||
}),
|
||||
@ -1570,11 +1619,11 @@ func TestRenderers(t *testing.T) {
|
||||
}, Change{
|
||||
renderer: List([]Change{
|
||||
{
|
||||
renderer: Primitive(nil, strptr("0")),
|
||||
renderer: Primitive(nil, 0.0, cty.Number),
|
||||
action: plans.Create,
|
||||
},
|
||||
{
|
||||
renderer: Primitive(nil, strptr("1")),
|
||||
renderer: Primitive(nil, 1.0, cty.Number),
|
||||
action: plans.Create,
|
||||
},
|
||||
}),
|
||||
|
@ -2,21 +2,20 @@ package change
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
|
||||
"github.com/hashicorp/terraform/internal/plans"
|
||||
)
|
||||
|
||||
func Sensitive(before, after interface{}, beforeSensitive, afterSensitive bool) Renderer {
|
||||
func Sensitive(change Change, beforeSensitive, afterSensitive bool) Renderer {
|
||||
return &sensitiveRenderer{
|
||||
before: before,
|
||||
after: after,
|
||||
change: change,
|
||||
beforeSensitive: beforeSensitive,
|
||||
afterSensitive: afterSensitive,
|
||||
}
|
||||
}
|
||||
|
||||
type sensitiveRenderer struct {
|
||||
before interface{}
|
||||
after interface{}
|
||||
change Change
|
||||
|
||||
beforeSensitive bool
|
||||
afterSensitive bool
|
||||
@ -27,7 +26,7 @@ func (renderer sensitiveRenderer) Render(change Change, indent int, opts RenderO
|
||||
}
|
||||
|
||||
func (renderer sensitiveRenderer) Warnings(change Change, indent int) []string {
|
||||
if (renderer.beforeSensitive == renderer.afterSensitive) || renderer.before == nil || renderer.after == nil {
|
||||
if (renderer.beforeSensitive == renderer.afterSensitive) || renderer.change.action == plans.Create || renderer.change.action == plans.Delete {
|
||||
// Only display warnings for sensitive values if they are changing from
|
||||
// being sensitive or to being sensitive and if they are not being
|
||||
// destroyed or created.
|
||||
@ -41,7 +40,7 @@ func (renderer sensitiveRenderer) Warnings(change Change, indent int) []string {
|
||||
warning = fmt.Sprintf(" # [yellow]Warning[reset]: this attribute value will be marked as sensitive and will not\n%s # display in UI output after applying this change.", change.indent(indent))
|
||||
}
|
||||
|
||||
if reflect.DeepEqual(renderer.before, renderer.after) {
|
||||
if renderer.change.action == plans.NoOp {
|
||||
return []string{fmt.Sprintf("%s The value is unchanged.", warning)}
|
||||
}
|
||||
return []string{warning}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package change
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"sort"
|
||||
"testing"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
@ -13,24 +13,25 @@ type ValidateChangeFunc func(t *testing.T, change Change)
|
||||
|
||||
func validateChange(t *testing.T, change Change, expectedAction plans.Action, expectedReplace bool) {
|
||||
if change.replace != expectedReplace || change.action != expectedAction {
|
||||
t.Fatalf("\nreplace:\n\texpected:%t\n\tactual:%t\naction:\n\texpected:%s\n\tactual:%s", expectedReplace, change.replace, expectedAction, change.action)
|
||||
t.Errorf("\nreplace:\n\texpected:%t\n\tactual:%t\naction:\n\texpected:%s\n\tactual:%s", expectedReplace, change.replace, expectedAction, change.action)
|
||||
}
|
||||
}
|
||||
|
||||
func ValidatePrimitive(before, after *string, action plans.Action, replace bool) ValidateChangeFunc {
|
||||
func ValidatePrimitive(before, after interface{}, action plans.Action, replace bool) ValidateChangeFunc {
|
||||
return func(t *testing.T, change Change) {
|
||||
validateChange(t, change, action, replace)
|
||||
|
||||
primitive, ok := change.renderer.(*primitiveRenderer)
|
||||
if !ok {
|
||||
t.Fatalf("invalid renderer type: %T", change.renderer)
|
||||
t.Errorf("invalid renderer type: %T", change.renderer)
|
||||
return
|
||||
}
|
||||
|
||||
beforeDiff := cmp.Diff(primitive.before, before)
|
||||
afterDiff := cmp.Diff(primitive.after, after)
|
||||
|
||||
if len(beforeDiff) > 0 || len(afterDiff) > 0 {
|
||||
t.Fatalf("before diff: (%s), after diff: (%s)", beforeDiff, afterDiff)
|
||||
t.Errorf("before diff: (%s), after diff: (%s)", beforeDiff, afterDiff)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -41,14 +42,15 @@ func ValidateObject(attributes map[string]ValidateChangeFunc, action plans.Actio
|
||||
|
||||
object, ok := change.renderer.(*objectRenderer)
|
||||
if !ok {
|
||||
t.Fatalf("invalid renderer type: %T", change.renderer)
|
||||
t.Errorf("invalid renderer type: %T", change.renderer)
|
||||
return
|
||||
}
|
||||
|
||||
if !object.overrideNullSuffix {
|
||||
t.Fatalf("created the wrong type of object renderer")
|
||||
t.Errorf("created the wrong type of object renderer")
|
||||
}
|
||||
|
||||
validateObject(t, object, attributes)
|
||||
validateMapType(t, object.attributes, attributes)
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,38 +60,15 @@ func ValidateNestedObject(attributes map[string]ValidateChangeFunc, action plans
|
||||
|
||||
object, ok := change.renderer.(*objectRenderer)
|
||||
if !ok {
|
||||
t.Fatalf("invalid renderer type: %T", change.renderer)
|
||||
t.Errorf("invalid renderer type: %T", change.renderer)
|
||||
return
|
||||
}
|
||||
|
||||
if object.overrideNullSuffix {
|
||||
t.Fatalf("created the wrong type of object renderer")
|
||||
t.Errorf("created the wrong type of object renderer")
|
||||
}
|
||||
|
||||
validateObject(t, object, attributes)
|
||||
}
|
||||
}
|
||||
|
||||
func validateObject(t *testing.T, object *objectRenderer, attributes map[string]ValidateChangeFunc) {
|
||||
if len(object.attributes) != len(attributes) {
|
||||
t.Fatalf("expected %d attributes but found %d attributes", len(attributes), len(object.attributes))
|
||||
}
|
||||
|
||||
var missing []string
|
||||
for key, expected := range attributes {
|
||||
actual, ok := object.attributes[key]
|
||||
if !ok {
|
||||
missing = append(missing, key)
|
||||
}
|
||||
|
||||
if len(missing) > 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
expected(t, actual)
|
||||
}
|
||||
|
||||
if len(missing) > 0 {
|
||||
t.Fatalf("missing the following attributes: %s", strings.Join(missing, ", "))
|
||||
validateMapType(t, object.attributes, attributes)
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,29 +78,42 @@ func ValidateMap(elements map[string]ValidateChangeFunc, action plans.Action, re
|
||||
|
||||
m, ok := change.renderer.(*mapRenderer)
|
||||
if !ok {
|
||||
t.Fatalf("invalid renderer type: %T", change.renderer)
|
||||
t.Errorf("invalid renderer type: %T", change.renderer)
|
||||
return
|
||||
}
|
||||
|
||||
if len(m.elements) != len(elements) {
|
||||
t.Fatalf("expected %d elements but found %d elements", len(elements), len(m.elements))
|
||||
}
|
||||
validateMapType(t, m.elements, elements)
|
||||
}
|
||||
}
|
||||
|
||||
var missing []string
|
||||
for key, expected := range elements {
|
||||
actual, ok := m.elements[key]
|
||||
if !ok {
|
||||
missing = append(missing, key)
|
||||
}
|
||||
|
||||
if len(missing) > 0 {
|
||||
continue
|
||||
}
|
||||
func validateMapType(t *testing.T, actual map[string]Change, expected map[string]ValidateChangeFunc) {
|
||||
validateKeys(t, actual, expected)
|
||||
|
||||
for key, expected := range expected {
|
||||
if actual, ok := actual[key]; ok {
|
||||
expected(t, actual)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(missing) > 0 {
|
||||
t.Fatalf("missing the following elements: %s", strings.Join(missing, ", "))
|
||||
func validateKeys[C, V any](t *testing.T, actual map[string]C, expected map[string]V) {
|
||||
if len(actual) != len(expected) {
|
||||
|
||||
var actualAttributes []string
|
||||
var expectedAttributes []string
|
||||
|
||||
for key := range actual {
|
||||
actualAttributes = append(actualAttributes, key)
|
||||
}
|
||||
for key := range expected {
|
||||
expectedAttributes = append(expectedAttributes, key)
|
||||
}
|
||||
|
||||
sort.Strings(actualAttributes)
|
||||
sort.Strings(expectedAttributes)
|
||||
|
||||
if diff := cmp.Diff(actualAttributes, expectedAttributes); len(diff) > 0 {
|
||||
t.Errorf("actual and expected attributes did not match: %s", diff)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -132,14 +124,15 @@ func ValidateList(elements []ValidateChangeFunc, action plans.Action, replace bo
|
||||
|
||||
list, ok := change.renderer.(*listRenderer)
|
||||
if !ok {
|
||||
t.Fatalf("invalid renderer type: %T", change.renderer)
|
||||
t.Errorf("invalid renderer type: %T", change.renderer)
|
||||
return
|
||||
}
|
||||
|
||||
if !list.displayContext {
|
||||
t.Fatalf("created the wrong type of list renderer")
|
||||
t.Errorf("created the wrong type of list renderer")
|
||||
}
|
||||
|
||||
validateList(t, list, elements)
|
||||
validateSliceType(t, list.elements, elements)
|
||||
}
|
||||
}
|
||||
|
||||
@ -149,24 +142,15 @@ func ValidateNestedList(elements []ValidateChangeFunc, action plans.Action, repl
|
||||
|
||||
list, ok := change.renderer.(*listRenderer)
|
||||
if !ok {
|
||||
t.Fatalf("invalid renderer type: %T", change.renderer)
|
||||
t.Errorf("invalid renderer type: %T", change.renderer)
|
||||
return
|
||||
}
|
||||
|
||||
if list.displayContext {
|
||||
t.Fatalf("created the wrong type of list renderer")
|
||||
t.Errorf("created the wrong type of list renderer")
|
||||
}
|
||||
|
||||
validateList(t, list, elements)
|
||||
}
|
||||
}
|
||||
|
||||
func validateList(t *testing.T, list *listRenderer, elements []ValidateChangeFunc) {
|
||||
if len(list.elements) != len(elements) {
|
||||
t.Fatalf("expected %d elements but found %d elements", len(elements), len(list.elements))
|
||||
}
|
||||
|
||||
for ix := 0; ix < len(elements); ix++ {
|
||||
elements[ix](t, list.elements[ix])
|
||||
validateSliceType(t, list.elements, elements)
|
||||
}
|
||||
}
|
||||
|
||||
@ -176,16 +160,22 @@ func ValidateSet(elements []ValidateChangeFunc, action plans.Action, replace boo
|
||||
|
||||
set, ok := change.renderer.(*setRenderer)
|
||||
if !ok {
|
||||
t.Fatalf("invalid renderer type: %T", change.renderer)
|
||||
t.Errorf("invalid renderer type: %T", change.renderer)
|
||||
return
|
||||
}
|
||||
|
||||
if len(set.elements) != len(elements) {
|
||||
t.Fatalf("expected %d elements but found %d elements", len(elements), len(set.elements))
|
||||
}
|
||||
validateSliceType(t, set.elements, elements)
|
||||
}
|
||||
}
|
||||
|
||||
for ix := 0; ix < len(elements); ix++ {
|
||||
elements[ix](t, set.elements[ix])
|
||||
}
|
||||
func validateSliceType(t *testing.T, actual []Change, expected []ValidateChangeFunc) {
|
||||
if len(actual) != len(expected) {
|
||||
t.Errorf("expected %d elements but found %d elements", len(expected), len(actual))
|
||||
return
|
||||
}
|
||||
|
||||
for ix := 0; ix < len(expected); ix++ {
|
||||
expected[ix](t, actual[ix])
|
||||
}
|
||||
}
|
||||
|
||||
@ -195,50 +185,29 @@ func ValidateBlock(attributes map[string]ValidateChangeFunc, blocks map[string][
|
||||
|
||||
block, ok := change.renderer.(*blockRenderer)
|
||||
if !ok {
|
||||
t.Fatalf("invalid renderer type: %T", change.renderer)
|
||||
t.Errorf("invalid renderer type: %T", change.renderer)
|
||||
return
|
||||
}
|
||||
|
||||
if len(block.attributes) != len(attributes) || len(block.blocks) != len(blocks) {
|
||||
t.Fatalf("expected %d attributes and %d blocks but found %d attributes and %d blocks", len(attributes), len(blocks), len(block.attributes), len(block.blocks))
|
||||
}
|
||||
|
||||
var missingAttributes []string
|
||||
var missingBlocks []string
|
||||
validateKeys(t, block.attributes, attributes)
|
||||
validateKeys(t, block.blocks, blocks)
|
||||
|
||||
for key, expected := range attributes {
|
||||
actual, ok := block.attributes[key]
|
||||
if !ok {
|
||||
missingAttributes = append(missingAttributes, key)
|
||||
if actual, ok := block.attributes[key]; ok {
|
||||
expected(t, actual)
|
||||
}
|
||||
|
||||
if len(missingAttributes) > 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
expected(t, actual)
|
||||
}
|
||||
|
||||
for key, expected := range blocks {
|
||||
actual, ok := block.blocks[key]
|
||||
if !ok {
|
||||
missingBlocks = append(missingBlocks, key)
|
||||
}
|
||||
if actual, ok := block.blocks[key]; ok {
|
||||
if len(actual) != len(expected) {
|
||||
t.Errorf("expected %d blocks within %s but found %d elements", len(expected), key, len(actual))
|
||||
|
||||
if len(missingAttributes) > 0 || len(missingBlocks) > 0 {
|
||||
continue
|
||||
for ix := range expected {
|
||||
expected[ix](t, actual[ix])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(expected) != len(actual) {
|
||||
t.Fatalf("expected %d blocks for %s but found %d", len(expected), key, len(actual))
|
||||
}
|
||||
|
||||
for ix := range expected {
|
||||
expected[ix](t, actual[ix])
|
||||
}
|
||||
}
|
||||
|
||||
if len(missingAttributes) > 0 || len(missingBlocks) > 0 {
|
||||
t.Fatalf("missing the following attributes: %s, and the following blocks: %s", strings.Join(missingAttributes, ", "), strings.Join(missingBlocks, ", "))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -249,7 +218,8 @@ func ValidateTypeChange(before, after ValidateChangeFunc, action plans.Action, r
|
||||
|
||||
typeChange, ok := change.renderer.(*typeChangeRenderer)
|
||||
if !ok {
|
||||
t.Fatalf("invalid renderer type: %T", change.renderer)
|
||||
t.Errorf("invalid renderer type: %T", change.renderer)
|
||||
return
|
||||
}
|
||||
|
||||
before(t, typeChange.before)
|
||||
@ -257,25 +227,21 @@ func ValidateTypeChange(before, after ValidateChangeFunc, action plans.Action, r
|
||||
}
|
||||
}
|
||||
|
||||
func ValidateSensitive(before, after interface{}, beforeSensitive, afterSensitive bool, action plans.Action, replace bool) ValidateChangeFunc {
|
||||
func ValidateSensitive(inner ValidateChangeFunc, beforeSensitive, afterSensitive bool, action plans.Action, replace bool) ValidateChangeFunc {
|
||||
return func(t *testing.T, change Change) {
|
||||
validateChange(t, change, action, replace)
|
||||
|
||||
sensitive, ok := change.renderer.(*sensitiveRenderer)
|
||||
if !ok {
|
||||
t.Fatalf("invalid renderer type: %T", change.renderer)
|
||||
t.Errorf("invalid renderer type: %T", change.renderer)
|
||||
return
|
||||
}
|
||||
|
||||
if beforeSensitive != sensitive.beforeSensitive || afterSensitive != sensitive.afterSensitive {
|
||||
t.Fatalf("before or after sensitive values don't match:\n\texpected; before: %t after: %t\n\tactual; before: %t, after: %t", beforeSensitive, afterSensitive, sensitive.beforeSensitive, sensitive.afterSensitive)
|
||||
t.Errorf("before or after sensitive values don't match:\n\texpected; before: %t after: %t\n\tactual; before: %t, after: %t", beforeSensitive, afterSensitive, sensitive.beforeSensitive, sensitive.afterSensitive)
|
||||
}
|
||||
|
||||
beforeDiff := cmp.Diff(sensitive.before, before)
|
||||
afterDiff := cmp.Diff(sensitive.after, after)
|
||||
|
||||
if len(beforeDiff) > 0 || len(afterDiff) > 0 {
|
||||
t.Fatalf("before diff: (%s), after diff: (%s)", beforeDiff, afterDiff)
|
||||
}
|
||||
inner(t, sensitive.change)
|
||||
}
|
||||
}
|
||||
|
||||
@ -285,18 +251,19 @@ func ValidateComputed(before ValidateChangeFunc, action plans.Action, replace bo
|
||||
|
||||
computed, ok := change.renderer.(*computedRenderer)
|
||||
if !ok {
|
||||
t.Fatalf("invalid renderer type: %T", change.renderer)
|
||||
t.Errorf("invalid renderer type: %T", change.renderer)
|
||||
return
|
||||
}
|
||||
|
||||
if before == nil {
|
||||
if computed.before.renderer != nil {
|
||||
t.Fatalf("did not expect a before renderer, but found one")
|
||||
t.Errorf("did not expect a before renderer, but found one")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if computed.before.renderer == nil {
|
||||
t.Fatalf("expected a before renderer, but found none")
|
||||
t.Errorf("expected a before renderer, but found none")
|
||||
}
|
||||
|
||||
before(t, computed.before)
|
||||
|
@ -16,7 +16,7 @@ func (v Value) ComputeChangeForAttribute(attribute *jsonprovider.Attribute) chan
|
||||
}
|
||||
|
||||
func (v Value) computeChangeForNestedAttribute(nested *jsonprovider.NestedType) change.Change {
|
||||
if sensitive, ok := v.checkForSensitive(); ok {
|
||||
if sensitive, ok := v.checkForSensitiveNestedAttribute(nested); ok {
|
||||
return sensitive
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ func (v Value) computeChangeForNestedAttribute(nested *jsonprovider.NestedType)
|
||||
}
|
||||
|
||||
func (v Value) computeChangeForType(ctype cty.Type) change.Change {
|
||||
if sensitive, ok := v.checkForSensitive(); ok {
|
||||
if sensitive, ok := v.checkForSensitiveType(ctype); ok {
|
||||
return sensitive
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
)
|
||||
|
||||
func (v Value) ComputeChangeForBlock(block *jsonprovider.Block) change.Change {
|
||||
if sensitive, ok := v.checkForSensitive(); ok {
|
||||
if sensitive, ok := v.checkForSensitiveBlock(block); ok {
|
||||
return sensitive
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func (v Value) ComputeChangeForOutput() change.Change {
|
||||
if sensitive, ok := v.checkForSensitive(); ok {
|
||||
if sensitive, ok := v.checkForSensitiveType(cty.DynamicPseudoType); ok {
|
||||
return sensitive
|
||||
}
|
||||
|
||||
|
@ -1,37 +1,11 @@
|
||||
package differ
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/zclconf/go-cty/cty"
|
||||
|
||||
"github.com/hashicorp/terraform/internal/command/jsonformat/change"
|
||||
)
|
||||
|
||||
func strptr(str string) *string {
|
||||
return &str
|
||||
}
|
||||
|
||||
func (v Value) computeAttributeChangeAsPrimitive(ctype cty.Type) change.Change {
|
||||
return v.asChange(change.Primitive(formatAsPrimitive(v.Before, ctype), formatAsPrimitive(v.After, ctype)))
|
||||
}
|
||||
|
||||
func formatAsPrimitive(value interface{}, ctyType cty.Type) *string {
|
||||
if value == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
switch {
|
||||
case ctyType == cty.String:
|
||||
return strptr(fmt.Sprintf("\"%s\"", value))
|
||||
case ctyType == cty.Bool:
|
||||
if value.(bool) {
|
||||
return strptr("true")
|
||||
}
|
||||
return strptr("false")
|
||||
case ctyType == cty.Number:
|
||||
return strptr(fmt.Sprintf("%g", value))
|
||||
default:
|
||||
panic("unrecognized primitive type: " + ctyType.FriendlyName())
|
||||
}
|
||||
return v.asChange(change.Primitive(v.Before, v.After, ctype))
|
||||
}
|
||||
|
@ -1,8 +1,31 @@
|
||||
package differ
|
||||
|
||||
import "github.com/hashicorp/terraform/internal/command/jsonformat/change"
|
||||
import (
|
||||
"github.com/zclconf/go-cty/cty"
|
||||
|
||||
func (v Value) checkForSensitive() (change.Change, bool) {
|
||||
"github.com/hashicorp/terraform/internal/command/jsonformat/change"
|
||||
"github.com/hashicorp/terraform/internal/command/jsonprovider"
|
||||
)
|
||||
|
||||
func (v Value) checkForSensitiveType(ctype cty.Type) (change.Change, bool) {
|
||||
return v.checkForSensitive(func(value Value) change.Change {
|
||||
return value.computeChangeForType(ctype)
|
||||
})
|
||||
}
|
||||
|
||||
func (v Value) checkForSensitiveNestedAttribute(attribute *jsonprovider.NestedType) (change.Change, bool) {
|
||||
return v.checkForSensitive(func(value Value) change.Change {
|
||||
return value.computeChangeForNestedAttribute(attribute)
|
||||
})
|
||||
}
|
||||
|
||||
func (v Value) checkForSensitiveBlock(block *jsonprovider.Block) (change.Change, bool) {
|
||||
return v.checkForSensitive(func(value Value) change.Change {
|
||||
return value.ComputeChangeForBlock(block)
|
||||
})
|
||||
}
|
||||
|
||||
func (v Value) checkForSensitive(computeChange func(value Value) change.Change) (change.Change, bool) {
|
||||
beforeSensitive := v.isBeforeSensitive()
|
||||
afterSensitive := v.isAfterSensitive()
|
||||
|
||||
@ -10,7 +33,27 @@ func (v Value) checkForSensitive() (change.Change, bool) {
|
||||
return change.Change{}, false
|
||||
}
|
||||
|
||||
return v.asChange(change.Sensitive(v.Before, v.After, beforeSensitive, afterSensitive)), true
|
||||
// We are still going to give the change the contents of the actual change.
|
||||
// So we create a new Value with everything matching the current value,
|
||||
// except for the sensitivity.
|
||||
//
|
||||
// The change can choose what to do with this information, in most cases
|
||||
// it will just be ignored in favour of printing `(sensitive value)`.
|
||||
|
||||
value := Value{
|
||||
BeforeExplicit: v.BeforeExplicit,
|
||||
AfterExplicit: v.AfterExplicit,
|
||||
Before: v.Before,
|
||||
After: v.After,
|
||||
Unknown: v.Unknown,
|
||||
BeforeSensitive: false,
|
||||
AfterSensitive: false,
|
||||
ReplacePaths: v.ReplacePaths,
|
||||
}
|
||||
|
||||
inner := computeChange(value)
|
||||
|
||||
return change.New(change.Sensitive(inner, beforeSensitive, afterSensitive), inner.Action(), v.replacePath()), true
|
||||
}
|
||||
|
||||
func (v Value) isBeforeSensitive() bool {
|
||||
|
@ -64,7 +64,7 @@ func TestValue_ObjectAttributes(t *testing.T) {
|
||||
"attribute_one": cty.String,
|
||||
},
|
||||
validateChanges: map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidatePrimitive(nil, strptr("\"new\""), plans.Create, false),
|
||||
"attribute_one": change.ValidatePrimitive(nil, "new", plans.Create, false),
|
||||
},
|
||||
validateAction: plans.Create,
|
||||
validateReplace: false,
|
||||
@ -80,7 +80,7 @@ func TestValue_ObjectAttributes(t *testing.T) {
|
||||
"attribute_one": cty.String,
|
||||
},
|
||||
validateChanges: map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidatePrimitive(strptr("\"old\""), nil, plans.Delete, false),
|
||||
"attribute_one": change.ValidatePrimitive("old", nil, plans.Delete, false),
|
||||
},
|
||||
validateAction: plans.Delete,
|
||||
validateReplace: false,
|
||||
@ -96,9 +96,20 @@ func TestValue_ObjectAttributes(t *testing.T) {
|
||||
attributes: map[string]cty.Type{
|
||||
"attribute_one": cty.String,
|
||||
},
|
||||
validateSingleChange: change.ValidateSensitive(nil, map[string]interface{}{
|
||||
"attribute_one": "new",
|
||||
}, false, true, plans.Create, false),
|
||||
validateSingleChange: change.ValidateSensitive(change.ValidateObject(map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidatePrimitive(nil, "new", plans.Create, false),
|
||||
}, plans.Create, false),
|
||||
false,
|
||||
true,
|
||||
plans.Create,
|
||||
false),
|
||||
validateNestedObject: change.ValidateSensitive(change.ValidateNestedObject(map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidatePrimitive(nil, "new", plans.Create, false),
|
||||
}, plans.Create, false),
|
||||
false,
|
||||
true,
|
||||
plans.Create,
|
||||
false),
|
||||
},
|
||||
"delete_sensitive": {
|
||||
input: Value{
|
||||
@ -111,9 +122,12 @@ func TestValue_ObjectAttributes(t *testing.T) {
|
||||
attributes: map[string]cty.Type{
|
||||
"attribute_one": cty.String,
|
||||
},
|
||||
validateSingleChange: change.ValidateSensitive(map[string]interface{}{
|
||||
"attribute_one": "old",
|
||||
}, nil, true, false, plans.Delete, false),
|
||||
validateSingleChange: change.ValidateSensitive(change.ValidateObject(map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidatePrimitive("old", nil, plans.Delete, false),
|
||||
}, plans.Delete, false), true, false, plans.Delete, false),
|
||||
validateNestedObject: change.ValidateSensitive(change.ValidateNestedObject(map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidatePrimitive("old", nil, plans.Delete, false),
|
||||
}, plans.Delete, false), true, false, plans.Delete, false),
|
||||
},
|
||||
"create_unknown": {
|
||||
input: Value{
|
||||
@ -138,15 +152,15 @@ func TestValue_ObjectAttributes(t *testing.T) {
|
||||
"attribute_one": cty.String,
|
||||
},
|
||||
validateObject: change.ValidateComputed(change.ValidateObject(map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidatePrimitive(strptr("\"old\""), nil, plans.Delete, false),
|
||||
"attribute_one": change.ValidatePrimitive("old", nil, plans.Delete, false),
|
||||
}, plans.Delete, false), plans.Update, false),
|
||||
validateNestedObject: change.ValidateComputed(change.ValidateNestedObject(map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidatePrimitive(strptr("\"old\""), nil, plans.Delete, false),
|
||||
"attribute_one": change.ValidatePrimitive("old", nil, plans.Delete, false),
|
||||
}, plans.Delete, false), plans.Update, false),
|
||||
validateSetChanges: &SetChange{
|
||||
Before: SetChangeEntry{
|
||||
ObjectChange: map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidatePrimitive(strptr("\"old\""), nil, plans.Delete, false),
|
||||
"attribute_one": change.ValidatePrimitive("old", nil, plans.Delete, false),
|
||||
},
|
||||
Action: plans.Delete,
|
||||
Replace: false,
|
||||
@ -167,7 +181,7 @@ func TestValue_ObjectAttributes(t *testing.T) {
|
||||
"attribute_one": cty.String,
|
||||
},
|
||||
validateChanges: map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidatePrimitive(nil, strptr("\"new\""), plans.Create, false),
|
||||
"attribute_one": change.ValidatePrimitive(nil, "new", plans.Create, false),
|
||||
},
|
||||
validateAction: plans.Update,
|
||||
validateReplace: false,
|
||||
@ -179,7 +193,7 @@ func TestValue_ObjectAttributes(t *testing.T) {
|
||||
},
|
||||
After: SetChangeEntry{
|
||||
ObjectChange: map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidatePrimitive(nil, strptr("\"new\""), plans.Create, false),
|
||||
"attribute_one": change.ValidatePrimitive(nil, "new", plans.Create, false),
|
||||
},
|
||||
Action: plans.Create,
|
||||
Replace: false,
|
||||
@ -199,7 +213,7 @@ func TestValue_ObjectAttributes(t *testing.T) {
|
||||
"attribute_one": cty.String,
|
||||
},
|
||||
validateChanges: map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidatePrimitive(nil, strptr("\"new\""), plans.Create, false),
|
||||
"attribute_one": change.ValidatePrimitive(nil, "new", plans.Create, false),
|
||||
},
|
||||
validateAction: plans.Update,
|
||||
validateReplace: false,
|
||||
@ -211,7 +225,7 @@ func TestValue_ObjectAttributes(t *testing.T) {
|
||||
},
|
||||
After: SetChangeEntry{
|
||||
ObjectChange: map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidatePrimitive(nil, strptr("\"new\""), plans.Create, false),
|
||||
"attribute_one": change.ValidatePrimitive(nil, "new", plans.Create, false),
|
||||
},
|
||||
Action: plans.Create,
|
||||
Replace: false,
|
||||
@ -229,14 +243,14 @@ func TestValue_ObjectAttributes(t *testing.T) {
|
||||
"attribute_one": cty.String,
|
||||
},
|
||||
validateChanges: map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidatePrimitive(strptr("\"old\""), nil, plans.Delete, false),
|
||||
"attribute_one": change.ValidatePrimitive("old", nil, plans.Delete, false),
|
||||
},
|
||||
validateAction: plans.Update,
|
||||
validateReplace: false,
|
||||
validateSetChanges: &SetChange{
|
||||
Before: SetChangeEntry{
|
||||
ObjectChange: map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidatePrimitive(strptr("\"old\""), nil, plans.Delete, false),
|
||||
"attribute_one": change.ValidatePrimitive("old", nil, plans.Delete, false),
|
||||
},
|
||||
Action: plans.Delete,
|
||||
Replace: false,
|
||||
@ -261,14 +275,14 @@ func TestValue_ObjectAttributes(t *testing.T) {
|
||||
"attribute_one": cty.String,
|
||||
},
|
||||
validateChanges: map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidatePrimitive(strptr("\"old\""), nil, plans.Delete, false),
|
||||
"attribute_one": change.ValidatePrimitive("old", nil, plans.Delete, false),
|
||||
},
|
||||
validateAction: plans.Update,
|
||||
validateReplace: false,
|
||||
validateSetChanges: &SetChange{
|
||||
Before: SetChangeEntry{
|
||||
ObjectChange: map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidatePrimitive(strptr("\"old\""), nil, plans.Delete, false),
|
||||
"attribute_one": change.ValidatePrimitive("old", nil, plans.Delete, false),
|
||||
},
|
||||
Action: plans.Delete,
|
||||
Replace: false,
|
||||
@ -293,21 +307,21 @@ func TestValue_ObjectAttributes(t *testing.T) {
|
||||
"attribute_one": cty.String,
|
||||
},
|
||||
validateChanges: map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidatePrimitive(strptr("\"old\""), strptr("\"new\""), plans.Update, false),
|
||||
"attribute_one": change.ValidatePrimitive("old", "new", plans.Update, false),
|
||||
},
|
||||
validateAction: plans.Update,
|
||||
validateReplace: false,
|
||||
validateSetChanges: &SetChange{
|
||||
Before: SetChangeEntry{
|
||||
ObjectChange: map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidatePrimitive(strptr("\"old\""), nil, plans.Delete, false),
|
||||
"attribute_one": change.ValidatePrimitive("old", nil, plans.Delete, false),
|
||||
},
|
||||
Action: plans.Delete,
|
||||
Replace: false,
|
||||
},
|
||||
After: SetChangeEntry{
|
||||
ObjectChange: map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidatePrimitive(nil, strptr("\"new\""), plans.Create, false),
|
||||
"attribute_one": change.ValidatePrimitive(nil, "new", plans.Create, false),
|
||||
},
|
||||
Action: plans.Create,
|
||||
Replace: false,
|
||||
@ -328,7 +342,7 @@ func TestValue_ObjectAttributes(t *testing.T) {
|
||||
"attribute_one": cty.String,
|
||||
},
|
||||
validateChanges: map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidateSensitive(nil, "new", false, true, plans.Create, false),
|
||||
"attribute_one": change.ValidateSensitive(change.ValidatePrimitive(nil, "new", plans.Create, false), false, true, plans.Create, false),
|
||||
},
|
||||
validateAction: plans.Update,
|
||||
validateReplace: false,
|
||||
@ -340,7 +354,7 @@ func TestValue_ObjectAttributes(t *testing.T) {
|
||||
},
|
||||
After: SetChangeEntry{
|
||||
ObjectChange: map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidateSensitive(nil, "new", false, true, plans.Create, false),
|
||||
"attribute_one": change.ValidateSensitive(change.ValidatePrimitive(nil, "new", plans.Create, false), false, true, plans.Create, false),
|
||||
},
|
||||
Action: plans.Create,
|
||||
Replace: false,
|
||||
@ -361,14 +375,14 @@ func TestValue_ObjectAttributes(t *testing.T) {
|
||||
"attribute_one": cty.String,
|
||||
},
|
||||
validateChanges: map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidateSensitive("old", nil, true, false, plans.Delete, false),
|
||||
"attribute_one": change.ValidateSensitive(change.ValidatePrimitive("old", nil, plans.Delete, false), true, false, plans.Delete, false),
|
||||
},
|
||||
validateAction: plans.Update,
|
||||
validateReplace: false,
|
||||
validateSetChanges: &SetChange{
|
||||
Before: SetChangeEntry{
|
||||
ObjectChange: map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidateSensitive("old", nil, true, false, plans.Delete, false),
|
||||
"attribute_one": change.ValidateSensitive(change.ValidatePrimitive("old", nil, plans.Delete, false), true, false, plans.Delete, false),
|
||||
},
|
||||
Action: plans.Delete,
|
||||
Replace: false,
|
||||
@ -399,21 +413,21 @@ func TestValue_ObjectAttributes(t *testing.T) {
|
||||
"attribute_one": cty.String,
|
||||
},
|
||||
validateChanges: map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidateSensitive("old", "new", true, true, plans.Update, false),
|
||||
"attribute_one": change.ValidateSensitive(change.ValidatePrimitive("old", "new", plans.Update, false), true, true, plans.Update, false),
|
||||
},
|
||||
validateAction: plans.Update,
|
||||
validateReplace: false,
|
||||
validateSetChanges: &SetChange{
|
||||
Before: SetChangeEntry{
|
||||
ObjectChange: map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidateSensitive("old", nil, true, false, plans.Delete, false),
|
||||
"attribute_one": change.ValidateSensitive(change.ValidatePrimitive("old", nil, plans.Delete, false), true, false, plans.Delete, false),
|
||||
},
|
||||
Action: plans.Delete,
|
||||
Replace: false,
|
||||
},
|
||||
After: SetChangeEntry{
|
||||
ObjectChange: map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidateSensitive(nil, "new", false, true, plans.Create, false),
|
||||
"attribute_one": change.ValidateSensitive(change.ValidatePrimitive(nil, "new", plans.Create, false), false, true, plans.Create, false),
|
||||
},
|
||||
Action: plans.Create,
|
||||
Replace: false,
|
||||
@ -466,7 +480,7 @@ func TestValue_ObjectAttributes(t *testing.T) {
|
||||
},
|
||||
validateChanges: map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidateComputed(
|
||||
change.ValidatePrimitive(strptr("\"old\""), nil, plans.Delete, false),
|
||||
change.ValidatePrimitive("old", nil, plans.Delete, false),
|
||||
plans.Update,
|
||||
false),
|
||||
},
|
||||
@ -475,7 +489,7 @@ func TestValue_ObjectAttributes(t *testing.T) {
|
||||
validateSetChanges: &SetChange{
|
||||
Before: SetChangeEntry{
|
||||
ObjectChange: map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidatePrimitive(strptr("\"old\""), nil, plans.Delete, false),
|
||||
"attribute_one": change.ValidatePrimitive("old", nil, plans.Delete, false),
|
||||
},
|
||||
Action: plans.Delete,
|
||||
Replace: false,
|
||||
@ -517,21 +531,21 @@ func TestValue_ObjectAttributes(t *testing.T) {
|
||||
"attribute_one": cty.String,
|
||||
},
|
||||
validateChanges: map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidatePrimitive(strptr("\"old\""), strptr("\"new\""), plans.Update, false),
|
||||
"attribute_one": change.ValidatePrimitive("old", "new", plans.Update, false),
|
||||
},
|
||||
validateAction: plans.Update,
|
||||
validateReplace: true,
|
||||
validateSetChanges: &SetChange{
|
||||
Before: SetChangeEntry{
|
||||
ObjectChange: map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidatePrimitive(strptr("\"old\""), nil, plans.Delete, false),
|
||||
"attribute_one": change.ValidatePrimitive("old", nil, plans.Delete, false),
|
||||
},
|
||||
Action: plans.Delete,
|
||||
Replace: true,
|
||||
},
|
||||
After: SetChangeEntry{
|
||||
ObjectChange: map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidatePrimitive(nil, strptr("\"new\""), plans.Create, false),
|
||||
"attribute_one": change.ValidatePrimitive(nil, "new", plans.Create, false),
|
||||
},
|
||||
Action: plans.Create,
|
||||
Replace: false,
|
||||
@ -554,21 +568,21 @@ func TestValue_ObjectAttributes(t *testing.T) {
|
||||
"attribute_one": cty.String,
|
||||
},
|
||||
validateChanges: map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidatePrimitive(strptr("\"old\""), strptr("\"new\""), plans.Update, true),
|
||||
"attribute_one": change.ValidatePrimitive("old", "new", plans.Update, true),
|
||||
},
|
||||
validateAction: plans.Update,
|
||||
validateReplace: false,
|
||||
validateSetChanges: &SetChange{
|
||||
Before: SetChangeEntry{
|
||||
ObjectChange: map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidatePrimitive(strptr("\"old\""), nil, plans.Delete, true),
|
||||
"attribute_one": change.ValidatePrimitive("old", nil, plans.Delete, true),
|
||||
},
|
||||
Action: plans.Delete,
|
||||
Replace: false,
|
||||
},
|
||||
After: SetChangeEntry{
|
||||
ObjectChange: map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidatePrimitive(nil, strptr("\"new\""), plans.Create, false),
|
||||
"attribute_one": change.ValidatePrimitive(nil, "new", plans.Create, false),
|
||||
},
|
||||
Action: plans.Create,
|
||||
Replace: false,
|
||||
@ -896,12 +910,12 @@ func TestValue_BlockAttributesAndNestedBlocks(t *testing.T) {
|
||||
},
|
||||
},
|
||||
validate: change.ValidateBlock(map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidatePrimitive(nil, strptr("\"new\""), plans.Create, false),
|
||||
"attribute_one": change.ValidatePrimitive(nil, "new", plans.Create, false),
|
||||
}, nil, plans.Update, false),
|
||||
validateSet: []change.ValidateChangeFunc{
|
||||
change.ValidateBlock(nil, nil, plans.Delete, false),
|
||||
change.ValidateBlock(map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidatePrimitive(nil, strptr("\"new\""), plans.Create, false),
|
||||
"attribute_one": change.ValidatePrimitive(nil, "new", plans.Create, false),
|
||||
}, nil, plans.Create, false),
|
||||
},
|
||||
},
|
||||
@ -920,14 +934,14 @@ func TestValue_BlockAttributesAndNestedBlocks(t *testing.T) {
|
||||
},
|
||||
},
|
||||
validate: change.ValidateBlock(map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidatePrimitive(strptr("\"old\""), strptr("\"new\""), plans.Update, false),
|
||||
"attribute_one": change.ValidatePrimitive("old", "new", plans.Update, false),
|
||||
}, nil, plans.Update, false),
|
||||
validateSet: []change.ValidateChangeFunc{
|
||||
change.ValidateBlock(map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidatePrimitive(strptr("\"old\""), nil, plans.Delete, false),
|
||||
"attribute_one": change.ValidatePrimitive("old", nil, plans.Delete, false),
|
||||
}, nil, plans.Delete, false),
|
||||
change.ValidateBlock(map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidatePrimitive(nil, strptr("\"new\""), plans.Create, false),
|
||||
"attribute_one": change.ValidatePrimitive(nil, "new", plans.Create, false),
|
||||
}, nil, plans.Create, false),
|
||||
},
|
||||
},
|
||||
@ -944,11 +958,11 @@ func TestValue_BlockAttributesAndNestedBlocks(t *testing.T) {
|
||||
},
|
||||
},
|
||||
validate: change.ValidateBlock(map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidatePrimitive(strptr("\"old\""), nil, plans.Delete, false),
|
||||
"attribute_one": change.ValidatePrimitive("old", nil, plans.Delete, false),
|
||||
}, nil, plans.Update, false),
|
||||
validateSet: []change.ValidateChangeFunc{
|
||||
change.ValidateBlock(map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidatePrimitive(strptr("\"old\""), nil, plans.Delete, false),
|
||||
"attribute_one": change.ValidatePrimitive("old", nil, plans.Delete, false),
|
||||
}, nil, plans.Delete, false),
|
||||
change.ValidateBlock(nil, nil, plans.Create, false),
|
||||
},
|
||||
@ -977,7 +991,7 @@ func TestValue_BlockAttributesAndNestedBlocks(t *testing.T) {
|
||||
validate: change.ValidateBlock(nil, map[string][]change.ValidateChangeFunc{
|
||||
"block_one": {
|
||||
change.ValidateBlock(map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidatePrimitive(nil, strptr("\"new\""), plans.Create, false),
|
||||
"attribute_one": change.ValidatePrimitive(nil, "new", plans.Create, false),
|
||||
}, nil, plans.Create, false),
|
||||
},
|
||||
}, plans.Update, false),
|
||||
@ -986,7 +1000,7 @@ func TestValue_BlockAttributesAndNestedBlocks(t *testing.T) {
|
||||
change.ValidateBlock(nil, map[string][]change.ValidateChangeFunc{
|
||||
"block_one": {
|
||||
change.ValidateBlock(map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidatePrimitive(nil, strptr("\"new\""), plans.Create, false),
|
||||
"attribute_one": change.ValidatePrimitive(nil, "new", plans.Create, false),
|
||||
}, nil, plans.Create, false),
|
||||
},
|
||||
}, plans.Create, false),
|
||||
@ -1020,7 +1034,7 @@ func TestValue_BlockAttributesAndNestedBlocks(t *testing.T) {
|
||||
validate: change.ValidateBlock(nil, map[string][]change.ValidateChangeFunc{
|
||||
"block_one": {
|
||||
change.ValidateBlock(map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidatePrimitive(strptr("\"old\""), strptr("\"new\""), plans.Update, false),
|
||||
"attribute_one": change.ValidatePrimitive("old", "new", plans.Update, false),
|
||||
}, nil, plans.Update, false),
|
||||
},
|
||||
}, plans.Update, false),
|
||||
@ -1028,14 +1042,14 @@ func TestValue_BlockAttributesAndNestedBlocks(t *testing.T) {
|
||||
change.ValidateBlock(nil, map[string][]change.ValidateChangeFunc{
|
||||
"block_one": {
|
||||
change.ValidateBlock(map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidatePrimitive(strptr("\"old\""), nil, plans.Delete, false),
|
||||
"attribute_one": change.ValidatePrimitive("old", nil, plans.Delete, false),
|
||||
}, nil, plans.Delete, false),
|
||||
},
|
||||
}, plans.Delete, false),
|
||||
change.ValidateBlock(nil, map[string][]change.ValidateChangeFunc{
|
||||
"block_one": {
|
||||
change.ValidateBlock(map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidatePrimitive(nil, strptr("\"new\""), plans.Create, false),
|
||||
"attribute_one": change.ValidatePrimitive(nil, "new", plans.Create, false),
|
||||
}, nil, plans.Create, false),
|
||||
},
|
||||
}, plans.Create, false),
|
||||
@ -1065,7 +1079,7 @@ func TestValue_BlockAttributesAndNestedBlocks(t *testing.T) {
|
||||
validate: change.ValidateBlock(nil, map[string][]change.ValidateChangeFunc{
|
||||
"block_one": {
|
||||
change.ValidateBlock(map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidatePrimitive(strptr("\"old\""), nil, plans.Delete, false),
|
||||
"attribute_one": change.ValidatePrimitive("old", nil, plans.Delete, false),
|
||||
}, nil, plans.Delete, false),
|
||||
},
|
||||
}, plans.Update, false),
|
||||
@ -1073,7 +1087,7 @@ func TestValue_BlockAttributesAndNestedBlocks(t *testing.T) {
|
||||
change.ValidateBlock(nil, map[string][]change.ValidateChangeFunc{
|
||||
"block_one": {
|
||||
change.ValidateBlock(map[string]change.ValidateChangeFunc{
|
||||
"attribute_one": change.ValidatePrimitive(strptr("\"old\""), nil, plans.Delete, false),
|
||||
"attribute_one": change.ValidatePrimitive("old", nil, plans.Delete, false),
|
||||
}, nil, plans.Delete, false),
|
||||
},
|
||||
}, plans.Delete, false),
|
||||
@ -1218,7 +1232,7 @@ func TestValue_Outputs(t *testing.T) {
|
||||
Before: nil,
|
||||
After: "new",
|
||||
},
|
||||
validateChange: change.ValidatePrimitive(nil, strptr("\"new\""), plans.Create, false),
|
||||
validateChange: change.ValidatePrimitive(nil, "new", plans.Create, false),
|
||||
},
|
||||
"map_create": {
|
||||
input: Value{
|
||||
@ -1229,8 +1243,8 @@ func TestValue_Outputs(t *testing.T) {
|
||||
},
|
||||
},
|
||||
validateChange: change.ValidateMap(map[string]change.ValidateChangeFunc{
|
||||
"element_one": change.ValidatePrimitive(nil, strptr("\"new_one\""), plans.Create, false),
|
||||
"element_two": change.ValidatePrimitive(nil, strptr("\"new_two\""), plans.Create, false),
|
||||
"element_one": change.ValidatePrimitive(nil, "new_one", plans.Create, false),
|
||||
"element_two": change.ValidatePrimitive(nil, "new_two", plans.Create, false),
|
||||
}, plans.Create, false),
|
||||
},
|
||||
"list_create": {
|
||||
@ -1242,8 +1256,8 @@ func TestValue_Outputs(t *testing.T) {
|
||||
},
|
||||
},
|
||||
validateChange: change.ValidateList([]change.ValidateChangeFunc{
|
||||
change.ValidatePrimitive(nil, strptr("\"new_one\""), plans.Create, false),
|
||||
change.ValidatePrimitive(nil, strptr("\"new_two\""), plans.Create, false),
|
||||
change.ValidatePrimitive(nil, "new_one", plans.Create, false),
|
||||
change.ValidatePrimitive(nil, "new_two", plans.Create, false),
|
||||
}, plans.Create, false),
|
||||
},
|
||||
"primitive_update": {
|
||||
@ -1251,7 +1265,7 @@ func TestValue_Outputs(t *testing.T) {
|
||||
Before: "old",
|
||||
After: "new",
|
||||
},
|
||||
validateChange: change.ValidatePrimitive(strptr("\"old\""), strptr("\"new\""), plans.Update, false),
|
||||
validateChange: change.ValidatePrimitive("old", "new", plans.Update, false),
|
||||
},
|
||||
"map_update": {
|
||||
input: Value{
|
||||
@ -1265,8 +1279,8 @@ func TestValue_Outputs(t *testing.T) {
|
||||
},
|
||||
},
|
||||
validateChange: change.ValidateMap(map[string]change.ValidateChangeFunc{
|
||||
"element_one": change.ValidatePrimitive(strptr("\"old_one\""), strptr("\"new_one\""), plans.Update, false),
|
||||
"element_two": change.ValidatePrimitive(strptr("\"old_two\""), strptr("\"new_two\""), plans.Update, false),
|
||||
"element_one": change.ValidatePrimitive("old_one", "new_one", plans.Update, false),
|
||||
"element_two": change.ValidatePrimitive("old_two", "new_two", plans.Update, false),
|
||||
}, plans.Update, false),
|
||||
},
|
||||
"list_update": {
|
||||
@ -1281,10 +1295,10 @@ func TestValue_Outputs(t *testing.T) {
|
||||
},
|
||||
},
|
||||
validateChange: change.ValidateList([]change.ValidateChangeFunc{
|
||||
change.ValidatePrimitive(strptr("\"old_one\""), nil, plans.Delete, false),
|
||||
change.ValidatePrimitive(strptr("\"old_two\""), nil, plans.Delete, false),
|
||||
change.ValidatePrimitive(nil, strptr("\"new_one\""), plans.Create, false),
|
||||
change.ValidatePrimitive(nil, strptr("\"new_two\""), plans.Create, false),
|
||||
change.ValidatePrimitive("old_one", nil, plans.Delete, false),
|
||||
change.ValidatePrimitive("old_two", nil, plans.Delete, false),
|
||||
change.ValidatePrimitive(nil, "new_one", plans.Create, false),
|
||||
change.ValidatePrimitive(nil, "new_two", plans.Create, false),
|
||||
}, plans.Update, false),
|
||||
},
|
||||
"primitive_delete": {
|
||||
@ -1292,7 +1306,7 @@ func TestValue_Outputs(t *testing.T) {
|
||||
Before: "old",
|
||||
After: nil,
|
||||
},
|
||||
validateChange: change.ValidatePrimitive(strptr("\"old\""), nil, plans.Delete, false),
|
||||
validateChange: change.ValidatePrimitive("old", nil, plans.Delete, false),
|
||||
},
|
||||
"map_delete": {
|
||||
input: Value{
|
||||
@ -1303,8 +1317,8 @@ func TestValue_Outputs(t *testing.T) {
|
||||
After: nil,
|
||||
},
|
||||
validateChange: change.ValidateMap(map[string]change.ValidateChangeFunc{
|
||||
"element_one": change.ValidatePrimitive(strptr("\"old_one\""), nil, plans.Delete, false),
|
||||
"element_two": change.ValidatePrimitive(strptr("\"old_two\""), nil, plans.Delete, false),
|
||||
"element_one": change.ValidatePrimitive("old_one", nil, plans.Delete, false),
|
||||
"element_two": change.ValidatePrimitive("old_two", nil, plans.Delete, false),
|
||||
}, plans.Delete, false),
|
||||
},
|
||||
"list_delete": {
|
||||
@ -1316,8 +1330,8 @@ func TestValue_Outputs(t *testing.T) {
|
||||
After: nil,
|
||||
},
|
||||
validateChange: change.ValidateList([]change.ValidateChangeFunc{
|
||||
change.ValidatePrimitive(strptr("\"old_one\""), nil, plans.Delete, false),
|
||||
change.ValidatePrimitive(strptr("\"old_two\""), nil, plans.Delete, false),
|
||||
change.ValidatePrimitive("old_one", nil, plans.Delete, false),
|
||||
change.ValidatePrimitive("old_two", nil, plans.Delete, false),
|
||||
}, plans.Delete, false),
|
||||
},
|
||||
"primitive_to_list": {
|
||||
@ -1329,10 +1343,10 @@ func TestValue_Outputs(t *testing.T) {
|
||||
},
|
||||
},
|
||||
validateChange: change.ValidateTypeChange(
|
||||
change.ValidatePrimitive(strptr("\"old\""), nil, plans.Delete, false),
|
||||
change.ValidatePrimitive("old", nil, plans.Delete, false),
|
||||
change.ValidateList([]change.ValidateChangeFunc{
|
||||
change.ValidatePrimitive(nil, strptr("\"new_one\""), plans.Create, false),
|
||||
change.ValidatePrimitive(nil, strptr("\"new_two\""), plans.Create, false),
|
||||
change.ValidatePrimitive(nil, "new_one", plans.Create, false),
|
||||
change.ValidatePrimitive(nil, "new_two", plans.Create, false),
|
||||
}, plans.Create, false), plans.Update, false),
|
||||
},
|
||||
"primitive_to_map": {
|
||||
@ -1344,10 +1358,10 @@ func TestValue_Outputs(t *testing.T) {
|
||||
},
|
||||
},
|
||||
validateChange: change.ValidateTypeChange(
|
||||
change.ValidatePrimitive(strptr("\"old\""), nil, plans.Delete, false),
|
||||
change.ValidatePrimitive("old", nil, plans.Delete, false),
|
||||
change.ValidateMap(map[string]change.ValidateChangeFunc{
|
||||
"element_one": change.ValidatePrimitive(nil, strptr("\"new_one\""), plans.Create, false),
|
||||
"element_two": change.ValidatePrimitive(nil, strptr("\"new_two\""), plans.Create, false),
|
||||
"element_one": change.ValidatePrimitive(nil, "new_one", plans.Create, false),
|
||||
"element_two": change.ValidatePrimitive(nil, "new_two", plans.Create, false),
|
||||
}, plans.Create, false), plans.Update, false),
|
||||
},
|
||||
"list_to_primitive": {
|
||||
@ -1360,10 +1374,10 @@ func TestValue_Outputs(t *testing.T) {
|
||||
},
|
||||
validateChange: change.ValidateTypeChange(
|
||||
change.ValidateList([]change.ValidateChangeFunc{
|
||||
change.ValidatePrimitive(strptr("\"old_one\""), nil, plans.Delete, false),
|
||||
change.ValidatePrimitive(strptr("\"old_two\""), nil, plans.Delete, false),
|
||||
change.ValidatePrimitive("old_one", nil, plans.Delete, false),
|
||||
change.ValidatePrimitive("old_two", nil, plans.Delete, false),
|
||||
}, plans.Delete, false),
|
||||
change.ValidatePrimitive(nil, strptr("\"new\""), plans.Create, false),
|
||||
change.ValidatePrimitive(nil, "new", plans.Create, false),
|
||||
plans.Update, false),
|
||||
},
|
||||
"list_to_map": {
|
||||
@ -1379,12 +1393,12 @@ func TestValue_Outputs(t *testing.T) {
|
||||
},
|
||||
validateChange: change.ValidateTypeChange(
|
||||
change.ValidateList([]change.ValidateChangeFunc{
|
||||
change.ValidatePrimitive(strptr("\"old_one\""), nil, plans.Delete, false),
|
||||
change.ValidatePrimitive(strptr("\"old_two\""), nil, plans.Delete, false),
|
||||
change.ValidatePrimitive("old_one", nil, plans.Delete, false),
|
||||
change.ValidatePrimitive("old_two", nil, plans.Delete, false),
|
||||
}, plans.Delete, false),
|
||||
change.ValidateMap(map[string]change.ValidateChangeFunc{
|
||||
"element_one": change.ValidatePrimitive(nil, strptr("\"new_one\""), plans.Create, false),
|
||||
"element_two": change.ValidatePrimitive(nil, strptr("\"new_two\""), plans.Create, false),
|
||||
"element_one": change.ValidatePrimitive(nil, "new_one", plans.Create, false),
|
||||
"element_two": change.ValidatePrimitive(nil, "new_two", plans.Create, false),
|
||||
}, plans.Create, false), plans.Update, false),
|
||||
},
|
||||
"map_to_primitive": {
|
||||
@ -1397,10 +1411,10 @@ func TestValue_Outputs(t *testing.T) {
|
||||
},
|
||||
validateChange: change.ValidateTypeChange(
|
||||
change.ValidateMap(map[string]change.ValidateChangeFunc{
|
||||
"element_one": change.ValidatePrimitive(strptr("\"old_one\""), nil, plans.Delete, false),
|
||||
"element_two": change.ValidatePrimitive(strptr("\"old_two\""), nil, plans.Delete, false),
|
||||
"element_one": change.ValidatePrimitive("old_one", nil, plans.Delete, false),
|
||||
"element_two": change.ValidatePrimitive("old_two", nil, plans.Delete, false),
|
||||
}, plans.Delete, false),
|
||||
change.ValidatePrimitive(nil, strptr("\"new\""), plans.Create, false),
|
||||
change.ValidatePrimitive(nil, "new", plans.Create, false),
|
||||
plans.Update, false),
|
||||
},
|
||||
"map_to_list": {
|
||||
@ -1416,12 +1430,12 @@ func TestValue_Outputs(t *testing.T) {
|
||||
},
|
||||
validateChange: change.ValidateTypeChange(
|
||||
change.ValidateMap(map[string]change.ValidateChangeFunc{
|
||||
"element_one": change.ValidatePrimitive(strptr("\"old_one\""), nil, plans.Delete, false),
|
||||
"element_two": change.ValidatePrimitive(strptr("\"old_two\""), nil, plans.Delete, false),
|
||||
"element_one": change.ValidatePrimitive("old_one", nil, plans.Delete, false),
|
||||
"element_two": change.ValidatePrimitive("old_two", nil, plans.Delete, false),
|
||||
}, plans.Delete, false),
|
||||
change.ValidateList([]change.ValidateChangeFunc{
|
||||
change.ValidatePrimitive(nil, strptr("\"new_one\""), plans.Create, false),
|
||||
change.ValidatePrimitive(nil, strptr("\"new_two\""), plans.Create, false),
|
||||
change.ValidatePrimitive(nil, "new_one", plans.Create, false),
|
||||
change.ValidatePrimitive(nil, "new_two", plans.Create, false),
|
||||
}, plans.Create, false), plans.Update, false),
|
||||
},
|
||||
}
|
||||
@ -1449,14 +1463,14 @@ func TestValue_PrimitiveAttributes(t *testing.T) {
|
||||
After: "new",
|
||||
},
|
||||
attribute: cty.String,
|
||||
validateChange: change.ValidatePrimitive(nil, strptr("\"new\""), plans.Create, false),
|
||||
validateChange: change.ValidatePrimitive(nil, "new", plans.Create, false),
|
||||
},
|
||||
"primitive_delete": {
|
||||
input: Value{
|
||||
Before: "old",
|
||||
},
|
||||
attribute: cty.String,
|
||||
validateChange: change.ValidatePrimitive(strptr("\"old\""), nil, plans.Delete, false),
|
||||
validateChange: change.ValidatePrimitive("old", nil, plans.Delete, false),
|
||||
},
|
||||
"primitive_update": {
|
||||
input: Value{
|
||||
@ -1464,10 +1478,10 @@ func TestValue_PrimitiveAttributes(t *testing.T) {
|
||||
After: "new",
|
||||
},
|
||||
attribute: cty.String,
|
||||
validateChange: change.ValidatePrimitive(strptr("\"old\""), strptr("\"new\""), plans.Update, false),
|
||||
validateChange: change.ValidatePrimitive("old", "new", plans.Update, false),
|
||||
validateSliceChanges: []change.ValidateChangeFunc{
|
||||
change.ValidatePrimitive(strptr("\"old\""), nil, plans.Delete, false),
|
||||
change.ValidatePrimitive(nil, strptr("\"new\""), plans.Create, false),
|
||||
change.ValidatePrimitive("old", nil, plans.Delete, false),
|
||||
change.ValidatePrimitive(nil, "new", plans.Create, false),
|
||||
},
|
||||
},
|
||||
"primitive_set_explicit_null": {
|
||||
@ -1477,9 +1491,9 @@ func TestValue_PrimitiveAttributes(t *testing.T) {
|
||||
AfterExplicit: true,
|
||||
},
|
||||
attribute: cty.String,
|
||||
validateChange: change.ValidatePrimitive(strptr("\"old\""), nil, plans.Update, false),
|
||||
validateChange: change.ValidatePrimitive("old", nil, plans.Update, false),
|
||||
validateSliceChanges: []change.ValidateChangeFunc{
|
||||
change.ValidatePrimitive(strptr("\"old\""), nil, plans.Delete, false),
|
||||
change.ValidatePrimitive("old", nil, plans.Delete, false),
|
||||
change.ValidatePrimitive(nil, nil, plans.Create, false),
|
||||
},
|
||||
},
|
||||
@ -1490,10 +1504,10 @@ func TestValue_PrimitiveAttributes(t *testing.T) {
|
||||
After: "new",
|
||||
},
|
||||
attribute: cty.String,
|
||||
validateChange: change.ValidatePrimitive(nil, strptr("\"new\""), plans.Update, false),
|
||||
validateChange: change.ValidatePrimitive(nil, "new", plans.Update, false),
|
||||
validateSliceChanges: []change.ValidateChangeFunc{
|
||||
change.ValidatePrimitive(nil, nil, plans.Delete, false),
|
||||
change.ValidatePrimitive(nil, strptr("\"new\""), plans.Create, false),
|
||||
change.ValidatePrimitive(nil, "new", plans.Create, false),
|
||||
},
|
||||
},
|
||||
"primitive_create_sensitive": {
|
||||
@ -1503,7 +1517,7 @@ func TestValue_PrimitiveAttributes(t *testing.T) {
|
||||
AfterSensitive: true,
|
||||
},
|
||||
attribute: cty.String,
|
||||
validateChange: change.ValidateSensitive(nil, "new", false, true, plans.Create, false),
|
||||
validateChange: change.ValidateSensitive(change.ValidatePrimitive(nil, "new", plans.Create, false), false, true, plans.Create, false),
|
||||
},
|
||||
"primitive_delete_sensitive": {
|
||||
input: Value{
|
||||
@ -1512,7 +1526,7 @@ func TestValue_PrimitiveAttributes(t *testing.T) {
|
||||
After: nil,
|
||||
},
|
||||
attribute: cty.String,
|
||||
validateChange: change.ValidateSensitive("old", nil, true, false, plans.Delete, false),
|
||||
validateChange: change.ValidateSensitive(change.ValidatePrimitive("old", nil, plans.Delete, false), true, false, plans.Delete, false),
|
||||
},
|
||||
"primitive_update_sensitive": {
|
||||
input: Value{
|
||||
@ -1522,10 +1536,10 @@ func TestValue_PrimitiveAttributes(t *testing.T) {
|
||||
AfterSensitive: true,
|
||||
},
|
||||
attribute: cty.String,
|
||||
validateChange: change.ValidateSensitive("old", "new", true, true, plans.Update, false),
|
||||
validateChange: change.ValidateSensitive(change.ValidatePrimitive("old", "new", plans.Update, false), true, true, plans.Update, false),
|
||||
validateSliceChanges: []change.ValidateChangeFunc{
|
||||
change.ValidateSensitive("old", nil, true, false, plans.Delete, false),
|
||||
change.ValidateSensitive(nil, "new", false, true, plans.Create, false),
|
||||
change.ValidateSensitive(change.ValidatePrimitive("old", nil, plans.Delete, false), true, false, plans.Delete, false),
|
||||
change.ValidateSensitive(change.ValidatePrimitive(nil, "new", plans.Create, false), false, true, plans.Create, false),
|
||||
},
|
||||
},
|
||||
"primitive_create_computed": {
|
||||
@ -1544,9 +1558,9 @@ func TestValue_PrimitiveAttributes(t *testing.T) {
|
||||
Unknown: true,
|
||||
},
|
||||
attribute: cty.String,
|
||||
validateChange: change.ValidateComputed(change.ValidatePrimitive(strptr("\"old\""), nil, plans.Delete, false), plans.Update, false),
|
||||
validateChange: change.ValidateComputed(change.ValidatePrimitive("old", nil, plans.Delete, false), plans.Update, false),
|
||||
validateSliceChanges: []change.ValidateChangeFunc{
|
||||
change.ValidatePrimitive(strptr("\"old\""), nil, plans.Delete, false),
|
||||
change.ValidatePrimitive("old", nil, plans.Delete, false),
|
||||
change.ValidateComputed(nil, plans.Create, false),
|
||||
},
|
||||
},
|
||||
@ -1559,10 +1573,10 @@ func TestValue_PrimitiveAttributes(t *testing.T) {
|
||||
},
|
||||
},
|
||||
attribute: cty.String,
|
||||
validateChange: change.ValidatePrimitive(strptr("\"old\""), strptr("\"new\""), plans.Update, true),
|
||||
validateChange: change.ValidatePrimitive("old", "new", plans.Update, true),
|
||||
validateSliceChanges: []change.ValidateChangeFunc{
|
||||
change.ValidatePrimitive(strptr("\"old\""), nil, plans.Delete, true),
|
||||
change.ValidatePrimitive(nil, strptr("\"new\""), plans.Create, false),
|
||||
change.ValidatePrimitive("old", nil, plans.Delete, true),
|
||||
change.ValidatePrimitive(nil, "new", plans.Create, false),
|
||||
},
|
||||
},
|
||||
"noop": {
|
||||
@ -1571,7 +1585,7 @@ func TestValue_PrimitiveAttributes(t *testing.T) {
|
||||
After: "old",
|
||||
},
|
||||
attribute: cty.String,
|
||||
validateChange: change.ValidatePrimitive(strptr("\"old\""), strptr("\"old\""), plans.NoOp, false),
|
||||
validateChange: change.ValidatePrimitive("old", "old", plans.NoOp, false),
|
||||
},
|
||||
"dynamic": {
|
||||
input: Value{
|
||||
@ -1579,10 +1593,10 @@ func TestValue_PrimitiveAttributes(t *testing.T) {
|
||||
After: "new",
|
||||
},
|
||||
attribute: cty.DynamicPseudoType,
|
||||
validateChange: change.ValidatePrimitive(strptr("\"old\""), strptr("\"new\""), plans.Update, false),
|
||||
validateChange: change.ValidatePrimitive("old", "new", plans.Update, false),
|
||||
validateSliceChanges: []change.ValidateChangeFunc{
|
||||
change.ValidatePrimitive(strptr("\"old\""), nil, plans.Delete, false),
|
||||
change.ValidatePrimitive(nil, strptr("\"new\""), plans.Create, false),
|
||||
change.ValidatePrimitive("old", nil, plans.Delete, false),
|
||||
change.ValidatePrimitive(nil, "new", plans.Create, false),
|
||||
},
|
||||
},
|
||||
"dynamic_type_change": {
|
||||
@ -1592,12 +1606,12 @@ func TestValue_PrimitiveAttributes(t *testing.T) {
|
||||
},
|
||||
attribute: cty.DynamicPseudoType,
|
||||
validateChange: change.ValidateTypeChange(
|
||||
change.ValidatePrimitive(strptr("\"old\""), nil, plans.Delete, false),
|
||||
change.ValidatePrimitive(nil, strptr("4"), plans.Create, false),
|
||||
change.ValidatePrimitive("old", nil, plans.Delete, false),
|
||||
change.ValidatePrimitive(nil, 4.0, plans.Create, false),
|
||||
plans.Update, false),
|
||||
validateSliceChanges: []change.ValidateChangeFunc{
|
||||
change.ValidatePrimitive(strptr("\"old\""), nil, plans.Delete, false),
|
||||
change.ValidatePrimitive(nil, strptr("4"), plans.Create, false),
|
||||
change.ValidatePrimitive("old", nil, plans.Delete, false),
|
||||
change.ValidatePrimitive(nil, 4.0, plans.Create, false),
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -1698,8 +1712,8 @@ func TestValue_CollectionAttributes(t *testing.T) {
|
||||
AttributeType: unmarshalType(t, cty.Map(cty.String)),
|
||||
},
|
||||
validateChange: change.ValidateMap(map[string]change.ValidateChangeFunc{
|
||||
"element_one": change.ValidatePrimitive(nil, strptr("\"one\""), plans.Create, false),
|
||||
"element_two": change.ValidatePrimitive(nil, strptr("\"two\""), plans.Create, false),
|
||||
"element_one": change.ValidatePrimitive(nil, "one", plans.Create, false),
|
||||
"element_two": change.ValidatePrimitive(nil, "two", plans.Create, false),
|
||||
}, plans.Create, false),
|
||||
},
|
||||
"map_delete_empty": {
|
||||
@ -1724,8 +1738,8 @@ func TestValue_CollectionAttributes(t *testing.T) {
|
||||
AttributeType: unmarshalType(t, cty.Map(cty.String)),
|
||||
},
|
||||
validateChange: change.ValidateMap(map[string]change.ValidateChangeFunc{
|
||||
"element_one": change.ValidatePrimitive(strptr("\"one\""), nil, plans.Delete, false),
|
||||
"element_two": change.ValidatePrimitive(strptr("\"two\""), nil, plans.Delete, false),
|
||||
"element_one": change.ValidatePrimitive("one", nil, plans.Delete, false),
|
||||
"element_two": change.ValidatePrimitive("two", nil, plans.Delete, false),
|
||||
}, plans.Delete, false),
|
||||
},
|
||||
"map_create_sensitive": {
|
||||
@ -1737,7 +1751,7 @@ func TestValue_CollectionAttributes(t *testing.T) {
|
||||
attribute: &jsonprovider.Attribute{
|
||||
AttributeType: unmarshalType(t, cty.Map(cty.String)),
|
||||
},
|
||||
validateChange: change.ValidateSensitive(nil, map[string]interface{}{}, false, true, plans.Create, false),
|
||||
validateChange: change.ValidateSensitive(change.ValidateMap(nil, plans.Create, false), false, true, plans.Create, false),
|
||||
},
|
||||
"map_update_sensitive": {
|
||||
input: Value{
|
||||
@ -1751,7 +1765,9 @@ func TestValue_CollectionAttributes(t *testing.T) {
|
||||
attribute: &jsonprovider.Attribute{
|
||||
AttributeType: unmarshalType(t, cty.Map(cty.String)),
|
||||
},
|
||||
validateChange: change.ValidateSensitive(map[string]interface{}{"element": "one"}, map[string]interface{}{}, true, true, plans.Update, false),
|
||||
validateChange: change.ValidateSensitive(change.ValidateMap(map[string]change.ValidateChangeFunc{
|
||||
"element": change.ValidatePrimitive("one", nil, plans.Delete, false),
|
||||
}, plans.Update, false), true, true, plans.Update, false),
|
||||
},
|
||||
"map_delete_sensitive": {
|
||||
input: Value{
|
||||
@ -1762,7 +1778,7 @@ func TestValue_CollectionAttributes(t *testing.T) {
|
||||
attribute: &jsonprovider.Attribute{
|
||||
AttributeType: unmarshalType(t, cty.Map(cty.String)),
|
||||
},
|
||||
validateChange: change.ValidateSensitive(map[string]interface{}{}, nil, true, false, plans.Delete, false),
|
||||
validateChange: change.ValidateSensitive(change.ValidateMap(nil, plans.Delete, false), true, false, plans.Delete, false),
|
||||
},
|
||||
"map_create_unknown": {
|
||||
input: Value{
|
||||
@ -1807,8 +1823,8 @@ func TestValue_CollectionAttributes(t *testing.T) {
|
||||
AttributeType: unmarshalType(t, cty.List(cty.String)),
|
||||
},
|
||||
validateChange: change.ValidateList([]change.ValidateChangeFunc{
|
||||
change.ValidatePrimitive(nil, strptr("\"one\""), plans.Create, false),
|
||||
change.ValidatePrimitive(nil, strptr("\"two\""), plans.Create, false),
|
||||
change.ValidatePrimitive(nil, "one", plans.Create, false),
|
||||
change.ValidatePrimitive(nil, "two", plans.Create, false),
|
||||
}, plans.Create, false),
|
||||
},
|
||||
"list_delete_empty": {
|
||||
@ -1830,8 +1846,8 @@ func TestValue_CollectionAttributes(t *testing.T) {
|
||||
AttributeType: unmarshalType(t, cty.List(cty.String)),
|
||||
},
|
||||
validateChange: change.ValidateList([]change.ValidateChangeFunc{
|
||||
change.ValidatePrimitive(strptr("\"one\""), nil, plans.Delete, false),
|
||||
change.ValidatePrimitive(strptr("\"two\""), nil, plans.Delete, false),
|
||||
change.ValidatePrimitive("one", nil, plans.Delete, false),
|
||||
change.ValidatePrimitive("two", nil, plans.Delete, false),
|
||||
}, plans.Delete, false),
|
||||
},
|
||||
"list_create_sensitive": {
|
||||
@ -1843,7 +1859,7 @@ func TestValue_CollectionAttributes(t *testing.T) {
|
||||
attribute: &jsonprovider.Attribute{
|
||||
AttributeType: unmarshalType(t, cty.List(cty.String)),
|
||||
},
|
||||
validateChange: change.ValidateSensitive(nil, []interface{}{}, false, true, plans.Create, false),
|
||||
validateChange: change.ValidateSensitive(change.ValidateList(nil, plans.Create, false), false, true, plans.Create, false),
|
||||
},
|
||||
"list_update_sensitive": {
|
||||
input: Value{
|
||||
@ -1855,7 +1871,9 @@ func TestValue_CollectionAttributes(t *testing.T) {
|
||||
attribute: &jsonprovider.Attribute{
|
||||
AttributeType: unmarshalType(t, cty.List(cty.String)),
|
||||
},
|
||||
validateChange: change.ValidateSensitive([]interface{}{"one"}, []interface{}{}, true, true, plans.Update, false),
|
||||
validateChange: change.ValidateSensitive(change.ValidateList([]change.ValidateChangeFunc{
|
||||
change.ValidatePrimitive("one", nil, plans.Delete, false),
|
||||
}, plans.Update, false), true, true, plans.Update, false),
|
||||
},
|
||||
"list_delete_sensitive": {
|
||||
input: Value{
|
||||
@ -1866,7 +1884,7 @@ func TestValue_CollectionAttributes(t *testing.T) {
|
||||
attribute: &jsonprovider.Attribute{
|
||||
AttributeType: unmarshalType(t, cty.List(cty.String)),
|
||||
},
|
||||
validateChange: change.ValidateSensitive([]interface{}{}, nil, true, false, plans.Delete, false),
|
||||
validateChange: change.ValidateSensitive(change.ValidateList(nil, plans.Delete, false), true, false, plans.Delete, false),
|
||||
},
|
||||
"list_create_unknown": {
|
||||
input: Value{
|
||||
@ -1909,8 +1927,8 @@ func TestValue_CollectionAttributes(t *testing.T) {
|
||||
AttributeType: unmarshalType(t, cty.Set(cty.String)),
|
||||
},
|
||||
validateChange: change.ValidateSet([]change.ValidateChangeFunc{
|
||||
change.ValidatePrimitive(nil, strptr("\"one\""), plans.Create, false),
|
||||
change.ValidatePrimitive(nil, strptr("\"two\""), plans.Create, false),
|
||||
change.ValidatePrimitive(nil, "one", plans.Create, false),
|
||||
change.ValidatePrimitive(nil, "two", plans.Create, false),
|
||||
}, plans.Create, false),
|
||||
},
|
||||
"set_delete_empty": {
|
||||
@ -1932,8 +1950,8 @@ func TestValue_CollectionAttributes(t *testing.T) {
|
||||
AttributeType: unmarshalType(t, cty.Set(cty.String)),
|
||||
},
|
||||
validateChange: change.ValidateSet([]change.ValidateChangeFunc{
|
||||
change.ValidatePrimitive(strptr("\"one\""), nil, plans.Delete, false),
|
||||
change.ValidatePrimitive(strptr("\"two\""), nil, plans.Delete, false),
|
||||
change.ValidatePrimitive("one", nil, plans.Delete, false),
|
||||
change.ValidatePrimitive("two", nil, plans.Delete, false),
|
||||
}, plans.Delete, false),
|
||||
},
|
||||
"set_create_sensitive": {
|
||||
@ -1945,7 +1963,7 @@ func TestValue_CollectionAttributes(t *testing.T) {
|
||||
attribute: &jsonprovider.Attribute{
|
||||
AttributeType: unmarshalType(t, cty.Set(cty.String)),
|
||||
},
|
||||
validateChange: change.ValidateSensitive(nil, []interface{}{}, false, true, plans.Create, false),
|
||||
validateChange: change.ValidateSensitive(change.ValidateSet(nil, plans.Create, false), false, true, plans.Create, false),
|
||||
},
|
||||
"set_update_sensitive": {
|
||||
input: Value{
|
||||
@ -1957,7 +1975,9 @@ func TestValue_CollectionAttributes(t *testing.T) {
|
||||
attribute: &jsonprovider.Attribute{
|
||||
AttributeType: unmarshalType(t, cty.Set(cty.String)),
|
||||
},
|
||||
validateChange: change.ValidateSensitive([]interface{}{"one"}, []interface{}{}, true, true, plans.Update, false),
|
||||
validateChange: change.ValidateSensitive(change.ValidateSet([]change.ValidateChangeFunc{
|
||||
change.ValidatePrimitive("one", nil, plans.Delete, false),
|
||||
}, plans.Update, false), true, true, plans.Update, false),
|
||||
},
|
||||
"set_delete_sensitive": {
|
||||
input: Value{
|
||||
@ -1968,7 +1988,7 @@ func TestValue_CollectionAttributes(t *testing.T) {
|
||||
attribute: &jsonprovider.Attribute{
|
||||
AttributeType: unmarshalType(t, cty.Set(cty.String)),
|
||||
},
|
||||
validateChange: change.ValidateSensitive([]interface{}{}, nil, true, false, plans.Delete, false),
|
||||
validateChange: change.ValidateSensitive(change.ValidateSet(nil, plans.Delete, false), true, false, plans.Delete, false),
|
||||
},
|
||||
"set_create_unknown": {
|
||||
input: Value{
|
||||
@ -2009,9 +2029,9 @@ func TestValue_CollectionAttributes(t *testing.T) {
|
||||
AttributeType: unmarshalType(t, cty.Tuple([]cty.Type{cty.String, cty.Number, cty.String})),
|
||||
},
|
||||
validateChange: change.ValidateList([]change.ValidateChangeFunc{
|
||||
change.ValidatePrimitive(strptr("\"one\""), strptr("\"one\""), plans.NoOp, false),
|
||||
change.ValidatePrimitive(strptr("2"), strptr("4"), plans.Update, false),
|
||||
change.ValidatePrimitive(strptr("\"three\""), strptr("\"three\""), plans.NoOp, false),
|
||||
change.ValidatePrimitive("one", "one", plans.NoOp, false),
|
||||
change.ValidatePrimitive(2.0, 4.0, plans.Update, false),
|
||||
change.ValidatePrimitive("three", "three", plans.NoOp, false),
|
||||
}, plans.Update, false),
|
||||
},
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user