Skip to content

Commit 01f4e64

Browse files
committed
NO-JIRA: feat(ci/check-json.sh): ask yq to output each result into a separate file, in case json strings are multiline
1 parent 001104d commit 01f4e64

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

ci/check-json.sh

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,17 @@ function check_json() {
3434
echo "Checking: '${f}' - for '${string}':"
3535

3636
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
4548
else
4649
echo " Ignoring as this file doesn't contain necessary key field '${string}' for check"
4750
fi

0 commit comments

Comments
 (0)