feat(provisioner): add support for .tf.json templates (#7835)

Co-authored-by: Colin Adler <colin1adler@gmail.com>
This commit is contained in:
Technofab
2023-06-08 00:06:50 +02:00
committed by GitHub
parent f0c5201617
commit 52ead3d933
5 changed files with 152 additions and 14 deletions

View File

@ -103,7 +103,7 @@ func loadEnabledFeatures(moduleDir string) (map[string]bool, hcl.Diagnostics) {
var found bool
for _, entry := range entries {
if !strings.HasSuffix(entry.Name(), ".tf") {
if !strings.HasSuffix(entry.Name(), ".tf") && !strings.HasSuffix(entry.Name(), ".tf.json") {
continue
}
@ -131,7 +131,12 @@ func parseFeatures(hclFilepath string) (map[string]bool, bool, hcl.Diagnostics)
}
parser := hclparse.NewParser()
parsedHCL, diags := parser.ParseHCLFile(hclFilepath)
var parsedHCL *hcl.File
if strings.HasSuffix(hclFilepath, ".tf.json") {
parsedHCL, diags = parser.ParseJSONFile(hclFilepath)
} else {
parsedHCL, diags = parser.ParseHCLFile(hclFilepath)
}
if diags.HasErrors() {
return flags, false, diags
}