@@ -491,6 +491,23 @@ function check_image_commit_id_matches_metadata() {
491491 }
492492}
493493
494+ function check_image_repo_name() {
495+ local image_variable=" ${1} "
496+ local image_url=" ${2} "
497+ local image_variable_filtered=" "
498+ local repository_name=" "
499+
500+ # Line record example:
501+ # odh-pipeline-runtime-tensorflow-rocm-py311-ubi9-n=quay.io/modh/odh-pipeline-runtime-tensorflow-rocm-py311-ubi9@sha256:ae1ebd1f0b3dd444b5271101a191eb16ec4cc9735c8cab7f836aae5dfe31ae89
502+ image_variable_filtered=$( echo " ${image_variable} " | sed ' s/\(.*\)-n.*/\1/' )
503+ repository_name=$( echo " ${image_url} " | sed ' s#.*/\(.*\)@.*#\1#' )
504+
505+ test " ${image_variable_filtered} " == " ${repository_name} " || {
506+ echo " The image repository name '${repository_name} ' doesn't match the filtered image variable value '${image_variable_filtered} '!"
507+ return 1
508+ }
509+ }
510+
494511function check_image() {
495512 local image_variable=" ${1} "
496513 local image_url=" ${2} "
@@ -507,19 +524,22 @@ function check_image() {
507524 echo " Couldn't download image config metadata with skopeo tool!"
508525 return 1
509526 }
510- image_name=$( echo " ${image_metadata_config} " | jq --raw-output ' .config.Labels.name' ) || {
527+ image_name=$( echo " ${image_metadata_config} " | jq --exit-status -- raw-output ' .config.Labels.name' ) || {
511528 echo " Couldn't parse '.config.Labels.name' from image metadata!"
512529 return 1
513530 }
514- image_commit_id=$( echo " ${image_metadata_config} " | jq --raw-output ' .config.Labels."io.openshift.build.commit.id"' ) || {
515- echo " Couldn't parse '.config.Labels." io.openshift.build.commit.id" ' from image metadata!"
516- return 1
531+ image_commit_id=$( echo " ${image_metadata_config} " | jq --exit-status --raw-output ' .config.Labels."io.openshift.build.commit.id"' ) || {
532+ echo " Couldn't parse '.config.Labels." io.openshift.build.commit.id" ' from image metadata, maybe this is a Konflux build?"
533+ image_commit_id=$( echo " ${image_metadata_config} " | jq --exit-status --raw-output ' .config.Labels."git.commit"' ) || {
534+ echo " Couldn't parse '.config.Labels." git.commit" ' from image metadata!"
535+ return 1
536+ }
517537 }
518- image_commitref=$( echo " ${image_metadata_config} " | jq --raw-output ' .config.Labels."io.openshift.build.commit.ref"' ) || {
538+ image_commitref=$( echo " ${image_metadata_config} " | jq --exit-status -- raw-output ' .config.Labels."io.openshift.build.commit.ref"' ) || {
519539 echo " Couldn't parse '.config.Labels." io.openshift.build.commit.ref" ' from image metadata!"
520540 return 1
521541 }
522- image_created=$( echo " ${image_metadata_config} " | jq --raw-output ' .created' ) || {
542+ image_created=$( echo " ${image_metadata_config} " | jq --exit-status -- raw-output ' .created' ) || {
523543 echo " Couldn't parse '.created' from image metadata!"
524544 return 1
525545 }
@@ -528,13 +548,15 @@ function check_image() {
528548 local build_name_raw
529549 local openshift_build_name
530550
531- config_env=$( echo " ${image_metadata_config} " | jq --raw-output ' .config.Env' ) || {
551+ config_env=$( echo " ${image_metadata_config} " | jq --exit-status -- raw-output ' .config.Env' ) || {
532552 echo " Couldn't parse '.config.Env' from image metadata!"
533553 return 1
534554 }
535555 build_name_raw=$( echo " ${config_env} " | grep ' "OPENSHIFT_BUILD_NAME=' ) || {
536- echo " Couldn't get 'OPENSHIFT_BUILD_NAME' from set of the image environment variables!"
537- return 1
556+ echo " Couldn't get 'OPENSHIFT_BUILD_NAME' from set of the image environment variables, maybe this is a Konflux build?"
557+ # Let's keep this check here until we have all images on konflux - just to keep this check for older releases.
558+ # For konflux images, the name of the repository should be now good enough as a check instead of this variable.
559+ build_name_raw=" OPENSHIFT_BUILD_NAME=konflux"
538560 }
539561 openshift_build_name=$( echo " ${build_name_raw} " | sed ' s/.*"OPENSHIFT_BUILD_NAME=\(.*\)".*/\1/' ) || {
540562 echo " Couldn't parse value of the 'OPENSHIFT_BUILD_NAME' variable from '${build_name_raw} '!"
@@ -553,7 +575,7 @@ function check_image() {
553575 # 'tests/containers/base_image_test.py#test_image_size_change' where we check against the extracted image size.
554576 # There is no actual reason to compare these different sizes except that in this case we want to do check the
555577 # image remotely, whereas in the othe test, we have the image present locally on the machine.
556- image_size=$( echo " ${image_metadata} " | jq ' [ .layers[].size ] | add' ) || {
578+ image_size=$( echo " ${image_metadata} " | jq --exit-status ' [ .layers[].size ] | add' ) || {
557579 echo " Couldn't count image size from image metadata!"
558580 return 1
559581 }
@@ -576,6 +598,11 @@ function check_image() {
576598
577599 check_image_commit_id_matches_metadata " ${image_variable} " " ${image_commit_id} " || return 1
578600
601+ if test " ${openshift_build_name} " == " konflux" ; then
602+ # We presume the image is build on Konflux and as such we are using explicit repository name for each image type.
603+ check_image_repo_name " ${image_variable} " " ${image_url} " || return 1
604+ fi
605+
579606 echo " ---------------------------------------------"
580607}
581608
0 commit comments