(filename string)
| 23 | } |
| 24 | |
| 25 | func 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 | |
| 45 | func parseVarsBody(body hcl.Body) (map[string]cty.Value, hcl.Diagnostics) { |
| 46 | attrs, diags := body.JustAttributes() |
no test coverage detected