Skip to content

Commit

Permalink
refactor(instant-chart): render containers & initContainers
Browse files Browse the repository at this point in the history
  • Loading branch information
kimyvgy committed Jul 26, 2024
1 parent 00ee68d commit ee5c73d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
12 changes: 12 additions & 0 deletions charts/instant-chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,15 @@ Clean volumes by removing .persistentVolumeClaim.requests
{{- end -}}
{{- $cleanVolumes | toYaml | nindent 0 | trim -}}
{{- end -}}

{{/*
Generate the container definitions
Usage:
{{- include "instant-chart.containers" (dict "containers" .Values.containers "prefix" "container") | trim | nindent 6 -}}
*/}}
{{- define "instant-chart.containers" -}}
{{- range $index, $container := .containers }}
- name: {{ $container.name | default (printf "%s-%d" $.prefix $index) }}
{{- omit $container "name" | toYaml | nindent 2 }}
{{- end -}}
{{- end -}}
10 changes: 2 additions & 8 deletions charts/instant-chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,10 @@ spec:
{{- include "instant-chart.labels" . | nindent 8 }}
spec:
containers:
{{- range $index, $container := .Values.containers }}
- name: {{ $container.name | default (printf "container-%d" $index) }}
{{- omit $container "name" | toYaml | nindent 8 }}
{{- end }}
{{- include "instant-chart.containers" (dict "containers" .Values.containers "prefix" "container") | trim | nindent 6 -}}
{{- with .Values.initContainers }}
initContainers:
{{- range $index, $container := . }}
- name: {{ $container.name | default (printf "init-%d" $index) }}
{{- omit $container "name" | toYaml | nindent 8 }}
{{- end }}
{{- include "instant-chart.containers" (dict "containers" . "prefix" "init") | trim | nindent 6 -}}
{{- end }}
{{- if .Values.volumes }}
volumes:
Expand Down

0 comments on commit ee5c73d

Please sign in to comment.