diff options
author | Serdar Sutay <serdar@opscode.com> | 2014-10-16 13:30:59 -0700 |
---|---|---|
committer | Serdar Sutay <serdar@opscode.com> | 2014-10-16 13:30:59 -0700 |
commit | 901e8eff95c953b91f597e4d83932d5b8803d31a (patch) | |
tree | 1dd8bd92a3d7d48766fc6528059af3be16941ae2 /lib/chef/resource | |
parent | 33b198b6b954742c313a84b40610ab8f842e5735 (diff) | |
parent | f4633e3db1794533bd22c929da6b4aacb9bb88e5 (diff) | |
download | chef-901e8eff95c953b91f597e4d83932d5b8803d31a.tar.gz |
Merge pull request #2223 from opscode/sersut/execute-guard-interpreter
Guards of execute resource doesn't inherit command options from its parent resource
Diffstat (limited to 'lib/chef/resource')
-rw-r--r-- | lib/chef/resource/conditional.rb | 6 | ||||
-rw-r--r-- | lib/chef/resource/execute.rb | 34 | ||||
-rw-r--r-- | lib/chef/resource/script.rb | 25 |
3 files changed, 29 insertions, 36 deletions
diff --git a/lib/chef/resource/conditional.rb b/lib/chef/resource/conditional.rb index 324c5a4676..8960a4d57f 100644 --- a/lib/chef/resource/conditional.rb +++ b/lib/chef/resource/conditional.rb @@ -59,8 +59,10 @@ class Chef @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 + # We should have a block if we get here + # Check to see if the user set the guard_interpreter on the parent resource. Note that + # this error will not be raised when using the default_guard_interpreter + if @parent_resource.guard_interpreter != @parent_resource.default_guard_interpreter 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 diff --git a/lib/chef/resource/execute.rb b/lib/chef/resource/execute.rb index 7c4fa48c0a..ae118b1c9e 100644 --- a/lib/chef/resource/execute.rb +++ b/lib/chef/resource/execute.rb @@ -35,12 +35,12 @@ class Chef @cwd = nil @environment = nil @group = nil - @path = nil @returns = 0 @timeout = nil @user = nil @allowed_actions.push(:run) @umask = nil + @default_guard_interpreter = :execute end def umask(arg=nil) @@ -93,14 +93,6 @@ class Chef ) end - def path(arg=nil) - set_or_return( - :path, - arg, - :kind_of => [ Array ] - ) - end - def returns(arg=nil) set_or_return( :returns, @@ -125,6 +117,30 @@ class Chef ) end + def self.set_guard_inherited_attributes(*inherited_attributes) + @class_inherited_attributes = inherited_attributes + end + + def self.guard_inherited_attributes(*inherited_attributes) + # Similar to patterns elsewhere, return attributes from this + # class and superclasses as a form of inheritance + ancestor_attributes = [] + + if superclass.respond_to?(:guard_inherited_attributes) + ancestor_attributes = superclass.guard_inherited_attributes + end + + ancestor_attributes.concat(@class_inherited_attributes ? @class_inherited_attributes : []).uniq + end + + set_guard_inherited_attributes( + :cwd, + :environment, + :group, + :user, + :umask + ) + end end end diff --git a/lib/chef/resource/script.rb b/lib/chef/resource/script.rb index 6f66fb9094..8cc9c6f0c5 100644 --- a/lib/chef/resource/script.rb +++ b/lib/chef/resource/script.rb @@ -58,31 +58,6 @@ class Chef ) end - def self.set_guard_inherited_attributes(*inherited_attributes) - @class_inherited_attributes = inherited_attributes - end - - def self.guard_inherited_attributes(*inherited_attributes) - # Similar to patterns elsewhere, return attributes from this - # class and superclasses as a form of inheritance - ancestor_attributes = [] - - if superclass.respond_to?(:guard_inherited_attributes) - ancestor_attributes = superclass.guard_inherited_attributes - end - - ancestor_attributes.concat(@class_inherited_attributes ? @class_inherited_attributes : []).uniq - end - - set_guard_inherited_attributes( - :cwd, - :environment, - :group, - :path, - :user, - :umask - ) - end end end |