Sha256: fe665f79a1988f6b69f14dc1f6696e1acd304975c9b95d91f53f7c6e64dac304

Contents?: true

Size: 1.06 KB

Versions: 20

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

require_relative '../../../puppet/transaction/report'
require_relative '../../../puppet/indirector/json'

class Puppet::Transaction::Report::Json < Puppet::Indirector::JSON
  include Puppet::Util::SymbolicFileMode

  desc "Store last report as a flat file, serialized using JSON."

  # Force report to be saved there
  def path(name, ext = '.json')
    Puppet[:lastrunreport]
  end

  def save(request)
    filename = path(request.key)
    mode = Puppet.settings.setting(:lastrunreport).mode

    unless valid_symbolic_mode?(mode)
      raise Puppet::DevError, _("replace_file mode: %{mode} is invalid") % { mode: mode }
    end

    mode = symbolic_mode_to_int(normalize_symbolic_mode(mode))

    FileUtils.mkdir_p(File.dirname(filename))

    begin
      Puppet::FileSystem.replace_file(filename, mode) do |fh|
        fh.print JSON.dump(request.instance)
      end
    rescue TypeError => detail
      Puppet.err _("Could not save %{indirection} %{request}: %{detail}") % { indirection: name, request: request.key, detail: detail }
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
puppet-8.10.0 lib/puppet/indirector/report/json.rb
puppet-8.10.0-x86-mingw32 lib/puppet/indirector/report/json.rb
puppet-8.10.0-x64-mingw32 lib/puppet/indirector/report/json.rb
puppet-8.10.0-universal-darwin lib/puppet/indirector/report/json.rb
puppet-8.9.0 lib/puppet/indirector/report/json.rb
puppet-8.9.0-x86-mingw32 lib/puppet/indirector/report/json.rb
puppet-8.9.0-x64-mingw32 lib/puppet/indirector/report/json.rb
puppet-8.9.0-universal-darwin lib/puppet/indirector/report/json.rb
puppet-8.8.1 lib/puppet/indirector/report/json.rb
puppet-8.8.1-x86-mingw32 lib/puppet/indirector/report/json.rb
puppet-8.8.1-x64-mingw32 lib/puppet/indirector/report/json.rb
puppet-8.8.1-universal-darwin lib/puppet/indirector/report/json.rb
puppet-8.7.0 lib/puppet/indirector/report/json.rb
puppet-8.7.0-x86-mingw32 lib/puppet/indirector/report/json.rb
puppet-8.7.0-x64-mingw32 lib/puppet/indirector/report/json.rb
puppet-8.7.0-universal-darwin lib/puppet/indirector/report/json.rb
puppet-8.6.0 lib/puppet/indirector/report/json.rb
puppet-8.6.0-x86-mingw32 lib/puppet/indirector/report/json.rb
puppet-8.6.0-x64-mingw32 lib/puppet/indirector/report/json.rb
puppet-8.6.0-universal-darwin lib/puppet/indirector/report/json.rb