terraform: use the new TypeUnknown type from HIL

This makes all the computed stuff "just work" since HIL uses the same
computed sentinel value (string UUID) and the type differentiates it
from a regular string.
This commit is contained in:
Mitchell Hashimoto 2016-10-27 00:00:24 -04:00
parent b979d8927e
commit 5ed1b5fc89
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
4 changed files with 15 additions and 15 deletions

View File

@ -87,7 +87,9 @@ func TestContext2Validate_computedVar(t *testing.T) {
t.Fatalf("bad: %#v", w)
}
if len(e) > 0 {
t.Fatalf("bad: %#v", e)
for _, err := range e {
t.Errorf("bad: %s", err)
}
}
}

View File

@ -121,7 +121,7 @@ func (i *Interpolater) valueCountVar(
func unknownVariable() ast.Variable {
return ast.Variable{
Type: ast.TypeString,
Type: ast.TypeUnknown,
Value: config.UnknownVariableValue,
}
}
@ -215,10 +215,7 @@ func (i *Interpolater) valueResourceVar(
// If we're computing all dynamic fields, then module vars count
// and we mark it as computed.
if i.Operation == walkValidate {
result[n] = ast.Variable{
Value: config.UnknownVariableValue,
Type: ast.TypeString,
}
result[n] = unknownVariable()
return nil
}
@ -243,10 +240,7 @@ func (i *Interpolater) valueResourceVar(
// This applies only to graph nodes that interpolate during the
// config walk, e.g. providers.
if i.Operation == walkInput {
result[n] = ast.Variable{
Value: config.UnknownVariableValue,
Type: ast.TypeString,
}
result[n] = unknownVariable()
return nil
}

View File

@ -306,7 +306,7 @@ func TestInterpolater_resourceVariableMissingDuringInput(t *testing.T) {
testInterpolate(t, i, scope, "aws_instance.web.foo", ast.Variable{
Value: config.UnknownVariableValue,
Type: ast.TypeString,
Type: ast.TypeUnknown,
})
}
@ -360,7 +360,7 @@ func TestInterpolater_resourceVariableMulti(t *testing.T) {
testInterpolate(t, i, scope, "aws_instance.web.*.foo", ast.Variable{
Value: config.UnknownVariableValue,
Type: ast.TypeString,
Type: ast.TypeUnknown,
})
}
@ -565,7 +565,7 @@ func TestInterpolator_resourceMultiAttributesComputed(t *testing.T) {
testInterpolate(t, i, scope, "aws_route53_zone.yada.name_servers", ast.Variable{
Value: config.UnknownVariableValue,
Type: ast.TypeString,
Type: ast.TypeUnknown,
})
}

View File

@ -209,9 +209,13 @@ func (c *ResourceConfig) GetRaw(k string) (interface{}, bool) {
// IsComputed returns whether the given key is computed or not.
func (c *ResourceConfig) IsComputed(k string) bool {
_, ok := c.get(k, c.Config)
v, ok := c.get(k, c.Config)
_, okRaw := c.get(k, c.Raw)
return !ok && okRaw
// Both tests probably aren't needed anymore since we don't remove
// values any longer. The latter is probably good enough since we
// thread through that value now.
return (!ok && okRaw) || v == config.UnknownVariableValue
}
// IsSet checks if the key in the configuration is set. A key is set if