Skip to content

Commit

Permalink
fix: changing len to 0 for empty maps (#42)
Browse files Browse the repository at this point in the history
Co-authored-by: osher.elmakaies <[email protected]>
  • Loading branch information
osherElm and osher.elmakaies authored May 24, 2023
1 parent 11ef984 commit 4dad8fe
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion internal/services/templates/locals_file.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ locals{ {{range $moduleName,$moduleData := .Module}}
{{$localName}} = coalesce(var.{{$moduleName}}.{{$localName}},{{$localValue}}) {{end}}{{end}}

{{define "typeMapLocalBlock"}} {{$moduleData := .ModuleData}} {{$moduleName := .ModuleName}}{{range $mapKey,$mapValue := $moduleData.MapLocals}}
{{$tempLen := len $mapValue }}{{if eq $tempLen 1}} {{$mapKey}} = var.{{$moduleName}}.{{$mapKey}} != null ? var.{{$moduleName}}.{{$mapKey}}:{} {{else}}
{{$tempLen := len $mapValue }}{{if eq $tempLen 0}} {{$mapKey}} = var.{{$moduleName}}.{{$mapKey}} != null ? var.{{$moduleName}}.{{$mapKey}}:{} {{else}}
{{$mapKey}} = var.{{$moduleName}}.{{$mapKey}} != null ? merge(var.{{$moduleName}}.{{$mapKey}},
tomap({ {{range $propertyName, $propertyValue := $mapValue}}
{{$propertyName}} = contains(keys(var.{{$moduleName}}.{{$mapKey}}),{{$propertyName}}) != false ? var.{{$moduleName}}.{{$mapKey}}[{{$propertyName}}] : {{$propertyValue}}{{end}}}
Expand Down

0 comments on commit 4dad8fe

Please sign in to comment.