Sha256: d0f9dd4875457a3d1baf1dabc3592057f95deb17b8239e221717e91a74a730b1

Contents?: true

Size: 1.37 KB

Versions: 48

Compression:

Stored size: 1.37 KB

Contents

require 'puppet/resource/catalog'
require 'puppet/indirector/rest'

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

  def find(request)
    return super unless use_http_client?

    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],
      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.nethttp)
      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.nethttp)
    end
  end
end

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
puppet-6.24.0 lib/puppet/indirector/catalog/rest.rb
puppet-6.24.0-x86-mingw32 lib/puppet/indirector/catalog/rest.rb
puppet-6.24.0-x64-mingw32 lib/puppet/indirector/catalog/rest.rb
puppet-6.24.0-universal-darwin lib/puppet/indirector/catalog/rest.rb
puppet-6.23.0 lib/puppet/indirector/catalog/rest.rb
puppet-6.23.0-x86-mingw32 lib/puppet/indirector/catalog/rest.rb
puppet-6.23.0-x64-mingw32 lib/puppet/indirector/catalog/rest.rb
puppet-6.23.0-universal-darwin lib/puppet/indirector/catalog/rest.rb
puppet-6.22.1 lib/puppet/indirector/catalog/rest.rb
puppet-6.22.1-x86-mingw32 lib/puppet/indirector/catalog/rest.rb
puppet-6.22.1-x64-mingw32 lib/puppet/indirector/catalog/rest.rb
puppet-6.22.1-universal-darwin lib/puppet/indirector/catalog/rest.rb
puppet-6.21.1 lib/puppet/indirector/catalog/rest.rb
puppet-6.21.1-x86-mingw32 lib/puppet/indirector/catalog/rest.rb
puppet-6.21.1-x64-mingw32 lib/puppet/indirector/catalog/rest.rb
puppet-6.21.1-universal-darwin lib/puppet/indirector/catalog/rest.rb
puppet-6.21.0 lib/puppet/indirector/catalog/rest.rb
puppet-6.21.0-x86-mingw32 lib/puppet/indirector/catalog/rest.rb
puppet-6.21.0-x64-mingw32 lib/puppet/indirector/catalog/rest.rb
puppet-6.21.0-universal-darwin lib/puppet/indirector/catalog/rest.rb