aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/hashicorp/hcl2/hcldec/decode.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/hashicorp/hcl2/hcldec/decode.go')
-rw-r--r--vendor/github.com/hashicorp/hcl2/hcldec/decode.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/vendor/github.com/hashicorp/hcl2/hcldec/decode.go b/vendor/github.com/hashicorp/hcl2/hcldec/decode.go
new file mode 100644
index 0000000..6cf93fe
--- /dev/null
+++ b/vendor/github.com/hashicorp/hcl2/hcldec/decode.go
@@ -0,0 +1,36 @@
1package hcldec
2
3import (
4 "github.com/hashicorp/hcl2/hcl"
5 "github.com/zclconf/go-cty/cty"
6)
7
8func decode(body hcl.Body, blockLabels []blockLabel, ctx *hcl.EvalContext, spec Spec, partial bool) (cty.Value, hcl.Body, hcl.Diagnostics) {
9 schema := ImpliedSchema(spec)
10
11 var content *hcl.BodyContent
12 var diags hcl.Diagnostics
13 var leftovers hcl.Body
14
15 if partial {
16 content, leftovers, diags = body.PartialContent(schema)
17 } else {
18 content, diags = body.Content(schema)
19 }
20
21 val, valDiags := spec.decode(content, blockLabels, ctx)
22 diags = append(diags, valDiags...)
23
24 return val, leftovers, diags
25}
26
27func impliedType(spec Spec) cty.Type {
28 return spec.impliedType()
29}
30
31func sourceRange(body hcl.Body, blockLabels []blockLabel, spec Spec) hcl.Range {
32 schema := ImpliedSchema(spec)
33 content, _, _ := body.PartialContent(schema)
34
35 return spec.sourceRange(content, blockLabels)
36}