diff --git a/hcl2template/parser.go b/hcl2template/parser.go index 6a14fba13..19e8de0ad 100644 --- a/hcl2template/parser.go +++ b/hcl2template/parser.go @@ -90,6 +90,11 @@ func (p *Parser) Parse(filename string, varFiles []string, argVars map[string]st if filename != "" { hclFiles, jsonFiles, moreDiags := GetHCL2Files(filename, hcl2FileExt, hcl2JsonFileExt) diags = append(diags, moreDiags...) + if moreDiags.HasErrors() { + // here this probably means that the file was not found, let's + // simply leave early. + return nil, diags + } if len(hclFiles)+len(jsonFiles) == 0 { diags = append(diags, &hcl.Diagnostic{ Severity: hcl.DiagError, diff --git a/hcl2template/utils.go b/hcl2template/utils.go index 488a5e32a..a8bfffbb8 100644 --- a/hcl2template/utils.go +++ b/hcl2template/utils.go @@ -57,7 +57,6 @@ func GetHCL2Files(filename, hclSuffix, jsonSuffix string) (hclFiles, jsonFiles [ if err != nil { diags = append(diags, &hcl.Diagnostic{ Severity: hcl.DiagError, - Summary: "Cannot tell wether " + filename + " is a directory", Detail: err.Error(), }) return nil, nil, diags