Method: Puppet::Generate::Type.find_inputs

Defined in:
lib/puppet/generate/type.rb

.find_inputs(format = :pcore, environment = Puppet.lookup(:current_environment)) ⇒ Array<Input>

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.

Finds the inputs for the generator.

Parameters:

  • format (Symbol) (defaults to: :pcore)

    The format to use.

  • environment (Puppet::Node::Environment) (defaults to: Puppet.lookup(:current_environment))

    The environment to search for inputs. Defaults to the current environment.

Returns:

  • (Array<Input>)

    Returns the array of inputs.



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/puppet/generate/type.rb', line 115

def self.find_inputs(format = :pcore, environment = Puppet.lookup(:current_environment))
  Puppet.debug "Searching environment '#{environment.name}' for custom types."
  inputs = []
  environment.modules.each do |mod|
    directory = File.join(Puppet::Util::Autoload.cleanpath(mod.plugin_directory), 'puppet', 'type')
    unless Puppet::FileSystem.exist?(directory)
      Puppet.debug "Skipping '#{mod.name}' module because it contains no custom types."
      next
    end

    Puppet.debug "Searching '#{mod.name}' module for custom types."
    Dir.glob("#{directory}/*.rb") do |file|
      next unless Puppet::FileSystem.file?(file)
      Puppet.debug "Found custom type source file '#{file}'."
      inputs << Input.new(mod.path, file, format)
    end
  end

  # Sort the inputs by path
  inputs.sort_by! { |input| input.path }
end