From d34103696f111366eea78f26a3db5caa1f2d3838 Mon Sep 17 00:00:00 2001 From: Pam Selle Date: Mon, 22 Jul 2019 16:04:45 -0400 Subject: [PATCH] Upgrade HCL to include fmt fix, involves #21434 --- go.mod | 2 +- go.sum | 6 ++-- .../hashicorp/go-version/constraint.go | 1 - .../hashicorp/hcl2/ext/dynblock/README.md | 2 +- .../hashicorp/hcl2/hcl/hclsyntax/spec.md | 2 +- vendor/github.com/hashicorp/hcl2/hcl/spec.md | 4 +-- .../hashicorp/hcl2/hcl/structure.go | 4 +-- .../hashicorp/hcl2/hclwrite/format.go | 35 ++----------------- vendor/modules.txt | 2 +- 9 files changed, 13 insertions(+), 45 deletions(-) diff --git a/go.mod b/go.mod index 63e50c126..34d110709 100644 --- a/go.mod +++ b/go.mod @@ -64,7 +64,7 @@ require ( github.com/hashicorp/go-version v1.1.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-20190719002611-618463aa7958 + github.com/hashicorp/hcl2 v0.0.0-20190725010614-0c3fe388e450 github.com/hashicorp/hil v0.0.0-20190212112733-ab17b08d6590 github.com/hashicorp/logutils v1.0.0 github.com/hashicorp/memberlist v0.1.0 // indirect diff --git a/go.sum b/go.sum index 5197bb86c..37ad97559 100644 --- a/go.sum +++ b/go.sum @@ -216,10 +216,8 @@ github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ github.com/hashicorp/hcl v0.0.0-20170504190234-a4b07c25de5f h1:UdxlrJz4JOnY8W+DbLISwf2B8WXEolNRA8BGCwI9jws= github.com/hashicorp/hcl v0.0.0-20170504190234-a4b07c25de5f/go.mod h1:oZtUIOe8dh44I2q6ScRibXws4Ajl+d+nod3AaR9vL5w= github.com/hashicorp/hcl2 v0.0.0-20181208003705-670926858200/go.mod h1:ShfpTh661oAaxo7VcNxg0zcZW6jvMa7Moy2oFx7e5dE= -github.com/hashicorp/hcl2 v0.0.0-20190702185634-5b39d9ff3a9a h1:1KfDwkIXrxrfMpqwuW//ujObiYNuR2DqaETSK2NB8Ug= -github.com/hashicorp/hcl2 v0.0.0-20190702185634-5b39d9ff3a9a/go.mod h1:FSQTwDi9qesxGBsII2VqhIzKQ4r0bHvBkOczWfD7llg= -github.com/hashicorp/hcl2 v0.0.0-20190719002611-618463aa7958 h1:tWvka6jPDo/2jqd06ErHWiWlrXZDczD63dTfBw2wxi0= -github.com/hashicorp/hcl2 v0.0.0-20190719002611-618463aa7958/go.mod h1:FSQTwDi9qesxGBsII2VqhIzKQ4r0bHvBkOczWfD7llg= +github.com/hashicorp/hcl2 v0.0.0-20190725010614-0c3fe388e450 h1:wpa0vOXOnSEuwZ++eVk1gQNm3Jy2+Envn0cQRgsl8K8= +github.com/hashicorp/hcl2 v0.0.0-20190725010614-0c3fe388e450/go.mod h1:FSQTwDi9qesxGBsII2VqhIzKQ4r0bHvBkOczWfD7llg= github.com/hashicorp/hil v0.0.0-20190212112733-ab17b08d6590 h1:2yzhWGdgQUWZUCNK+AoO35V+HTsgEmcM4J9IkArh7PI= github.com/hashicorp/hil v0.0.0-20190212112733-ab17b08d6590/go.mod h1:n2TSygSNwsLJ76m8qFXTSc7beTb+auJxYdqrnoqwZWE= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= diff --git a/vendor/github.com/hashicorp/go-version/constraint.go b/vendor/github.com/hashicorp/go-version/constraint.go index d05575961..b24e0660d 100644 --- a/vendor/github.com/hashicorp/go-version/constraint.go +++ b/vendor/github.com/hashicorp/go-version/constraint.go @@ -59,7 +59,6 @@ func NewConstraint(v string) (Constraints, error) { if err != nil { return nil, err } - result[i] = c } diff --git a/vendor/github.com/hashicorp/hcl2/ext/dynblock/README.md b/vendor/github.com/hashicorp/hcl2/ext/dynblock/README.md index 2b24fdbe8..f59ce92e9 100644 --- a/vendor/github.com/hashicorp/hcl2/ext/dynblock/README.md +++ b/vendor/github.com/hashicorp/hcl2/ext/dynblock/README.md @@ -95,7 +95,7 @@ schema model provides a description of only one level of nested blocks at a time, and thus a new schema must be provided for each additional level of nesting. -To make this arduous process as convenient as possbile, this package provides +To make this arduous process as convenient as possible, this package provides a helper function `WalkForEachVariables`, which returns a `WalkVariablesNode` instance that can be used to find variables directly in a given body and also determine which nested blocks require recursive calls. Using this mechanism diff --git a/vendor/github.com/hashicorp/hcl2/hcl/hclsyntax/spec.md b/vendor/github.com/hashicorp/hcl2/hcl/hclsyntax/spec.md index 091c1c23c..d7faeedce 100644 --- a/vendor/github.com/hashicorp/hcl2/hcl/hclsyntax/spec.md +++ b/vendor/github.com/hashicorp/hcl2/hcl/hclsyntax/spec.md @@ -187,7 +187,7 @@ for later evaluation by the calling application. ### Blocks A _block_ creates a child body that is annotated with a block _type_ and -zero or more block _labels_. Blocks create a structural hierachy which can be +zero or more block _labels_. Blocks create a structural hierarchy which can be interpreted by the calling application. Block labels can either be quoted literal strings or naked identifiers. diff --git a/vendor/github.com/hashicorp/hcl2/hcl/spec.md b/vendor/github.com/hashicorp/hcl2/hcl/spec.md index 8bbaff817..97ef61318 100644 --- a/vendor/github.com/hashicorp/hcl2/hcl/spec.md +++ b/vendor/github.com/hashicorp/hcl2/hcl/spec.md @@ -66,7 +66,7 @@ _block header schemata_: Within a schema, it is an error to request the same attribute name twice or to request a block type whose name is also an attribute name. While this can in principle be supported in some syntaxes, in other syntaxes the attribute -and block namespaces are combined and so an an attribute cannot coexist with +and block namespaces are combined and so an attribute cannot coexist with a block whose type name is identical to the attribute name. The result of applying a body schema to a body is _body content_, which @@ -497,7 +497,7 @@ producing an unknown value of the target type. Conversion of any value _to_ the dynamic pseudo-type is a no-op. The result is the input value, verbatim. This is the only situation where the conversion -result value is not of the the given target type. +result value is not of the given target type. ### Primitive Type Conversions diff --git a/vendor/github.com/hashicorp/hcl2/hcl/structure.go b/vendor/github.com/hashicorp/hcl2/hcl/structure.go index b336f300d..aab09457d 100644 --- a/vendor/github.com/hashicorp/hcl2/hcl/structure.go +++ b/vendor/github.com/hashicorp/hcl2/hcl/structure.go @@ -33,9 +33,9 @@ type Blocks []*Block type Attributes map[string]*Attribute // Body is a container for attributes and blocks. It serves as the primary -// unit of heirarchical structure within configuration. +// unit of hierarchical structure within configuration. // -// The content of a body cannot be meaningfully intepreted without a schema, +// The content of a body cannot be meaningfully interpreted without a schema, // so Body represents the raw body content and has methods that allow the // content to be extracted in terms of a given schema. type Body interface { diff --git a/vendor/github.com/hashicorp/hcl2/hclwrite/format.go b/vendor/github.com/hashicorp/hcl2/hclwrite/format.go index f20ae23a8..ded7fb426 100644 --- a/vendor/github.com/hashicorp/hcl2/hclwrite/format.go +++ b/vendor/github.com/hashicorp/hcl2/hclwrite/format.go @@ -54,22 +54,12 @@ func formatIndent(lines []formatLine) { // which should be more than enough for reasonable HCL uses. indents := make([]int, 0, 10) - inHeredoc := false for i := range lines { line := &lines[i] if len(line.lead) == 0 { continue } - if inHeredoc { - for _, token := range line.lead { - if token.Type == hclsyntax.TokenCHeredoc { - inHeredoc = false - } - } - continue // don't touch indentation inside heredocs - } - if line.lead[0].Type == hclsyntax.TokenNewline { // Never place spaces before a newline line.lead[0].SpacesBefore = 0 @@ -80,9 +70,10 @@ func formatIndent(lines []formatLine) { for _, token := range line.lead { netBrackets += tokenBracketChange(token) if token.Type == hclsyntax.TokenOHeredoc { - inHeredoc = true + break } } + for _, token := range line.assign { netBrackets += tokenBracketChange(token) } @@ -391,9 +382,9 @@ func linesForFormat(tokens Tokens) []formatLine { // Now we'll pick off any trailing comments and attribute assignments // to shuffle off into the "comment" and "assign" cells. - inHeredoc := false for i := range lines { line := &lines[i] + if len(line.lead) == 0 { // if the line is empty then there's nothing for us to do // (this should happen only for the final line, because all other @@ -401,26 +392,6 @@ func linesForFormat(tokens Tokens) []formatLine { continue } - if inHeredoc { - for _, tok := range line.lead { - if tok.Type == hclsyntax.TokenCHeredoc { - inHeredoc = false - break - } - } - // Inside a heredoc everything is "lead", even if there's a - // template interpolation embedded in there that might otherwise - // confuse our logic below. - continue - } - - for _, tok := range line.lead { - if tok.Type == hclsyntax.TokenOHeredoc { - inHeredoc = true - break - } - } - if len(line.lead) > 1 && line.lead[len(line.lead)-1].Type == hclsyntax.TokenComment { line.comment = line.lead[len(line.lead)-1:] line.lead = line.lead[:len(line.lead)-1] diff --git a/vendor/modules.txt b/vendor/modules.txt index b0c6dc945..23f3dfac8 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -326,7 +326,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-20190719002611-618463aa7958 +# github.com/hashicorp/hcl2 v0.0.0-20190725010614-0c3fe388e450 github.com/hashicorp/hcl2/hcl github.com/hashicorp/hcl2/hcl/hclsyntax github.com/hashicorp/hcl2/hcldec