aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/hashicorp/hcl2/hcl
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/hashicorp/hcl2/hcl')
-rw-r--r--vendor/github.com/hashicorp/hcl2/hcl/hclsyntax/expression.go31
-rw-r--r--vendor/github.com/hashicorp/hcl2/hcl/hclsyntax/expression_template.go20
-rw-r--r--vendor/github.com/hashicorp/hcl2/hcl/hclsyntax/parser.go8
-rw-r--r--vendor/github.com/hashicorp/hcl2/hcl/hclsyntax/spec.md2
-rw-r--r--vendor/github.com/hashicorp/hcl2/hcl/json/structure.go6
-rw-r--r--vendor/github.com/hashicorp/hcl2/hcl/spec.md4
-rw-r--r--vendor/github.com/hashicorp/hcl2/hcl/structure.go4
-rw-r--r--vendor/github.com/hashicorp/hcl2/hcl/traversal_for_expr.go2
8 files changed, 67 insertions, 10 deletions
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.
104func (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
189A _block_ creates a child body that is annotated with a block _type_ and 189A _block_ creates a child body that is annotated with a block _type_ and
190zero or more block _labels_. Blocks create a structural hierachy which can be 190zero or more block _labels_. Blocks create a structural hierarchy which can be
191interpreted by the calling application. 191interpreted by the calling application.
192 192
193Block labels can either be quoted literal strings or naked identifiers. 193Block 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_:
66Within a schema, it is an error to request the same attribute name twice or 66Within a schema, it is an error to request the same attribute name twice or
67to request a block type whose name is also an attribute name. While this can 67to request a block type whose name is also an attribute name. While this can
68in principle be supported in some syntaxes, in other syntaxes the attribute 68in principle be supported in some syntaxes, in other syntaxes the attribute
69and block namespaces are combined and so an an attribute cannot coexist with 69and block namespaces are combined and so an attribute cannot coexist with
70a block whose type name is identical to the attribute name. 70a block whose type name is identical to the attribute name.
71 71
72The result of applying a body schema to a body is _body content_, which 72The 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
498Conversion of any value _to_ the dynamic pseudo-type is a no-op. The result 498Conversion of any value _to_ the dynamic pseudo-type is a no-op. The result
499is the input value, verbatim. This is the only situation where the conversion 499is the input value, verbatim. This is the only situation where the conversion
500result value is not of the the given target type. 500result 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
33type Attributes map[string]*Attribute 33type 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.
41type Body interface { 41type 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 }