aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/hashicorp/hcl2/hcldec/variables.go
diff options
context:
space:
mode:
authorAlex Pilon <apilon@hashicorp.com>2019-02-22 18:24:37 -0500
committerAlex Pilon <apilon@hashicorp.com>2019-02-22 18:24:37 -0500
commit15c0b25d011f37e7c20aeca9eaf461f78285b8d9 (patch)
tree255c250a5c9d4801c74092d33b7337d8c14438ff /vendor/github.com/hashicorp/hcl2/hcldec/variables.go
parent07971ca38143c5faf951d152fba370ddcbe26ad5 (diff)
downloadterraform-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/hcldec/variables.go')
-rw-r--r--vendor/github.com/hashicorp/hcl2/hcldec/variables.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/vendor/github.com/hashicorp/hcl2/hcldec/variables.go b/vendor/github.com/hashicorp/hcl2/hcldec/variables.go
new file mode 100644
index 0000000..427b0d0
--- /dev/null
+++ b/vendor/github.com/hashicorp/hcl2/hcldec/variables.go
@@ -0,0 +1,34 @@
1package hcldec
2
3import (
4 "github.com/hashicorp/hcl2/hcl"
5)
6
7// Variables processes the given body with the given spec and returns a
8// list of the variable traversals that would be required to decode
9// the same pairing of body and spec.
10//
11// This can be used to conditionally populate the variables in the EvalContext
12// passed to Decode, for applications where a static scope is insufficient.
13//
14// If the given body is not compliant with the given schema, the result may
15// be incomplete, but that's assumed to be okay because the eventual call
16// to Decode will produce error diagnostics anyway.
17func Variables(body hcl.Body, spec Spec) []hcl.Traversal {
18 schema := ImpliedSchema(spec)
19
20 content, _, _ := body.PartialContent(schema)
21
22 var vars []hcl.Traversal
23
24 if vs, ok := spec.(specNeedingVariables); ok {
25 vars = append(vars, vs.variablesNeeded(content)...)
26 }
27 spec.visitSameBodyChildren(func(s Spec) {
28 if vs, ok := s.(specNeedingVariables); ok {
29 vars = append(vars, vs.variablesNeeded(content)...)
30 }
31 })
32
33 return vars
34}