Merge pull request #22112 from hashicorp/appilon/move-unkownvariablevalue

Begin removing config package, starting with config.UnknownVariableValue
This commit is contained in:
appilon 2019-07-17 23:28:17 -04:00 committed by GitHub
commit 72354bc122
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 119 additions and 118 deletions

View File

@ -3,7 +3,7 @@ package test
import (
"fmt"
"github.com/hashicorp/terraform/config"
"github.com/hashicorp/terraform/config/hcl2shim"
"github.com/hashicorp/terraform/helper/schema"
)
@ -26,7 +26,7 @@ func testResourceMap() *schema.Resource {
ValidateFunc: func(v interface{}, _ string) ([]string, []error) {
errs := []error{}
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))
}
}

View File

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

View File

@ -4,6 +4,7 @@ import (
"testing"
"github.com/hashicorp/terraform/config"
"github.com/hashicorp/terraform/config/hcl2shim"
"github.com/hashicorp/terraform/helper/schema"
"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) {
c := testConfig(t, map[string]interface{}{
"content": config.UnknownVariableValue,
"content": hcl2shim.UnknownVariableValue,
"destination": "/tmp/bar",
})

View File

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

View File

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

View File

@ -17,12 +17,6 @@ import (
"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
// where the overall structure is unknown since it will be used
// to configure a plugin or some other similar external component.

View File

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

View File

@ -3,7 +3,7 @@ package diff
import (
"strings"
"github.com/hashicorp/terraform/config"
"github.com/hashicorp/terraform/config/hcl2shim"
"github.com/hashicorp/terraform/flatmap"
"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
// 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
originalV = v

View File

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

View File

@ -10,7 +10,6 @@ import (
"strings"
"github.com/hashicorp/terraform/addrs"
"github.com/hashicorp/terraform/config"
"github.com/hashicorp/terraform/config/hcl2shim"
"github.com/hashicorp/terraform/states"
@ -341,7 +340,7 @@ func legacyDiffComparisonString(changes *plans.Changes) string {
v := newAttrs[attrK]
u := oldAttrs[attrK]
if v == config.UnknownVariableValue {
if v == hcl2shim.UnknownVariableValue {
v = "<computed>"
}
// 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/terraform/config"
"github.com/hashicorp/terraform/config/hcl2shim"
"github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/terraform"
)
@ -103,7 +104,7 @@ func TestConfigFieldReader_custom(t *testing.T) {
"bool": "${var.foo}",
}, map[string]ast.Variable{
"var.foo": ast.Variable{
Value: config.UnknownVariableValue,
Value: hcl2shim.UnknownVariableValue,
Type: ast.TypeString,
},
}),
@ -273,7 +274,7 @@ func TestConfigFieldReader_ComputedMap(t *testing.T) {
},
}, map[string]ast.Variable{
"var.foo": ast.Variable{
Value: config.UnknownVariableValue,
Value: hcl2shim.UnknownVariableValue,
Type: ast.TypeString,
},
}),
@ -495,7 +496,7 @@ func TestConfigFieldReader_ComputedSet(t *testing.T) {
"strSet": []interface{}{"${var.foo}"},
}, map[string]ast.Variable{
"var.foo": ast.Variable{
Value: config.UnknownVariableValue,
Value: hcl2shim.UnknownVariableValue,
Type: ast.TypeUnknown,
},
}),
@ -513,7 +514,7 @@ func TestConfigFieldReader_ComputedSet(t *testing.T) {
"strSet": []interface{}{"${var.foo}/32"},
}, map[string]ast.Variable{
"var.foo": ast.Variable{
Value: config.UnknownVariableValue,
Value: hcl2shim.UnknownVariableValue,
Type: ast.TypeUnknown,
},
}),
@ -622,7 +623,7 @@ func TestConfigFieldReader_computedComplexSet(t *testing.T) {
},
}, map[string]ast.Variable{
"var.foo": ast.Variable{
Value: config.UnknownVariableValue,
Value: hcl2shim.UnknownVariableValue,
Type: ast.TypeUnknown,
},
}),
@ -645,7 +646,7 @@ func TestConfigFieldReader_computedComplexSet(t *testing.T) {
},
}, map[string]ast.Variable{
"var.foo": ast.Variable{
Value: config.UnknownVariableValue,
Value: hcl2shim.UnknownVariableValue,
Type: ast.TypeUnknown,
},
}),

View File

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

View File

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

View File

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

View File

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

View File

@ -6,7 +6,7 @@ import (
"github.com/zclconf/go-cty/cty"
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/terraform"
)
@ -50,7 +50,7 @@ func removeConfigUnknowns(cfg map[string]interface{}) {
for k, v := range cfg {
switch v := v.(type) {
case string:
if v == config.UnknownVariableValue {
if v == hcl2shim.UnknownVariableValue {
delete(cfg, k)
}
case []interface{}:

View File

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

View File

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

View File

@ -13,7 +13,6 @@ import (
"sync"
"github.com/hashicorp/terraform/addrs"
"github.com/hashicorp/terraform/config"
"github.com/hashicorp/terraform/config/hcl2shim"
"github.com/hashicorp/terraform/configs/configschema"
"github.com/zclconf/go-cty/cty"
@ -665,7 +664,7 @@ func (d *InstanceDiff) applySingleAttrDiff(path []string, attrs map[string]strin
old, exists := attrs[currentKey]
if diff != nil && diff.NewComputed {
result[attr] = config.UnknownVariableValue
result[attr] = hcl2shim.UnknownVariableValue
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.
if attr == "id" && len(path) == 1 {
if old == "" {
result[attr] = config.UnknownVariableValue
result[attr] = hcl2shim.UnknownVariableValue
} else {
result[attr] = old
}
@ -704,8 +703,8 @@ func (d *InstanceDiff) applySingleAttrDiff(path []string, attrs map[string]strin
// check for missmatched diff values
if exists &&
old != diff.Old &&
old != config.UnknownVariableValue &&
diff.Old != config.UnknownVariableValue {
old != hcl2shim.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)
}
@ -723,7 +722,7 @@ func (d *InstanceDiff) applySingleAttrDiff(path []string, attrs map[string]strin
}
if attrSchema.Computed && diff.NewComputed {
result[attr] = config.UnknownVariableValue
result[attr] = hcl2shim.UnknownVariableValue
return result, nil
}
@ -756,7 +755,7 @@ func (d *InstanceDiff) applyCollectionDiff(path []string, attrs map[string]strin
}
if diff.NewComputed {
result[k[len(prefix):]] = config.UnknownVariableValue
result[k[len(prefix):]] = hcl2shim.UnknownVariableValue
return result, nil
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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