Sha256: 4e7412575c28fc0fa5175e3615621e549a8a35ddb1e7ec8667830dfbc21360d3

Contents?: true

Size: 858 Bytes

Versions: 3

Compression:

Stored size: 858 Bytes

Contents

# frozen_string_literal: true

require 'puppet/resource_api/base_context'
require 'puppet/util/logging'

# Implement Resource API Context to log through Puppet facilities
# and access/expose the puppet process' current device/transport
class Puppet::ResourceApi::PuppetContext < Puppet::ResourceApi::BaseContext
  def device
    # TODO: evaluate facter_url setting for loading config if there is no `current` NetworkDevice
    raise 'no device configured' unless Puppet::Util::NetworkDevice.current
    Puppet::Util::NetworkDevice.current
  end

  def transport
    device.transport
  end

  def log_exception(exception, message: 'Error encountered', trace: false)
    super(exception, message: message, trace: trace || Puppet[:trace])
  end

  protected

  def send_log(level, message)
    Puppet::Util::Log.create(level: level, message: message)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
puppet-resource_api-1.9.0 lib/puppet/resource_api/puppet_context.rb
puppet-resource_api-1.8.18 lib/puppet/resource_api/puppet_context.rb
puppet-resource_api-1.8.14 lib/puppet/resource_api/puppet_context.rb