Skip to content

Commit

Permalink
fix: fixing locals not working with empty value (#43)
Browse files Browse the repository at this point in the history
* fix: fixing locals not working with empty value

* fix: reverting main.tf change

* fix: revert changes

* fix: revert changes template

---------

Co-authored-by: osher.elmakaies <[email protected]>
  • Loading branch information
osherElm and osher.elmakaies authored May 24, 2023
1 parent 4dad8fe commit a6e1da6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion internal/services/terraform.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ func (t *Terraform) GenerateModuleDefaultLocals(modulesFilePath, destinationPath
rawDefault = strings.ReplaceAll(rawDefault, "}", emptyString)
rawDefault = strings.TrimSpace(rawDefault)

if rawDefault == "" {
out.Module[k].MapLocals[v.Name] = make(templates.ComplexVariableData, 0)

continue
}

splittedRawString := strings.Split(rawDefault, "\n")

separator := "="
Expand All @@ -139,7 +145,7 @@ func (t *Terraform) GenerateModuleDefaultLocals(modulesFilePath, destinationPath
}

// if property name is none string
if !strings.Contains(propertyName, `"`) {
if !strings.Contains(propertyName, "\"") {
propertyName = fmt.Sprintf(`"%s"`, propertyName)
}

Expand Down

0 comments on commit a6e1da6

Please sign in to comment.