@@ -31,6 +31,7 @@ EXPECTED_NUM_RECORDS=20
31
31
32
32
function check_variables_uniq() {
33
33
local env_file_path=" ${1} "
34
+ local allow_value_duplicity=" ${2:= false} "
34
35
local ret_code=0
35
36
36
37
echo " Checking that all variables in the file '${env_file_path} ' are unique and expected"
@@ -45,10 +46,31 @@ function check_variables_uniq() {
45
46
num_uniq_records=$( echo " ${content} " | uniq | wc -l)
46
47
47
48
test " ${num_records} " -eq " ${num_uniq_records} " || {
48
- echo " Some of the records in the file aren't unique!"
49
+ echo " Some of the variables in the file aren't unique!"
49
50
ret_code=1
50
51
}
51
52
53
+ # ----
54
+ if test " ${allow_value_duplicity} " = " false" ; then
55
+ echo " Checking that all values assigned to variables in the file '${env_file_path} ' are unique and expected"
56
+
57
+ content=$( sed ' s#.*=\(.*\)#\1#' " ${env_file_path} " | sort)
58
+
59
+ local num_values
60
+ num_values=$( echo " ${content} " | wc -l)
61
+
62
+ local num_uniq_values
63
+ num_uniq_values=$( echo " ${content} " | uniq | wc -l)
64
+
65
+ test " ${num_values} " -eq " ${num_uniq_values} " || {
66
+ echo " Some of the values in the file aren't unique!"
67
+ ret_code=1
68
+ }
69
+ fi
70
+
71
+ # ----
72
+ echo " Checking that there are expected number of records in the file '${env_file_path} '"
73
+
52
74
test " ${num_records} " -eq " ${EXPECTED_NUM_RECORDS} " || {
53
75
echo " Number of records in the file is incorrect - expected '${EXPECTED_NUM_RECORDS} ' but got '${num_records} '!"
54
76
ret_code=1
@@ -226,6 +248,7 @@ function check_image() {
226
248
local image_name
227
249
local image_commit_id
228
250
local image_commitref
251
+ local image_created
229
252
230
253
image_metadata=" $( skopeo inspect --config " docker://${image_url} " ) " || {
231
254
echo " Couldn't download image metadata with skopeo tool!"
@@ -243,6 +266,10 @@ function check_image() {
243
266
echo " Couldn't parse '.config.Labels." io.openshift.build.commit.ref" ' from image metadata!"
244
267
return 1
245
268
}
269
+ image_created=$( echo " ${image_metadata} " | jq --raw-output ' .created' ) || {
270
+ echo " Couldn't parse '.created' from image metadata!"
271
+ return 1
272
+ }
246
273
247
274
local config_env
248
275
local build_name_raw
@@ -267,6 +294,7 @@ function check_image() {
267
294
}
268
295
269
296
echo " Image name retrieved: '${image_name} '"
297
+ echo " Image created: '${image_created} '"
270
298
271
299
check_image_variable_matches_name_and_commitref " ${image_variable} " " ${image_name} " " ${image_commitref} " " ${openshift_build_name} " || return 1
272
300
@@ -282,13 +310,13 @@ ret_code=0
282
310
echo " Starting check of image references in files: '${COMMIT_ENV_PATH} ' and '${PARAMS_ENV_PATH} '"
283
311
echo " ---------------------------------------------"
284
312
285
- check_variables_uniq " ${COMMIT_ENV_PATH} " || {
313
+ check_variables_uniq " ${COMMIT_ENV_PATH} " " true " || {
286
314
echo " ERROR: Variable names in the '${COMMIT_ENV_PATH} ' file failed validation!"
287
315
echo " ----------------------------------------------------"
288
316
ret_code=1
289
317
}
290
318
291
- check_variables_uniq " ${PARAMS_ENV_PATH} " || {
319
+ check_variables_uniq " ${PARAMS_ENV_PATH} " " false " || {
292
320
echo " ERROR: Variable names in the '${PARAMS_ENV_PATH} ' file failed validation!"
293
321
echo " ----------------------------------------------------"
294
322
ret_code=1
0 commit comments