Sha256: a744d7ec801ef1802e631d440eba8876ddca78b2306c06f5d5429b0aaf5fb5dd

Contents?: true

Size: 1.28 KB

Versions: 48

Compression:

Stored size: 1.28 KB

Contents

class Puppet::InfoService::TaskInformationService
  require_relative '../../puppet/module'

  def self.tasks_per_environment(environment_name)
    # get the actual environment object, raise error if the named env doesn't exist
    env = Puppet.lookup(:environments).get!(environment_name)
    env.modules.map do |mod|
      mod.tasks.map do |task|
        {:module => {:name => task.module.name}, :name => task.name}
      end
    end.flatten
  end

  def self.task_data(environment_name, module_name, task_name)
    # raise EnvironmentNotFound if applicable
    Puppet.lookup(:environments).get!(environment_name)

    pup_module = Puppet::Module.find(module_name, environment_name)
    if pup_module.nil?
      raise Puppet::Module::MissingModule, _("Module %{module_name} not found in environment %{environment_name}.") %
                                            {module_name: module_name, environment_name: environment_name}
    end

    task = pup_module.tasks.find { |t| t.name == task_name }
    if task.nil?
      raise Puppet::Module::Task::TaskNotFound.new(task_name, module_name)
    end

    begin
      task.validate
      {:metadata => task.metadata, :files => task.files}
    rescue Puppet::Module::Task::Error => err
      { :metadata => nil, :files => [], :error => err.to_h }
    end
  end
end

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
puppet-7.17.0 lib/puppet/info_service/task_information_service.rb
puppet-7.17.0-x86-mingw32 lib/puppet/info_service/task_information_service.rb
puppet-7.17.0-x64-mingw32 lib/puppet/info_service/task_information_service.rb
puppet-7.17.0-universal-darwin lib/puppet/info_service/task_information_service.rb
puppet-7.16.0 lib/puppet/info_service/task_information_service.rb
puppet-7.16.0-x86-mingw32 lib/puppet/info_service/task_information_service.rb
puppet-7.16.0-x64-mingw32 lib/puppet/info_service/task_information_service.rb
puppet-7.16.0-universal-darwin lib/puppet/info_service/task_information_service.rb
puppet-7.15.0 lib/puppet/info_service/task_information_service.rb
puppet-7.15.0-x86-mingw32 lib/puppet/info_service/task_information_service.rb
puppet-7.15.0-x64-mingw32 lib/puppet/info_service/task_information_service.rb
puppet-7.15.0-universal-darwin lib/puppet/info_service/task_information_service.rb
puppet-7.14.0 lib/puppet/info_service/task_information_service.rb
puppet-7.14.0-x86-mingw32 lib/puppet/info_service/task_information_service.rb
puppet-7.14.0-x64-mingw32 lib/puppet/info_service/task_information_service.rb
puppet-7.14.0-universal-darwin lib/puppet/info_service/task_information_service.rb
puppet-7.13.1 lib/puppet/info_service/task_information_service.rb
puppet-7.13.1-x86-mingw32 lib/puppet/info_service/task_information_service.rb
puppet-7.13.1-x64-mingw32 lib/puppet/info_service/task_information_service.rb
puppet-7.13.1-universal-darwin lib/puppet/info_service/task_information_service.rb