remove UnknownVariabeValue from config and update references to shim

This commit is contained in:
Alex Pilon 2019-07-17 22:41:24 -04:00
parent db2fe3dbd9
commit 7f8f198719
No known key found for this signature in database
GPG Key ID: 95659F6AEFC48D7E
25 changed files with 119 additions and 118 deletions

View File

@ -3,7 +3,7 @@ package test
import ( import (
"fmt" "fmt"
"github.com/hashicorp/terraform/config" "github.com/hashicorp/terraform/config/hcl2shim"
"github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/helper/schema"
) )
@ -26,7 +26,7 @@ func testResourceMap() *schema.Resource {
ValidateFunc: func(v interface{}, _ string) ([]string, []error) { ValidateFunc: func(v interface{}, _ string) ([]string, []error) {
errs := []error{} errs := []error{}
for k, v := range v.(map[string]interface{}) { for k, v := range v.(map[string]interface{}) {
if v == config.UnknownVariableValue { if v == hcl2shim.UnknownVariableValue {
errs = append(errs, fmt.Errorf("unknown value in ValidateFunc: %q=%q", k, v)) errs = append(errs, fmt.Errorf("unknown value in ValidateFunc: %q=%q", k, v))
} }
} }

View File

@ -7,6 +7,7 @@ import (
"github.com/hashicorp/terraform/communicator" "github.com/hashicorp/terraform/communicator"
"github.com/hashicorp/terraform/config" "github.com/hashicorp/terraform/config"
"github.com/hashicorp/terraform/config/hcl2shim"
"github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform" "github.com/hashicorp/terraform/terraform"
) )
@ -64,7 +65,7 @@ func TestResourceProvider_Validate_computedValues(t *testing.T) {
"server_url": "https://chef.local", "server_url": "https://chef.local",
"user_name": "bob", "user_name": "bob",
"user_key": "USER-KEY", "user_key": "USER-KEY",
"attributes_json": config.UnknownVariableValue, "attributes_json": hcl2shim.UnknownVariableValue,
}) })
warn, errs := Provisioner().Validate(c) warn, errs := Provisioner().Validate(c)

View File

@ -4,6 +4,7 @@ import (
"testing" "testing"
"github.com/hashicorp/terraform/config" "github.com/hashicorp/terraform/config"
"github.com/hashicorp/terraform/config/hcl2shim"
"github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform" "github.com/hashicorp/terraform/terraform"
) )
@ -50,7 +51,7 @@ func TestResourceProvider_Validate_good_content(t *testing.T) {
func TestResourceProvider_Validate_good_unknown_variable_value(t *testing.T) { func TestResourceProvider_Validate_good_unknown_variable_value(t *testing.T) {
c := testConfig(t, map[string]interface{}{ c := testConfig(t, map[string]interface{}{
"content": config.UnknownVariableValue, "content": hcl2shim.UnknownVariableValue,
"destination": "/tmp/bar", "destination": "/tmp/bar",
}) })

View File

@ -7,6 +7,7 @@ import (
"github.com/hashicorp/hil" "github.com/hashicorp/hil"
"github.com/hashicorp/hil/ast" "github.com/hashicorp/hil/ast"
"github.com/hashicorp/terraform/config/hcl2shim"
"github.com/mitchellh/reflectwalk" "github.com/mitchellh/reflectwalk"
) )
@ -160,7 +161,7 @@ func (w *interpolationWalker) Primitive(v reflect.Value) error {
if w.loc == reflectwalk.SliceElem { if w.loc == reflectwalk.SliceElem {
switch typedReplaceVal := replaceVal.(type) { switch typedReplaceVal := replaceVal.(type) {
case string: case string:
if typedReplaceVal == UnknownVariableValue { if typedReplaceVal == hcl2shim.UnknownVariableValue {
remove = true remove = true
} }
case []interface{}: case []interface{}:
@ -168,7 +169,7 @@ func (w *interpolationWalker) Primitive(v reflect.Value) error {
remove = true remove = true
} }
} }
} else if replaceVal == UnknownVariableValue { } else if replaceVal == hcl2shim.UnknownVariableValue {
remove = true remove = true
} }
@ -224,7 +225,7 @@ func (w *interpolationWalker) replaceCurrent(v reflect.Value) {
func hasUnknownValue(variable []interface{}) bool { func hasUnknownValue(variable []interface{}) bool {
for _, value := range variable { for _, value := range variable {
if strVal, ok := value.(string); ok { if strVal, ok := value.(string); ok {
if strVal == UnknownVariableValue { if strVal == hcl2shim.UnknownVariableValue {
return true return true
} }
} }

View File

@ -6,6 +6,7 @@ import (
"testing" "testing"
"github.com/hashicorp/hil/ast" "github.com/hashicorp/hil/ast"
"github.com/hashicorp/terraform/config/hcl2shim"
"github.com/mitchellh/reflectwalk" "github.com/mitchellh/reflectwalk"
) )
@ -171,12 +172,12 @@ func TestInterpolationWalker_replace(t *testing.T) {
}, },
Output: map[string]interface{}{ Output: map[string]interface{}{
"foo": []interface{}{ "foo": []interface{}{
UnknownVariableValue, hcl2shim.UnknownVariableValue,
"baz", "baz",
"bing", "bing",
}, },
}, },
Value: []interface{}{UnknownVariableValue, "baz"}, Value: []interface{}{hcl2shim.UnknownVariableValue, "baz"},
}, },
} }

View File

@ -17,12 +17,6 @@ import (
"github.com/mitchellh/reflectwalk" "github.com/mitchellh/reflectwalk"
) )
// UnknownVariableValue is a sentinel value that can be used
// to denote that the value of a variable is unknown at this time.
// RawConfig uses this information to build up data about
// unknown keys.
const UnknownVariableValue = "74D93920-ED26-11E3-AC10-0800200C9A66"
// RawConfig is a structure that holds a piece of configuration // RawConfig is a structure that holds a piece of configuration
// where the overall structure is unknown since it will be used // where the overall structure is unknown since it will be used
// to configure a plugin or some other similar external component. // to configure a plugin or some other similar external component.

View File

