From ca2dd29bbd88f00e03b4ee49d713aa28bb17426e Mon Sep 17 00:00:00 2001
From: Alan Meadows <alan.meadows@gmail.com>
Date: Wed, 21 Dec 2016 09:58:13 -0800
Subject: [PATCH] Add configmap hashing approach to horizon to allow rolling
 updates when configmaps are updated

---
 common/templates/_funcs.tpl       | 11 +++++++++++
 horizon/templates/deployment.yaml |  2 ++
 2 files changed, 13 insertions(+)

diff --git a/common/templates/_funcs.tpl b/common/templates/_funcs.tpl
index 86c2bd3057..e83d171a97 100644
--- a/common/templates/_funcs.tpl
+++ b/common/templates/_funcs.tpl
@@ -11,3 +11,14 @@
 {{- $wtf := $context.Template.Name | replace $last $name -}}
 {{ include $wtf $context }}
 {{- end -}}
+
+{{- define "hash" -}}
+{{- $name := index . 0 -}}
+{{- $context := index . 1 -}}
+{{- $v:= $context.Template.Name | split "/" -}}
+{{- $n := len $v -}}
+{{- $last := sub $n 1 | printf "_%d" | index $v -}}
+{{- $wtf := $context.Template.Name | replace $last $name -}}
+{{- include $wtf $context | sha256sum | quote -}}
+{{- end -}}
+
diff --git a/horizon/templates/deployment.yaml b/horizon/templates/deployment.yaml
index 76b6288acb..2baa6bc36f 100644
--- a/horizon/templates/deployment.yaml
+++ b/horizon/templates/deployment.yaml
@@ -9,6 +9,8 @@ spec:
       labels:
         app: horizon
       annotations:
+        configmap-bin-hash: {{ tuple "configmap-bin.yaml" . | include "hash" }}
+        configmap-etc-hash: {{ tuple "configmap-etc.yaml" . | include "hash" }}
         pod.beta.kubernetes.io/init-containers: '[
           {
             "name": "init",