VOL-2110 - update how default image tags are managed

- Sneak in a work around for helm 2.15

Change-Id: Iabe4fa98b5b4a574061f1fac7a876b3f1f05c398
diff --git a/voltha-adapter-openolt/Chart.yaml b/voltha-adapter-openolt/Chart.yaml
index 629d817..6fb02ed 100644
--- a/voltha-adapter-openolt/Chart.yaml
+++ b/voltha-adapter-openolt/Chart.yaml
@@ -17,5 +17,5 @@
 description: A Helm chart for Voltha OpenOLT Adapter
 icon: https://guide.opencord.org/logos/cord.svg
 
-version: 2.1.2
+version: 2.1.3
 appVersion: 2.1.2
diff --git a/voltha-adapter-openolt/templates/adapters-openolt.yaml b/voltha-adapter-openolt/templates/adapters-openolt.yaml
index ae4ae38..a1b4f69 100644
--- a/voltha-adapter-openolt/templates/adapters-openolt.yaml
+++ b/voltha-adapter-openolt/templates/adapters-openolt.yaml
@@ -60,7 +60,7 @@
     spec:
       containers:
         - name: adapter-open-olt
-          image: {{ tpl .Values.images.adapter_open_olt.registry . }}{{ tpl .Values.images.adapter_open_olt.repository . }}:{{ tpl ( tpl .Values.images.adapter_open_olt.tag . ) . }}
+          image: '{{ tpl .Values.images.adapter_open_olt.registry . }}{{ tpl .Values.images.adapter_open_olt.repository . }}:{{ tpl ( tpl .Values.images.adapter_open_olt.tag . ) . }}'
           imagePullPolicy: {{ tpl .Values.images.adapter_open_olt.pullPolicy . }}
           args:
             - "/app/openolt"
diff --git a/voltha-adapter-openonu/Chart.yaml b/voltha-adapter-openonu/Chart.yaml
index a97bd27..3400c3a 100644
--- a/voltha-adapter-openonu/Chart.yaml
+++ b/voltha-adapter-openonu/Chart.yaml
@@ -17,5 +17,5 @@
 description: A Helm chart for Voltha OpenONU Adapter
 icon: https://guide.opencord.org/logos/cord.svg
 
-version: 2.1.2
+version: 2.1.3
 appVersion: 2.1.1
diff --git a/voltha-adapter-openonu/templates/adapters-openonu.yaml b/voltha-adapter-openonu/templates/adapters-openonu.yaml
index 98c4b3e..475f018 100644
--- a/voltha-adapter-openonu/templates/adapters-openonu.yaml
+++ b/voltha-adapter-openonu/templates/adapters-openonu.yaml
@@ -60,7 +60,7 @@
     spec:
       containers:
         - name: adapter-open-onu
-          image: {{ tpl .Values.images.adapter_open_onu.registry . }}{{ tpl .Values.images.adapter_open_onu.repository . }}:{{ tpl ( tpl .Values.images.adapter_open_onu.tag . ) . }}
+          image: '{{ tpl .Values.images.adapter_open_onu.registry . }}{{ tpl .Values.images.adapter_open_onu.repository . }}:{{ tpl ( tpl .Values.images.adapter_open_onu.tag . ) . }}'
           imagePullPolicy: {{ tpl .Values.images.adapter_open_onu.pullPolicy . }}
           args:
             - "/voltha/adapters/brcm_openomci_onu/main.py"
diff --git a/voltha-adapter-simulated/Chart.yaml b/voltha-adapter-simulated/Chart.yaml
index b87f1af..7c29ba6 100644
--- a/voltha-adapter-simulated/Chart.yaml
+++ b/voltha-adapter-simulated/Chart.yaml
@@ -17,7 +17,7 @@
 description: A Helm chart for Voltha Simulated Adaptyer based on K8S resources in Voltha project
 icon: https://guide.opencord.org/logos/cord.svg
 
-version: 2.1.5
+version: 2.1.6
 
 # appVersion is 2 because this chart contains multiple 2.x images that may have
 # different individual image versions.
diff --git a/voltha-adapter-simulated/templates/adapters-simulated.yaml b/voltha-adapter-simulated/templates/adapters-simulated.yaml
index defea69..830c2a5 100644
--- a/voltha-adapter-simulated/templates/adapters-simulated.yaml
+++ b/voltha-adapter-simulated/templates/adapters-simulated.yaml
@@ -61,7 +61,7 @@
     spec:
       containers:
         - name: adapter-simulated-olt
