diff --git a/go.mod b/go.mod index 589b6cf94..d287537ba 100644 --- a/go.mod +++ b/go.mod @@ -72,7 +72,7 @@ require ( github.com/hashicorp/go-version v1.0.0 github.com/hashicorp/golang-lru v0.5.0 // indirect github.com/hashicorp/hcl v0.0.0-20170504190234-a4b07c25de5f - github.com/hashicorp/hcl2 v0.0.0-20181219235215-291f7fbe431d + github.com/hashicorp/hcl2 v0.0.0-20181220012050-6631d7cd0a68 github.com/hashicorp/hil v0.0.0-20170627220502-fa9f258a9250 github.com/hashicorp/logutils v0.0.0-20150609070431-0dc08b1671f3 github.com/hashicorp/memberlist v0.1.0 // indirect diff --git a/go.sum b/go.sum index 229d58d95..42b10352f 100644 --- a/go.sum +++ b/go.sum @@ -171,6 +171,8 @@ github.com/hashicorp/hcl2 v0.0.0-20181219223929-62acf2ce821d h1:sd9/19rMHTRn7UTY github.com/hashicorp/hcl2 v0.0.0-20181219223929-62acf2ce821d/go.mod h1:ShfpTh661oAaxo7VcNxg0zcZW6jvMa7Moy2oFx7e5dE= github.com/hashicorp/hcl2 v0.0.0-20181219235215-291f7fbe431d h1:/htY6cNUFEn929uHLoI/5rYUHcaKLXZpbE6zEOymf78= github.com/hashicorp/hcl2 v0.0.0-20181219235215-291f7fbe431d/go.mod h1:ShfpTh661oAaxo7VcNxg0zcZW6jvMa7Moy2oFx7e5dE= +github.com/hashicorp/hcl2 v0.0.0-20181220012050-6631d7cd0a68 h1:d2VhAXrdo8KXWFsn8lNHp5IL0OUXmXMIIlcZBmZa1iU= +github.com/hashicorp/hcl2 v0.0.0-20181220012050-6631d7cd0a68/go.mod h1:ShfpTh661oAaxo7VcNxg0zcZW6jvMa7Moy2oFx7e5dE= github.com/hashicorp/hil v0.0.0-20170627220502-fa9f258a9250 h1:fooK5IvDL/KIsi4LxF/JH68nVdrBSiGNPhS2JAQjtjo= github.com/hashicorp/hil v0.0.0-20170627220502-fa9f258a9250/go.mod h1:KHvg/R2/dPtaePb16oW4qIyzkMxXOL38xjRN64adsts= github.com/hashicorp/logutils v0.0.0-20150609070431-0dc08b1671f3 h1:oD64EFjELI9RY9yoWlfua58r+etdnoIC871z+rr6lkA= diff --git a/vendor/github.com/hashicorp/hcl2/ext/dynblock/expand_body.go b/vendor/github.com/hashicorp/hcl2/ext/dynblock/expand_body.go index 697440e09..97d1e4dd5 100644 --- a/vendor/github.com/hashicorp/hcl2/ext/dynblock/expand_body.go +++ b/vendor/github.com/hashicorp/hcl2/ext/dynblock/expand_body.go @@ -234,7 +234,8 @@ func (b *expandBody) expandBlocks(schema *hcl.BodySchema, rawBlocks hcl.Blocks, } func (b *expandBody) expandChild(child hcl.Body, i *iteration) hcl.Body { - ret := Expand(child, b.forEachCtx) + chiCtx := i.EvalContext(b.forEachCtx) + ret := Expand(child, chiCtx) ret.(*expandBody).iteration = i return ret } diff --git a/vendor/github.com/hashicorp/hcl2/ext/dynblock/expand_spec.go b/vendor/github.com/hashicorp/hcl2/ext/dynblock/expand_spec.go index be76cd04d..41c0be267 100644 --- a/vendor/github.com/hashicorp/hcl2/ext/dynblock/expand_spec.go +++ b/vendor/github.com/hashicorp/hcl2/ext/dynblock/expand_spec.go @@ -41,11 +41,14 @@ func (b *expandBody) decodeSpec(blockS *hcl.BlockHeaderSchema, rawSpec *hcl.Bloc eachVal, eachDiags := eachAttr.Expr.Value(b.forEachCtx) diags = append(diags, eachDiags...) - if !eachVal.CanIterateElements() { + if !eachVal.CanIterateElements() && eachVal.Type() != cty.DynamicPseudoType { + // We skip this error for DynamicPseudoType because that means we either + // have a null (which is checked immediately below) or an unknown + // (which is handled in the expandBody Content methods). diags = append(diags, &hcl.Diagnostic{ Severity: hcl.DiagError, Summary: "Invalid dynamic for_each value", - Detail: fmt.Sprintf("Cannot use a value of type %s in for_each. An iterable collection is required.", eachVal.Type()), + Detail: fmt.Sprintf("Cannot use a %s value in for_each. An iterable collection is required.", eachVal.Type().FriendlyName()), Subject: eachAttr.Expr.Range().Ptr(), Expression: eachAttr.Expr, EvalContext: b.forEachCtx, diff --git a/vendor/github.com/hashicorp/hcl2/ext/dynblock/iteration.go b/vendor/github.com/hashicorp/hcl2/ext/dynblock/iteration.go index 580fa43f9..7056d3360 100644 --- a/vendor/github.com/hashicorp/hcl2/ext/dynblock/iteration.go +++ b/vendor/github.com/hashicorp/hcl2/ext/dynblock/iteration.go @@ -30,12 +30,14 @@ func (i *iteration) Object() cty.Value { func (i *iteration) EvalContext(base *hcl.EvalContext) *hcl.EvalContext { new := base.NewChild() - new.Variables = map[string]cty.Value{} - for name, otherIt := range i.Inherited { - new.Variables[name] = otherIt.Object() + if i != nil { + new.Variables = map[string]cty.Value{} + for name, otherIt := range i.Inherited { + new.Variables[name] = otherIt.Object() + } + new.Variables[i.IteratorName] = i.Object() } - new.Variables[i.IteratorName] = i.Object() return new } diff --git a/vendor/modules.txt b/vendor/modules.txt index 376d9f545..c8b0eb43b 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -351,7 +351,7 @@ github.com/hashicorp/hcl/hcl/scanner github.com/hashicorp/hcl/hcl/strconv github.com/hashicorp/hcl/json/scanner github.com/hashicorp/hcl/json/token -# github.com/hashicorp/hcl2 v0.0.0-20181219235215-291f7fbe431d +# github.com/hashicorp/hcl2 v0.0.0-20181220012050-6631d7cd0a68 github.com/hashicorp/hcl2/hcl github.com/hashicorp/hcl2/hcl/hclsyntax github.com/hashicorp/hcl2/hcldec