MCPcopy
hub / github.com/hashicorp/hcl / loadSpecFile

Function loadSpecFile

cmd/hcldec/spec.go:27–44  ·  view source on GitHub ↗
(filename string)

Source from the content-addressed store, hash-verified

25}
26
27func 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
46func 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 {

Callers 1

realmainFunction · 0.85

Calls 4

decodeSpecDeclsFunction · 0.85
decodeSpecRootFunction · 0.85
ParseHCLFileMethod · 0.80
HasErrorsMethod · 0.80

Tested by

no test coverage detected