class Puppet::InfoService::PlanInformationService

Public Class Methods

plan_data(environment_name, module_name, plan_name) click to toggle source
   # File lib/puppet/info_service/plan_information_service.rb
14 def self.plan_data(environment_name, module_name, plan_name)
15   # raise EnvironmentNotFound if applicable
16   Puppet.lookup(:environments).get!(environment_name)
17 
18   pup_module = Puppet::Module.find(module_name, environment_name)
19   if pup_module.nil?
20     raise Puppet::Module::MissingModule, _("Module %{module_name} not found in environment %{environment_name}.") %
21                                           {module_name: module_name, environment_name: environment_name}
22   end
23 
24   plan = pup_module.plans.find { |t| t.name == plan_name }
25   if plan.nil?
26     raise Puppet::Module::Plan::PlanNotFound.new(plan_name, module_name)
27   end
28 
29   begin
30     plan.validate
31     {:metadata => plan.metadata, :files => plan.files}
32   rescue Puppet::Module::Plan::Error => err
33     { :metadata => nil, :files => [], :error => err.to_h }
34   end
35 end
plans_per_environment(environment_name) click to toggle source
   # File lib/puppet/info_service/plan_information_service.rb
 4 def self.plans_per_environment(environment_name)
 5   # get the actual environment object, raise error if the named env doesn't exist
 6   env = Puppet.lookup(:environments).get!(environment_name)
 7   env.modules.map do |mod|
 8     mod.plans.map do |plan|
 9       {:module => {:name => plan.module.name}, :name => plan.name}
10     end
11   end.flatten
12 end