From 45dab0499c8d2a7ac606f3f25e5fdbb039752b0f Mon Sep 17 00:00:00 2001 From: Madison Grubb Date: Thu, 27 Jun 2024 17:25:31 -0400 Subject: [PATCH] move volume checks to helper template --- charts/netobserv/Chart.yaml | 2 +- charts/netobserv/templates/_helpers.tpl | 54 ++++++++++++++++++++++ charts/netobserv/templates/deployment.yaml | 4 +- 3 files changed, 57 insertions(+), 3 deletions(-) diff --git a/charts/netobserv/Chart.yaml b/charts/netobserv/Chart.yaml index 3a35a05..0ddc470 100644 --- a/charts/netobserv/Chart.yaml +++ b/charts/netobserv/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: netobserv description: ElastiFlow NetObserv type: application -version: 0.1.2 +version: 0.2.0 appVersion: 7.0.1 keywords: diff --git a/charts/netobserv/templates/_helpers.tpl b/charts/netobserv/templates/_helpers.tpl index 0b2a7a8..202fa60 100644 --- a/charts/netobserv/templates/_helpers.tpl +++ b/charts/netobserv/templates/_helpers.tpl @@ -60,3 +60,57 @@ Create the name of the service account to use {{- default "default" .Values.serviceAccount.name }} {{- end }} {{- end }} + + +{{/* +Manage Volumes via checking if values that require volumes are enabled. +*/}} +{{- define "maxmindEnabled" -}} + {{- or .Values.maxmind.asnEnabled .Values.maxmind.geoipEnabled -}} +{{- end -}} + +{{- define "outputKafkaEnabled" -}} + {{- .Values.outputKafka.tls.enabled -}} +{{- end -}} + +{{- define "outputElasticsearchEnabled" -}} + {{- .Values.outputElasticsearch.tls.enabled -}} +{{- end -}} + +{{- define "outputOpenSearchEnabled" -}} + {{- .Values.outputOpenSearch.tls.enabled -}} +{{- end -}} + +{{- define "extraVolumeMountsEnabled" -}} + {{- .Values.extraVolumeMounts -}} +{{- end -}} + +{{- define "extraVolumesEnabled" -}} + {{- .Values.extraVolumes -}} +{{- end -}} + +{{/* +Determine if volumes need to be created +*/}} +{{- define "volumesEnabled" -}} + {{- or + (include "maxmindEnabled" .) + (include "outputKafkaEnabled" .) + (include "outputElasticsearchEnabled" .) + (include "outputOpenSearchEnabled" .) + (include "extraVolumesEnabled" .) + -}} +{{- end -}} + +{{/* +Determine if volumeMounts need to be created +*/}} +{{- define "volumeMountsEnabled" -}} + {{- or + (include "maxmindEnabled" .) + (include "outputKafkaEnabled" .) + (include "outputElasticsearchEnabled" .) + (include "outputOpenSearchEnabled" .) + (include "extraVolumeMountsEnabled" .) + -}} +{{- end -}} diff --git a/charts/netobserv/templates/deployment.yaml b/charts/netobserv/templates/deployment.yaml index 96cf27b..4ae8c02 100644 --- a/charts/netobserv/templates/deployment.yaml +++ b/charts/netobserv/templates/deployment.yaml @@ -142,7 +142,7 @@ spec: {{- end }} resources: {{- toYaml .Values.resources | nindent 12 }} - {{- if or .Values.maxmind.asnEnabled .Values.maxmind.geoipEnabled .Values.outputKafka.tls.enabled .Values.outputElasticsearch.tls.enabled .Values.outputOpenSearch.tls.enabled .Values.extraVolumeMounts }} + {{- if include "volumeMountsEnabled" . }} volumeMounts: {{- if or .Values.maxmind.asnEnabled .Values.maxmind.geoipEnabled }} - name: geolite2-data @@ -195,7 +195,7 @@ spec: - name: geolite2-data mountPath: /data {{- end }} - {{- if or .Values.maxmind.asnEnabled .Values.maxmind.geoipEnabled .Values.outputKafka.tls.enabled .Values.outputElasticsearch.tls.enabled .Values.outputOpenSearch.tls.enabled .Values.extraVolumes }} + {{- if include "volumesEnabled" . }} volumes: {{- if or .Values.maxmind.asnEnabled .Values.maxmind.geoipEnabled }} - name: geolite2-data