From 2dcf0bfb4248875529c7d4019de3875c8ced17bd Mon Sep 17 00:00:00 2001 From: Victor Yagofarov Date: Thu, 29 Nov 2018 16:57:05 +0300 Subject: [PATCH 1/2] fix changes before switch branch --- .gitignore | 5 +++++ reports/.gitkeep | 0 2 files changed, 5 insertions(+) create mode 100644 reports/.gitkeep diff --git a/.gitignore b/.gitignore index f1c181e..f51f67e 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,8 @@ # Output of the go coverage tool, specifically when used with LiteIDE *.out + +# Artifacts directories and reports +artifacts/ +reports/ + diff --git a/reports/.gitkeep b/reports/.gitkeep new file mode 100644 index 0000000..e69de29 From 13fbc815918eab87abf61f5745c3e81bc8c0b184 Mon Sep 17 00:00:00 2001 From: Victor Yagofarov Date: Thu, 29 Nov 2018 17:42:39 +0300 Subject: [PATCH 2/2] #98 Integrate last nodes.json into a top of each report --- check | 15 +++++++++++++-- resources/templates/report.json | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/check b/check index 9e0a90c..e1ab972 100755 --- a/check +++ b/check @@ -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 @@ -496,7 +498,7 @@ 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' \ @@ -504,6 +506,14 @@ generate_report_json() { > "$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}'" } @@ -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}" \ diff --git a/resources/templates/report.json b/resources/templates/report.json index fbf5ecf..78ed030 100644 --- a/resources/templates/report.json +++ b/resources/templates/report.json @@ -4,6 +4,7 @@ "checkId": null, "timestamptz": null, "dependencies": {"null": "null"}, + "last_nodes_json": null, "results": { } }