From 3c165b637d075927114bcb893ea849eeb2b4a69b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 6 May 2021 13:45:23 +0000 Subject: [PATCH] Bump github.com/hashicorp/hcl/v2 from 2.9.1 to 2.10.0 Bumps [github.com/hashicorp/hcl/v2](https://github.com/hashicorp/hcl) from 2.9.1 to 2.10.0. - [Release notes](https://github.com/hashicorp/hcl/releases) - [Changelog](https://github.com/hashicorp/hcl/blob/main/CHANGELOG.md) - [Commits](https://github.com/hashicorp/hcl/compare/v2.9.1...v2.10.0) Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 3 +- .../github.com/hashicorp/hcl/v2/CHANGELOG.md | 7 + .../hashicorp/hcl/v2/hcldec/spec.go | 215 ++++++++++-------- vendor/modules.txt | 2 +- 5 files changed, 136 insertions(+), 93 deletions(-) diff --git a/go.mod b/go.mod index aef37a4b..27781f52 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/vultr/packer-plugin-vultr go 1.16 require ( - github.com/hashicorp/hcl/v2 v2.9.1 + github.com/hashicorp/hcl/v2 v2.10.0 github.com/hashicorp/packer-plugin-sdk v0.2.0 github.com/vultr/govultr/v2 v2.4.2 github.com/zclconf/go-cty v1.8.3 diff --git a/go.sum b/go.sum index 214f5717..8051007c 100644 --- a/go.sum +++ b/go.sum @@ -231,8 +231,9 @@ github.com/hashicorp/golang-lru v0.5.3 h1:YPkqC67at8FYaadspW/6uE0COsBxS2656RLEr8 github.com/hashicorp/golang-lru v0.5.3/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= -github.com/hashicorp/hcl/v2 v2.9.1 h1:eOy4gREY0/ZQHNItlfuEZqtcQbXIxzojlP301hDpnac= github.com/hashicorp/hcl/v2 v2.9.1/go.mod h1:FwWsfWEjyV/CMj8s/gqAuiviY72rJ1/oayI9WftqcKg= +github.com/hashicorp/hcl/v2 v2.10.0 h1:1S1UnuhDGlv3gRFV4+0EdwB+znNP5HmcGbIqwnSCByg= +github.com/hashicorp/hcl/v2 v2.10.0/go.mod h1:FwWsfWEjyV/CMj8s/gqAuiviY72rJ1/oayI9WftqcKg= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= github.com/hashicorp/mdns v1.0.1/go.mod h1:4gW7WsVCke5TE7EPeYliwHlRUyBtfCwuFwuMg2DmyNY= diff --git a/vendor/github.com/hashicorp/hcl/v2/CHANGELOG.md b/vendor/github.com/hashicorp/hcl/v2/CHANGELOG.md index 5e6655a2..449187ca 100644 --- a/vendor/github.com/hashicorp/hcl/v2/CHANGELOG.md +++ b/vendor/github.com/hashicorp/hcl/v2/CHANGELOG.md @@ -1,5 +1,12 @@ # HCL Changelog +## v2.10.0 (April 20, 2021) + +### Enhancements + +* dynblock,hcldec: Using dynblock in conjunction with hcldec can now decode blocks with unknown dynamic for_each arguments as entirely unknown values ([#461](https://github.com/hashicorp/hcl/pull/461)) +* hclsyntax: Some syntax errors during parsing of the inside of `${` ... `}` template interpolation sequences will now produce an extra hint message about the need to escape as `$${` when trying to include interpolation syntax for other languages like shell scripting, AWS IAM policies, etc. ([#462](https://github.com/hashicorp/hcl/pull/462)) + ## v2.9.1 (March 10, 2021) ### Bugs Fixed diff --git a/vendor/github.com/hashicorp/hcl/v2/hcldec/spec.go b/vendor/github.com/hashicorp/hcl/v2/hcldec/spec.go index b3cb1f84..afc06b67 100644 --- a/vendor/github.com/hashicorp/hcl/v2/hcldec/spec.go +++ b/vendor/github.com/hashicorp/hcl/v2/hcldec/spec.go @@ -64,6 +64,12 @@ type specNeedingVariables interface { variablesNeeded(content *hcl.BodyContent) []hcl.Traversal } +// UnknownBody can be optionally implemented by an hcl.Body instance which may +// be entirely unknown. +type UnknownBody interface { + Unknown() bool +} + func (s ObjectSpec) visitSameBodyChildren(cb visitFunc) { for _, c := range s { cb(c) @@ -462,6 +468,14 @@ func (s *BlockListSpec) decode(content *hcl.BodyContent, blockLabels []blockLabe continue } + if u, ok := childBlock.Body.(UnknownBody); ok { + if u.Unknown() { + // If any block Body is unknown, then the entire block value + // must be unknown + return cty.UnknownVal(s.impliedType()), diags + } + } + val, _, childDiags := decode(childBlock.Body, labelsForBlock(childBlock), ctx, s.Nested, false) diags = append(diags, childDiags...) elems = append(elems, val) @@ -484,53 +498,49 @@ func (s *BlockListSpec) decode(content *hcl.BodyContent, blockLabels []blockLabe }) } - var ret cty.Value - if len(elems) == 0 { - ret = cty.ListValEmpty(s.Nested.impliedType()) - } else { - // Since our target is a list, all of the decoded elements must have the - // same type or cty.ListVal will panic below. Different types can arise - // if there is an attribute spec of type cty.DynamicPseudoType in the - // nested spec; all given values must be convertable to a single type - // in order for the result to be considered valid. - etys := make([]cty.Type, len(elems)) - for i, v := range elems { - etys[i] = v.Type() - } - ety, convs := convert.UnifyUnsafe(etys) - if ety == cty.NilType { - // FIXME: This is a pretty terrible error message. - diags = append(diags, &hcl.Diagnostic{ - Severity: hcl.DiagError, - Summary: fmt.Sprintf("Unconsistent argument types in %s blocks", s.TypeName), - Detail: "Corresponding attributes in all blocks of this type must be the same.", - Subject: &sourceRanges[0], - }) - return cty.DynamicVal, diags - } - for i, v := range elems { - if convs[i] != nil { - newV, err := convs[i](v) - if err != nil { - // FIXME: This is a pretty terrible error message. - diags = append(diags, &hcl.Diagnostic{ - Severity: hcl.DiagError, - Summary: fmt.Sprintf("Unconsistent argument types in %s blocks", s.TypeName), - Detail: fmt.Sprintf("Block with index %d has inconsistent argument types: %s.", i, err), - Subject: &sourceRanges[i], - }) - // Bail early here so we won't panic below in cty.ListVal - return cty.DynamicVal, diags - } - elems[i] = newV + return cty.ListValEmpty(s.Nested.impliedType()), diags + } + + // Since our target is a list, all of the decoded elements must have the + // same type or cty.ListVal will panic below. Different types can arise + // if there is an attribute spec of type cty.DynamicPseudoType in the + // nested spec; all given values must be convertable to a single type + // in order for the result to be considered valid. + etys := make([]cty.Type, len(elems)) + for i, v := range elems { + etys[i] = v.Type() + } + ety, convs := convert.UnifyUnsafe(etys) + if ety == cty.NilType { + // FIXME: This is a pretty terrible error message. + diags = append(diags, &hcl.Diagnostic{ + Severity: hcl.DiagError, + Summary: fmt.Sprintf("Unconsistent argument types in %s blocks", s.TypeName), + Detail: "Corresponding attributes in all blocks of this type must be the same.", + Subject: &sourceRanges[0], + }) + return cty.DynamicVal, diags + } + for i, v := range elems { + if convs[i] != nil { + newV, err := convs[i](v) + if err != nil { + // FIXME: This is a pretty terrible error message. + diags = append(diags, &hcl.Diagnostic{ + Severity: hcl.DiagError, + Summary: fmt.Sprintf("Unconsistent argument types in %s blocks", s.TypeName), + Detail: fmt.Sprintf("Block with index %d has inconsistent argument types: %s.", i, err), + Subject: &sourceRanges[i], + }) + // Bail early here so we won't panic below in cty.ListVal + return cty.DynamicVal, diags } + elems[i] = newV } - - ret = cty.ListVal(elems) } - return ret, diags + return cty.ListVal(elems), diags } func (s *BlockListSpec) impliedType() cty.Type { @@ -619,6 +629,14 @@ func (s *BlockTupleSpec) decode(content *hcl.BodyContent, blockLabels []blockLab continue } + if u, ok := childBlock.Body.(UnknownBody); ok { + if u.Unknown() { + // If any block Body is unknown, then the entire block value + // must be unknown + return cty.UnknownVal(s.impliedType()), diags + } + } + val, _, childDiags := decode(childBlock.Body, labelsForBlock(childBlock), ctx, s.Nested, false) diags = append(diags, childDiags...) elems = append(elems, val) @@ -641,15 +659,11 @@ func (s *BlockTupleSpec) decode(content *hcl.BodyContent, blockLabels []blockLab }) } - var ret cty.Value - if len(elems) == 0 { - ret = cty.EmptyTupleVal - } else { - ret = cty.TupleVal(elems) + return cty.EmptyTupleVal, diags } - return ret, diags + return cty.TupleVal(elems), diags } func (s *BlockTupleSpec) impliedType() cty.Type { @@ -731,11 +745,20 @@ func (s *BlockSetSpec) decode(content *hcl.BodyContent, blockLabels []blockLabel var elems []cty.Value var sourceRanges []hcl.Range + for _, childBlock := range content.Blocks { if childBlock.Type != s.TypeName { continue } + if u, ok := childBlock.Body.(UnknownBody); ok { + if u.Unknown() { + // If any block Body is unknown, then the entire block value + // must be unknown + return cty.UnknownVal(s.impliedType()), diags + } + } + val, _, childDiags := decode(childBlock.Body, labelsForBlock(childBlock), ctx, s.Nested, false) diags = append(diags, childDiags...) elems = append(elems, val) @@ -758,53 +781,49 @@ func (s *BlockSetSpec) decode(content *hcl.BodyContent, blockLabels []blockLabel }) } - var ret cty.Value - if len(elems) == 0 { - ret = cty.SetValEmpty(s.Nested.impliedType()) - } else { - // Since our target is a set, all of the decoded elements must have the - // same type or cty.SetVal will panic below. Different types can arise - // if there is an attribute spec of type cty.DynamicPseudoType in the - // nested spec; all given values must be convertable to a single type - // in order for the result to be considered valid. - etys := make([]cty.Type, len(elems)) - for i, v := range elems { - etys[i] = v.Type() - } - ety, convs := convert.UnifyUnsafe(etys) - if ety == cty.NilType { - // FIXME: This is a pretty terrible error message. - diags = append(diags, &hcl.Diagnostic{ - Severity: hcl.DiagError, - Summary: fmt.Sprintf("Unconsistent argument types in %s blocks", s.TypeName), - Detail: "Corresponding attributes in all blocks of this type must be the same.", - Subject: &sourceRanges[0], - }) - return cty.DynamicVal, diags - } - for i, v := range elems { - if convs[i] != nil { - newV, err := convs[i](v) - if err != nil { - // FIXME: This is a pretty terrible error message. - diags = append(diags, &hcl.Diagnostic{ - Severity: hcl.DiagError, - Summary: fmt.Sprintf("Unconsistent argument types in %s blocks", s.TypeName), - Detail: fmt.Sprintf("Block with index %d has inconsistent argument types: %s.", i, err), - Subject: &sourceRanges[i], - }) - // Bail early here so we won't panic below in cty.ListVal - return cty.DynamicVal, diags - } - elems[i] = newV + return cty.SetValEmpty(s.Nested.impliedType()), diags + } + + // Since our target is a set, all of the decoded elements must have the + // same type or cty.SetVal will panic below. Different types can arise + // if there is an attribute spec of type cty.DynamicPseudoType in the + // nested spec; all given values must be convertable to a single type + // in order for the result to be considered valid. + etys := make([]cty.Type, len(elems)) + for i, v := range elems { + etys[i] = v.Type() + } + ety, convs := convert.UnifyUnsafe(etys) + if ety == cty.NilType { + // FIXME: This is a pretty terrible error message. + diags = append(diags, &hcl.Diagnostic{ + Severity: hcl.DiagError, + Summary: fmt.Sprintf("Unconsistent argument types in %s blocks", s.TypeName), + Detail: "Corresponding attributes in all blocks of this type must be the same.", + Subject: &sourceRanges[0], + }) + return cty.DynamicVal, diags + } + for i, v := range elems { + if convs[i] != nil { + newV, err := convs[i](v) + if err != nil { + // FIXME: This is a pretty terrible error message. + diags = append(diags, &hcl.Diagnostic{ + Severity: hcl.DiagError, + Summary: fmt.Sprintf("Unconsistent argument types in %s blocks", s.TypeName), + Detail: fmt.Sprintf("Block with index %d has inconsistent argument types: %s.", i, err), + Subject: &sourceRanges[i], + }) + // Bail early here so we won't panic below in cty.ListVal + return cty.DynamicVal, diags } + elems[i] = newV } - - ret = cty.SetVal(elems) } - return ret, diags + return cty.SetVal(elems), diags } func (s *BlockSetSpec) impliedType() cty.Type { @@ -893,6 +912,14 @@ func (s *BlockMapSpec) decode(content *hcl.BodyContent, blockLabels []blockLabel continue } + if u, ok := childBlock.Body.(UnknownBody); ok { + if u.Unknown() { + // If any block Body is unknown, then the entire block value + // must be unknown + return cty.UnknownVal(s.impliedType()), diags + } + } + childLabels := labelsForBlock(childBlock) val, _, childDiags := decode(childBlock.Body, childLabels[len(s.LabelNames):], ctx, s.Nested, false) targetMap := elems @@ -1039,6 +1066,14 @@ func (s *BlockObjectSpec) decode(content *hcl.BodyContent, blockLabels []blockLa continue } + if u, ok := childBlock.Body.(UnknownBody); ok { + if u.Unknown() { + // If any block Body is unknown, then the entire block value + // must be unknown + return cty.UnknownVal(s.impliedType()), diags + } + } + childLabels := labelsForBlock(childBlock) val, _, childDiags := decode(childBlock.Body, childLabels[len(s.LabelNames):], ctx, s.Nested, false) targetMap := elems diff --git a/vendor/modules.txt b/vendor/modules.txt index fcc776e9..32a1b9d7 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -152,7 +152,7 @@ github.com/hashicorp/hcl/hcl/token github.com/hashicorp/hcl/json/parser github.com/hashicorp/hcl/json/scanner github.com/hashicorp/hcl/json/token -# github.com/hashicorp/hcl/v2 v2.9.1 +# github.com/hashicorp/hcl/v2 v2.10.0 ## explicit github.com/hashicorp/hcl/v2 github.com/hashicorp/hcl/v2/ext/customdecode