@@ -76,11 +76,27 @@ cat <<'EOF'
76
76
EOF
77
77
)
78
78
79
+ POD_ANNOTATIONS=$(
80
+ cat << 'EOF '
81
+ {{- with .Values.podAnnotations }}
82
+ {{- toYaml . | nindent 8}}
83
+ {{- end }}
84
+ EOF
85
+ )
86
+
87
+ POD_LABELS=$(
88
+ cat << 'EOF '
89
+ {{- with .Values.podLabels }}
90
+ {{- toYaml . | nindent 8}}
91
+ {{- end }}
92
+ EOF
93
+ )
94
+
79
95
# Update templates
80
96
for output_file in ${TEMPLATESDIR} /* .yaml; do
81
97
# Add prefix placeholder to Resource Name
82
98
if [ " $( $YQ ' .metadata | has("name")' $output_file ) " = " true" ]; then
83
-
99
+
84
100
resourcename=$( $YQ -N ' .metadata.name' $output_file | sed s/hnc-//g) $YQ -N -i ' .metadata.name |= "{{ include \"hnc.fullname\" . }}-" + strenv(resourcename)' $output_file
85
101
86
102
# Add prefix placeholder to Service Name of WebhookConfiguration
@@ -148,6 +164,12 @@ for output_file in ${TEMPLATESDIR}/*.yaml; do
148
164
sed -i -e ' s/tolerations:/\{{- with .Values.manager.tolerations }}\n \ tolerations:/' $output_file
149
165
sed -i -e ' /tolerations:/a \ {{- end }}' $output_file
150
166
167
+ # Add scope block for podLabels
168
+ awk -i inplace -v pl=" $POD_LABELS " ' BEGIN{found=0} /labels:/ {count++} (count==2 && found==0) {print $0 "\n" pl; found=1; next} 1' $output_file
169
+
170
+ # Add scope block for podAnnotations
171
+ awk -i inplace -v pa=" $POD_ANNOTATIONS " ' BEGIN{found=0} /annotations:/ {count++} (count==1 && found==0) {print $0 "\n" pa; found=1; next} 1' $output_file
172
+
151
173
# [HA] Additional update for controller-manager-ha Deployment
152
174
elif [ " $( $YQ ' .metadata.name | (. == "*-controller-manager-ha")' $output_file ) " = " true" ]; then
153
175
@@ -167,6 +189,12 @@ for output_file in ${TEMPLATESDIR}/*.yaml; do
167
189
sed -i -e ' s/tolerations:/\{{- with .Values.ha.manager.tolerations }}\n \ tolerations:/' $output_file
168
190
sed -i -e ' /tolerations:/a \ {{- end }}' $output_file
169
191
192
+ # [HA] Add scope block for podLabels
193
+ awk -i inplace -v pl=" $POD_LABELS " ' BEGIN{found=0} /labels:/ {count++} (count==2 && found==0) {print $0 "\n" pl; found=1; next} 1' $output_file
194
+
195
+ # [HA] Add scope block for podAnnotations
196
+ awk -i inplace -v pa=" $POD_ANNOTATIONS " ' BEGIN{found=0} /annotations:/ {count++} (count==1 && found==0) {print $0 "\n" pa; found=1; next} 1' $output_file
197
+
170
198
# [HA] Add conditional blocks for controller-manager-ha Deployment
171
199
sed -i -e ' 1s/^/{{- if .Values.ha.enabled }}\n/g' $output_file
172
200
sed -i -e ' $s/$/\n{{- end }}/g' $output_file
@@ -184,7 +212,7 @@ for output_file in ${TEMPLATESDIR}/*.yaml; do
184
212
sed -i -e ' /imagePullPolicy:/a \ {{- end }}' $output_file
185
213
186
214
# Remove extra '' from templates
187
- sed -i -e s/\' //g $output_file
215
+ sed -i -e s/\' //g $output_file
188
216
189
217
# Update RoleBinding template
190
218
elif [ " $( $YQ ' .kind | (. == "RoleBinding")' $output_file ) " = " true" ]; then
@@ -214,4 +242,4 @@ for output_file in ${TEMPLATESDIR}/*.yaml; do
214
242
echo " $HRQWEBHOOK " >> " $output_file "
215
243
fi
216
244
217
- done
245
+ done
0 commit comments