(body hcl.Body)
| 44 | } |
| 45 | |
| 46 | func decodeSpecDecls(body hcl.Body) (map[string]cty.Value, map[string]function.Function, hcl.Body, hcl.Diagnostics) { |
| 47 | funcs, body, diags := userfunc.DecodeUserFunctions(body, "function", func() *hcl.EvalContext { |
| 48 | return specCtx |
| 49 | }) |
| 50 | |
| 51 | content, body, moreDiags := body.PartialContent(&hcl.BodySchema{ |
| 52 | Blocks: []hcl.BlockHeaderSchema{ |
| 53 | { |
| 54 | Type: "variables", |
| 55 | }, |
| 56 | }, |
| 57 | }) |
| 58 | diags = append(diags, moreDiags...) |
| 59 | |
| 60 | vars := make(map[string]cty.Value) |
| 61 | for _, block := range content.Blocks { |
| 62 | // We only have one block type in our schema, so we can assume all |
| 63 | // blocks are of that type. |
| 64 | attrs, moreDiags := block.Body.JustAttributes() |
| 65 | diags = append(diags, moreDiags...) |
| 66 | |
| 67 | for name, attr := range attrs { |
| 68 | val, moreDiags := attr.Expr.Value(specCtx) |
| 69 | diags = append(diags, moreDiags...) |
| 70 | vars[name] = val |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | return vars, funcs, body, diags |
| 75 | } |
| 76 | |
| 77 | func decodeSpecRoot(body hcl.Body) (hcldec.Spec, hcl.Diagnostics) { |
| 78 | content, diags := body.Content(specSchemaUnlabelled) |
no test coverage detected