diff options
Diffstat (limited to 'vendor/github.com/hashicorp/hcl2')
10 files changed, 71 insertions, 43 deletions
diff --git a/vendor/github.com/hashicorp/hcl2/ext/dynblock/README.md b/vendor/github.com/hashicorp/hcl2/ext/dynblock/README.md index 2b24fdb..f59ce92 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 | |||
95 | a time, and thus a new schema must be provided for each additional level of | 95 | a time, and thus a new schema must be provided for each additional level of |
96 | nesting. | 96 | nesting. |
97 | 97 | ||
98 | To make this arduous process as convenient as possbile, this package provides | 98 | To make this arduous process as convenient as possible, this package provides |
99 | a helper function `WalkForEachVariables`, which returns a `WalkVariablesNode` | 99 | a helper function `WalkForEachVariables`, which returns a `WalkVariablesNode` |
100 | instance that can be used to find variables directly in a given body and also | 100 | instance that can be used to find variables directly in a given body and also |
101 | determine which nested blocks require recursive calls. Using this mechanism | 101 | determine which nested blocks require recursive calls. Using this mechanism |
diff --git a/vendor/github.com/hashicorp/hcl2/hcl/hclsyntax/expression.go b/vendor/github.com/hashicorp/hcl2/hcl/hclsyntax/expression.go index 26819a2..d3f7a74 100644 --- a/vendor/github.com/hashicorp/hcl2/hcl/hclsyntax/expression.go +++ b/vendor/github.com/hashicorp/hcl2/hcl/hclsyntax/expression.go | |||
@@ -473,8 +473,35 @@ func (e *ConditionalExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostic | |||
473 | falseResult, falseDiags := e.FalseResult.Value(ctx) | 473 | falseResult, falseDiags := e.FalseResult.Value(ctx) |
474 | var diags hcl.Diagnostics | 474 | var diags hcl.Diagnostics |
475 | 475 | ||
476 | // Try to find a type that both results can be converted to. | 476 | resultType := cty.DynamicPseudoType |
477 | resultType, convs := convert.UnifyUnsafe([]cty.Type{trueResult.Type(), falseResult.Type()}) | 477 | convs := make([]convert.Conversion, 2) |
478 | |||
479 | switch { | ||
480 | // If either case is a dynamic null value (which would result from a | ||
481 | // literal null in the config), we know that it can convert to the expected | ||
482 | // type of the opposite case, and we don't need to speculatively reduce the | ||
483 | // final result type to DynamicPseudoType. | ||
484 | |||
485 | // If we know that either Type is a DynamicPseudoType, we can be certain | ||
486 | // that the other value can convert since it's a pass-through, and we don't | ||
487 | // need to unify the types. If the final evaluation results in the dynamic | ||
488 | // value being returned, there's no conversion we can do, so we return the | ||
489 | // value directly. | ||
490 | case trueResult.RawEquals(cty.NullVal(cty.DynamicPseudoType)): | ||
491 | resultType = falseResult.Type() | ||
492 | convs[0] = convert.GetConversionUnsafe(cty.DynamicPseudoType, resultType) | ||
493 | case falseResult.RawEquals(cty.NullVal(cty.DynamicPseudoType)): | ||
494 | resultType = trueResult.Type() | ||
495 | convs[1] = convert.GetConversionUnsafe(cty.DynamicPseudoType, resultType) | ||
496 | case trueResult.Type() == cty.DynamicPseudoType, falseResult.Type() == cty.DynamicPseudoType: | ||
497 | // the final resultType type is still unknown | ||
498 | // we don't need to get the conversion, because both are a noop. | ||
499 | |||
500 | default: | ||
501 | // Try to find a type that both results can be converted to. | ||
502 | resultType, convs = convert.UnifyUnsafe([]cty.Type{trueResult.Type(), falseResult.Type()}) | ||
503 | } | ||
504 | |||
478 | if resultType == cty.NilType { | 505 | if resultType == cty.NilType { |
479 | return cty.DynamicVal, hcl.Diagnostics{ | 506 | return cty.DynamicVal, hcl.Diagnostics{ |
480 | { | 507 | { |
diff --git a/vendor/github.com/hashicorp/hcl2/hcl/hclsyntax/expression_template.go b/vendor/github.com/hashicorp/hcl2/hcl/hclsyntax/expression_template.go index fa79e3d..ca3dae1 100644 --- a/vendor/github.com/hashicorp/hcl2/hcl/hclsyntax/expression_template.go +++ b/vendor/github.com/hashicorp/hcl2/hcl/hclsyntax/expression_template.go | |||
@@ -89,6 +89,26 @@ func (e *TemplateExpr) StartRange() hcl.Range { | |||
89 | return e.Parts[0].StartRange() | 89 | return e.Parts[0].StartRange() |
90 | } | 90 | } |
91 | 91 | ||
92 | // IsStringLiteral returns true if and only if the template consists only of | ||
93 | // single string literal, as would be created for a simple quoted string like | ||
94 | // "foo". | ||
95 | // | ||
96 | // If this function returns true, then calling Value on the same expression | ||
97 | // with a nil EvalContext will return the literal value. | ||
98 | // | ||
99 | // Note that "${"foo"}", "${1}", etc aren't considered literal values for the | ||
100 | // purposes of this method, because the intent of this method is to identify | ||
101 | // situations where the user seems to be explicitly intending literal string | ||
102 | // interpretation, not situations that result in literals as a technicality | ||
103 | // of the template expression unwrapping behavior. | ||
104 | func (e *TemplateExpr) IsStringLiteral() bool { | ||
105 | if len(e.Parts) != 1 { | ||
106 | return false | ||
107 | } | ||
108 | _, ok := e.Parts[0].(*LiteralValueExpr) | ||
109 | return ok | ||
110 | } | ||
111 | |||
92 | // TemplateJoinExpr is used to convert tuples of strings produced by template | 112 | // TemplateJoinExpr is used to convert tuples of strings produced by template |
93 | // constructs (i.e. for loops) into flat strings, by converting the values | 113 | // constructs (i.e. for loops) into flat strings, by converting the values |
94 | // tos strings and joining them. This AST node is not used directly; it's | 114 | // tos strings and joining them. This AST node is not used directly; it's |
diff --git a/vendor/github.com/hashicorp/hcl2/hcl/hclsyntax/parser.go b/vendor/github.com/hashicorp/hcl2/hcl/hclsyntax/parser.go index 253ad50..772ebae 100644 --- a/vendor/github.com/hashicorp/hcl2/hcl/hclsyntax/parser.go +++ b/vendor/github.com/hashicorp/hcl2/hcl/hclsyntax/parser.go | |||
@@ -853,6 +853,14 @@ Traversal: | |||
853 | SrcRange: rng, | 853 | SrcRange: rng, |
854 | } | 854 | } |
855 | ret = makeRelativeTraversal(ret, step, rng) | 855 | ret = makeRelativeTraversal(ret, step, rng) |
856 | } else if tmpl, isTmpl := keyExpr.(*TemplateExpr); isTmpl && tmpl.IsStringLiteral() { | ||
857 | litKey, _ := tmpl.Value(nil) | ||
858 | rng := hcl.RangeBetween(open.Range, close.Range) | ||
859 | step := hcl.TraverseIndex{ | ||
860 | Key: litKey, | ||
861 | SrcRange: rng, | ||
862 | } | ||
863 | ret = makeRelativeTraversal(ret, step, rng) | ||
856 | } else { | 864 | } else { |
857 | rng := hcl.RangeBetween(open.Range, close.Range) | 865 | rng := hcl.RangeBetween(open.Range, close.Range) |
858 | ret = &IndexExpr{ | 866 | ret = &IndexExpr{ |
diff --git a/vendor/github.com/hashicorp/hcl2/hcl/hclsyntax/spec.md b/vendor/github.com/hashicorp/hcl2/hcl/hclsyntax/spec.md index 091c1c2..d7faeed 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. | |||
187 | ### Blocks | 187 | ### Blocks |
188 | 188 | ||
189 | A _block_ creates a child body that is annotated with a block _type_ and | 189 | A _block_ creates a child body that is annotated with a block _type_ and |
190 | zero or more block _labels_. Blocks create a structural hierachy which can be | 190 | zero or more block _labels_. Blocks create a structural hierarchy which can be |
191 | interpreted by the calling application. | 191 | interpreted by the calling application. |
192 | 192 | ||
193 | Block labels can either be quoted literal strings or naked identifiers. | 193 | Block labels can either be quoted literal strings or naked identifiers. |
diff --git a/vendor/github.com/hashicorp/hcl2/hcl/json/structure.go b/vendor/github.com/hashicorp/hcl2/hcl/json/structure.go index bdc0e98..74847c7 100644 --- a/vendor/github.com/hashicorp/hcl2/hcl/json/structure.go +++ b/vendor/github.com/hashicorp/hcl2/hcl/json/structure.go | |||
@@ -416,12 +416,14 @@ func (e *expression) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics) { | |||
416 | case *booleanVal: | 416 | case *booleanVal: |
417 | return cty.BoolVal(v.Value), nil | 417 | return cty.BoolVal(v.Value), nil |
418 | case *arrayVal: | 418 | case *arrayVal: |
419 | var diags hcl.Diagnostics | ||
419 | vals := []cty.Value{} | 420 | vals := []cty.Value{} |
420 | for _, jsonVal := range v.Values { | 421 | for _, jsonVal := range v.Values { |
421 | val, _ := (&expression{src: jsonVal}).Value(ctx) | 422 | val, valDiags := (&expression{src: jsonVal}).Value(ctx) |
422 | vals = append(vals, val) | 423 | vals = append(vals, val) |
424 | diags = append(diags, valDiags...) | ||
423 | } | 425 | } |
424 | return cty.TupleVal(vals), nil | 426 | return cty.TupleVal(vals), diags |
425 | case *objectVal: | 427 | case *objectVal: |
426 | var diags hcl.Diagnostics | 428 | var diags hcl.Diagnostics |
427 | attrs := map[string]cty.Value{} | 429 | attrs := map[string]cty.Value{} |
diff --git a/vendor/github.com/hashicorp/hcl2/hcl/spec.md b/vendor/github.com/hashicorp/hcl2/hcl/spec.md index 8bbaff8..97ef613 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_: | |||
66 | Within a schema, it is an error to request the same attribute name twice or | 66 | Within a schema, it is an error to request the same attribute name twice or |
67 | to request a block type whose name is also an attribute name. While this can | 67 | to request a block type whose name is also an attribute name. While this can |
68 | in principle be supported in some syntaxes, in other syntaxes the attribute | 68 | in principle be supported in some syntaxes, in other syntaxes the attribute |
69 | and block namespaces are combined and so an an attribute cannot coexist with | 69 | and block namespaces are combined and so an attribute cannot coexist with |
70 | a block whose type name is identical to the attribute name. | 70 | a block whose type name is identical to the attribute name. |
71 | 71 | ||
72 | The result of applying a body schema to a body is _body content_, which | 72 | 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. | |||
497 | 497 | ||
498 | Conversion of any value _to_ the dynamic pseudo-type is a no-op. The result | 498 | Conversion of any value _to_ the dynamic pseudo-type is a no-op. The result |
499 | is the input value, verbatim. This is the only situation where the conversion | 499 | is the input value, verbatim. This is the only situation where the conversion |
500 | result value is not of the the given target type. | 500 | result value is not of the given target type. |
501 | 501 | ||
502 | ### Primitive Type Conversions | 502 | ### Primitive Type Conversions |
503 | 503 | ||
diff --git a/vendor/github.com/hashicorp/hcl2/hcl/structure.go b/vendor/github.com/hashicorp/hcl2/hcl/structure.go index b336f30..aab0945 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 | |||
33 | type Attributes map[string]*Attribute | 33 | type Attributes map[string]*Attribute |
34 | 34 | ||
35 | // Body is a container for attributes and blocks. It serves as the primary | 35 | // Body is a container for attributes and blocks. It serves as the primary |
36 | // unit of heirarchical structure within configuration. | 36 | // unit of hierarchical structure within configuration. |
37 | // | 37 | // |
38 | // The content of a body cannot be meaningfully intepreted without a schema, | 38 | // The content of a body cannot be meaningfully interpreted without a schema, |
39 | // so Body represents the raw body content and has methods that allow the | 39 | // so Body represents the raw body content and has methods that allow the |
40 | // content to be extracted in terms of a given schema. | 40 | // content to be extracted in terms of a given schema. |
41 | type Body interface { | 41 | type Body interface { |
diff --git a/vendor/github.com/hashicorp/hcl2/hcl/traversal_for_expr.go b/vendor/github.com/hashicorp/hcl2/hcl/traversal_for_expr.go index d4a565a..f69d5fe 100644 --- a/vendor/github.com/hashicorp/hcl2/hcl/traversal_for_expr.go +++ b/vendor/github.com/hashicorp/hcl2/hcl/traversal_for_expr.go | |||
@@ -36,7 +36,7 @@ func AbsTraversalForExpr(expr Expression) (Traversal, Diagnostics) { | |||
36 | &Diagnostic{ | 36 | &Diagnostic{ |
37 | Severity: DiagError, | 37 | Severity: DiagError, |
38 | Summary: "Invalid expression", | 38 | Summary: "Invalid expression", |
39 | Detail: "A static variable reference is required.", | 39 | Detail: "A single static variable reference is required: only attribute access and indexing with constant keys. No calculations, function calls, template expressions, etc are allowed here.", |
40 | Subject: expr.Range().Ptr(), | 40 | Subject: expr.Range().Ptr(), |
41 | }, | 41 | }, |
42 | } | 42 | } |
diff --git a/vendor/github.com/hashicorp/hcl2/hclwrite/format.go b/vendor/github.com/hashicorp/hcl2/hclwrite/format.go index f20ae23..ded7fb4 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) { | |||
54 | // which should be more than enough for reasonable HCL uses. | 54 | // which should be more than enough for reasonable HCL uses. |
55 | indents := make([]int, 0, 10) | 55 | indents := make([]int, 0, 10) |
56 | 56 | ||
57 | inHeredoc := false | ||
58 | for i := range lines { | 57 | for i := range lines { |
59 | line := &lines[i] | 58 | line := &lines[i] |
60 | if len(line.lead) == 0 { | 59 | if len(line.lead) == 0 { |
61 | continue | 60 | continue |
62 | } | 61 | } |
63 | 62 | ||
64 | if inHeredoc { | ||
65 | for _, token := range line.lead { | ||
66 | if token.Type == hclsyntax.TokenCHeredoc { | ||
67 | inHeredoc = false | ||
68 | } | ||
69 | } | ||
70 | continue // don't touch indentation inside heredocs | ||
71 | } | ||
72 | |||
73 | if line.lead[0].Type == hclsyntax.TokenNewline { | 63 | if line.lead[0].Type == hclsyntax.TokenNewline { |
74 | // Never place spaces before a newline | 64 | // Never place spaces before a newline |
75 | line.lead[0].SpacesBefore = 0 | 65 | line.lead[0].SpacesBefore = 0 |
@@ -80,9 +70,10 @@ func formatIndent(lines []formatLine) { | |||
80 | for _, token := range line.lead { | 70 | for _, token := range line.lead { |
81 | netBrackets += tokenBracketChange(token) | 71 | netBrackets += tokenBracketChange(token) |
82 | if token.Type == hclsyntax.TokenOHeredoc { | 72 | if token.Type == hclsyntax.TokenOHeredoc { |
83 | inHeredoc = true | 73 | break |
84 | } | 74 | } |
85 | } | 75 | } |
76 | |||
86 | for _, token := range line.assign { | 77 | for _, token := range line.assign { |
87 | netBrackets += tokenBracketChange(token) | 78 | netBrackets += tokenBracketChange(token) |
88 | } | 79 | } |
@@ -391,9 +382,9 @@ func linesForFormat(tokens Tokens) []formatLine { | |||
391 | 382 | ||
392 | // Now we'll pick off any trailing comments and attribute assignments | 383 | // Now we'll pick off any trailing comments and attribute assignments |
393 | // to shuffle off into the "comment" and "assign" cells. | 384 | // to shuffle off into the "comment" and "assign" cells. |
394 | inHeredoc := false | ||
395 | for i := range lines { | 385 | for i := range lines { |
396 | line := &lines[i] | 386 | line := &lines[i] |
387 | |||
397 | if len(line.lead) == 0 { | 388 | if len(line.lead) == 0 { |
398 | // if the line is empty then there's nothing for us to do | 389 | // if the line is empty then there's nothing for us to do |
399 | // (this should happen only for the final line, because all other | 390 | // (this should happen only for the final line, because all other |
@@ -401,26 +392,6 @@ func linesForFormat(tokens Tokens) []formatLine { | |||
401 | continue | 392 | continue |
402 | } | 393 | } |
403 | 394 | ||
404 | if inHeredoc { | ||
405 | for _, tok := range line.lead { | ||
406 | if tok.Type == hclsyntax.TokenCHeredoc { | ||
407 | inHeredoc = false | ||
408 | break | ||
409 | } | ||
410 | } | ||
411 | // Inside a heredoc everything is "lead", even if there's a | ||
412 | // template interpolation embedded in there that might otherwise | ||
413 | // confuse our logic below. | ||
414 | continue | ||
415 | } | ||
416 | |||
417 | for _, tok := range line.lead { | ||
418 | if tok.Type == hclsyntax.TokenOHeredoc { | ||
419 | inHeredoc = true | ||
420 | break | ||
421 | } | ||
422 | } | ||
423 | |||
424 | if len(line.lead) > 1 && line.lead[len(line.lead)-1].Type == hclsyntax.TokenComment { | 395 | if len(line.lead) > 1 && line.lead[len(line.lead)-1].Type == hclsyntax.TokenComment { |
425 | line.comment = line.lead[len(line.lead)-1:] | 396 | line.comment = line.lead[len(line.lead)-1:] |
426 | line.lead = line.lead[:len(line.lead)-1] | 397 | line.lead = line.lead[:len(line.lead)-1] |