Skip to content

Commit a2d91e6

Browse files
Merge pull request #1013 from jstourac/fixRuntimeImageCheck
RHOAIENG-20241: fix the CI check for the runtime image definition
2 parents dfc2bf7 + 35d6e9d commit a2d91e6

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

.github/workflows/params-env.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on: # yamllint disable-line rule:truthy
88
- 'manifests/base/params.env'
99
- 'ci/check-params-env.sh'
1010
- 'ci/check-runtime-images.sh'
11+
- 'manifests/base/runtime-*-imagestream.yaml'
1112
workflow_dispatch:
1213

1314
permissions:

ci/check-runtime-images.sh

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,24 +88,43 @@ function check_image() {
8888
echo "---------------------------------------------"
8989
echo "Checking file: '${runtime_image_file}'"
9090

91+
local runtime_image_metadata
9192
local img_tag
9293
local img_url
9394
local img_metadata_config
9495
local img_created
9596
local img_commit_ref
9697
local img_name
9798

98-
img_tag=$(jq -r '.metadata.tags[0]' "${runtime_image_file}") || {
99+
runtime_image_metadata=$(yq -r '.spec.tags[0].annotations."opendatahub.io/runtime-image-metadata"' "${runtime_image_file}") || {
100+
echo "ERROR: Couldn't parse runtime image metadata for '${runtime_image_file}' file!"
101+
return 1
102+
}
103+
echo "Runtime image metadata: '${runtime_image_metadata}'"
104+
105+
# There are 2 places in the current runtime imagestreams where the image url is saved today.
106+
img_url_from=$(yq -r '.spec.tags[0].from.name' "${runtime_image_file}") || {
107+
echo "ERROR: Couldn't parse image URL from '.spec.tags[0].from.name' field for '${runtime_image_file}' file!"
108+
return 1
109+
}
110+
echo "Image URL from '.spec.tags[0].from.name' field: '${img_url_from}'"
111+
112+
img_tag=$(echo "${runtime_image_metadata}" | jq -r '.[0].metadata.tags[0]') || {
99113
echo "ERROR: Couldn't parse image tags metadata for '${runtime_image_file}' runtime image file!"
100114
return 1
101115
}
102116
echo "Image tag: '${img_tag}'"
103117

104-
img_url=$(jq -r '.metadata.image_name' "${runtime_image_file}") || {
105-
echo "ERROR: Couldn't parse image URL metadata for '${runtime_image_file}' runtime image file!"
118+
img_url=$(echo "${runtime_image_metadata}" | jq -r '.[0].metadata.image_name') || {
119+
echo "ERROR: Couldn't parse image URL from image JSON metadata for '${runtime_image_file}' runtime image file!"
120+
return 1
121+
}
122+
echo "Image URL from JSON metadata: '${img_url}'"
123+
124+
test "${img_url_from}" == "${img_url}" || {
125+
echo "ERROR: The image URL in '.spec.tags[0].from.name' doesn't match what is provide in JSON metadata in '${runtime_image_file}' runtime image file!"
106126
return 1
107127
}
108-
echo "Image URL: '${img_url}'"
109128

110129
img_metadata_config="$(skopeo inspect --retry-times "${SKOPEO_RETRY}" --config "docker://${img_url}")" || {
111130
echo "ERROR: Couldn't download '${img_url}' image config metadata with skopeo tool!"
@@ -175,8 +194,7 @@ function check_image() {
175194
function main() {
176195
ret_code=0
177196

178-
# If name of the directory isn't good enough, maybe we can improve this to search for the: `"schema_name": "runtime-image"` string.
179-
runtime_image_files=$(find . -name "*.json" | grep "runtime-images" | sort --unique)
197+
runtime_image_files=$(find . -name "*imagestream.yaml" | grep "runtime" | sort --unique)
180198

181199
IFS=$'\n'
182200
for file in ${runtime_image_files}; do

0 commit comments

Comments
 (0)