Method: Puppet::Pops::Loader::ModuleLoaders::AbstractPathBasedModuleLoader#discover

Defined in:
lib/puppet/pops/loader/module_loaders.rb

#discover(type, error_collector = nil, name_authority = Pcore::RUNTIME_NAME_AUTHORITY, &block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/puppet/pops/loader/module_loaders.rb', line 143

def discover(type, error_collector = nil, name_authority = Pcore::RUNTIME_NAME_AUTHORITY, &block)
  global = global?
  if name_authority == Pcore::RUNTIME_NAME_AUTHORITY
    smart_paths.effective_paths(type).each do |sp|
      relative_paths(sp).each do |rp|
        tp = sp.typed_name(type, name_authority, rp, global ? nil : @module_name)
        next unless sp.valid_name?(tp)

        begin
          load_typed(tp) unless block_given? && !block.yield(tp)
        rescue StandardError => e
          if error_collector.nil?
            Puppet.warn_once(:unloadable_entity, tp.to_s, e.message)
          else
            err = Puppet::DataTypes::Error.new(
              Issues::LOADER_FAILURE.format(:type => type),
              'PUPPET_LOADER_FAILURE',
              { 'original_error' => e.message },
              Issues::LOADER_FAILURE.issue_code
            )
            error_collector << err unless error_collector.include?(err)
          end
        end
      end
    end
  end
  super
end