Commit 502e7001 authored by Waqar Ahmed's avatar Waqar Ahmed

Add method to render all volumes/env variables

parent 88bda7e5
...@@ -28,3 +28,14 @@ Render environment variables ...@@ -28,3 +28,14 @@ Render environment variables
{{- include "common.containers.environmentVariable" $envVariable | nindent 0 -}} {{- include "common.containers.environmentVariable" $envVariable | nindent 0 -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
{{/*
Render environment variables if present
*/}}
{{- define "common.containers.allEnvironmentVariables" -}}
{{- $values := . -}}
{{- include "common.schema.validateKeys" (dict "values" $values "checkKeys" (list "environmentVariables")) -}}
{{- if $values.environmentVariables -}}
env: {{- include "common.containers.environmentVariables" $values | nindent 2 -}}
{{- end -}}
{{- end -}}
...@@ -2,8 +2,10 @@ ...@@ -2,8 +2,10 @@
Define appVolumeMounts for container Define appVolumeMounts for container
*/}} */}}
{{- define "common.storage.configureAppVolumeMountsInContainer" -}} {{- define "common.storage.configureAppVolumeMountsInContainer" -}}
{{- if and .Values.appVolumesEnabled .Values.appVolumeMounts }} {{- include "common.schema.validateKeys" (dict "values" . "checkKeys" (list "appVolumeMounts")) -}}
{{- range $name, $avm := .Values.appVolumeMounts -}} {{- $appVolumeMounts := .appVolumeMounts -}}
{{- if $appVolumeMounts }}
{{- range $name, $avm := $appVolumeMounts -}}
{{- if (default true $avm.enabled) }} {{- if (default true $avm.enabled) }}
{{- if $avm.containerNameOverride -}} {{- if $avm.containerNameOverride -}}
{{- $name = $avm.containerNameOverride -}} {{- $name = $avm.containerNameOverride -}}
...@@ -23,19 +25,22 @@ Define appVolumeMounts for container ...@@ -23,19 +25,22 @@ Define appVolumeMounts for container
Define hostPath for appVolumes Define hostPath for appVolumes
*/}} */}}
{{- define "common.storage.configureAppVolumes" -}} {{- define "common.storage.configureAppVolumes" -}}
{{- if .Values.appVolumeMounts }} {{- include "common.schema.validateKeys" (dict "values" . "checkKeys" (list "appVolumeMounts")) -}}
{{- range $name, $av := .Values.appVolumeMounts -}} {{- $appVolumeMounts := .appVolumeMounts -}}
{{- if $appVolumeMounts }}
{{- range $name, $av := $appVolumeMounts -}}
{{- if (default true $av.enabled) }} {{- if (default true $av.enabled) }}
- name: {{ $name }} - name: {{ $name }}
{{- if or $av.emptyDir $.Values.emptyDirVolumes }} {{- if or $av.emptyDir $.emptyDirVolumes }}
emptyDir: {} emptyDir: {}
{{- else }} {{- else }}
hostPath: hostPath:
{{ if $av.hostPathEnabled }} {{ if $av.hostPathEnabled }}
path: {{ required "hostPath not set" $av.hostPath }} path: {{ required "hostPath not set" $av.hostPath }}
{{- else }} {{- else }}
{{- include "common.schema.validateKeys" (dict "values" . "checkKeys" (list "ixVolumes")) -}}
{{- include "common.schema.validateKeys" (dict "values" $av "checkKeys" (list "datasetName")) -}} {{- include "common.schema.validateKeys" (dict "values" $av "checkKeys" (list "datasetName")) -}}
{{- $volDict := dict "datasetName" $av.datasetName "ixVolumes" $.Values.ixVolumes -}} {{- $volDict := dict "datasetName" $av.datasetName "ixVolumes" $.ixVolumes -}}
path: {{ include "common.storage.retrieveHostPathFromiXVolume" $volDict }} path: {{ include "common.storage.retrieveHostPathFromiXVolume" $volDict }}
{{- end }} {{- end }}
{{- end }} {{- end }}
...@@ -43,3 +48,25 @@ Define hostPath for appVolumes ...@@ -43,3 +48,25 @@ Define hostPath for appVolumes
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- end -}} {{- end -}}
{{/*
Get all volumes configuration
*/}}
{{- define "common.storage.allAppVolumes" -}}
{{- $appVolumeMounts := .appVolumeMounts -}}
{{- if $appVolumeMounts -}}
volumes: {{- include "common.storage.configureAppVolumes" . | nindent 2 -}}
{{- end -}}
{{- end -}}
{{/*
Get all container volume moutns configuration
*/}}
{{- define "common.storage.allContainerVolumeMounts" -}}
{{- $appVolumeMounts := .appVolumeMounts -}}
{{- if $appVolumeMounts -}}
volumeMounts: {{- include "common.storage.configureAppVolumeMountsInContainer" . | nindent 2 -}}
{{- end -}}
{{- end -}}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment