Skip to content

Commit 9d2b35a

Browse files
committed
fix(provisioner): parser variable scope
1 parent 90d7e1b commit 9d2b35a

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

provisioner/terraform/parameters.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@ func rawRichParameterNames(workdir string) ([]string, error) {
3131
continue
3232
}
3333

34+
var parsedHCL *hcl.File
35+
var diags hcl.Diagnostics
3436
hclFilepath := path.Join(workdir, entry.Name())
3537
parser := hclparse.NewParser()
3638
if strings.HasSuffix(entry.Name(), ".tf.json") {
37-
parsedHCL, diags := parser.ParseJSONFile(hclFilepath)
39+
parsedHCL, diags = parser.ParseJSONFile(hclFilepath)
3840
} else {
39-
parsedHCL, diags := parser.ParseHCLFile(hclFilepath)
41+
parsedHCL, diags = parser.ParseHCLFile(hclFilepath)
4042
}
4143
if diags.HasErrors() {
4244
return nil, hcl.Diagnostics{

provisioner/terraform/parse.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,11 @@ func parseFeatures(hclFilepath string) (map[string]bool, bool, hcl.Diagnostics)
131131
}
132132

133133
parser := hclparse.NewParser()
134+
var parsedHCL *hcl.File
134135
if strings.HasSuffix(hclFilepath, ".tf.json") {
135-
parsedHCL, diags := parser.ParseJSONFile(hclFilepath)
136+
parsedHCL, diags = parser.ParseJSONFile(hclFilepath)
136137
} else {
137-
parsedHCL, diags := parser.ParseHCLFile(hclFilepath)
138+
parsedHCL, diags = parser.ParseHCLFile(hclFilepath)
138139
}
139140
if diags.HasErrors() {
140141
return flags, false, diags

0 commit comments

Comments
 (0)