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/execute.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/execute.rb')
-rw-r--r-- | lib/chef/resource/execute.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/chef/resource/execute.rb b/lib/chef/resource/execute.rb index 80ee16c5ec..e0a1bbb8c0 100644 --- a/lib/chef/resource/execute.rb +++ b/lib/chef/resource/execute.rb @@ -40,6 +40,7 @@ class Chef @user = nil @allowed_actions.push(:run) @umask = nil + @guard_interpreter = :execute end def umask(arg=nil) @@ -116,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 |