From 8b9f1b4fd040d4eecc35758be126520d952cf79a Mon Sep 17 00:00:00 2001
From: Siraj Yasin <sirajudeen.yasin@gmail.com>
Date: Wed, 29 Sep 2021 21:07:07 +0000
Subject: [PATCH] Fix Templater condition issue

* for some reason the one liner with multiple conditions is not
  working and due to which the generation of ethernet_mac_address
  is completely ignored

Change-Id: I642fc744c039cafbbd9cea48f861931fb67948c1
---
 krm-functions/templater/local-resource/example-use.yaml | 4 +++-
 manifests/function/hostgenerator-m3/hosttemplate.yaml   | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/krm-functions/templater/local-resource/example-use.yaml b/krm-functions/templater/local-resource/example-use.yaml
index 981987d8d..7ad5b6bd8 100644
--- a/krm-functions/templater/local-resource/example-use.yaml
+++ b/krm-functions/templater/local-resource/example-use.yaml
@@ -36,7 +36,9 @@ template: |
   metadata:
     name: {{ .name }}
   spec:
-    {{- if and (.macAddresses) (.macAddresses.oam) }}
+    {{- if .macAddresses }}
+    {{- if .macAddresses.oam }}
     bootMACAddress: {{ .macAddresses.oam }}
     {{- end }}
+    {{- end }}
   {{ end -}}
diff --git a/manifests/function/hostgenerator-m3/hosttemplate.yaml b/manifests/function/hostgenerator-m3/hosttemplate.yaml
index 4e641fd81..3b2a3bd6e 100644
--- a/manifests/function/hostgenerator-m3/hosttemplate.yaml
+++ b/manifests/function/hostgenerator-m3/hosttemplate.yaml
@@ -92,10 +92,12 @@ template: |
         {{- range $envAll.commonNetworking.links }}
       -
   {{ toYaml . | indent 6 }}
-        {{- if and ($host.macAddresses) (index $host.macAddresses .id) }}
+        {{- if $host.macAddresses }}
+        {{- if index $host.macAddresses .id }}
         ethernet_mac_address: {{ index $host.macAddresses .id }}
         {{- end }}
         {{- end }}
+        {{- end }}
       networks:
         {{- range $envAll.commonNetworking.networks }}
       -