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

Function parseVarsFile

cmd/hcldec/vars.go:25–43  ·  view source on GitHub ↗
(filename string)

Source from the content-addressed store, hash-verified

23}
24
25func parseVarsFile(filename string) (map[string]cty.Value, hcl.Diagnostics) {
26 var f *hcl.File
27 var diags hcl.Diagnostics
28
29 if strings.HasSuffix(filename, ".json") {
30 f, diags = parser.ParseJSONFile(filename)
31 } else {
32 f, diags = parser.ParseHCLFile(filename)
33 }
34
35 if f == nil {
36 return nil, diags
37 }
38
39 vals, valsDiags := parseVarsBody(f.Body)
40 diags = append(diags, valsDiags...)
41 return vals, diags
42
43}
44
45func parseVarsBody(body hcl.Body) (map[string]cty.Value, hcl.Diagnostics) {
46 attrs, diags := body.JustAttributes()

Callers 1

realmainFunction · 0.85

Calls 3

parseVarsBodyFunction · 0.85
ParseJSONFileMethod · 0.80
ParseHCLFileMethod · 0.80

Tested by

no test coverage detected