@@ -47,7 +47,7 @@ function check_variables_uniq() {
47
47
local allow_value_duplicity=" ${3:= false} "
48
48
local is_params_env=" ${4:= false} "
49
49
local ret_code=0
50
-
50
+
51
51
52
52
echo " Checking that all variables in the file '${env_file_path_1} ' & '${env_file_path_2} ' are unique and expected"
53
53
@@ -368,6 +368,23 @@ function check_image_commit_id_matches_metadata() {
368
368
}
369
369
}
370
370
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
+
371
388
function check_image() {
372
389
local image_variable=" ${1} "
373
390
local image_url=" ${2} "
@@ -384,19 +401,22 @@ function check_image() {
384
401
echo " Couldn't download image config metadata with skopeo tool!"
385
402
return 1
386
403
}
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' ) || {
388
405
echo " Couldn't parse '.config.Labels.name' from image metadata!"
389
406
return 1
390
407
}
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
+ }
394
414
}
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"' ) || {
396
416
echo " Couldn't parse '.config.Labels." io.openshift.build.commit.ref" ' from image metadata!"
397
417
return 1
398
418
}
399
- image_created=$( echo " ${image_metadata_config} " | jq --raw-output ' .created' ) || {
419
+ image_created=$( echo " ${image_metadata_config} " | jq --exit-status -- raw-output ' .created' ) || {
400
420
echo " Couldn't parse '.created' from image metadata!"
401
421
return 1
402
422
}
@@ -405,13 +425,15 @@ function check_image() {
405
425
local build_name_raw
406
426
local openshift_build_name
407
427
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' ) || {
409
429
echo " Couldn't parse '.config.Env' from image metadata!"
410
430
return 1
411
431
}
412
432
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"
415
437
}
416
438
openshift_build_name=$( echo " ${build_name_raw} " | sed ' s/.*"OPENSHIFT_BUILD_NAME=\(.*\)".*/\1/' ) || {
417
439
echo " Couldn't parse value of the 'OPENSHIFT_BUILD_NAME' variable from '${build_name_raw} '!"
@@ -430,7 +452,7 @@ function check_image() {
430
452
# 'tests/containers/base_image_test.py#test_image_size_change' where we check against the extracted image size.
431
453
# There is no actual reason to compare these different sizes except that in this case we want to do check the
432
454
# 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' ) || {
434
456
echo " Couldn't count image size from image metadata!"
435
457
return 1
436
458
}
@@ -453,6 +475,11 @@ function check_image() {
453
475
454
476
check_image_commit_id_matches_metadata " ${image_variable} " " ${image_commit_id} " || return 1
455
477
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
+
456
483
echo " ---------------------------------------------"
457
484
}
458
485
0 commit comments