@ -7,6 +7,7 @@ import (
hcl2 "github.com/hashicorp/hcl2/hcl" hcl2 "github.com/hashicorp/hcl2/hcl"
"github.com/hashicorp/hil/ast" "github.com/hashicorp/hil/ast"
"github.com/hashicorp/terraform/config/hcl2shim"
) )
func TestNewRawConfig(t *testing.T) { func TestNewRawConfig(t *testing.T) {
@ -191,7 +192,7 @@ func TestRawConfig_merge(t *testing.T) {
Type: ast.TypeString, Type: ast.TypeString,
}, },
"var.baz": ast.Variable{ "var.baz": ast.Variable{
Value: UnknownVariableValue, Value: hcl2shim.UnknownVariableValue,
Type: ast.TypeUnknown, Type: ast.TypeUnknown,
}, },
} }
@ -217,7 +218,7 @@ func TestRawConfig_merge(t *testing.T) {
expected := map[string]interface{}{ expected := map[string]interface{}{
"foo": "foovalue", "foo": "foovalue",
"bar": "barvalue", "bar": "barvalue",
"baz": UnknownVariableValue, "baz": hcl2shim.UnknownVariableValue,
} }
if !reflect.DeepEqual(actual, expected) { if !reflect.DeepEqual(actual, expected) {
t.Fatalf("bad: %#v", actual) t.Fatalf("bad: %#v", actual)
@ -251,7 +252,7 @@ func TestRawConfig_unknown(t *testing.T) {
vars := map[string]ast.Variable{ vars := map[string]ast.Variable{
"var.bar": ast.Variable{ "var.bar": ast.Variable{
Value: UnknownVariableValue, Value: hcl2shim.UnknownVariableValue,
Type: ast.TypeUnknown, Type: ast.TypeUnknown,
}, },
} }
@ -260,7 +261,7 @@ func TestRawConfig_unknown(t *testing.T) {
} }
actual := rc.Config() actual := rc.Config()
expected := map[string]interface{}{"foo": UnknownVariableValue} expected := map[string]interface{}{"foo": hcl2shim.UnknownVariableValue}
if !reflect.DeepEqual(actual, expected) { if !reflect.DeepEqual(actual, expected) {
t.Fatalf("bad: %#v", actual) t.Fatalf("bad: %#v", actual)
@ -284,7 +285,7 @@ func TestRawConfig_unknownPartial(t *testing.T) {
vars := map[string]ast.Variable{ vars := map[string]ast.Variable{
"var.bar": ast.Variable{ "var.bar": ast.Variable{
Value: UnknownVariableValue, Value: hcl2shim.UnknownVariableValue,
Type: ast.TypeUnknown, Type: ast.TypeUnknown,
}, },
} }
@ -293,7 +294,7 @@ func TestRawConfig_unknownPartial(t *testing.T) {
} }
actual := rc.Config() actual := rc.Config()
expected := map[string]interface{}{"foo": UnknownVariableValue} expected := map[string]interface{}{"foo": hcl2shim.UnknownVariableValue}
if !reflect.DeepEqual(actual, expected) { if !reflect.DeepEqual(actual, expected) {
t.Fatalf("bad: %#v", actual) t.Fatalf("bad: %#v", actual)
@ -319,7 +320,7 @@ func TestRawConfig_unknownPartialList(t *testing.T) {
vars := map[string]ast.Variable{ vars := map[string]ast.Variable{
"var.bar": ast.Variable{ "var.bar": ast.Variable{
Value: UnknownVariableValue, Value: hcl2shim.UnknownVariableValue,
Type: ast.TypeUnknown, Type: ast.TypeUnknown,
}, },
} }
@ -328,7 +329,7 @@ func TestRawConfig_unknownPartialList(t *testing.T) {
} }
actual := rc.Config() actual := rc.Config()
expected := map[string]interface{}{"foo": []interface{}{UnknownVariableValue}} expected := map[string]interface{}{"foo": []interface{}{hcl2shim.UnknownVariableValue}}
if !reflect.DeepEqual(actual, expected) { if !reflect.DeepEqual(actual, expected) {
t.Fatalf("bad: %#v", actual) t.Fatalf("bad: %#v", actual)
@ -356,7 +357,7 @@ func TestRawConfig_sliceIndexLoss(t *testing.T) {
vars := map[string]ast.Variable{ vars := map[string]ast.Variable{
"var.unknown": ast.Variable{ "var.unknown": ast.Variable{
Value: UnknownVariableValue, Value: hcl2shim.UnknownVariableValue,
Type: ast.TypeUnknown, Type: ast.TypeUnknown,
}, },
"var.known": ast.Variable{ "var.known": ast.Variable{

View File

@ -3,7 +3,7 @@ package diff
import ( import (
"strings" "strings"
"github.com/hashicorp/terraform/config" "github.com/hashicorp/terraform/config/hcl2shim"
"github.com/hashicorp/terraform/flatmap" "github.com/hashicorp/terraform/flatmap"
"github.com/hashicorp/terraform/terraform" "github.com/hashicorp/terraform/terraform"
) )
@ -95,7 +95,7 @@ func (b *ResourceBuilder) Diff(
// If this key is in the cleaned config, then use that value // If this key is in the cleaned config, then use that value
// because it'll have its variables properly interpolated // because it'll have its variables properly interpolated
if cleanV, ok := flatConfig[k]; ok && cleanV != config.UnknownVariableValue { if cleanV, ok := flatConfig[k]; ok && cleanV != hcl2shim.UnknownVariableValue {
v = cleanV v = cleanV
originalV = v originalV = v

View File

@ -3,7 +3,7 @@ package diff
import ( import (
"testing" "testing"
"github.com/hashicorp/terraform/config" "github.com/hashicorp/terraform/config/hcl2shim"
"github.com/hashicorp/terraform/terraform" "github.com/hashicorp/terraform/terraform"
) )
@ -287,7 +287,7 @@ func TestResourceBuilder_preProcessUnknown(t *testing.T) {
c := testConfig(t, map[string]interface{}{ c := testConfig(t, map[string]interface{}{
"foo": "${var.unknown}", "foo": "${var.unknown}",
}, map[string]string{ }, map[string]string{
"var.unknown": config.UnknownVariableValue, "var.unknown": hcl2shim.UnknownVariableValue,
}) })
diff, err := rb.Diff(state, c) diff, err := rb.Diff(state, c)
@ -378,7 +378,7 @@ func TestResourceBuilder_unknown(t *testing.T) {
"foo": "${var.unknown}", "foo": "${var.unknown}",
}, map[string]string{ }, map[string]string{
"var.foo": "bar", "var.foo": "bar",
"var.unknown": config.UnknownVariableValue, "var.unknown": hcl2shim.UnknownVariableValue,
}) })
diff, err := rb.Diff(state, c) diff, err := rb.Diff(state, c)

View File

@ -10,7 +10,6 @@ import (
"strings" "strings"
"github.com/hashicorp/terraform/addrs" "github.com/hashicorp/terraform/addrs"
"github.com/hashicorp/terraform/config"
"github.com/hashicorp/terraform/config/hcl2shim" "github.com/hashicorp/terraform/config/hcl2shim"
"github.com/hashicorp/terraform/states" "github.com/hashicorp/terraform/states"
@ -341,7 +340,7 @@ func legacyDiffComparisonString(changes *plans.Changes) string {
v := newAttrs[attrK] v := newAttrs[attrK]
u := oldAttrs[attrK] u := oldAttrs[attrK]
if v == config.UnknownVariableValue { if v == hcl2shim.UnknownVariableValue {
v = "<computed>" v = "<computed>"
} }
// NOTE: we don't support <sensitive> here because we would // NOTE: we don't support <sensitive> here because we would

View File

@ -8,6 +8,7 @@ import (
"github.com/hashicorp/hil/ast" "github.com/hashicorp/hil/ast"
"github.com/hashicorp/terraform/config" "github.com/hashicorp/terraform/config"
"github.com/hashicorp/terraform/config/hcl2shim"
"github.com/hashicorp/terraform/helper/hashcode" "github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/terraform" "github.com/hashicorp/terraform/terraform"
) )
@ -103,7 +104,7 @@ func TestConfigFieldReader_custom(t *testing.T) {
"bool": "${var.foo}", "bool": "${var.foo}",
}, map[string]ast.Variable{ }, map[string]ast.Variable{
"var.foo": ast.Variable{ "var.foo": ast.Variable{
Value: config.UnknownVariableValue, Value: hcl2shim.UnknownVariableValue,
Type: ast.TypeString, Type: ast.TypeString,
}, },
}), }),
@ -273,7 +274,7 @@ func TestConfigFieldReader_ComputedMap(t *testing.T) {
}, },
}, map[string]ast.Variable{ }, map[string]ast.Variable{
"var.foo": ast.Variable{ "var.foo": ast.Variable{
Value: config.UnknownVariableValue, Value: hcl2shim.UnknownVariableValue,
Type: ast.TypeString, Type: ast.TypeString,
}, },
}), }),
@ -495,7 +496,7 @@ func TestConfigFieldReader_ComputedSet(t *testing.T) {
"strSet": []interface{}{"${var.foo}"}, "strSet": []interface{}{"${var.foo}"},
}, map[string]ast.Variable{ }, map[string]ast.Variable{
"var.foo": ast.Variable{ "var.foo": ast.Variable{
Value: config.UnknownVariableValue, Value: hcl2shim.UnknownVariableValue,
Type: ast.TypeUnknown, Type: ast.TypeUnknown,
}, },
}), }),
@ -513,7 +514,7 @@ func TestConfigFieldReader_ComputedSet(t *testing.T) {
"strSet": []interface{}{"${var.foo}/32"}, "strSet": []interface{}{"${var.foo}/32"},
}, map[string]ast.Variable{ }, map[string]ast.Variable{
"var.foo": ast.Variable{ "var.foo": ast.Variable{
Value: config.UnknownVariableValue, Value: hcl2shim.UnknownVariableValue,
Type: ast.TypeUnknown, Type: ast.TypeUnknown,
}, },
}), }),
@ -622,7 +623,7 @@ func TestConfigFieldReader_computedComplexSet(t *testing.T) {
}, },
}, map[string]ast.Variable{ }, map[string]ast.Variable{
"var.foo": ast.Variable{ "var.foo": ast.Variable{
Value: config.UnknownVariableValue, Value: hcl2shim.UnknownVariableValue,
Type: ast.TypeUnknown, Type: ast.TypeUnknown,
}, },
}), }),
@ -645,7 +646,7 @@ func TestConfigFieldReader_computedComplexSet(t *testing.T) {
}, },
}, map[string]ast.Variable{ }, map[string]ast.Variable{
"var.foo": ast.Variable{ "var.foo": ast.Variable{
Value: config.UnknownVariableValue, Value: hcl2shim.UnknownVariableValue,
Type: ast.TypeUnknown, Type: ast.TypeUnknown,
}, },
}), }),