-          image: {{ tpl .Values.images.adapter_simulated_olt.registry . }}{{ tpl .Values.images.adapter_simulated_olt.repository . }}:{{ tpl ( tpl .Values.images.adapter_simulated_olt.tag . ) . }}
+          image: '{{ tpl .Values.images.adapter_simulated_olt.registry . }}{{ tpl .Values.images.adapter_simulated_olt.repository . }}:{{ tpl .Values.images.adapter_simulated_olt.tag . }}'
           imagePullPolicy: {{ tpl .Values.images.adapter_simulated_olt.pullPolicy . }}
           args:
             - "/app/simulated_olt"
@@ -137,7 +137,7 @@
     spec:
       containers:
         - name: adapter-simulated-onu
-          image: {{ tpl .Values.images.adapter_simulated_onu.registry . }}{{ tpl .Values.images.adapter_simulated_onu.repository . }}:{{ tpl ( tpl .Values.images.adapter_simulated_onu.tag . ) . }}
+          image: '{{ tpl .Values.images.adapter_simulated_onu.registry . }}{{ tpl .Values.images.adapter_simulated_onu.repository . }}:{{ tpl .Values.images.adapter_simulated_onu.tag . }}'
           imagePullPolicy: {{ tpl .Values.images.adapter_simulated_onu.pullPolicy . }}
           args:
             - "/app/simulated_onu"
diff --git a/voltha-adapter-simulated/values.yaml b/voltha-adapter-simulated/values.yaml
index 6098a7d..62d524b 100644
--- a/voltha-adapter-simulated/values.yaml
+++ b/voltha-adapter-simulated/values.yaml
@@ -46,11 +46,11 @@
   adapter_simulated_olt:
     registry: '{{ .Values.defaults.image_registry }}'
     repository: '{{ .Values.defaults.image_org }}voltha-adapter-simulated-olt'
-    tag: '{{ if hasKey .Values.defaults "image_tag" }}{{ .Values.defaults.image_tag }}{{ else }}2.2.0{{ end }}'
+    tag: '{{- if hasKey .Values.defaults "image_tag" }}{{- if .Values.defaults.image_tag }}{{ .Values.defaults.image_tag }}{{- else }}2.2.0{{- end }}{{- else }}2.2.0{{- end }}'
     pullPolicy: '{{ .Values.defaults.image_pullPolicy }}'
 
   adapter_simulated_onu:
     registry: '{{ .Values.defaults.image_registry }}'
     repository: '{{ .Values.defaults.image_org }}voltha-adapter-simulated-onu'
-    tag: '{{ if hasKey .Values.defaults "image_tag" }}{{ .Values.defaults.image_tag }}{{ else }}2.2.0{{ end }}'
+    tag: '{{- if hasKey .Values.defaults "image_tag" }}{{- if .Values.defaults.image_tag }}{{ .Values.defaults.image_tag }}{{- else }}2.2.0{{- end }}{{- else }}2.2.0{{- end }}'
     pullPolicy: '{{ .Values.defaults.image_pullPolicy }}'
diff --git a/voltha/Chart.yaml b/voltha/Chart.yaml
index 467e848..5f82959 100644
--- a/voltha/Chart.yaml
+++ b/voltha/Chart.yaml
@@ -17,7 +17,7 @@
 description: A Helm chart for Voltha based on K8S resources in Voltha project
 icon: https://guide.opencord.org/logos/cord.svg
 
-version: 2.1.10
+version: 2.1.11
 
 # appVersion is 2 because this chart contains multiple 2.x images that may have
 # different individual image versions.
