diff options
author | Alex Pilon <apilon@hashicorp.com> | 2019-02-22 18:24:37 -0500 |
---|---|---|
committer | Alex Pilon <apilon@hashicorp.com> | 2019-02-22 18:24:37 -0500 |
commit | 15c0b25d011f37e7c20aeca9eaf461f78285b8d9 (patch) | |
tree | 255c250a5c9d4801c74092d33b7337d8c14438ff /vendor/github.com/hashicorp/hcl2/hcl/expr_list.go | |
parent | 07971ca38143c5faf951d152fba370ddcbe26ad5 (diff) | |
download | terraform-provider-statuscake-15c0b25d011f37e7c20aeca9eaf461f78285b8d9.tar.gz terraform-provider-statuscake-15c0b25d011f37e7c20aeca9eaf461f78285b8d9.tar.zst terraform-provider-statuscake-15c0b25d011f37e7c20aeca9eaf461f78285b8d9.zip |
deps: github.com/hashicorp/terraform@sdk-v0.11-with-go-modules
Updated via: go get github.com/hashicorp/terraform@sdk-v0.11-with-go-modules and go mod tidy
Diffstat (limited to 'vendor/github.com/hashicorp/hcl2/hcl/expr_list.go')
-rw-r--r-- | vendor/github.com/hashicorp/hcl2/hcl/expr_list.go | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/vendor/github.com/hashicorp/hcl2/hcl/expr_list.go b/vendor/github.com/hashicorp/hcl2/hcl/expr_list.go new file mode 100644 index 0000000..d05cca0 --- /dev/null +++ b/vendor/github.com/hashicorp/hcl2/hcl/expr_list.go | |||
@@ -0,0 +1,37 @@ | |||
1 | package hcl | ||
2 | |||
3 | // ExprList tests if the given expression is a static list construct and, | ||
4 | // if so, extracts the expressions that represent the list elements. | ||
5 | // If the given expression is not a static list, error diagnostics are | ||
6 | // returned. | ||
7 | // | ||
8 | // A particular Expression implementation can support this function by | ||
9 | // offering a method called ExprList that takes no arguments and returns | ||
10 | // []Expression. This method should return nil if a static list cannot | ||
11 | // be extracted. Alternatively, an implementation can support | ||
12 | // UnwrapExpression to delegate handling of this function to a wrapped | ||
13 | // Expression object. | ||
14 | func ExprList(expr Expression) ([]Expression, Diagnostics) { | ||
15 | type exprList interface { | ||
16 | ExprList() []Expression | ||
17 | } | ||
18 | |||
19 | physExpr := UnwrapExpressionUntil(expr, func(expr Expression) bool { | ||
20 | _, supported := expr.(exprList) | ||
21 | return supported | ||
22 | }) | ||
23 | |||
24 | if exL, supported := physExpr.(exprList); supported { | ||
25 | if list := exL.ExprList(); list != nil { | ||
26 | return list, nil | ||
27 | } | ||
28 | } | ||
29 | return nil, Diagnostics{ | ||
30 | &Diagnostic{ | ||
31 | Severity: DiagError, | ||
32 | Summary: "Invalid expression", | ||
33 | Detail: "A static list expression is required.", | ||
34 | Subject: expr.StartRange().Ptr(), | ||
35 | }, | ||
36 | } | ||
37 | } | ||