View File

@ -8,7 +8,7 @@ import (
"github.com/davecgh/go-spew/spew" "github.com/davecgh/go-spew/spew"
"github.com/hashicorp/hil/ast" "github.com/hashicorp/hil/ast"
"github.com/hashicorp/terraform/config" "github.com/hashicorp/terraform/config/hcl2shim"
"github.com/hashicorp/terraform/terraform" "github.com/hashicorp/terraform/terraform"
) )
@ -1907,7 +1907,7 @@ func TestResourceDiffNewValueKnown(t *testing.T) {
}, },
map[string]ast.Variable{ map[string]ast.Variable{
"var.foo": ast.Variable{ "var.foo": ast.Variable{
Value: config.UnknownVariableValue, Value: hcl2shim.UnknownVariableValue,
Type: ast.TypeString, Type: ast.TypeString,
}, },
}, },
@ -1938,7 +1938,7 @@ func TestResourceDiffNewValueKnown(t *testing.T) {
}, },
map[string]ast.Variable{ map[string]ast.Variable{
"var.foo": ast.Variable{ "var.foo": ast.Variable{
Value: config.UnknownVariableValue, Value: hcl2shim.UnknownVariableValue,
Type: ast.TypeString, Type: ast.TypeString,
}, },
}, },
@ -1998,7 +1998,7 @@ func TestResourceDiffNewValueKnownSetNew(t *testing.T) {
}, },
map[string]ast.Variable{ map[string]ast.Variable{
"var.foo": ast.Variable{ "var.foo": ast.Variable{
Value: config.UnknownVariableValue, Value: hcl2shim.UnknownVariableValue,
Type: ast.TypeString, Type: ast.TypeString,
}, },
}, },

View File

