diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2015-01-07 09:14:50 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2015-01-12 11:53:15 -0800 |
commit | 6d7ee4010e67f6921a78e2b57152de9eaa725b11 (patch) | |
tree | ebf595bb3c98847ca0f2e4485973ade18427c714 /lib/chef/resource/chef_gem.rb | |
parent | c1869a22ecec29aaafdd09e19e5291b1946e6498 (diff) | |
download | chef-6d7ee4010e67f6921a78e2b57152de9eaa725b11.tar.gz |
add a compile_time flag to chef_gem resource
the default is still the same, but will warn that users should start
being explicit. setting compile_time false will become the new
default in chef-13 and is encouraged to avoid the compile_time arms
race.
Diffstat (limited to 'lib/chef/resource/chef_gem.rb')
-rw-r--r-- | lib/chef/resource/chef_gem.rb | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/lib/chef/resource/chef_gem.rb b/lib/chef/resource/chef_gem.rb index b4ead11f1d..126e3d56c3 100644 --- a/lib/chef/resource/chef_gem.rb +++ b/lib/chef/resource/chef_gem.rb @@ -28,6 +28,7 @@ class Chef def initialize(name, run_context=nil) super @resource_name = :chef_gem + @compile_time = nil @gem_binary = RbConfig::CONFIG['bindir'] + "/gem" end @@ -40,13 +41,29 @@ class Chef @gem_binary end + def compile_time(arg=nil) + set_or_return( + :compile_time, + arg, + :kind_of => [ TrueClass, FalseClass ] + ) + end + def after_created # Chef::Resource.run_action: Caveat: this skips Chef::Runner.run_action, where notifications are handled # Action could be an array of symbols, but probably won't (think install + enable for a package) - Array(@action).each do |action| - self.run_action(action) + if compile_time.nil? + Chef::Log.warn "The chef_gem installation at compile time is deprecated and this behavior will change in the future." + Chef::Log.warn "Please set `compile_time false` on the resource to use the new behavior and suppress this warning," + Chef::Log.warn "or you may set `compile_time true` on the resource if compile_time behavior is necessary." + end + + if compile_time || compile_time.nil? + Array(action).each do |action| + self.run_action(action) + end + Gem.clear_paths end - Gem.clear_paths end end end |