class Puppet::Indirector::ResourceType::Parser

The main terminus for Puppet::Resource::Type

This exposes the known resource types from within Puppet. Only find and search are supported. When a request is received, Puppet will attempt to load all resource types (by parsing manifests and modules) and returns a description of the resource types found. The format of these objects is documented at {Puppet::Resource::Type}.

@api public

Public Instance Methods

find(request) click to toggle source

Find will return the first resource_type with the given name. It is not possible to specify the kind of the resource type.

@param request [Puppet::Indirector::Request] The request object.

The only parameters used from the request are `environment` and
`key`, which corresponds to the resource type's `name` field.

@return [Puppet::Resource::Type, nil] @api public

# File lib/puppet/indirector/resource_type/parser.rb, line 25
def find(request)
  Puppet.override(:squelch_parse_errors => true) do
    krt = resource_types_in(request.environment)

    # This is a bit ugly.
    [:hostclass, :definition, :node].each do |type|
      # We have to us 'find_<type>' here because it will
      # load any missing types from disk, whereas the plain
      # '<type>' method only returns from memory.
      if r = krt.send("find_#{type}", [""], request.key)
        return r
      end
    end
    nil
  end
end
resource_types_in(environment) click to toggle source
# File lib/puppet/indirector/resource_type/parser.rb, line 97
def resource_types_in(environment)
  environment.check_for_reparse
  environment.known_resource_types
end