@ -5,7 +5,7 @@ import (
"log" "log"
"time" "time"
"github.com/hashicorp/terraform/config" "github.com/hashicorp/terraform/config/hcl2shim"
"github.com/hashicorp/terraform/terraform" "github.com/hashicorp/terraform/terraform"
"github.com/mitchellh/copystructure" "github.com/mitchellh/copystructure"
) )
@ -70,7 +70,7 @@ func (t *ResourceTimeout) ConfigDecode(s *Resource, c *terraform.ResourceConfig)
case []map[string]interface{}: case []map[string]interface{}:
rawTimeouts = raw rawTimeouts = raw
case string: case string:
if raw == config.UnknownVariableValue { if raw == hcl2shim.UnknownVariableValue {
// Timeout is not defined in the config // Timeout is not defined in the config
// Defaults will be used instead // Defaults will be used instead
return nil return nil

View File

@ -22,7 +22,7 @@ import (
"strings" "strings"
"sync" "sync"
"github.com/hashicorp/terraform/config" "github.com/hashicorp/terraform/config/hcl2shim"
"github.com/hashicorp/terraform/terraform" "github.com/hashicorp/terraform/terraform"
"github.com/mitchellh/copystructure" "github.com/mitchellh/copystructure"
"github.com/mitchellh/mapstructure" "github.com/mitchellh/mapstructure"
@ -1386,7 +1386,7 @@ func (m schemaMap) validate(
func isWhollyKnown(raw interface{}) bool { func isWhollyKnown(raw interface{}) bool {
switch raw := raw.(type) { switch raw := raw.(type) {
case string: case string:
if raw == config.UnknownVariableValue { if raw == hcl2shim.UnknownVariableValue {
return false return false
} }
case []interface{}: case []interface{}:
@ -1415,7 +1415,7 @@ func (m schemaMap) validateConflictingAttributes(
for _, conflictingKey := range schema.ConflictsWith { for _, conflictingKey := range schema.ConflictsWith {
if raw, ok := c.Get(conflictingKey); ok { if raw, ok := c.Get(conflictingKey); ok {
if raw == config.UnknownVariableValue { if raw == hcl2shim.UnknownVariableValue {
// An unknown value might become unset (null) once known, so // An unknown value might become unset (null) once known, so
// we must defer validation until it's known. // we must defer validation until it's known.
continue continue
@ -1435,7 +1435,7 @@ func (m schemaMap) validateList(
c *terraform.ResourceConfig) ([]string, []error) { c *terraform.ResourceConfig) ([]string, []error) {
// first check if the list is wholly unknown // first check if the list is wholly unknown
if s, ok := raw.(string); ok { if s, ok := raw.(string); ok {
if s == config.UnknownVariableValue { if s == hcl2shim.UnknownVariableValue {
return nil, nil return nil, nil
} }
} }
@ -1513,7 +1513,7 @@ func (m schemaMap) validateMap(
c *terraform.ResourceConfig) ([]string, []error) { c *terraform.ResourceConfig) ([]string, []error) {
// first check if the list is wholly unknown // first check if the list is wholly unknown
if s, ok := raw.(string); ok { if s, ok := raw.(string); ok {
if s == config.UnknownVariableValue { if s == hcl2shim.UnknownVariableValue {
return nil, nil return nil, nil
} }
} }

View File

@ -14,6 +14,7 @@ import (
"github.com/hashicorp/hil" "github.com/hashicorp/hil"
"github.com/hashicorp/hil/ast" "github.com/hashicorp/hil/ast"
"github.com/hashicorp/terraform/config" "github.com/hashicorp/terraform/config"
"github.com/hashicorp/terraform/config/hcl2shim"
"github.com/hashicorp/terraform/helper/hashcode" "github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/terraform" "github.com/hashicorp/terraform/terraform"
) )
@ -446,7 +447,7 @@ func TestSchemaMap_Diff(t *testing.T) {
}, },
ConfigVariables: map[string]ast.Variable{ ConfigVariables: map[string]ast.Variable{
"var.foo": interfaceToVariableSwallowError(config.UnknownVariableValue), "var.foo": interfaceToVariableSwallowError(hcl2shim.UnknownVariableValue),
}, },
Diff: &terraform.InstanceDiff{ Diff: &terraform.InstanceDiff{
@ -711,7 +712,7 @@ func TestSchemaMap_Diff(t *testing.T) {
ConfigVariables: map[string]ast.Variable{ ConfigVariables: map[string]ast.Variable{
"var.foo": interfaceToVariableSwallowError([]interface{}{ "var.foo": interfaceToVariableSwallowError([]interface{}{
config.UnknownVariableValue, "5"}), hcl2shim.UnknownVariableValue, "5"}),
}, },
Diff: &terraform.InstanceDiff{ Diff: &terraform.InstanceDiff{
@ -1091,7 +1092,7 @@ func TestSchemaMap_Diff(t *testing.T) {
ConfigVariables: map[string]ast.Variable{ ConfigVariables: map[string]ast.Variable{
"var.foo": interfaceToVariableSwallowError([]interface{}{ "var.foo": interfaceToVariableSwallowError([]interface{}{
config.UnknownVariableValue, "5"}), hcl2shim.UnknownVariableValue, "5"}),
}, },
Diff: &terraform.InstanceDiff{ Diff: &terraform.InstanceDiff{
@ -1777,7 +1778,7 @@ func TestSchemaMap_Diff(t *testing.T) {
}, },
ConfigVariables: map[string]ast.Variable{ ConfigVariables: map[string]ast.Variable{
"var.foo": interfaceToVariableSwallowError(config.UnknownVariableValue), "var.foo": interfaceToVariableSwallowError(hcl2shim.UnknownVariableValue),
}, },
Diff: &terraform.InstanceDiff{ Diff: &terraform.InstanceDiff{
@ -1829,7 +1830,7 @@ func TestSchemaMap_Diff(t *testing.T) {
}, },
ConfigVariables: map[string]ast.Variable{ ConfigVariables: map[string]ast.Variable{
"var.foo": interfaceToVariableSwallowError(config.UnknownVariableValue), "var.foo": interfaceToVariableSwallowError(hcl2shim.UnknownVariableValue),
}, },
Diff: &terraform.InstanceDiff{ Diff: &terraform.InstanceDiff{
@ -1897,7 +1898,7 @@ func TestSchemaMap_Diff(t *testing.T) {
}, },
ConfigVariables: map[string]ast.Variable{ ConfigVariables: map[string]ast.Variable{
"var.foo": interfaceToVariableSwallowError(config.UnknownVariableValue), "var.foo": interfaceToVariableSwallowError(hcl2shim.UnknownVariableValue),
}, },
Diff: &terraform.InstanceDiff{ Diff: &terraform.InstanceDiff{
@ -1966,7 +1967,7 @@ func TestSchemaMap_Diff(t *testing.T) {
}, },
ConfigVariables: map[string]ast.Variable{ ConfigVariables: map[string]ast.Variable{
"var.foo": interfaceToVariableSwallowError(config.UnknownVariableValue), "var.foo": interfaceToVariableSwallowError(hcl2shim.UnknownVariableValue),
}, },
Diff: &terraform.InstanceDiff{ Diff: &terraform.InstanceDiff{
@ -2326,7 +2327,7 @@ func TestSchemaMap_Diff(t *testing.T) {
}, },
ConfigVariables: map[string]ast.Variable{ ConfigVariables: map[string]ast.Variable{
"var.foo": interfaceToVariableSwallowError(config.UnknownVariableValue), "var.foo": interfaceToVariableSwallowError(hcl2shim.UnknownVariableValue),
}, },
Diff: &terraform.InstanceDiff{ Diff: &terraform.InstanceDiff{
@ -2720,7 +2721,7 @@ func TestSchemaMap_Diff(t *testing.T) {
ConfigVariables: map[string]ast.Variable{ ConfigVariables: map[string]ast.Variable{
"var.foo": interfaceToVariableSwallowError( "var.foo": interfaceToVariableSwallowError(
config.UnknownVariableValue), hcl2shim.UnknownVariableValue),
}, },
Diff: &terraform.InstanceDiff{ Diff: &terraform.InstanceDiff{
@ -2765,7 +2766,7 @@ func TestSchemaMap_Diff(t *testing.T) {
}, },
ConfigVariables: map[string]ast.Variable{ ConfigVariables: map[string]ast.Variable{
"var.foo": interfaceToVariableSwallowError(config.UnknownVariableValue), "var.foo": interfaceToVariableSwallowError(hcl2shim.UnknownVariableValue),
}, },
Diff: &terraform.InstanceDiff{ Diff: &terraform.InstanceDiff{
@ -2807,9 +2808,9 @@ func TestSchemaMap_Diff(t *testing.T) {
ConfigVariables: map[string]ast.Variable{ ConfigVariables: map[string]ast.Variable{
"var.a": interfaceToVariableSwallowError( "var.a": interfaceToVariableSwallowError(
config.UnknownVariableValue), hcl2shim.UnknownVariableValue),
"var.b": interfaceToVariableSwallowError( "var.b": interfaceToVariableSwallowError(
config.UnknownVariableValue), hcl2shim.UnknownVariableValue),
}, },
Diff: &terraform.InstanceDiff{ Diff: &terraform.InstanceDiff{
@ -4101,7 +4102,7 @@ func TestSchemaMap_DiffSuppress(t *testing.T) {
}, },
ConfigVariables: map[string]ast.Variable{ ConfigVariables: map[string]ast.Variable{
"var.bar": interfaceToVariableSwallowError(config.UnknownVariableValue), "var.bar": interfaceToVariableSwallowError(hcl2shim.UnknownVariableValue),
}, },
ExpectedDiff: &terraform.InstanceDiff{ ExpectedDiff: &terraform.InstanceDiff{
@ -4176,7 +4177,7 @@ func TestSchemaMap_DiffSuppress(t *testing.T) {
}, },
ConfigVariables: map[string]ast.Variable{ ConfigVariables: map[string]ast.Variable{
"var.bar": interfaceToVariableSwallowError(config.UnknownVariableValue), "var.bar": interfaceToVariableSwallowError(hcl2shim.UnknownVariableValue),
}, },
ExpectedDiff: &terraform.InstanceDiff{ ExpectedDiff: &terraform.InstanceDiff{
@ -4267,7 +4268,7 @@ func TestSchemaMap_Validate(t *testing.T) {
}, },
Vars: map[string]string{ Vars: map[string]string{
"var.foo": config.UnknownVariableValue, "var.foo": hcl2shim.UnknownVariableValue,
}, },
}, },
@ -4503,7 +4504,7 @@ func TestSchemaMap_Validate(t *testing.T) {
}, },
Config: map[string]interface{}{ Config: map[string]interface{}{
"strings": config.UnknownVariableValue, "strings": hcl2shim.UnknownVariableValue,
}, },
Err: false, Err: false,
@ -4610,7 +4611,7 @@ func TestSchemaMap_Validate(t *testing.T) {
}, },
Vars: map[string]string{ Vars: map[string]string{
"var.port": config.UnknownVariableValue, "var.port": hcl2shim.UnknownVariableValue,
}, },
Err: false, Err: false,
@ -4648,7 +4649,7 @@ func TestSchemaMap_Validate(t *testing.T) {
}, },
Vars: map[string]string{ Vars: map[string]string{
"var.foo": config.UnknownVariableValue, "var.foo": hcl2shim.UnknownVariableValue,
}, },
Err: true, Err: true,
@ -5016,7 +5017,7 @@ func TestSchemaMap_Validate(t *testing.T) {
Config: map[string]interface{}{ Config: map[string]interface{}{
"whitelist": "white-val", "whitelist": "white-val",
"blacklist": config.UnknownVariableValue, "blacklist": hcl2shim.UnknownVariableValue,
}, },
Err: false, Err: false,
@ -5036,7 +5037,7 @@ func TestSchemaMap_Validate(t *testing.T) {
}, },
Config: map[string]interface{}{ Config: map[string]interface{}{
"whitelist": config.UnknownVariableValue, "whitelist": hcl2shim.UnknownVariableValue,
"blacklist": "black-val", "blacklist": "black-val",
}, },
@ -5063,7 +5064,7 @@ func TestSchemaMap_Validate(t *testing.T) {
}, },
Config: map[string]interface{}{ Config: map[string]interface{}{
"whitelist": config.UnknownVariableValue, "whitelist": hcl2shim.UnknownVariableValue,
"blacklist": "black-val", "blacklist": "black-val",
"greenlist": "green-val", "greenlist": "green-val",
}, },
@ -5277,7 +5278,7 @@ func TestSchemaMap_Validate(t *testing.T) {
"validate_me": "${var.foo}", "validate_me": "${var.foo}",
}, },
Vars: map[string]string{ Vars: map[string]string{
"var.foo": config.UnknownVariableValue, "var.foo": hcl2shim.UnknownVariableValue,
}, },
Err: false, Err: false,
@ -5460,7 +5461,7 @@ func TestSchemaMap_Validate(t *testing.T) {
}, },
Vars: map[string]string{ Vars: map[string]string{
"var.a": "A", "var.a": "A",
"var.b": config.UnknownVariableValue, "var.b": hcl2shim.UnknownVariableValue,
}, },
Err: false, Err: false,
}, },

View File

@ -6,7 +6,7 @@ import (
"github.com/zclconf/go-cty/cty" "github.com/zclconf/go-cty/cty"
ctyjson "github.com/zclconf/go-cty/cty/json" ctyjson "github.com/zclconf/go-cty/cty/json"
"github.com/hashicorp/terraform/config" "github.com/hashicorp/terraform/config/hcl2shim"
"github.com/hashicorp/terraform/configs/configschema" "github.com/hashicorp/terraform/configs/configschema"
"github.com/hashicorp/terraform/terraform" "github.com/hashicorp/terraform/terraform"
) )
@ -50,7 +50,7 @@ func removeConfigUnknowns(cfg map[string]interface{}) {
for k, v := range cfg { for k, v := range cfg {
switch v := v.(type) { switch v := v.(type) {
case string: case string:
if v == config.UnknownVariableValue { if v == hcl2shim.UnknownVariableValue {
delete(cfg, k) delete(cfg, k)
} }
case []interface{}: case []interface{}:

View File

@ -108,9 +108,9 @@ func TestShimResourcePlan_destroyCreate(t *testing.T) {
} }
expected := &terraform.InstanceState{ expected := &terraform.InstanceState{
ID: config.UnknownVariableValue, ID: hcl2shim.UnknownVariableValue,
Attributes: map[string]string{ Attributes: map[string]string{
"id": config.UnknownVariableValue, "id": hcl2shim.UnknownVariableValue,
"foo": "42", "foo": "42",
}, },
Meta: map[string]interface{}{ Meta: map[string]interface{}{
@ -815,7 +815,7 @@ func TestShimSchemaMap_Diff(t *testing.T) {
}, },
ConfigVariables: map[string]ast.Variable{ ConfigVariables: map[string]ast.Variable{
"var.foo": interfaceToVariableSwallowError(config.UnknownVariableValue), "var.foo": interfaceToVariableSwallowError(hcl2shim.UnknownVariableValue),
}, },
Diff: &terraform.InstanceDiff{ Diff: &terraform.InstanceDiff{
@ -1048,7 +1048,7 @@ func TestShimSchemaMap_Diff(t *testing.T) {
ConfigVariables: map[string]ast.Variable{ ConfigVariables: map[string]ast.Variable{
"var.foo": interfaceToVariableSwallowError([]interface{}{ "var.foo": interfaceToVariableSwallowError([]interface{}{
config.UnknownVariableValue, "5"}), hcl2shim.UnknownVariableValue, "5"}),
}, },
Diff: &terraform.InstanceDiff{ Diff: &terraform.InstanceDiff{
@ -1431,7 +1431,7 @@ func TestShimSchemaMap_Diff(t *testing.T) {
ConfigVariables: map[string]ast.Variable{ ConfigVariables: map[string]ast.Variable{
"var.foo": interfaceToVariableSwallowError([]interface{}{ "var.foo": interfaceToVariableSwallowError([]interface{}{
config.UnknownVariableValue, "5"}), hcl2shim.UnknownVariableValue, "5"}),
}, },
Diff: &terraform.InstanceDiff{ Diff: &terraform.InstanceDiff{
@ -2060,7 +2060,7 @@ func TestShimSchemaMap_Diff(t *testing.T) {
}, },
ConfigVariables: map[string]ast.Variable{ ConfigVariables: map[string]ast.Variable{
"var.foo": interfaceToVariableSwallowError(config.UnknownVariableValue), "var.foo": interfaceToVariableSwallowError(hcl2shim.UnknownVariableValue),
}, },
Diff: &terraform.InstanceDiff{ Diff: &terraform.InstanceDiff{
@ -2112,7 +2112,7 @@ func TestShimSchemaMap_Diff(t *testing.T) {
}, },
ConfigVariables: map[string]ast.Variable{ ConfigVariables: map[string]ast.Variable{
"var.foo": interfaceToVariableSwallowError(config.UnknownVariableValue), "var.foo": interfaceToVariableSwallowError(hcl2shim.UnknownVariableValue),
}, },
Diff: &terraform.InstanceDiff{ Diff: &terraform.InstanceDiff{
@ -2180,7 +2180,7 @@ func TestShimSchemaMap_Diff(t *testing.T) {
}, },
ConfigVariables: map[string]ast.Variable{ ConfigVariables: map[string]ast.Variable{
"var.foo": interfaceToVariableSwallowError(config.UnknownVariableValue), "var.foo": interfaceToVariableSwallowError(hcl2shim.UnknownVariableValue),
}, },
Diff: &terraform.InstanceDiff{ Diff: &terraform.InstanceDiff{
@ -2250,7 +2250,7 @@ func TestShimSchemaMap_Diff(t *testing.T) {
}, },
ConfigVariables: map[string]ast.Variable{ ConfigVariables: map[string]ast.Variable{
"var.foo": interfaceToVariableSwallowError(config.UnknownVariableValue), "var.foo": interfaceToVariableSwallowError(hcl2shim.UnknownVariableValue),
}, },
Diff: &terraform.InstanceDiff{ Diff: &terraform.InstanceDiff{
@ -2617,7 +2617,7 @@ func TestShimSchemaMap_Diff(t *testing.T) {
}, },
ConfigVariables: map[string]ast.Variable{ ConfigVariables: map[string]ast.Variable{
"var.foo": interfaceToVariableSwallowError(config.UnknownVariableValue), "var.foo": interfaceToVariableSwallowError(hcl2shim.UnknownVariableValue),
}, },
Diff: &terraform.InstanceDiff{ Diff: &terraform.InstanceDiff{
@ -3009,7 +3009,7 @@ func TestShimSchemaMap_Diff(t *testing.T) {
ConfigVariables: map[string]ast.Variable{ ConfigVariables: map[string]ast.Variable{
"var.foo": interfaceToVariableSwallowError( "var.foo": interfaceToVariableSwallowError(
config.UnknownVariableValue), hcl2shim.UnknownVariableValue),
}, },
Diff: &terraform.InstanceDiff{ Diff: &terraform.InstanceDiff{
@ -3055,7 +3055,7 @@ func TestShimSchemaMap_Diff(t *testing.T) {
}, },
ConfigVariables: map[string]ast.Variable{ ConfigVariables: map[string]ast.Variable{
"var.foo": interfaceToVariableSwallowError(config.UnknownVariableValue), "var.foo": interfaceToVariableSwallowError(hcl2shim.UnknownVariableValue),
}, },
Diff: &terraform.InstanceDiff{ Diff: &terraform.InstanceDiff{
@ -3096,9 +3096,9 @@ func TestShimSchemaMap_Diff(t *testing.T) {
ConfigVariables: map[string]ast.Variable{ ConfigVariables: map[string]ast.Variable{
"var.a": interfaceToVariableSwallowError( "var.a": interfaceToVariableSwallowError(
config.UnknownVariableValue), hcl2shim.UnknownVariableValue),
"var.b": interfaceToVariableSwallowError( "var.b": interfaceToVariableSwallowError(
config.UnknownVariableValue), hcl2shim.UnknownVariableValue),
}, },
Diff: &terraform.InstanceDiff{ Diff: &terraform.InstanceDiff{
@ -3593,7 +3593,7 @@ func TestShimSchemaMap_Diff(t *testing.T) {
// there would be no unknown config variables during apply, so // there would be no unknown config variables during apply, so
// return early here. // return early here.
for _, v := range tc.ConfigVariables { for _, v := range tc.ConfigVariables {
if s, ok := v.Value.(string); ok && s == config.UnknownVariableValue { if s, ok := v.Value.(string); ok && s == hcl2shim.UnknownVariableValue {
return return
} }
} }

View File

@ -21,7 +21,6 @@ import (
"github.com/hashicorp/hil" "github.com/hashicorp/hil"
"github.com/zclconf/go-cty/cty" "github.com/zclconf/go-cty/cty"
"github.com/hashicorp/terraform/config"
"github.com/hashicorp/terraform/config/hcl2shim" "github.com/hashicorp/terraform/config/hcl2shim"
"github.com/hashicorp/terraform/configs" "github.com/hashicorp/terraform/configs"
"github.com/hashicorp/terraform/configs/configload" "github.com/hashicorp/terraform/configs/configload"
@ -165,7 +164,7 @@ func testApplyFn(
id = idAttr.New id = idAttr.New
} }
if id == "" || id == config.UnknownVariableValue { if id == "" || id == hcl2shim.UnknownVariableValue {
id = "foo" id = "foo"
} }
@ -978,7 +977,7 @@ func legacyDiffComparisonString(changes *plans.Changes) string {
v := newAttrs[attrK] v := newAttrs[attrK]
u := oldAttrs[attrK] u := oldAttrs[attrK]
if v == config.UnknownVariableValue { if v == hcl2shim.UnknownVariableValue {
v = "<computed>" v = "<computed>"
} }
// NOTE: we don't support <sensitive> here because we would // NOTE: we don't support <sensitive> here because we would

View File

@ -13,7 +13,6 @@ import (
"sync" "sync"
"github.com/hashicorp/terraform/addrs" "github.com/hashicorp/terraform/addrs"
"github.com/hashicorp/terraform/config"
"github.com/hashicorp/terraform/config/hcl2shim" "github.com/hashicorp/terraform/config/hcl2shim"
"github.com/hashicorp/terraform/configs/configschema" "github.com/hashicorp/terraform/configs/configschema"
"github.com/zclconf/go-cty/cty" "github.com/zclconf/go-cty/cty"
@ -665,7 +664,7 @@ func (d *InstanceDiff) applySingleAttrDiff(path []string, attrs map[string]strin
old, exists := attrs[currentKey] old, exists := attrs[currentKey]
if diff != nil && diff.NewComputed { if diff != nil && diff.NewComputed {
result[attr] = config.UnknownVariableValue result[attr] = hcl2shim.UnknownVariableValue
return result, nil return result, nil
} }
@ -673,7 +672,7 @@ func (d *InstanceDiff) applySingleAttrDiff(path []string, attrs map[string]strin
// This only applied to top-level "id" fields. // This only applied to top-level "id" fields.
if attr == "id" && len(path) == 1 { if attr == "id" && len(path) == 1 {
if old == "" { if old == "" {
result[attr] = config.UnknownVariableValue result[attr] = hcl2shim.UnknownVariableValue
} else { } else {
result[attr] = old result[attr] = old
} }
@ -704,8 +703,8 @@ func (d *InstanceDiff) applySingleAttrDiff(path []string, attrs map[string]strin
// check for missmatched diff values // check for missmatched diff values
if exists && if exists &&
old != diff.Old && old != diff.Old &&
old != config.UnknownVariableValue && old != hcl2shim.UnknownVariableValue &&
diff.Old != config.UnknownVariableValue { diff.Old != hcl2shim.UnknownVariableValue {
return result, fmt.Errorf("diff apply conflict for %s: diff expects %q, but prior value has %q", attr, diff.Old, old) return result, fmt.Errorf("diff apply conflict for %s: diff expects %q, but prior value has %q", attr, diff.Old, old)
} }
@ -723,7 +722,7 @@ func (d *InstanceDiff) applySingleAttrDiff(path []string, attrs map[string]strin
} }
if attrSchema.Computed && diff.NewComputed { if attrSchema.Computed && diff.NewComputed {
result[attr] = config.UnknownVariableValue result[attr] = hcl2shim.UnknownVariableValue
return result, nil return result, nil
} }
@ -756,7 +755,7 @@ func (d *InstanceDiff) applyCollectionDiff(path []string, attrs map[string]strin
} }
if diff.NewComputed { if diff.NewComputed {
result[k[len(prefix):]] = config.UnknownVariableValue result[k[len(prefix):]] = hcl2shim.UnknownVariableValue
return result, nil return result, nil
} }

View File

@ -12,6 +12,7 @@ import (
"github.com/hashicorp/terraform/addrs" "github.com/hashicorp/terraform/addrs"
"github.com/hashicorp/terraform/config" "github.com/hashicorp/terraform/config"
"github.com/hashicorp/terraform/config/hcl2shim"
"github.com/hashicorp/terraform/config/module" "github.com/hashicorp/terraform/config/module"
"github.com/zclconf/go-cty/cty" "github.com/zclconf/go-cty/cty"
"github.com/zclconf/go-cty/cty/convert" "github.com/zclconf/go-cty/cty/convert"
@ -60,7 +61,7 @@ func (n *EvalTypeCheckVariable) Eval(ctx EvalContext) (interface{}, error) {
continue continue
} }
if proposedValue == config.UnknownVariableValue { if proposedValue == hcl2shim.UnknownVariableValue {
continue continue
} }

View File

@ -11,6 +11,7 @@ import (
"github.com/hashicorp/hil" "github.com/hashicorp/hil"
"github.com/hashicorp/hil/ast" "github.com/hashicorp/hil/ast"
"github.com/hashicorp/terraform/config" "github.com/hashicorp/terraform/config"
"github.com/hashicorp/terraform/config/hcl2shim"
"github.com/hashicorp/terraform/config/module" "github.com/hashicorp/terraform/config/module"
"github.com/hashicorp/terraform/flatmap" "github.com/hashicorp/terraform/flatmap"
) )
@ -71,7 +72,7 @@ func (i *Interpolater) valueCountVar(
func unknownVariable() ast.Variable { func unknownVariable() ast.Variable {
return ast.Variable{ return ast.Variable{
Type: ast.TypeUnknown, Type: ast.TypeUnknown,
Value: config.UnknownVariableValue, Value: hcl2shim.UnknownVariableValue,
} }
} }
@ -659,7 +660,7 @@ func (i *Interpolater) interpolateComplexTypeAttribute(
// ".#" count field is marked as unknown to indicate "this whole list is // ".#" count field is marked as unknown to indicate "this whole list is
// unknown". We must honor that meaning here so computed references can be // unknown". We must honor that meaning here so computed references can be
// treated properly during the plan phase. // treated properly during the plan phase.
if lengthAttr == config.UnknownVariableValue { if lengthAttr == hcl2shim.UnknownVariableValue {
return unknownVariable(), nil return unknownVariable(), nil
} }
@ -675,7 +676,7 @@ func (i *Interpolater) interpolateComplexTypeAttribute(
// ".%" count field is marked as unknown to indicate "this whole list is // ".%" count field is marked as unknown to indicate "this whole list is
// unknown". We must honor that meaning here so computed references can be // unknown". We must honor that meaning here so computed references can be
// treated properly during the plan phase. // treated properly during the plan phase.
if lengthAttr == config.UnknownVariableValue { if lengthAttr == hcl2shim.UnknownVariableValue {
return unknownVariable(), nil return unknownVariable(), nil
} }

View File

@ -8,7 +8,6 @@ import (
"github.com/zclconf/go-cty/cty" "github.com/zclconf/go-cty/cty"
ctyjson "github.com/zclconf/go-cty/cty/json" ctyjson "github.com/zclconf/go-cty/cty/json"
"github.com/hashicorp/terraform/config"
"github.com/hashicorp/terraform/config/hcl2shim" "github.com/hashicorp/terraform/config/hcl2shim"
"github.com/hashicorp/terraform/providers" "github.com/hashicorp/terraform/providers"
"github.com/hashicorp/terraform/tfdiags" "github.com/hashicorp/terraform/tfdiags"
@ -391,7 +390,7 @@ func (p *MockProvider) ApplyResourceChange(r providers.ApplyResourceChangeReques
for k, new := range plannedMap { for k, new := range plannedMap {
old := priorMap[k] old := priorMap[k]
newComputed := false newComputed := false
if new == config.UnknownVariableValue { if new == hcl2shim.UnknownVariableValue {
new = "" new = ""
newComputed = true newComputed = true
} }

View File

@ -12,6 +12,7 @@ import (
"github.com/hashicorp/hil" "github.com/hashicorp/hil"
"github.com/hashicorp/hil/ast" "github.com/hashicorp/hil/ast"
"github.com/hashicorp/terraform/config" "github.com/hashicorp/terraform/config"
"github.com/hashicorp/terraform/config/hcl2shim"
"github.com/mitchellh/reflectwalk" "github.com/mitchellh/reflectwalk"
) )
@ -840,10 +841,10 @@ func TestNewResourceConfigShimmed(t *testing.T) {
Expected: &ResourceConfig{ Expected: &ResourceConfig{
ComputedKeys: []string{"foo"}, ComputedKeys: []string{"foo"},
Raw: map[string]interface{}{ Raw: map[string]interface{}{
"foo": config.UnknownVariableValue, "foo": hcl2shim.UnknownVariableValue,
}, },
Config: map[string]interface{}{ Config: map[string]interface{}{
"foo": config.UnknownVariableValue, "foo": hcl2shim.UnknownVariableValue,
}, },
}, },
}, },
@ -868,12 +869,12 @@ func TestNewResourceConfigShimmed(t *testing.T) {
Expected: &ResourceConfig{ Expected: &ResourceConfig{
ComputedKeys: []string{"bar", "baz"}, ComputedKeys: []string{"bar", "baz"},
Raw: map[string]interface{}{ Raw: map[string]interface{}{
"bar": config.UnknownVariableValue, "bar": hcl2shim.UnknownVariableValue,
"baz": config.UnknownVariableValue, "baz": hcl2shim.UnknownVariableValue,
}, },
Config: map[string]interface{}{ Config: map[string]interface{}{
"bar": config.UnknownVariableValue, "bar": hcl2shim.UnknownVariableValue,
"baz": config.UnknownVariableValue, "baz": hcl2shim.UnknownVariableValue,
}, },
}, },
}, },
@ -921,12 +922,12 @@ func TestNewResourceConfigShimmed(t *testing.T) {
Expected: &ResourceConfig{ Expected: &ResourceConfig{
ComputedKeys: []string{"bar", "baz"}, ComputedKeys: []string{"bar", "baz"},
Raw: map[string]interface{}{ Raw: map[string]interface{}{
"bar": config.UnknownVariableValue, "bar": hcl2shim.UnknownVariableValue,
"baz": config.UnknownVariableValue, "baz": hcl2shim.UnknownVariableValue,
}, },
Config: map[string]interface{}{ Config: map[string]interface{}{
"bar": config.UnknownVariableValue, "bar": hcl2shim.UnknownVariableValue,
"baz": config.UnknownVariableValue, "baz": hcl2shim.UnknownVariableValue,
}, },
}, },
}, },

View File

@ -1201,7 +1201,7 @@ func (m *ModuleState) prune() {
} }
for k, v := range m.Outputs { for k, v := range m.Outputs {
if v.Value == config.UnknownVariableValue { if v.Value == hcl2shim.UnknownVariableValue {
delete(m.Outputs, k) delete(m.Outputs, k)
} }
} }
@ -1827,7 +1827,7 @@ func (s *InstanceState) MergeDiff(d *InstanceDiff) *InstanceState {
continue continue
} }
if diff.NewComputed { if diff.NewComputed {
result.Attributes[k] = config.UnknownVariableValue result.Attributes[k] = hcl2shim.UnknownVariableValue
continue continue
} }

View File

@ -14,6 +14,7 @@ import (
"github.com/hashicorp/terraform/addrs" "github.com/hashicorp/terraform/addrs"
"github.com/hashicorp/terraform/config" "github.com/hashicorp/terraform/config"
"github.com/hashicorp/terraform/config/hcl2shim"
) )
func TestStateValidate(t *testing.T) { func TestStateValidate(t *testing.T) {
@ -1416,7 +1417,7 @@ func TestInstanceState_MergeDiff(t *testing.T) {
expected := map[string]string{ expected := map[string]string{
"foo": "baz", "foo": "baz",
"bar": "foo", "bar": "foo",
"baz": config.UnknownVariableValue, "baz": hcl2shim.UnknownVariableValue,
} }
if !reflect.DeepEqual(expected, is2.Attributes) { if !reflect.DeepEqual(expected, is2.Attributes) {
@ -1455,7 +1456,7 @@ func TestInstanceState_MergeDiff_computedSet(t *testing.T) {
expected := map[string]string{ expected := map[string]string{
"config.#": "1", "config.#": "1",
"config.0.name": "hello", "config.0.name": "hello",
"config.0.rules.#": config.UnknownVariableValue, "config.0.rules.#": hcl2shim.UnknownVariableValue,
} }
if !reflect.DeepEqual(expected, is2.Attributes) { if !reflect.DeepEqual(expected, is2.Attributes) {