Sha256: 20f4b85e9dd80da7f1f08c8f4d82cb3e2c25804491de96a620788f4b965883cd

Contents?: true

Size: 1 KB

Versions: 32

Compression:

Stored size: 1 KB

Contents

# frozen_string_literal: true

require_relative '../../../puppet/node'
require_relative '../../../puppet/indirector/rest'

class Puppet::Node::Rest < Puppet::Indirector::REST
  desc "Get a node via REST. Puppet agent uses this to allow the puppet master
    to override its environment."

  def find(request)
    session = Puppet.lookup(:http_session)
    api = session.route_to(:puppet)
    _, node = api.get_node(
      request.key,
      environment: request.environment.to_s,
      configured_environment: request.options[:configured_environment],
      transaction_uuid: request.options[:transaction_uuid]
    )
    node
  rescue Puppet::HTTP::ResponseError => e
    if e.response.code == 404
      return nil unless request.options[:fail_on_404]

      _, body = parse_response(e.response)
      msg = _("Find %{uri} resulted in 404 with the message: %{body}") % { uri: elide(e.response.url.path, 100), body: body }
      raise Puppet::Error, msg
    else
      raise convert_to_http_error(e.response)
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

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