lib/puppet/resource/catalog.rb
# Look a resource up by its reference (e.g., File[/etc/passwd]).
Look a resource up by its reference .
Look a resource up by its reference .
def resource(type, title = nil)
    type_name = type.is_a?(Puppet::CompilableResourceType) || type.is_a?(Puppet::Resource::Type) ? type.name : type
    type_name, title = Puppet::Resource.type_and_title(type_name, title)
    type = type_name if type.is_a?(String)
    title_key   = [type_name, title.to_s]
    result = @resource_table[title_key]
    if result.nil?
      res = Puppet::Resource.new(type, title, { :environment => @environment_instance })
      result = @resource_table[[type_name, res.uniqueness_key].flatten]
      if result.nil?
        resource_type = res.resource_type
        if resource_type && resource_type.is_capability?
          result = Puppet::Resource::CapabilityFinder.find(environment, code_id, res)
          add_resource(result) if result
        end
      end
    end
    result
  end
def resource ( type , title = nil ) type_name = type . is_a? ( Puppet :: CompilableResourceType ) || type . is_a? ( Puppet :: Resource :: Type ) ? type . name : type type_name , title = Puppet :: Resource . type_and_title ( type_name , title ) type = type_name if type . is_a? ( String ) title_key = [ type_name , title . to_s ] result = @resource_table [ title_key ] if result . nil? res = Puppet :: Resource . new ( type , title , { :environment => @environment_instance } ) result = @resource_table [ [ type_name , res . uniqueness_key ] . flatten ] if result . nil? resource_type = res . resource_type if resource_type && resource_type . is_capability? result = Puppet :: Resource :: CapabilityFinder . find ( environment , code_id , res ) add_resource ( result ) if result end end end result end
Look a resource up by its reference (e.g., File[/etc/passwd]).
Look a resource up by its reference ( e . g . File [ / etc / passwd ] ) .
# Retain type if it's a type # an instance has to be created in order to construct the unique key used when # searching for aliases, or nothing is found as it is needed by the CapabilityFinder. # Must check with uniqueness key because of aliases or if resource transforms title in title # to attribute mappings. # @todo lutter 2015-03-10: this assumes that it is legal to just # mention a capability resource in code and have it automatically # made available, even if the current component does not require it
type
title