Skip to content

Commit

Permalink
move volume checks to helper template
Browse files Browse the repository at this point in the history
  • Loading branch information
kgrubb committed Jun 27, 2024
1 parent f1bf0fc commit 45dab04
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 3 deletions.
2 changes: 1 addition & 1 deletion charts/netobserv/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
54 changes: 54 additions & 0 deletions charts/netobserv/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
4 changes: 2 additions & 2 deletions charts/netobserv/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 45dab04

Please sign in to comment.