Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

Commit

Permalink
Accept a string as extraInitContainers value for filebeat
Browse files Browse the repository at this point in the history
This makes the filebeat chart consistent with the other beats, while
preserving backwards compatibility.

Fixes #490
  • Loading branch information
flaper87 committed Mar 19, 2020
1 parent 8f21b1b commit 6d13606
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
10 changes: 10 additions & 0 deletions filebeat/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,17 @@ spec:
{{- end }}
{{- if .Values.extraInitContainers }}
initContainers:
# All the other beats accept a string here while
# filebeat accepts a valid yaml array. We're keeping
# this as a backwards compatible change, while adding
# also a way to pass a string as other templates to
# make these implementations consistent.
# https://github.com/elastic/helm-charts/issues/490
{{- if eq "string" (printf "%T" .Values.extraInitContainers) }}
{{ tpl .Values.extraInitContainers . | indent 8 }}
{{- else }}
{{ toYaml .Values.extraInitContainers | indent 8 }}
{{- end }}
{{- end }}
containers:
- name: "filebeat"
Expand Down
18 changes: 17 additions & 1 deletion filebeat/tests/filebeat_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def test_adding_a_extra_container():
} in extraContainer


def test_adding_init_containers():
def test_adding_init_containers_as_yaml():
config = """
extraInitContainers:
- name: dummy-init
Expand All @@ -90,6 +90,22 @@ def test_adding_init_containers():
} in initContainers


def test_adding_init_containers():
config = """
extraInitContainers: |
- name: dummy-init
image: busybox
command: ['echo', 'hey']
"""
r = helm_template(config)
initContainers = r["daemonset"][name]["spec"]["template"]["spec"]["initContainers"]
assert {
"name": "dummy-init",
"image": "busybox",
"command": ["echo", "hey"],
} in initContainers


def test_adding_image_pull_secrets():
config = """
imagePullSecrets:
Expand Down

0 comments on commit 6d13606

Please sign in to comment.