(filename string)
| 25 | } |
| 26 | |
| 27 | func loadSpecFile(filename string) (specFileContent, hcl.Diagnostics) { |
| 28 | file, diags := parser.ParseHCLFile(filename) |
| 29 | if diags.HasErrors() { |
| 30 | return specFileContent{RootSpec: errSpec}, diags |
| 31 | } |
| 32 | |
| 33 | vars, funcs, specBody, declDiags := decodeSpecDecls(file.Body) |
| 34 | diags = append(diags, declDiags...) |
| 35 | |
| 36 | spec, specDiags := decodeSpecRoot(specBody) |
| 37 | diags = append(diags, specDiags...) |
| 38 | |
| 39 | return specFileContent{ |
| 40 | Variables: vars, |
| 41 | Functions: funcs, |
| 42 | RootSpec: spec, |
| 43 | }, diags |
| 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 { |
no test coverage detected