@@ -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
@@ -282,13 +304,13 @@ ret_code=0
282
304
echo " Starting check of image references in files: '${COMMIT_ENV_PATH} ' and '${PARAMS_ENV_PATH} '"
283
305
echo " ---------------------------------------------"
284
306
285
- check_variables_uniq " ${COMMIT_ENV_PATH} " || {
307
+ check_variables_uniq " ${COMMIT_ENV_PATH} " " true " || {
286
308
echo " ERROR: Variable names in the '${COMMIT_ENV_PATH} ' file failed validation!"
287
309
echo " ----------------------------------------------------"
288
310
ret_code=1
289
311
}
290
312
291
- check_variables_uniq " ${PARAMS_ENV_PATH} " || {
313
+ check_variables_uniq " ${PARAMS_ENV_PATH} " " false " || {
292
314
echo " ERROR: Variable names in the '${PARAMS_ENV_PATH} ' file failed validation!"
293
315
echo " ----------------------------------------------------"
294
316
ret_code=1
0 commit comments