@@ -69,6 +69,84 @@ def discover_paths(type, name_authority = Pcore::RUNTIME_NAME_AUTHORITY)
6969 end
7070end
7171
72+ # The Null Loader was removed in Puppet 6.11.0+ (and friends) so monkey patch it back in!
73+ # Last known source is at - https://github.com/puppetlabs/puppet/blob/6.10.1/lib/puppet/pops/loader/null_loader.rb
74+ if defined? ( ::Puppet ::Pops ::Loader ::NullLoader ) . nil?
75+ # This came direct from Puppet so ignore Rubocop
76+ # rubocop:disable Lint/UnusedMethodArgument
77+ # rubocop:disable Style/ClassAndModuleChildren
78+ # rubocop:disable Layout/SpaceAroundEqualsInParameterDefault
79+ # rubocop:disable Style/StringLiterals
80+ # rubocop:disable Style/TrivialAccessors
81+ # rubocop:disable Style/DefWithParentheses
82+ # The null loader is empty and delegates everything to its parent if it has one.
83+ #
84+ class ::Puppet ::Pops ::Loader ::NullLoader < ::Puppet ::Pops ::Loader ::Loader
85+ attr_reader :loader_name
86+
87+ # Construct a NullLoader, optionally with a parent loader
88+ #
89+ def initialize ( parent_loader = nil , loader_name = "null-loader" )
90+ super ( loader_name )
91+ @parent = parent_loader
92+ end
93+
94+ # Has parent if one was set when constructed
95+ def parent
96+ @parent
97+ end
98+
99+ def find ( typed_name )
100+ if @parent . nil?
101+ nil
102+ else
103+ @parent . find ( typed_name )
104+ end
105+ end
106+
107+ def load_typed ( typed_name )
108+ if @parent . nil?
109+ nil
110+ else
111+ @parent . load_typed ( typed_name )
112+ end
113+ end
114+
115+ def loaded_entry ( typed_name , check_dependencies = false )
116+ if @parent . nil?
117+ nil
118+ else
119+ @parent . loaded_entry ( typed_name , check_dependencies )
120+ end
121+ end
122+
123+ # Has no entries on its own - always nil
124+ def get_entry ( typed_name )
125+ nil
126+ end
127+
128+ # Finds nothing, there are no entries
129+ def find ( name )
130+ nil
131+ end
132+
133+ # Cannot store anything
134+ def set_entry ( typed_name , value , origin = nil )
135+ nil
136+ end
137+
138+ def to_s ( )
139+ "(NullLoader '#{ loader_name } ')"
140+ end
141+ end
142+ # rubocop:enable Lint/UnusedMethodArgument
143+ # rubocop:enable Style/ClassAndModuleChildren
144+ # rubocop:enable Layout/SpaceAroundEqualsInParameterDefault
145+ # rubocop:enable Style/StringLiterals
146+ # rubocop:enable Style/TrivialAccessors
147+ # rubocop:enable Style/DefWithParentheses
148+ end
149+
72150# While this is not a monkey patch, but a new class, this class is used purely to
73151# enumerate the paths of puppet "things" that aren't already covered as part of the
74152# usual loaders. It is implemented as a null loader as it can't actually _load_
0 commit comments