@@ -491,6 +491,23 @@ function check_image_commit_id_matches_metadata() {
491
491
}
492
492
}
493
493
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
+
494
511
function check_image() {
495
512
local image_variable=" ${1} "
496
513
local image_url=" ${2} "
@@ -507,19 +524,22 @@ function check_image() {
507
524
echo " Couldn't download image config metadata with skopeo tool!"
508
525
return 1
509
526
}
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' ) || {
511
528
echo " Couldn't parse '.config.Labels.name' from image metadata!"
512
529
return 1
513
530
}
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
+ }
517
537
}
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"' ) || {
519
539
echo " Couldn't parse '.config.Labels." io.openshift.build.commit.ref" ' from image metadata!"
520
540
return 1
521
541
}
522
- image_created=$( echo " ${image_metadata_config} " | jq --raw-output ' .created' ) || {
542
+ image_created=$( echo " ${image_metadata_config} " | jq --exit-status -- raw-output ' .created' ) || {
523
543
echo " Couldn't parse '.created' from image metadata!"
524
544
return 1
525
545
}
@@ -528,13 +548,15 @@ function check_image() {
528
548
local build_name_raw
529
549
local openshift_build_name
530
550
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' ) || {
532
552
echo " Couldn't parse '.config.Env' from image metadata!"
533
553
return 1
534
554
}
535
555
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"
538
560
}
539
561
openshift_build_name=$( echo " ${build_name_raw} " | sed ' s/.*"OPENSHIFT_BUILD_NAME=\(.*\)".*/\1/' ) || {
540
562
echo " Couldn't parse value of the 'OPENSHIFT_BUILD_NAME' variable from '${build_name_raw} '!"
@@ -553,7 +575,7 @@ function check_image() {
553
575
# 'tests/containers/base_image_test.py#test_image_size_change' where we check against the extracted image size.
554
576
# There is no actual reason to compare these different sizes except that in this case we want to do check the
555
577
# 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' ) || {
557
579
echo " Couldn't count image size from image metadata!"
558
580
return 1
559
581
}
@@ -576,6 +598,11 @@ function check_image() {
576
598
577
599
check_image_commit_id_matches_metadata " ${image_variable} " " ${image_commit_id} " || return 1
578
600
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
+
579
606
echo " ---------------------------------------------"
580
607
}
581
608
0 commit comments