From a6e1da65a3be2c5c04f76578986e63bd3cac4aa2 Mon Sep 17 00:00:00 2001 From: osherElm <52105667+osherElm@users.noreply.github.com> Date: Wed, 24 May 2023 14:49:19 +0300 Subject: [PATCH] fix: fixing locals not working with empty value (#43) * 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 --- internal/services/terraform.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/services/terraform.go b/internal/services/terraform.go index 608762e..26ff02c 100644 --- a/internal/services/terraform.go +++ b/internal/services/terraform.go @@ -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 := "=" @@ -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) }