class Chef::Compliance::Reporter::JsonFile

Public Class Methods

new(opts) click to toggle source
# File lib/chef/compliance/reporter/json_file.rb, line 8
def initialize(opts)
  @path = opts.fetch(:file)
end

Public Instance Methods

send_report(report) click to toggle source
# File lib/chef/compliance/reporter/json_file.rb, line 12
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
validate_config!() click to toggle source
# File lib/chef/compliance/reporter/json_file.rb, line 18
def validate_config!
  if @path.nil? || @path.class != String || @path.empty?
    raise "CMPL009: json_file reporter: node['audit']['json_file']['location'] must contain a file path"
  end
end