diff --git a/voltha/templates/afrouter-config.yaml b/voltha/templates/afrouter-config.yaml
index 4fffddc..1b57d5d 100644
--- a/voltha/templates/afrouter-config.yaml
+++ b/voltha/templates/afrouter-config.yaml
@@ -178,7 +178,15 @@
           {
             "name": "vcore",
             "backends": [
-{{- range $i, $e := until (int .Values.replicas.rw_core) }}
+{{- /*
+    The conversion of the the recplicas.rw_core (number) to a string
+    and then back to an int is a work-a-round required for helm
+    v.2.15. It is currently considered a regression bug in helm
+    (https://github.com/helm/helm/issues/6708). The need for this
+    work-a-round should be re-checked against helm occationally and 
+    removed if no longer needed.
+*/ -}}
+{{- range $i, $e := until (int (toString .Values.replicas.rw_core)) }}
 {{- $cluster := add1 $i }}
               {
                 "name": "vcore{{ $cluster }}",
@@ -201,14 +209,30 @@
                     "port": "50057"
                   }
                 ]
-              }{{ if lt $cluster (int $root.Values.replicas.rw_core) }},{{ end }}
+{{- /*
+    The conversion of the the recplicas.rw_core (number) to a string
+    and then back to an int is a work-a-round required for helm
+    v.2.15. It is currently considered a regression bug in helm
+    (https://github.com/helm/helm/issues/6708). The need for this
+    work-a-round should be re-checked against helm occationally and 
+    removed if no longer needed.
+*/ -}}
+              }{{ if lt $cluster (int (toString $root.Values.replicas.rw_core)) }},{{ end }}
 {{- end}}
             ]
           },
           {
             "name": "ro_vcore",
             "backends": [
-{{- range $core_idx, $e := until (int .Values.replicas.rw_core) }}
+{{- /*
+    The conversion of the the recplicas.rw_core (number) to a string
+    and then back to an int is a work-a-round required for helm
+    v.2.15. It is currently considered a regression bug in helm
+    (https://github.com/helm/helm/issues/6708). The need for this
+    work-a-round should be re-checked against helm occationally and 
+    removed if no longer needed.
+*/ -}}
+{{- range $core_idx, $e := until (int (toString .Values.replicas.rw_core)) }}
               {
                 "name": "ro_vcore{{ $core_idx }}",
                 "type": "server",
@@ -219,7 +243,15 @@
                     "port": "50057"
                   }
                 ]
-              }{{ if lt (add1 $core_idx) (int $root.Values.replicas.rw_core) }},{{ end }}
+{{- /*
+    The conversion of the the recplicas.rw_core (number) to a string
+    and then back to an int is a work-a-round required for helm
+    v.2.15. It is currently considered a regression bug in helm
+    (https://github.com/helm/helm/issues/6708). The need for this
+    work-a-round should be re-checked against helm occationally and 
+    removed if no longer needed.
+*/ -}}
+              }{{ if lt (add1 $core_idx) (int (toString $root.Values.replicas.rw_core)) }},{{ end }}
 {{- end}}
             ]
           },
diff --git a/voltha/templates/api-server.yaml b/voltha/templates/api-server.yaml
index c14c881..8a8f59f 100644
--- a/voltha/templates/api-server.yaml
+++ b/voltha/templates/api-server.yaml
@@ -74,7 +74,7 @@
       serviceAccountName: {{ .Values.serviceaccount }}
       containers:
       - name: arouter
-        image: {{ tpl .Values.images.afrouter.registry . }}{{ tpl .Values.images.afrouter.repository . }}:{{ tpl ( tpl .Values.images.afrouter.tag . ) . }}
+        image: '{{ tpl .Values.images.afrouter.registry . }}{{ tpl .Values.images.afrouter.repository . }}:{{ tpl .Values.images.afrouter.tag . }}'
         imagePullPolicy: {{ tpl .Values.images.afrouter.pullPolicy . }}
         volumeMounts:
         - name: config-volume
@@ -96,7 +96,7 @@
           value: {{ quote .Values.services.kafka.cluster.port }}
         - name: KAFKA_TOPIC
           value: {{ quote .Values.api_server.kafka_topic }}
-        image: {{ tpl .Values.images.afrouterd.registry . }}{{ tpl .Values.images.afrouterd.repository . }}:{{ tpl ( tpl .Values.images.afrouterd.tag . ) . }}
+        image: '{{ tpl .Values.images.afrouterd.registry . }}{{ tpl .Values.images.afrouterd.repository . }}:{{ tpl .Values.images.afrouterd.tag . }}'
         imagePullPolicy: {{ tpl .Values.images.afrouterd.pullPolicy . }}
         command: ["/app/arouterd"]
       restartPolicy: Always
