File tree Expand file tree Collapse file tree 2 files changed +28
-7
lines changed Expand file tree Collapse file tree 2 files changed +28
-7
lines changed Original file line number Diff line number Diff line change @@ -592,13 +592,17 @@ def check(value)
592592 cmd = self [ :command ]
593593 cmd = cmd [ 0 ] if cmd . is_a? Array
594594
595- cmd . scan ( file_regex ) { |str |
596- reqs << str
597- }
595+ if cmd . is_a? ( Puppet ::Pops ::Evaluator ::DeferredValue )
596+ self . debug ( "The 'command' parameter is deferred and cannot be autorequired" )
597+ else
598+ cmd . scan ( file_regex ) { |str |
599+ reqs << str
600+ }
598601
599- cmd . scan ( /^"([^"]+)"/ ) { |str |
600- reqs << str
601- }
602+ cmd . scan ( /^"([^"]+)"/ ) { |str |
603+ reqs << str
604+ }
605+ end
602606
603607 [ :onlyif , :unless ] . each { |param |
604608 tmp = self [ param ]
@@ -613,7 +617,11 @@ def check(value)
613617 # unqualified files, but, well, that's a bit more annoying
614618 # to do.
615619 line = line [ 0 ] if line . is_a? Array
616- reqs += line . scan ( file_regex )
620+ if line . is_a? ( Puppet ::Pops ::Evaluator ::DeferredValue )
621+ self . debug ( "The '#{ param } ' parameter is deferred and cannot be autorequired" )
622+ else
623+ reqs += line . scan ( file_regex )
624+ end
617625 end
618626 }
619627
Original file line number Diff line number Diff line change @@ -252,6 +252,19 @@ def exec_stub(options = {})
252252 expect ( dependencies . collect ( &:to_s ) ) . to eq ( [ Puppet ::Relationship . new ( tmp , execer ) . to_s ] )
253253 end
254254
255+ it "skips autorequire for deferred commands" do
256+ foo = make_absolute ( '/bin/foo' )
257+ catalog = Puppet ::Resource ::Catalog . new
258+ tmp = Puppet ::Type . type ( :file ) . new ( :name => foo )
259+ execer = Puppet ::Type . type ( :exec ) . new ( :name => 'test array' , :command => Puppet ::Pops ::Evaluator ::DeferredValue . new ( nil ) )
260+
261+ catalog . add_resource tmp
262+ catalog . add_resource execer
263+ dependencies = execer . autorequire ( catalog )
264+
265+ expect ( dependencies . collect ( &:to_s ) ) . to eq ( [ ] )
266+ end
267+
255268 describe "when handling the path parameter" do
256269 expect = %w{ one two three four }
257270 { "an array" => expect ,
You can’t perform that action at this time.
0 commit comments