Sha256: 9ff9754ecd0fe56823d105a244ee6a5f11c3c0321b655dc940d375e5097963ee

Contents?: true

Size: 1.31 KB

Versions: 20

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true
class Puppet::InfoService::PlanInformationService
  require_relative '../../puppet/module'

  def self.plans_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.plans.map do |plan|
        {:module => {:name => plan.module.name}, :name => plan.name}
      end
    end.flatten
  end

  def self.plan_data(environment_name, module_name, plan_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

    plan = pup_module.plans.find { |t| t.name == plan_name }
    if plan.nil?
      raise Puppet::Module::Plan::PlanNotFound.new(plan_name, module_name)
    end

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

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
puppet-8.3.0 lib/puppet/info_service/plan_information_service.rb
puppet-8.3.0-x86-mingw32 lib/puppet/info_service/plan_information_service.rb
puppet-8.3.0-x64-mingw32 lib/puppet/info_service/plan_information_service.rb
puppet-8.3.0-universal-darwin lib/puppet/info_service/plan_information_service.rb
puppet-8.3.1 lib/puppet/info_service/plan_information_service.rb
puppet-8.3.1-x86-mingw32 lib/puppet/info_service/plan_information_service.rb
puppet-8.3.1-x64-mingw32 lib/puppet/info_service/plan_information_service.rb
puppet-8.3.1-universal-darwin lib/puppet/info_service/plan_information_service.rb
puppet-8.2.0 lib/puppet/info_service/plan_information_service.rb
puppet-8.2.0-x86-mingw32 lib/puppet/info_service/plan_information_service.rb
puppet-8.2.0-x64-mingw32 lib/puppet/info_service/plan_information_service.rb
puppet-8.2.0-universal-darwin lib/puppet/info_service/plan_information_service.rb
puppet-8.1.0 lib/puppet/info_service/plan_information_service.rb
puppet-8.1.0-x86-mingw32 lib/puppet/info_service/plan_information_service.rb
puppet-8.1.0-x64-mingw32 lib/puppet/info_service/plan_information_service.rb
puppet-8.1.0-universal-darwin lib/puppet/info_service/plan_information_service.rb
puppet-8.0.1 lib/puppet/info_service/plan_information_service.rb
puppet-8.0.1-x86-mingw32 lib/puppet/info_service/plan_information_service.rb
puppet-8.0.1-x64-mingw32 lib/puppet/info_service/plan_information_service.rb
puppet-8.0.1-universal-darwin lib/puppet/info_service/plan_information_service.rb