aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/hashicorp/hcl2/hcldec/schema.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/schema.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/schema.go')
-rw-r--r--vendor/github.com/hashicorp/hcl2/hcldec/schema.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/vendor/github.com/hashicorp/hcl2/hcldec/schema.go b/vendor/github.com/hashicorp/hcl2/hcldec/schema.go
new file mode 100644
index 0000000..b57bd96
--- /dev/null
+++ b/vendor/github.com/hashicorp/hcl2/hcldec/schema.go
@@ -0,0 +1,36 @@
1package hcldec
2
3import (
4 "github.com/hashicorp/hcl2/hcl"
5)
6
7// ImpliedSchema returns the *hcl.BodySchema implied by the given specification.
8// This is the schema that the Decode function will use internally to
9// access the content of a given body.
10func ImpliedSchema(spec Spec) *hcl.BodySchema {
11 var attrs []hcl.AttributeSchema
12 var blocks []hcl.BlockHeaderSchema
13
14 // visitSameBodyChildren walks through the spec structure, calling
15 // the given callback for each descendent spec encountered. We are
16 // interested in the specs that reference attributes and blocks.
17 var visit visitFunc
18 visit = func(s Spec) {
19 if as, ok := s.(attrSpec); ok {
20 attrs = append(attrs, as.attrSchemata()...)
21 }
22
23 if bs, ok := s.(blockSpec); ok {
24 blocks = append(blocks, bs.blockHeaderSchemata()...)
25 }
26
27 s.visitSameBodyChildren(visit)
28 }
29
30 visit(spec)
31
32 return &hcl.BodySchema{
33 Attributes: attrs,
34 Blocks: blocks,
35 }
36}