Skip to content

Commit

Permalink
refactor(cinder-csi-plugin): define helper templates for podLabels, p…
Browse files Browse the repository at this point in the history
…odAnnotations
  • Loading branch information
roehlc committed Feb 14, 2024
1 parent b9fe10a commit e088cd3
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 20 deletions.
41 changes: 41 additions & 0 deletions charts/cinder-csi-plugin/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ component: controllerplugin
{{ include "cinder-csi.common.metaLabels" . }}
{{- end -}}

{{- define "cinder-csi.controllerplugin.podLabels" -}}
{{ include "cinder-csi.controllerplugin.labels" . }}
{{ if .Values.csi.plugin.controllerPlugin.podLabels }}
{{- toYaml .Values.csi.plugin.controllerPlugin.podLabels }}
{{- end }}
{{- end -}}

{{- define "cinder-csi.nodeplugin.matchLabels" -}}
component: nodeplugin
{{ include "cinder-csi.common.matchLabels" . }}
Expand All @@ -92,6 +99,13 @@ component: nodeplugin
{{ include "cinder-csi.common.metaLabels" . }}
{{- end -}}

{{- define "cinder-csi.nodeplugin.podLabels" -}}
{{ include "cinder-csi.nodeplugin.labels" . }}
{{ if .Values.csi.plugin.nodePlugin.podLabels }}
{{- toYaml .Values.csi.plugin.nodePlugin.podLabels }}
{{- end }}
{{- end -}}

{{- define "cinder-csi.snapshot-controller.matchLabels" -}}
component: snapshot-controller
{{ include "cinder-csi.common.matchLabels" . }}
Expand All @@ -101,3 +115,30 @@ component: snapshot-controller
{{ include "cinder-csi.snapshot-controller.matchLabels" . }}
{{ include "cinder-csi.common.metaLabels" . }}
{{- end -}}

{{/*
Common annotations
*/}}
{{- define "cinder-csi.annotations" -}}
{{- if .Values.commonAnnotations }}
{{- toYaml .Values.commonAnnotations }}
{{- end }}
{{- end -}}


{{/*
Create unified annotations for cinder-csi components
*/}}
{{- define "cinder-csi.controllerplugin.podAnnotations" -}}
{{ include "cinder-csi.annotations" . }}
{{ if .Values.csi.plugin.controllerPlugin.podAnnotations }}
{{- toYaml .Values.csi.plugin.controllerPlugin.podAnnotations }}
{{- end }}
{{- end -}}

{{- define "cinder-csi.nodeplugin.podAnnotations" -}}
{{ include "cinder-csi.annotations" . }}
{{ if .Values.csi.plugin.nodePlugin.podAnnotations }}
{{- toYaml .Values.csi.plugin.nodePlugin.podAnnotations }}
{{- end }}
{{- end -}}
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,9 @@ spec:
template:
metadata:
labels:
{{- include "cinder-csi.controllerplugin.labels" . | nindent 8 }}
{{- with .Values.csi.plugin.controllerPlugin.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "cinder-csi.controllerplugin.podLabels" . | nindent 8 }}
annotations:
{{- with .Values.commonAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.csi.plugin.controllerPlugin.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "cinder-csi.controllerplugin.podAnnotations" . | nindent 8 }}
spec:
serviceAccount: csi-cinder-controller-sa
securityContext:
Expand Down
12 changes: 2 additions & 10 deletions charts/cinder-csi-plugin/templates/nodeplugin-daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,9 @@ spec:
template:
metadata:
labels:
{{- include "cinder-csi.nodeplugin.labels" . | nindent 8 }}
{{- with .Values.csi.plugin.nodePlugin.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "cinder-csi.nodeplugin.podLabels" . | nindent 8 }}
annotations:
{{- with .Values.commonAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.csi.plugin.nodePlugin.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "cinder-csi.nodeplugin.podAnnotations" . | nindent 8 }}
spec:
serviceAccount: csi-cinder-node-sa
hostNetwork: true
Expand Down

0 comments on commit e088cd3

Please sign in to comment.