File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -34,14 +34,17 @@ function check_json() {
34
34
echo " Checking: '${f} ' - for '${string} ':"
35
35
36
36
if grep --quiet --extended-regexp " ${string} " " ${f} " ; then
37
- # if $(grep -e "${string}" "${f}"); then
38
- jsons=$( yq -r " .spec.tags[].annotations.\" ${string} \" " " ${f} " )
39
-
40
- while IFS= read -r json; do
41
- echo " ${json} "
42
- echo -n " > " ; echo " ${json} " | json_verify || ret_code=" ${?} "
43
- done <<< " ${jsons}"
44
- tmp_dir=$( mktemp --directory -t=check-jsons-in-file-)
37
+ local tmp_dir
38
+ tmp_dir=$( mktemp --directory -t check-jsons-in-file-XXXXXXXXXX-)
39
+ if ! (cd " ${tmp_dir} " ; yq --split-exp " \$ index" --unwrapScalar " .spec.tags[].annotations.\" ${string} \" " " ${f} " ); then
40
+ echo " yq failed to run"
41
+ return 1
42
+ fi
43
+
44
+ for json in " ${tmp_dir} " /* .yml; do
45
+ echo " " ; cat " ${json} "
46
+ echo -n " > " ; json_verify < " ${json} " || ret_code=" ${?} "
47
+ done
45
48
else
46
49
echo " Ignoring as this file doesn't contain necessary key field '${string} ' for check"
47
50
fi
You can’t perform that action at this time.
0 commit comments