Skip to content

Commit d6bc7f2

Browse files
committed
refactor(cinder-csi-plugin): define helper templates for podLabels, podAnnotations
1 parent d199ec6 commit d6bc7f2

File tree

3 files changed

+45
-20
lines changed

3 files changed

+45
-20
lines changed

charts/cinder-csi-plugin/templates/_helpers.tpl

+41
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,13 @@ component: controllerplugin
8282
{{ include "cinder-csi.common.metaLabels" . }}
8383
{{- end -}}
8484

85+
{{- define "cinder-csi.controllerplugin.podLabels" -}}
86+
{{ include "cinder-csi.controllerplugin.labels" . }}
87+
{{ if .Values.csi.plugin.controllerPlugin.podLabels }}
88+
{{- toYaml .Values.csi.plugin.controllerPlugin.podLabels }}
89+
{{- end }}
90+
{{- end -}}
91+
8592
{{- define "cinder-csi.nodeplugin.matchLabels" -}}
8693
component: nodeplugin
8794
{{ include "cinder-csi.common.matchLabels" . }}
@@ -92,6 +99,13 @@ component: nodeplugin
9299
{{ include "cinder-csi.common.metaLabels" . }}
93100
{{- end -}}
94101

102+
{{- define "cinder-csi.nodeplugin.podLabels" -}}
103+
{{ include "cinder-csi.nodeplugin.labels" . }}
104+
{{ if .Values.csi.plugin.nodePlugin.podLabels }}
105+
{{- toYaml .Values.csi.plugin.nodePlugin.podLabels }}
106+
{{- end }}
107+
{{- end -}}
108+
95109
{{- define "cinder-csi.snapshot-controller.matchLabels" -}}
96110
component: snapshot-controller
97111
{{ include "cinder-csi.common.matchLabels" . }}
@@ -101,3 +115,30 @@ component: snapshot-controller
101115
{{ include "cinder-csi.snapshot-controller.matchLabels" . }}
102116
{{ include "cinder-csi.common.metaLabels" . }}
103117
{{- end -}}
118+
119+
{{/*
120+
Common annotations
121+
*/}}
122+
{{- define "cinder-csi.annotations" -}}
123+
{{- if .Values.commonAnnotations }}
124+
{{- toYaml .Values.commonAnnotations }}
125+
{{- end }}
126+
{{- end -}}
127+
128+
129+
{{/*
130+
Create unified annotations for cinder-csi components
131+
*/}}
132+
{{- define "cinder-csi.controllerplugin.podAnnotations" -}}
133+
{{ include "cinder-csi.annotations" . }}
134+
{{ if .Values.csi.plugin.controllerPlugin.podAnnotations }}
135+
{{- toYaml .Values.csi.plugin.controllerPlugin.podAnnotations }}
136+
{{- end }}
137+
{{- end -}}
138+
139+
{{- define "cinder-csi.nodeplugin.podAnnotations" -}}
140+
{{ include "cinder-csi.annotations" . }}
141+
{{ if .Values.csi.plugin.nodePlugin.podAnnotations }}
142+
{{- toYaml .Values.csi.plugin.nodePlugin.podAnnotations }}
143+
{{- end }}
144+
{{- end -}}

charts/cinder-csi-plugin/templates/controllerplugin-deployment.yaml

+2-10
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,9 @@ spec:
2424
template:
2525
metadata:
2626
labels:
27-
{{- include "cinder-csi.controllerplugin.labels" . | nindent 8 }}
28-
{{- with .Values.csi.plugin.controllerPlugin.podLabels }}
29-
{{- toYaml . | nindent 8 }}
30-
{{- end }}
27+
{{- include "cinder-csi.controllerplugin.podLabels" . | nindent 8 }}
3128
annotations:
32-
{{- with .Values.commonAnnotations }}
33-
{{- toYaml . | nindent 8 }}
34-
{{- end }}
35-
{{- with .Values.csi.plugin.controllerPlugin.podAnnotations }}
36-
{{- toYaml . | nindent 8 }}
37-
{{- end }}
29+
{{- include "cinder-csi.controllerplugin.podAnnotations" . | nindent 8 }}
3830
spec:
3931
serviceAccount: csi-cinder-controller-sa
4032
securityContext:

charts/cinder-csi-plugin/templates/nodeplugin-daemonset.yaml

+2-10
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,9 @@ spec:
1616
template:
1717
metadata:
1818
labels:
19-
{{- include "cinder-csi.nodeplugin.labels" . | nindent 8 }}
20-
{{- with .Values.csi.plugin.nodePlugin.podLabels }}
21-
{{- toYaml . | nindent 8 }}
22-
{{- end }}
19+
{{- include "cinder-csi.nodeplugin.podLabels" . | nindent 8 }}
2320
annotations:
24-
{{- with .Values.commonAnnotations }}
25-
{{- toYaml . | nindent 8 }}
26-
{{- end }}
27-
{{- with .Values.csi.plugin.nodePlugin.podAnnotations }}
28-
{{- toYaml . | nindent 8 }}
29-
{{- end }}
21+
{{- include "cinder-csi.nodeplugin.podAnnotations" . | nindent 8 }}
3022
spec:
3123
serviceAccount: csi-cinder-node-sa
3224
hostNetwork: true

0 commit comments

Comments
 (0)