diff --git a/voltha/templates/cli.yaml b/voltha/templates/cli.yaml
index 4ec8519..c92c00c 100644
--- a/voltha/templates/cli.yaml
+++ b/voltha/templates/cli.yaml
@@ -77,7 +77,7 @@
       serviceAccountName: {{ .Values.serviceaccount }}
       containers:
         - name: vcli
-          image: {{ tpl .Values.images.cli.registry . }}{{ tpl .Values.images.cli.repository . }}:{{ tpl ( tpl .Values.images.cli.tag . ) . }}
+          image: '{{ tpl .Values.images.cli.registry . }}{{ tpl .Values.images.cli.repository . }}:{{ tpl .Values.images.cli.tag . }}'
           imagePullPolicy: {{ tpl .Values.images.cli.pullPolicy . }}
           env:
             - name: POD_IP
diff --git a/voltha/templates/ofagent.yaml b/voltha/templates/ofagent.yaml
index ca8e5d5..0e9dc49 100644
--- a/voltha/templates/ofagent.yaml
+++ b/voltha/templates/ofagent.yaml
@@ -60,7 +60,7 @@
       serviceAccountName: {{ .Values.serviceaccount }}
       containers:
       - name: ofagent
-        image: {{ tpl .Values.images.ofagent.registry . }}{{ tpl .Values.images.ofagent.repository . }}:{{ tpl ( tpl .Values.images.ofagent.tag . ) . }}
+        image: '{{ tpl .Values.images.ofagent.registry . }}{{ tpl .Values.images.ofagent.repository . }}:{{ tpl .Values.images.ofagent.tag . }}'
         imagePullPolicy: {{ tpl .Values.images.ofagent.pullPolicy . }}
         env:
         - name: CONTROLLER_SERVICE
diff --git a/voltha/templates/ro-core.yaml b/voltha/templates/ro-core.yaml
index 7553c28..0879cc0 100644
--- a/voltha/templates/ro-core.yaml
+++ b/voltha/templates/ro-core.yaml
@@ -104,7 +104,7 @@
       serviceAccountName: {{ .Values.serviceaccount }}
       containers:
         - name: voltha
-          image: {{ tpl .Values.images.ro_core.registry . }}{{ tpl .Values.images.ro_core.repository . }}:{{ tpl ( tpl .Values.images.ro_core.tag . ) . }}
+          image: '{{ tpl .Values.images.ro_core.registry . }}{{ tpl .Values.images.ro_core.repository . }}:{{ tpl .Values.images.ro_core.tag . }}'
           imagePullPolicy: {{ tpl .Values.images.ro_core.pullPolicy . }}
           env:
             - name: NAMESPACE
diff --git a/voltha/templates/rw-core.yaml b/voltha/templates/rw-core.yaml
index ff78767..75333a6 100644
--- a/voltha/templates/rw-core.yaml
+++ b/voltha/templates/rw-core.yaml
@@ -13,7 +13,7 @@
 # limitations under the License.
 
 {{- $root := . -}}
-{{- $tag := tpl ( tpl .Values.images.rw_core.tag . ) . }}
+{{- $tag := tpl .Values.images.rw_core.tag . }}
 {{- $repository := tpl .Values.images.rw_core.repository . }}
 {{- $registry := tpl .Values.images.rw_core.registry . }}
 {{- $pullpolicy := tpl .Values.images.rw_core.pullPolicy . }}
@@ -37,7 +37,15 @@
 {{- else }}
 {{- $log_level = 3 }}
 {{- end }}
-{{- range $i, $e := until (int .Values.replicas.rw_core) }}
+{{- /*
+    The conversion of the the recplicas.rw_core (number) to a string
+    and then back to an int is a work-a-round required for helm
+    v.2.15. It is currently considered a regression bug in helm
+    (https://github.com/helm/helm/issues/6708). The need for this
+    work-a-round should be re-checked against helm occationally and 
+    removed if no longer needed.
+*/ -}}
+{{- range $i, $e := until (int (toString .Values.replicas.rw_core)) }}
 {{- $cluster := add1 $i }}
 {{- range $i, $e := until 2 }}
 {{- $cluster_core_id := add1 $i }}
@@ -127,7 +135,7 @@
       serviceAccountName: {{ $root.Values.serviceaccount }}
       containers:
         - name: voltha
-          image: {{ $registry }}{{ $repository }}:{{ $tag }}
+          image: '{{ $registry }}{{ $repository }}:{{ $tag }}'
           imagePullPolicy: {{ $pullpolicy }}
           env:
             - name: NAMESPACE
