@@ -47,7 +47,7 @@ function check_variables_uniq() {
4747 local allow_value_duplicity=" ${3:= false} "
4848 local is_params_env=" ${4:= false} "
4949 local ret_code=0
50-
50+
5151
5252 echo " Checking that all variables in the file '${env_file_path_1} ' & '${env_file_path_2} ' are unique and expected"
5353
@@ -368,6 +368,23 @@ function check_image_commit_id_matches_metadata() {
368368 }
369369}
370370
371+ function check_image_repo_name() {
372+ local image_variable=" ${1} "
373+ local image_url=" ${2} "
374+ local image_variable_filtered=" "
375+ local repository_name=" "
376+
377+ # Line record example:
378+ # odh-pipeline-runtime-tensorflow-rocm-py311-ubi9-n=quay.io/modh/odh-pipeline-runtime-tensorflow-rocm-py311-ubi9@sha256:ae1ebd1f0b3dd444b5271101a191eb16ec4cc9735c8cab7f836aae5dfe31ae89
379+ image_variable_filtered=$( echo " ${image_variable} " | sed ' s/\(.*\)-n.*/\1/' )
380+ repository_name=$( echo " ${image_url} " | sed ' s#.*/\(.*\)@.*#\1#' )
381+
382+ test " ${image_variable_filtered} " == " ${repository_name} " || {
383+ echo " The image repository name '${repository_name} ' doesn't match the filtered image variable value '${image_variable_filtered} '!"
384+ return 1
385+ }
386+ }
387+
371388function check_image() {
372389 local image_variable=" ${1} "
373390 local image_url=" ${2} "
@@ -384,19 +401,22 @@ function check_image() {
384401 echo " Couldn't download image config metadata with skopeo tool!"
385402 return 1
386403 }
387- image_name=$( echo " ${image_metadata_config} " | jq --raw-output ' .config.Labels.name' ) || {
404+ image_name=$( echo " ${image_metadata_config} " | jq --exit-status -- raw-output ' .config.Labels.name' ) || {
388405 echo " Couldn't parse '.config.Labels.name' from image metadata!"
389406 return 1
390407 }
391- image_commit_id=$( echo " ${image_metadata_config} " | jq --raw-output ' .config.Labels."io.openshift.build.commit.id"' ) || {
392- echo " Couldn't parse '.config.Labels." io.openshift.build.commit.id" ' from image metadata!"
393- return 1
408+ image_commit_id=$( echo " ${image_metadata_config} " | jq --exit-status --raw-output ' .config.Labels."io.openshift.build.commit.id"' ) || {
409+ echo " Couldn't parse '.config.Labels." io.openshift.build.commit.id" ' from image metadata, maybe this is a Konflux build?"
410+ image_commit_id=$( echo " ${image_metadata_config} " | jq --exit-status --raw-output ' .config.Labels."git.commit"' ) || {
411+ echo " Couldn't parse '.config.Labels." git.commit" ' from image metadata!"
412+ return 1
413+ }
394414 }
395- image_commitref=$( echo " ${image_metadata_config} " | jq --raw-output ' .config.Labels."io.openshift.build.commit.ref"' ) || {
415+ image_commitref=$( echo " ${image_metadata_config} " | jq --exit-status -- raw-output ' .config.Labels."io.openshift.build.commit.ref"' ) || {
396416 echo " Couldn't parse '.config.Labels." io.openshift.build.commit.ref" ' from image metadata!"
397417 return 1
398418 }
399- image_created=$( echo " ${image_metadata_config} " | jq --raw-output ' .created' ) || {
419+ image_created=$( echo " ${image_metadata_config} " | jq --exit-status -- raw-output ' .created' ) || {
400420 echo " Couldn't parse '.created' from image metadata!"
401421 return 1
402422 }
@@ -405,13 +425,15 @@ function check_image() {
405425 local build_name_raw
406426 local openshift_build_name
407427
408- config_env=$( echo " ${image_metadata_config} " | jq --raw-output ' .config.Env' ) || {
428+ config_env=$( echo " ${image_metadata_config} " | jq --exit-status -- raw-output ' .config.Env' ) || {
409429 echo " Couldn't parse '.config.Env' from image metadata!"
410430 return 1
411431 }
412432 build_name_raw=$( echo " ${config_env} " | grep ' "OPENSHIFT_BUILD_NAME=' ) || {
413- echo " Couldn't get 'OPENSHIFT_BUILD_NAME' from set of the image environment variables!"
414- return 1
433+ echo " Couldn't get 'OPENSHIFT_BUILD_NAME' from set of the image environment variables, maybe this is a Konflux build?"
434+ # Let's keep this check here until we have all images on konflux - just to keep this check for older releases.
435+ # For konflux images, the name of the repository should be now good enough as a check instead of this variable.
436+ build_name_raw=" OPENSHIFT_BUILD_NAME=konflux"
415437 }
416438 openshift_build_name=$( echo " ${build_name_raw} " | sed ' s/.*"OPENSHIFT_BUILD_NAME=\(.*\)".*/\1/' ) || {
417439 echo " Couldn't parse value of the 'OPENSHIFT_BUILD_NAME' variable from '${build_name_raw} '!"
@@ -430,7 +452,7 @@ function check_image() {
430452 # 'tests/containers/base_image_test.py#test_image_size_change' where we check against the extracted image size.
431453 # There is no actual reason to compare these different sizes except that in this case we want to do check the
432454 # image remotely, whereas in the othe test, we have the image present locally on the machine.
433- image_size=$( echo " ${image_metadata} " | jq ' [ .layers[].size ] | add' ) || {
455+ image_size=$( echo " ${image_metadata} " | jq --exit-status ' [ .layers[].size ] | add' ) || {
434456 echo " Couldn't count image size from image metadata!"
435457 return 1
436458 }
@@ -453,6 +475,11 @@ function check_image() {
453475
454476 check_image_commit_id_matches_metadata " ${image_variable} " " ${image_commit_id} " || return 1
455477
478+ if test " ${openshift_build_name} " == " konflux" ; then
479+ # We presume the image is build on Konflux and as such we are using explicit repository name for each image type.
480+ check_image_repo_name " ${image_variable} " " ${image_url} " || return 1
481+ fi
482+
456483 echo " ---------------------------------------------"
457484}
458485
0 commit comments