Skip to content
This repository was archived by the owner on Jul 6, 2021. It is now read-only.

Put nodes json into top of reports #99

Merged
merged 2 commits into from
Nov 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Artifacts directories and reports
artifacts/
reports/

15 changes: 13 additions & 2 deletions check
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,10 @@ generate_report_json() {
# save function's input as a temporary file
echo "$input_json" > "$tmp_input_json_fname"

# use template or existing file
# final report file name
local json_output_fname="${JSON_REPORT_DIR}/${check_id}_${check_name}.json"

# use template or existing file
if [[ -f "$json_output_fname" ]]; then
local json_input_fname="${json_output_fname}"
else
Expand All @@ -496,14 +498,22 @@ generate_report_json() {
mv "${tmp_output_json_fname}" "${json_output_fname}"
rm "$tmp_input_json_fname"

# extend check with actual 'nodes.json'
# extend check for current host with actual 'nodes.json' inside a json report
tmp_output_json_fname=$(mktemp "${JSON_REPORT_DIR}"/${check_id}_${check_name}_tmp_ex_XXXXXX)
jq --argfile nodes_json "${PROJECT_DIR}/nodes.json" \
'.results.'"${NATIVE_HOSTNAME}"'."nodes.json" = $nodes_json' \
"${json_output_fname}" \
> "$tmp_output_json_fname"
mv "$tmp_output_json_fname" "${json_output_fname}"

# update json report by attaching 'nodes.json' into top of the report
tmp_output_json_fname=$(mktemp "${JSON_REPORT_DIR}"/${check_id}_${check_name}_tmp_ex_XXXXXX)
jq --argfile nodes_json "${PROJECT_DIR}/nodes.json" \
'.last_nodes_json = $nodes_json' \
"${json_output_fname}" \
> "$tmp_output_json_fname"
mv "$tmp_output_json_fname" "${json_output_fname}"

msg "Artifacts saved at: '${json_output_fname}'"
}

Expand Down Expand Up @@ -634,6 +644,7 @@ update_nodes_json() {
exit 1
fi

# finally, fill nodes.json file
local result_fname="${PROJECT_DIR}/nodes.json"
local result_fname_tmp=$(mktemp "${PROJECT_DIR}"/nodes.json.tmp_XXXXXX)
jq --arg NativeHostname "${NATIVE_HOSTNAME}" \
Expand Down
Empty file added reports/.gitkeep
Empty file.
1 change: 1 addition & 0 deletions resources/templates/report.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"checkId": null,
"timestamptz": null,
"dependencies": {"null": "null"},
"last_nodes_json": null,
"results": {
}
}