summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc A. Paradise <marc.paradise@gmail.com>2021-04-23 11:22:45 -0400
committerMarc A. Paradise <marc.paradise@gmail.com>2021-04-23 11:22:45 -0400
commitd45e26c4212b04e1ca05f9d766f00305616ce3cb (patch)
tree118f9b7f9a12165efd8b2013c0f4ece476e7811c
parent22dc63b40744e879edf13ef40cf6362f57e7a158 (diff)
downloadchef-d45e26c4212b04e1ca05f9d766f00305616ce3cb.tar.gz
Make json-file compliance report path is visible
We were previously logging it earlier in the run, and it could get lost in backscroll. With this change, we'll log it at/near the end, at the time we write the report. Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
-rw-r--r--lib/chef/compliance/reporter/json_file.rb3
-rw-r--r--lib/chef/compliance/runner.rb1
2 files changed, 2 insertions, 2 deletions
diff --git a/lib/chef/compliance/reporter/json_file.rb b/lib/chef/compliance/reporter/json_file.rb
index ecd2e77b55..69091e3c7b 100644
--- a/lib/chef/compliance/reporter/json_file.rb
+++ b/lib/chef/compliance/reporter/json_file.rb
@@ -1,4 +1,5 @@
require_relative "../../json_compat"
+require_relative "../../log"
class Chef
module Compliance
@@ -9,8 +10,8 @@ class Chef
end
def send_report(report)
+ Chef::Log.info "Writing compliance report to #{@path}"
FileUtils.mkdir_p(File.dirname(@path), mode: 0700)
-
File.write(@path, Chef::JSONCompat.to_json(report))
end
diff --git a/lib/chef/compliance/runner.rb b/lib/chef/compliance/runner.rb
index 68b40ce35b..6bc134d08e 100644
--- a/lib/chef/compliance/runner.rb
+++ b/lib/chef/compliance/runner.rb
@@ -249,7 +249,6 @@ class Chef
when "json-file"
require_relative "reporter/json_file"
path = node.dig("audit", "json_file", "location")
- logger.info "Writing compliance report to #{path}"
Chef::Compliance::Reporter::JsonFile.new(file: path)
when "audit-enforcer"
require_relative "reporter/compliance_enforcer"