diff options
author | Serdar Sutay <serdar@opscode.com> | 2014-10-13 15:57:56 -0700 |
---|---|---|
committer | Serdar Sutay <serdar@opscode.com> | 2014-10-16 13:30:23 -0700 |
commit | 8dd586b1fdbb13705a1a3a5f7f792568cc39e434 (patch) | |
tree | 19ac34de330ce11140655c6394f2d1a1604322bc /lib/chef/resource/conditional.rb | |
parent | 28fd0c9c87c6fceb7068776a04c32cd8381fe8f6 (diff) | |
download | chef-8dd586b1fdbb13705a1a3a5f7f792568cc39e434.tar.gz |
Enable guard_interpreters for the execute resource and set the default interpreter for the execute resource to be :execute.
This ensures that attributes of the resource like :environment & :cwd can be inherited by the guard when guard is specified as a string.
Diffstat (limited to 'lib/chef/resource/conditional.rb')
-rw-r--r-- | lib/chef/resource/conditional.rb | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/lib/chef/resource/conditional.rb b/lib/chef/resource/conditional.rb index 324c5a4676..6a987d3086 100644 --- a/lib/chef/resource/conditional.rb +++ b/lib/chef/resource/conditional.rb @@ -54,23 +54,29 @@ class Chef end def configure - case @command - when String - @guard_interpreter = new_guard_interpreter(@parent_resource, @command, @command_opts, &@block) - @block = nil - when nil - # we should have a block if we get here - if @parent_resource.guard_interpreter != :default - msg = "#{@parent_resource.name} was given a guard_interpreter of #{@parent_resource.guard_interpreter}, " - msg << "but not given a command as a string. guard_interpreter does not support blocks (because they just contain ruby)." - raise ArgumentError, msg - end - + if @block_given + # If a block is given, we will not interpret the block with a guard interpreter. @guard_interpreter = nil @command, @command_opts = nil, nil else - # command was passed, but it wasn't a String - raise ArgumentError, "Invalid only_if/not_if command, expected a string: #{command.inspect} (#{command.class})" + case @command + when String + @guard_interpreter = new_guard_interpreter(@parent_resource, @command, @command_opts, &@block) + @block = nil + when nil + # We should have a block if we get here + if @parent_resource.guard_interpreter != :default + msg = "#{@parent_resource.name} was given a guard_interpreter of #{@parent_resource.guard_interpreter}, " + msg << "but not given a command as a string. guard_interpreter does not support blocks (because they just contain ruby)." + raise ArgumentError, msg + end + + @guard_interpreter = nil + @command, @command_opts = nil, nil + else + # command was passed, but it wasn't a String + raise ArgumentError, "Invalid only_if/not_if command, expected a string: #{command.inspect} (#{command.class})" + end end end |