From ac7af88e7fe62ceee03a32f21e6b07ecec67b1df Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Date: Thu, 8 Oct 2020 02:12:50 +0500 Subject: [PATCH] Add helper functions for determining workload type --- .../ix-chart/2009.0.1/templates/_helpers.tpl | 34 +++++++++++++++++-- .../2009.0.1/templates/deployment.yaml | 2 +- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/charts/ix-chart/2009.0.1/templates/_helpers.tpl b/charts/ix-chart/2009.0.1/templates/_helpers.tpl index 8b7a70394a..17020dbe86 100644 --- a/charts/ix-chart/2009.0.1/templates/_helpers.tpl +++ b/charts/ix-chart/2009.0.1/templates/_helpers.tpl @@ -63,8 +63,36 @@ Create the name of the service account to use {{- end }} {{/* -Name for external interfaces to be added to chart +Check if workload type is a deployment */}} -{{- define "externalInterfaceName" -}} -{{- printf "ix-%s" $.Release.Name }} +{{- define "workloadIsDeployment" }} +{{- if eq .Values.workloadType "Deployment" }} +{{- true -}} +{{- else }} +{{- false -}} +{{- end }} +{{- end }} + +{{/* +Check if workload type is a cronjob +*/}} +{{- define "workloadIsCronJob" }} +{{- if eq .Values.workloadType "CronJob" }} +{{- true -}} +{{- else }} +{{- false -}} +{{- end }} +{{- end }} + +{{/* +Get API Version based on workload type +*/}} +{{- define "apiVersion" -}} +{{- if eq (include "workloadIsDeployment" .) "true" }} +{{- printf "apps/v1" }} +{{- else if eq (include "workloadIsCronJob" .) "true" }} +{{- printf "batch/v1beta1" }} +{{- else }} +{{- printf "batch/v1" }} +{{- end }} {{- end }} diff --git a/charts/ix-chart/2009.0.1/templates/deployment.yaml b/charts/ix-chart/2009.0.1/templates/deployment.yaml index 2c97addd3a..8d04b133a9 100644 --- a/charts/ix-chart/2009.0.1/templates/deployment.yaml +++ b/charts/ix-chart/2009.0.1/templates/deployment.yaml @@ -1,4 +1,4 @@ -apiVersion: apps/v1 +apiVersion: {{ template "apiVersion" . }} kind: {{ .Values.workloadType }} metadata: name: {{ include "ix-chart.fullname" . }}