Skip to content
This repository was archived by the owner on Apr 17, 2025. It is now read-only.

Commit a445d7b

Browse files
committed
Add pod annotations and labels to update-helm.sh
1 parent ff05f32 commit a445d7b

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

hack/helm_patches/update-helm.sh

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,27 @@ cat <<'EOF'
7676
EOF
7777
)
7878

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+
7995
# Update templates
8096
for output_file in ${TEMPLATESDIR}/*.yaml; do
8197
# Add prefix placeholder to Resource Name
8298
if [ "$($YQ '.metadata | has("name")' $output_file)" = "true" ]; then
83-
99+
84100
resourcename=$($YQ -N '.metadata.name' $output_file | sed s/hnc-//g) $YQ -N -i '.metadata.name |= "{{ include \"hnc.fullname\" . }}-" + strenv(resourcename)' $output_file
85101

86102
# Add prefix placeholder to Service Name of WebhookConfiguration
@@ -148,6 +164,12 @@ for output_file in ${TEMPLATESDIR}/*.yaml; do
148164
sed -i -e 's/tolerations:/\{{- with .Values.manager.tolerations }}\n \ tolerations:/' $output_file
149165
sed -i -e '/tolerations:/a \ {{- end }}' $output_file
150166

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+
151173
# [HA] Additional update for controller-manager-ha Deployment
152174
elif [ "$($YQ '.metadata.name | (. == "*-controller-manager-ha")' $output_file)" = "true" ]; then
153175

@@ -167,6 +189,12 @@ for output_file in ${TEMPLATESDIR}/*.yaml; do
167189
sed -i -e 's/tolerations:/\{{- with .Values.ha.manager.tolerations }}\n \ tolerations:/' $output_file
168190
sed -i -e '/tolerations:/a \ {{- end }}' $output_file
169191

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+
170198
# [HA] Add conditional blocks for controller-manager-ha Deployment
171199
sed -i -e '1s/^/{{- if .Values.ha.enabled }}\n/g' $output_file
172200
sed -i -e '$s/$/\n{{- end }}/g' $output_file
@@ -184,7 +212,7 @@ for output_file in ${TEMPLATESDIR}/*.yaml; do
184212
sed -i -e '/imagePullPolicy:/a \ {{- end }}' $output_file
185213

186214
# Remove extra '' from templates
187-
sed -i -e s/\'//g $output_file
215+
sed -i -e s/\'//g $output_file
188216

189217
# Update RoleBinding template
190218
elif [ "$($YQ '.kind | (. == "RoleBinding")' $output_file)" = "true" ]; then
@@ -214,4 +242,4 @@ for output_file in ${TEMPLATESDIR}/*.yaml; do
214242
echo "$HRQWEBHOOK" >> "$output_file"
215243
fi
216244

217-
done
245+
done

0 commit comments

Comments
 (0)