diff --git a/voltha/values.yaml b/voltha/values.yaml
index 7b6a6bd..e50f9b4 100644
--- a/voltha/values.yaml
+++ b/voltha/values.yaml
@@ -93,36 +93,36 @@
   cli:
     registry: '{{ .Values.defaults.image_registry }}'
     repository: '{{ .Values.defaults.image_org }}voltha-cli'
-    tag: '{{ if hasKey .Values.defaults "image_tag" }}{{ .Values.defaults.image_tag }}{{ else }}2.1.3{{ end }}'
+    tag: '{{- if hasKey .Values.defaults "image_tag" }}{{- if .Values.defaults.image_tag }}{{ .Values.defaults.image_tag }}{{- else }}2.1.3{{- end }}{{- else }}2.1.3{{- end }}'
     pullPolicy: '{{ .Values.defaults.image_pullPolicy }}'
 
   ofagent:
     registry: '{{ .Values.defaults.image_registry }}'
     repository: '{{ .Values.defaults.image_org }}voltha-ofagent'
-    tag: '{{ if hasKey .Values.defaults "image_tag" }}{{ .Values.defaults.image_tag }}{{ else }}2.1.3{{ end }}'
+    tag: '{{- if hasKey .Values.defaults "image_tag" }}{{- if .Values.defaults.image_tag }}{{ .Values.defaults.image_tag }}{{- else }}2.1.3{{- end }}{{- else }}2.1.3{{- end }}'
     pullPolicy: '{{ .Values.defaults.image_pullPolicy }}'
 
   ro_core:
     registry: '{{ .Values.defaults.image_registry }}'
     repository: '{{ .Values.defaults.image_org }}voltha-ro-core'
-    tag: '{{ if hasKey .Values.defaults "image_tag" }}{{ .Values.defaults.image_tag }}{{ else }}2.1.3{{ end }}'
+    tag: '{{- if hasKey .Values.defaults "image_tag" }}{{- if .Values.defaults.image_tag }}{{ .Values.defaults.image_tag }}{{- else }}2.1.3{{- end }}{{- else }}2.1.3{{- end }}'
     pullPolicy: '{{ .Values.defaults.image_pullPolicy }}'
 
   rw_core:
     registry: '{{ .Values.defaults.image_registry }}'
     repository: '{{ .Values.defaults.image_org }}voltha-rw-core'
-    tag: '{{ if hasKey .Values.defaults "image_tag" }}{{ .Values.defaults.image_tag }}{{ else }}2.1.3{{ end }}'
+    tag: '{{- if hasKey .Values.defaults "image_tag" }}{{- if .Values.defaults.image_tag }}{{ .Values.defaults.image_tag }}{{- else }}2.1.3{{- end }}{{- else }}2.1.3{{- end }}'
     pullPolicy: '{{ .Values.defaults.image_pullPolicy }}'
 
   afrouter:
     registry: '{{ .Values.defaults.image_registry }}'
     repository: '{{ .Values.defaults.image_org }}voltha-afrouter'
-    tag: '{{ if hasKey .Values.defaults "image_tag" }}{{ .Values.defaults.image_tag }}{{ else }}2.2.0{{ end }}'
+    tag: '{{- if hasKey .Values.defaults "image_tag" }}{{- if .Values.defaults.image_tag }}{{ .Values.defaults.image_tag }}{{- else }}2.2.0{{- end }}{{- else }}2.2.0{{- end }}'
     pullPolicy: '{{ .Values.defaults.image_pullPolicy }}'
 
   afrouterd:
     registry: '{{ .Values.defaults.image_registry }}'
     repository: '{{ .Values.defaults.image_org }}voltha-afrouterd'
-    tag: '{{ if hasKey .Values.defaults "image_tag" }}{{ .Values.defaults.image_tag }}{{ else }}2.2.0{{ end }}'
+    tag: '{{- if hasKey .Values.defaults "image_tag" }}{{- if .Values.defaults.image_tag }}{{ .Values.defaults.image_tag }}{{- else }}2.2.0{{- end }}{{- else }}2.2.0{{- end }}'
     pullPolicy: '{{ .Values.defaults.image_pullPolicy }}'
     restartPolicy: 'Always'