From 2d309cbfb25ca0f5d3c3633445144d2c5ed1de54 Mon Sep 17 00:00:00 2001 From: Michael Russell Date: Mon, 24 Jun 2019 15:45:32 +0200 Subject: [PATCH] [elasticsearch] Fix pvc annotations with multiple fields Fixes: #183 This worked just fine if there was only 1 annotation being added. When adding multiple annotations the extra whitespace was causing it to break. --- elasticsearch/templates/statefulset.yaml | 2 +- elasticsearch/tests/elasticsearch_test.py | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/elasticsearch/templates/statefulset.yaml b/elasticsearch/templates/statefulset.yaml index 0c5444094..be2d44f8e 100644 --- a/elasticsearch/templates/statefulset.yaml +++ b/elasticsearch/templates/statefulset.yaml @@ -23,7 +23,7 @@ spec: name: {{ template "uname" . }} {{- with .Values.persistence.annotations }} annotations: - {{ toYaml . | indent 4 }} +{{ toYaml . | indent 8 }} {{- end }} spec: {{ toYaml .Values.volumeClaimTemplate | indent 6 }} diff --git a/elasticsearch/tests/elasticsearch_test.py b/elasticsearch/tests/elasticsearch_test.py index 5635c972e..9422858a2 100755 --- a/elasticsearch/tests/elasticsearch_test.py +++ b/elasticsearch/tests/elasticsearch_test.py @@ -343,7 +343,20 @@ def test_adding_storageclass_annotation_to_volumeclaimtemplate(): ''' r = helm_template(config) annotations = r['statefulset'][uname]['spec']['volumeClaimTemplates'][0]['metadata']['annotations'] - assert {'volume.beta.kubernetes.io/storage-class': 'id'} == annotations + assert annotations['volume.beta.kubernetes.io/storage-class'] == 'id' + +def test_adding_multiple_persistence_annotations(): + config = ''' + persistence: + annotations: + hello: world + world: hello + ''' + r = helm_template(config) + annotations = r['statefulset'][uname]['spec']['volumeClaimTemplates'][0]['metadata']['annotations'] + + assert annotations['hello'] == 'world' + assert annotations['world'] == 'hello' def test_adding_a_secret_mount():