@@ -108,46 +108,56 @@ download_cert_manager(){
108
108
# convert from cert-manager-operator.v1.16.0 to cert-manager-x.y
109
109
branch_name=$( echo ${operator} | awk -F' [^0-9]*' ' {print "cert-manager-"$2"."$3}' )
110
110
clone_repo " https://github.com/openshift/cert-manager-operator" " $branch_name " " ."
111
+ popd
111
112
112
113
}
113
114
114
- # Updates the image digests in pkg/release/release*.go
115
- # update_images() {
116
- # if [ ! -f "${STAGING_DIR}/release_amd64.json" ] || [ ! -f "${STAGING_DIR}/release_arm64.json" ]; then
117
- # >&2 echo "No release found in ${STAGING_DIR}, you need to download one first."
118
- # exit 1
119
- # fi
120
- # pushd "${STAGING_DIR}" >/dev/null
121
-
122
-
123
- # }
124
-
125
-
115
+ # helper to append an image mapping to kustomization.yaml, supporting digest or tag
116
+ add_image_to_kustomize () {
117
+ local alias_name=" $1 "
118
+ local full_image_ref=" $2 "
119
+ if [[ " ${full_image_ref} " == * @sha256:* ]]; then
120
+ local image_name_no_digest=" ${full_image_ref%@* } "
121
+ local image_digest=" ${full_image_ref#*@ } "
122
+ yq -i " .images += [{\" name\" : \" ${alias_name} \" , \" newName\" : \" ${image_name_no_digest} \" , \" digest\" : \" ${image_digest} \" }]" " ${cert_manager_kustomization_yaml} "
123
+ else
124
+ local image_name_no_tag=" ${full_image_ref%:* } "
125
+ local image_tag=" ${full_image_ref##*: } "
126
+ yq -i " .images += [{\" name\" : \" ${alias_name} \" , \" newName\" : \" ${image_name_no_tag} \" , \" newTag\" : \" ${image_tag} \" }]" " ${cert_manager_kustomization_yaml} "
127
+ fi
128
+ }
126
129
127
130
write_cert_manager_images_for_arch () {
128
131
local arch=" $1 "
129
132
title " Updating images for ${arch} "
130
- # local csv_manifest="${arch_dir}/servicemeshoperator3.clusterserviceversion.yaml"
131
- # local kustomization_arch_file="${REPOROOT}/assets/optional/gateway-api/kustomization.${GOARCH_TO_UNAME_MAP[${arch}]}.yaml"
132
133
local cert_manager_release_json=" ${REPOROOT} /assets/optional/cert-manager/release-cert-manager-${GOARCH_TO_UNAME_MAP[${arch}]} .json"
133
134
local cert_manager_operator_yaml=" ${REPOROOT} /assets/optional/cert-manager/manager/manager.yaml"
134
135
local cert_manager_kustomization_yaml=" ${REPOROOT} /assets/optional/cert-manager/manager/kustomization.yaml"
135
136
136
- local base_release=4.20
137
- jq -n " {\" release\" : {\" base\" : \" ${base_release} \" }, \" images\" : {}}" > " ${cert_manager_release_json} "
137
+ local operatorVersion=$( yq ' .properties[] | select(.type == "olm.package").value.version' " ${OPERATOR_CERT_MANAGER_INDEX} " )
138
+
139
+ jq -n " {\" release\" : {\" base\" : \" ${operatorVersion} \" }, \" images\" : {}}" > " ${cert_manager_release_json} "
138
140
139
141
# containerImage
140
- local operatorImage=$( yq ' .properties[] | select(.type == "olm.csv.metadata").value.annotations.containerImage' " ${OPERATOR_CERT_MANAGER_INDEX} " )
141
-
142
- yq -i -o json " .images += {\" cert-manager-operator\" : \" ${operatorImage} \" }" " ${cert_manager_release_json} "
143
- sed -i " s#newName:.*openshift.io\/cert-manager-operator.*#newName: ${operatorImage} #g" " ${cert_manager_kustomization_yaml} "
142
+ local operatorImageFull=$( yq ' .properties[] | select(.type == "olm.csv.metadata").value.annotations.containerImage' " ${OPERATOR_CERT_MANAGER_INDEX} " )
143
+ local operatorImage=" ${operatorImageFull%:* } "
144
+ local operatorTag=" ${operatorImageFull#*: } "
145
+
146
+ yq -i -o json " .images += {\" cert-manager-operator\" : \" ${operatorImageFull} \" }" " ${cert_manager_release_json} "
147
+
148
+ # reset and rebuild the images list in kustomization.yaml from opm output
149
+ yq -i ' del(.images) | .images = []' " ${cert_manager_kustomization_yaml} "
150
+
151
+ # add operator image to kustomization images (named 'controller')
152
+ add_image_to_kustomize " controller" " ${operatorImageFull} "
144
153
145
154
# relatedImages
146
155
for index in $( yq ' .relatedImages.[] | path | .[-1] ' " ${OPERATOR_CERT_MANAGER_INDEX} " ) ; do
147
156
local image=$( yq " .relatedImages.${index} .image" " ${OPERATOR_CERT_MANAGER_INDEX} " )
148
157
local component=$( yq " .relatedImages.${index} .name" " ${OPERATOR_CERT_MANAGER_INDEX} " )
149
158
if [[ -n " ${component} " && " ${OPERATOR_COMPONENTS} " == * " ${component} " * ]]; then
150
159
yq -i -o json " .images += {\" ${component} \" : \" ${image} \" }" " ${cert_manager_release_json} "
160
+ add_image_to_kustomize " ${component} " " ${image} "
151
161
sed -i " s#value:.*${component} .*#value: ${image} #g" " ${cert_manager_operator_yaml} "
152
162
153
163
# handle special case istiocsr v istio-csr mismatch
@@ -183,34 +193,17 @@ copy_manifests() {
183
193
" $REPOROOT /scripts/auto-rebase/handle_assets.py" " ./scripts/auto-rebase/assets_cert_manager.yaml"
184
194
}
185
195
186
-
187
- # Updates embedded component manifests by gathering these from various places
188
- # in the staged repos and copying them into the asset directorcay.
189
- update_cert_manager_manifests () {
190
- pushd " ${STAGING_DIR} " > /dev/null
191
-
192
- title " Modifying OpenShift manifests"
193
-
194
- for index in $( yq ' .[] | path | .[-1] ' " ${OPERATOR_CERT_MANAGER_INDEX} " )
195
- do
196
- image=$( yq " .${index} .image" " ${OPERATOR_CERT_MANAGER_INDEX} " )
197
- component=$( yq " .${index} .name" " ${OPERATOR_CERT_MANAGER_INDEX} " )
198
-
199
- if [[ -n " ${component} " && " ${OPERATOR_COMPONENTS} " == * " ${component} " * ]]; then
200
- # clone_repo "${repo}" "${commit}" "."
201
- # echo "${repo} embedded-component ${commit}" >> "${new_commits_file}"
202
- echo " ${image} ${component} "
203
- fi
204
- done
205
-
206
-
207
- popd > /dev/null
196
+ rebase_cert_manager_to (){
197
+ local -r operator_bundle=" ${1} "
198
+ download_cert_manager " ${operator_bundle} "
199
+ copy_manifests
200
+ update_cert_manager_images
208
201
}
209
202
210
203
usage () {
211
204
echo " Usage:"
212
- echo " $( basename " $0 " ) to RELEASE_IMAGE_INTEL RELEASE_IMAGE_ARM Performs all the steps to rebase to a release image. Specify both amd64 and arm64 OCP releases ."
213
- echo " $( basename " $0 " ) download RELEASE_IMAGE_INTEL RELEASE_IMAGE_ARM Downloads the content of a release image to disk in preparation for rebasing. Specify both amd64 and arm64 OCP releases ."
205
+ echo " $( basename " $0 " ) to OPM_RELEASE_IMAGE Performs all the steps to rebase to a release image."
206
+ echo " $( basename " $0 " ) download OPM_RELEASE_IMAGE Downloads the content of a release image to disk in preparation for rebasing."
214
207
echo " $( basename " $0 " ) images Rebases the component images to the downloaded release"
215
208
echo " $( basename " $0 " ) manifests Rebases the component manifests to the downloaded release"
216
209
exit 1
@@ -221,8 +214,8 @@ check_preconditions
221
214
command=${1:- help}
222
215
case " $command " in
223
216
to)
224
- [[ $# -lt 3 ]] && usage
225
- rebase_to " $2 " " $3 "
217
+ [[ $# -lt 2 ]] && usage
218
+ rebase_cert_manager_to " $2 "
226
219
;;
227
220
download)
228
221
# [[ $# -lt 3 ]] && usage
@@ -235,7 +228,6 @@ case "$command" in
235
228
236
229
manifests)
237
230
copy_manifests
238
- update_cert_manager_manifests
239
231
;;
240
232
* ) usage;;
241
233
esac
0 commit comments