Sha256: 3d181193f9de030fd25dceba1372a36e9cdd10134fcd9608a84a3976c9c73263

Contents?: true

Size: 711 Bytes

Versions: 65

Compression:

Stored size: 711 Bytes

Contents

require_relative "../../json_compat"
require_relative "../../log"

class Chef
  module Compliance
    module Reporter
      class JsonFile
        def initialize(opts)
          @path = opts.fetch(:file)
        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

        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
      end
    end
  end
end

Version data entries

65 entries across 65 versions & 1 rubygems

Version Path
chef-18.6.2-universal-mingw-ucrt lib/chef/compliance/reporter/json_file.rb
chef-18.6.2 lib/chef/compliance/reporter/json_file.rb
chef-17.10.163-universal-mingw32 lib/chef/compliance/reporter/json_file.rb
chef-17.10.163 lib/chef/compliance/reporter/json_file.rb
chef-18.5.0-x64-mingw-ucrt lib/chef/compliance/reporter/json_file.rb
chef-18.5.0 lib/chef/compliance/reporter/json_file.rb
chef-18.4.12-x64-mingw-ucrt lib/chef/compliance/reporter/json_file.rb
chef-18.4.12 lib/chef/compliance/reporter/json_file.rb
chef-17.10.122-universal-mingw32 lib/chef/compliance/reporter/json_file.rb
chef-17.10.122 lib/chef/compliance/reporter/json_file.rb
chef-17.10.114-universal-mingw32 lib/chef/compliance/reporter/json_file.rb
chef-17.10.114 lib/chef/compliance/reporter/json_file.rb
chef-18.4.2-x64-mingw-ucrt lib/chef/compliance/reporter/json_file.rb
chef-18.4.2 lib/chef/compliance/reporter/json_file.rb
chef-17.10.95-universal-mingw32 lib/chef/compliance/reporter/json_file.rb
chef-17.10.95 lib/chef/compliance/reporter/json_file.rb
chef-18.3.0-x64-mingw-ucrt lib/chef/compliance/reporter/json_file.rb
chef-18.3.0 lib/chef/compliance/reporter/json_file.rb
chef-17.10.68-universal-mingw32 lib/chef/compliance/reporter/json_file.rb
chef-18.2.7-x64-mingw-ucrt lib/chef/compliance/reporter/json_file.rb