Sha256: 85fee220c95c5638c99b68831b936f697c7700e3381466d7ccc688ee936c7829

Contents?: true

Size: 1.41 KB

Versions: 76

Compression:

Stored size: 1.41 KB

Contents

require_relative '../../../puppet/resource/catalog'
require_relative '../../../puppet/indirector/rest'

class Puppet::Resource::Catalog::Rest < Puppet::Indirector::REST
  desc "Find resource catalogs over HTTP via REST."

  def find(request)
    checksum_type = if request.options[:checksum_type]
                      request.options[:checksum_type].split('.')
                    else
                      Puppet[:supported_checksum_types]
                    end

    session = Puppet.lookup(:http_session)
    api = session.route_to(:puppet)
    _, catalog = api.post_catalog(
      request.key,
      facts: request.options[:facts_for_catalog],
      environment: request.environment.to_s,
      configured_environment: request.options[:configured_environment],
      check_environment: request.options[:check_environment],
      transaction_uuid: request.options[:transaction_uuid],
      job_uuid: request.options[:job_id],
      static_catalog: request.options[:static_catalog],
      checksum_type: checksum_type
    )
    catalog
  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

76 entries across 76 versions & 1 rubygems

Version Path
puppet-7.27.0 lib/puppet/indirector/catalog/rest.rb
puppet-7.27.0-x86-mingw32 lib/puppet/indirector/catalog/rest.rb
puppet-7.27.0-x64-mingw32 lib/puppet/indirector/catalog/rest.rb
puppet-7.27.0-universal-darwin lib/puppet/indirector/catalog/rest.rb
puppet-7.26.0 lib/puppet/indirector/catalog/rest.rb
puppet-7.26.0-x86-mingw32 lib/puppet/indirector/catalog/rest.rb
puppet-7.26.0-x64-mingw32 lib/puppet/indirector/catalog/rest.rb
puppet-7.26.0-universal-darwin lib/puppet/indirector/catalog/rest.rb
puppet-7.25.0 lib/puppet/indirector/catalog/rest.rb
puppet-7.25.0-x86-mingw32 lib/puppet/indirector/catalog/rest.rb
puppet-7.25.0-x64-mingw32 lib/puppet/indirector/catalog/rest.rb
puppet-7.25.0-universal-darwin lib/puppet/indirector/catalog/rest.rb
puppet-7.24.0 lib/puppet/indirector/catalog/rest.rb
puppet-7.24.0-x86-mingw32 lib/puppet/indirector/catalog/rest.rb
puppet-7.24.0-x64-mingw32 lib/puppet/indirector/catalog/rest.rb
puppet-7.24.0-universal-darwin lib/puppet/indirector/catalog/rest.rb
puppet-7.23.0 lib/puppet/indirector/catalog/rest.rb
puppet-7.23.0-x86-mingw32 lib/puppet/indirector/catalog/rest.rb
puppet-7.23.0-x64-mingw32 lib/puppet/indirector/catalog/rest.rb
puppet-7.23.0-universal-darwin lib/puppet/indirector/catalog/rest.rb