Skip to content

Commit

Permalink
avoid caching parsed files
Browse files Browse the repository at this point in the history
  • Loading branch information
radeksimko committed Aug 6, 2020
1 parent 26aef09 commit 06a2c6c
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions tfconfig/load_hcl.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,20 @@ func loadModule(fs FS, dir string) (*Module, Diagnostics) {
for _, filename := range primaryPaths {
var file *hcl.File
var fileDiags hcl.Diagnostics

b, err := fs.ReadFile(filename)
if err != nil {
diags = append(diags, &hcl.Diagnostic{
Severity: hcl.DiagError,
Summary: "Failed to read file",
Detail: fmt.Sprintf("The configuration file %q could not be read.", filename),
})
continue
}
if strings.HasSuffix(filename, ".json") {
file, fileDiags = parser.ParseJSONFile(filename)
file, fileDiags = parser.ParseJSON(b, filename)
} else {
file, fileDiags = parser.ParseHCLFile(filename)
file, fileDiags = parser.ParseHCL(b, filename)
}
diags = append(diags, fileDiags...)
if file == nil {
Expand Down

0 comments on commit 06a2c6c

Please sign in to comment.