Skip to content

Commit c98599b

Browse files
committed
(PUP-9512) Allow discovering and loading of YAML plans
This adds a second loader for plans which will find plans with a .yaml extension. Because plans in general, and YAML plans especially, aren't a meaningful concept in Puppet proper, this loader just calls out to an injected `yaml_plan_instantiator` to handle actual creation of the plan once it's been loaded. This will prefer .pp plans over .yaml when two files with the same name exist.
1 parent 293b874 commit c98599b

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

lib/puppet/pops/loader/loader_paths.rb

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def self.relative_paths_for_type(type, loader)
3030
end
3131
when :plan
3232
result << PlanPathPP.new(loader)
33+
result << PlanPathYaml.new(loader)
3334
when :task
3435
result << TaskPath.new(loader) if Puppet[:tasks] && loader.loadables.include?(:task)
3536
when :type
@@ -324,7 +325,7 @@ def instantiator()
324325
end
325326

326327
def typed_name(type, name_authority, relative_path, module_name)
327-
if relative_path == 'init.pp' && !(module_name.nil? || module_name.empty?)
328+
if relative_path == "init#{extension}" && !(module_name.nil? || module_name.empty?)
328329
TypedName.new(type, module_name, name_authority)
329330
else
330331
n = ''
@@ -342,6 +343,18 @@ def typed_name(type, name_authority, relative_path, module_name)
342343
end
343344
end
344345

346+
class PlanPathYaml < PlanPathPP
347+
EXTENSION = '.yaml'.freeze
348+
349+
def instantiator()
350+
Puppet.lookup(:yaml_plan_instantiator)
351+
end
352+
353+
def extension
354+
EXTENSION
355+
end
356+
end
357+
345358
# SmartPaths
346359
# ===
347360
# Holds effective SmartPath instances per type

0 commit comments

Comments
 (0)