Skip to content

Commit 0265fd9

Browse files
committed
Update rebase_rhoai.sh to match conventions
1 parent 71e2933 commit 0265fd9

File tree

2 files changed

+84
-6
lines changed

2 files changed

+84
-6
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash -x
2+
./scripts/auto-rebase/rebase_rhoai.sh to "registry.redhat.io/rhoai/odh-operator-bundle:v2.16.0"

scripts/auto-rebase/rebase_rhoai.sh

Lines changed: 82 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,18 @@ PULL_SECRET_FILE="${HOME}/.pull-secret.json"
2121

2222
RELEASE_JSON="${REPOROOT}/assets/optional/rhoai/release-x86_64.json"
2323

24+
KEEP_STAGING="${KEEP_STAGING:-false}"
25+
2426
title() {
2527
echo -e "\E[34m$1\E[00m";
2628
}
2729

2830
check_preconditions() {
31+
if [[ "${REPOROOT}" != "$(pwd)" ]]; then
32+
echo "Script must be executed from root of the MicroShift repository"
33+
exit 1
34+
fi
35+
2936
if ! hash yq; then
3037
title "Installing yq"
3138

@@ -83,7 +90,7 @@ get_auth() {
8390
download_rhoai_manifests() {
8491
local -r bundle_ref="${1}"
8592

86-
# Jan 2025: Only x86_64 is supported (https://access.redhat.com/articles/rhoai-supported-configs)
93+
# Jan/Feb 2025: Only x86_64 is supported (https://access.redhat.com/articles/rhoai-supported-configs)
8794
# therefore there's no loop over architectures.
8895

8996
rm -rf "${STAGING_RHOAI}" && mkdir -p "${STAGING_BUNDLE}" "${STAGING_OPERATOR}"
@@ -110,7 +117,7 @@ process_rhoai_manifests() {
110117
"${REPOROOT}/scripts/auto-rebase/handle_assets.py" ./scripts/auto-rebase/assets_rhoai.yaml
111118

112119
title "Initializing release.json file"
113-
local -r version=$(yq '.spec.version' "${STAGING_BUNDLE}/${CSV_FILENAME}")
120+
local -r version=$(get_rhoai_bundle_version)
114121
echo "{ \"release\": {\"base\": \"${version}\"}, \"images\": {}}" | yq -o json > "${RELEASE_JSON}"
115122

116123
update_runtimes
@@ -138,7 +145,7 @@ update_runtimes() {
138145
done
139146
done
140147

141-
title "Creating ServingRuntime images kustomization"
148+
title "Creating ClusterServingRuntimes images kustomization"
142149

143150
local -r kustomization_images="${REPOROOT}/assets/optional/rhoai/runtimes/kustomization.x86_64.yaml"
144151
cat <<EOF > "${kustomization_images}"
@@ -153,7 +160,7 @@ EOF
153160
local image_ref_repo="${image_ref%@*}"
154161
local image_ref_digest="${image_ref#*@}"
155162

156-
tee -a "${kustomization_images}" <<EOF
163+
cat <<EOF >> "${kustomization_images}"
157164
- name: ${image_name}
158165
newName: ${image_ref_repo}
159166
digest: ${image_ref_digest}
@@ -163,5 +170,74 @@ EOF
163170
done
164171
}
165172

166-
download_rhoai_manifests "registry.redhat.io/rhoai/odh-operator-bundle:v2.16.0"
167-
process_rhoai_manifests
173+
get_rhoai_bundle_version() {
174+
yq '.spec.version' "${STAGING_BUNDLE}/${CSV_FILENAME}"
175+
}
176+
177+
update_last_rebase_rhoai_sh() {
178+
local -r operator_bundle="${1}"
179+
180+
title "Updating last_rebase_rhoai.sh"
181+
local -r last_rebase_script="${REPOROOT}/scripts/auto-rebase/last_rebase_rhoai.sh"
182+
183+
rm -f "${last_rebase_script}"
184+
cat - >"${last_rebase_script}" <<EOF
185+
#!/bin/bash -x
186+
./scripts/auto-rebase/rebase_rhoai.sh to "${operator_bundle}"
187+
EOF
188+
chmod +x "${last_rebase_script}"
189+
}
190+
191+
rebase_model_serving_to() {
192+
local -r operator_bundle="${1}"
193+
194+
title "Rebasing RHOAI Model Serving for MicroShift to ${operator_bundle}"
195+
196+
download_rhoai_manifests "${operator_bundle}"
197+
local -r version=$(get_rhoai_bundle_version)
198+
199+
update_last_rebase_rhoai_sh "${operator_bundle}"
200+
201+
process_rhoai_manifests
202+
203+
if [[ -n "$(git status -s assets ./scripts/auto-rebase/last_rebase_rhoai.sh)" ]]; then
204+
branch="rebase-rhoai-${version}"
205+
title "Detected changes to assets/ or last_rebase_rhoai.sh - creating branch ${branch}"
206+
git branch -D "${branch}" 2>/dev/null || true && git checkout -b "${branch}"
207+
208+
title "Committing changes"
209+
git add assets ./scripts/auto-rebase/last_rebase_rhoai.sh
210+
git commit -m "Update RHOAI"
211+
else
212+
title "No changes to assets/ or last_rebase_rhoai.sh"
213+
fi
214+
215+
if ! "${KEEP_STAGING}"; then
216+
title "Removing staging directory"
217+
rm -rf "${STAGING_RHOAI}"
218+
fi
219+
}
220+
221+
usage() {
222+
echo "Usage:"
223+
echo "$(basename "$0") to RHOAI_OPERATOR_BUNDLE Performs all the steps to rebase RHOAI Model Serving for MicroShift"
224+
echo "$(basename "$0") download RHOAI_OPERATOR_BUNDLE Downloads the contents of the RHOAI Operator (Bundle) to disk in preparation for rebasing"
225+
echo "$(basename "$0") process Process already downloaded RHOAI Operator (Bundle) artifacts to update RHOAI Model Serving for MicroShift"
226+
exit 1
227+
}
228+
229+
check_preconditions
230+
231+
command=${1:-help}
232+
case "${command}" in
233+
to)
234+
rebase_model_serving_to "$2"
235+
;;
236+
download)
237+
download_rhoai_manifests "$2"
238+
;;
239+
process)
240+
process_rhoai_manifests
241+
;;
242+
*) usage;;
243+
esac

0 commit comments

Comments
 (0)