summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2017-02-24 17:32:52 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2017-02-28 11:19:48 -0800
commitec52255d450f04055ae3a558043874f8eae97cfa (patch)
tree1beca070cfee6afc14cd6d5fede16744be01d79f
parent83ea603889231310af768b0689a677f56d1dd448 (diff)
downloadchef-ec52255d450f04055ae3a558043874f8eae97cfa.tar.gz
Chef-13: chef_gem no longer runs at compile time by default
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r--RELEASE_NOTES.md8
-rw-r--r--chef-config/lib/chef-config/config.rb9
-rw-r--r--lib/chef/application.rb9
-rw-r--r--lib/chef/deprecated.rb12
-rw-r--r--lib/chef/resource/chef_gem.rb13
-rw-r--r--spec/unit/resource/chef_gem_spec.rb78
6 files changed, 31 insertions, 98 deletions
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index 057068bcca..d1d8d498e4 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -14,3 +14,11 @@ to simply delete it.
This was always a usage mistake. The command property was used internally by the script resource and was not intended to be exposed
to users. Users should use the code property instead (or use the command property on an execute resource to execute a single command).
+### The chef_gem resource defaults to not run at compile time
+
+The `compile_time true` flag may still be used to force compile time.
+
+### The Chef::Config[:chef_gem_compile_time] config option has been removed
+
+In order to for community cookbooks to behave consistently across all users this optional flag has been removed.
+
diff --git a/chef-config/lib/chef-config/config.rb b/chef-config/lib/chef-config/config.rb
index 4f2516331d..00af16687a 100644
--- a/chef-config/lib/chef-config/config.rb
+++ b/chef-config/lib/chef-config/config.rb
@@ -4,7 +4,7 @@
# Author:: AJ Christensen (<aj@chef.io>)
# Author:: Mark Mzyk (<mmzyk@chef.io>)
# Author:: Kyle Goodwin (<kgoodwin@primerevenue.com>)
-# Copyright:: Copyright 2008-2016, Chef Software Inc.
+# Copyright:: Copyright 2008-2017, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -825,13 +825,6 @@ module ChefConfig
#
default :no_lazy_load, true
- # Default for the chef_gem compile_time attribute. Nil is the same as true but will emit
- # warnings on every use of chef_gem prompting the user to be explicit. If the user sets this to
- # true then the user will get backcompat behavior but with a single nag warning that cookbooks
- # may break with this setting in the future. The false setting is the recommended setting and
- # will become the default.
- default :chef_gem_compile_time, nil
-
# A whitelisted array of attributes you want sent over the wire when node
# data is saved.
# The default setting is nil, which collects all data. Setting to [] will not
diff --git a/lib/chef/application.rb b/lib/chef/application.rb
index ab19e6571e..86078300c2 100644
--- a/lib/chef/application.rb
+++ b/lib/chef/application.rb
@@ -1,7 +1,7 @@
#
# Author:: AJ Christensen (<aj@chef.io>)
# Author:: Mark Mzyk (mmzyk@chef.io)
-# Copyright:: Copyright 2008-2016, Chef Software, Inc.
+# Copyright:: Copyright 2008-2017, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -48,7 +48,6 @@ class Chef
configure_chef
configure_logging
configure_encoding
- emit_warnings
end
# Get this party started
@@ -332,12 +331,6 @@ class Chef
ENV
end
- def emit_warnings
- if Chef::Config[:chef_gem_compile_time]
- Chef.deprecated :chef_gem_compile_time, "setting chef_gem_compile_time to true is deprecated"
- end
- end
-
class << self
def debug_stacktrace(e)
message = "#{e.class}: #{e}\n#{e.backtrace.join("\n")}"
diff --git a/lib/chef/deprecated.rb b/lib/chef/deprecated.rb
index e5026d2317..25eea5b5ec 100644
--- a/lib/chef/deprecated.rb
+++ b/lib/chef/deprecated.rb
@@ -1,5 +1,5 @@
#--
-# Copyright:: Copyright 2016 Chef Software, Inc.
+# Copyright:: Copyright 2016-2017, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -86,15 +86,7 @@ class Chef
end
end
- class ChefGemCompileTime < Base
- def id
- 3
- end
-
- def target
- "chef_gem_compile_time.html"
- end
- end
+ # id 3 has been deleted
class Attributes < Base
def id
diff --git a/lib/chef/resource/chef_gem.rb b/lib/chef/resource/chef_gem.rb
index 5f51c9e208..7025d74e58 100644
--- a/lib/chef/resource/chef_gem.rb
+++ b/lib/chef/resource/chef_gem.rb
@@ -1,6 +1,6 @@
#
# Author:: Bryan McLellan <btm@loftninjas.org>
-# Copyright:: Copyright 2012-2016, Chef Software Inc.
+# Copyright:: Copyright 2012-2017, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -28,17 +28,10 @@ class Chef
callbacks: {
"The chef_gem resource is restricted to the current gem environment, use gem_package to install to other environments." => proc { |v| v == "#{RbConfig::CONFIG['bindir']}/gem" },
}
- property :compile_time, [ true, false, nil ], default: lazy { Chef::Config[:chef_gem_compile_time] }, desired_state: false
+ property :compile_time, [ true, false ], default: false, desired_state: false
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)
- if compile_time.nil?
- message = "#{self} chef_gem compile_time installation is deprecated. Please set `compile_time false` on the resource to use the new behavior, or set `compile_time true` on the resource if compile_time behavior is required."
- Chef.deprecated :chef_gem_compile_time, message
- end
-
- if compile_time || compile_time.nil?
+ if compile_time
Array(action).each do |action|
run_action(action)
end
diff --git a/spec/unit/resource/chef_gem_spec.rb b/spec/unit/resource/chef_gem_spec.rb
index c98b447582..2b09fb388f 100644
--- a/spec/unit/resource/chef_gem_spec.rb
+++ b/spec/unit/resource/chef_gem_spec.rb
@@ -1,7 +1,7 @@
#
# Author:: Adam Jacob (<adam@chef.io>)
# Author:: Bryan McLellan <btm@loftninjas.org>
-# Copyright:: Copyright 2008-2016, Chef Software Inc.
+# Copyright:: Copyright 2008-2017, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -42,8 +42,8 @@ describe Chef::Resource::ChefGem, "gem_binary" do
expect(resource.gem_binary).to eql("#{RbConfig::CONFIG['bindir']}/gem")
end
- it "should set the gem_binary based on computing it from RbConfig" do
- expect(resource.compile_time).to be nil
+ it "should set compile_time to false by default" do
+ expect(resource.compile_time).to be false
end
context "when building the resource" do
@@ -70,22 +70,13 @@ describe Chef::Resource::ChefGem, "gem_binary" do
expect(Chef::Resource::ChefGem).to receive(:new).and_return(resource)
end
- it "runs the install at compile-time by default", chef: "< 13" do
- expect(resource).to receive(:run_action).with(:install)
- expect(Chef::Log).to receive(:deprecation).at_least(:once)
- recipe.chef_gem "foo"
- end
-
- # the default behavior will change in Chef-13
- it "does not runs the install at compile-time by default", chef: ">= 13" do
+ it "does not runs the install at compile-time by default" do
expect(resource).not_to receive(:run_action).with(:install)
- expect(Chef::Log).not_to receive(:deprecation)
recipe.chef_gem "foo"
end
it "compile_time true installs at compile-time" do
expect(resource).to receive(:run_action).with(:install)
- expect(Chef::Log).not_to receive(:deprecation)
recipe.chef_gem "foo" do
compile_time true
end
@@ -93,64 +84,27 @@ describe Chef::Resource::ChefGem, "gem_binary" do
it "compile_time false does not install at compile-time" do
expect(resource).not_to receive(:run_action).with(:install)
- expect(Chef::Log).not_to receive(:deprecation)
recipe.chef_gem "foo" do
compile_time false
end
end
- describe "when Chef::Config[:chef_gem_compile_time] is explicitly true" do
- let(:chef_gem_compile_time) { true }
-
- before do
- expect(Chef::Log).not_to receive(:deprecation)
- end
-
- it "by default installs at compile-time" do
- expect(resource).to receive(:run_action).with(:install)
- recipe.chef_gem "foo"
- end
-
- it "compile_time true installs at compile-time" do
- expect(resource).to receive(:run_action).with(:install)
- recipe.chef_gem "foo" do
- compile_time true
- end
- end
-
- it "compile_time false does not install at compile-time" do
- expect(resource).not_to receive(:run_action).with(:install)
- recipe.chef_gem "foo" do
- compile_time false
- end
- end
+ it "by default does not install at compile-time" do
+ expect(resource).not_to receive(:run_action).with(:install)
+ recipe.chef_gem "foo"
end
- describe "when Chef::Config[:chef_gem_compile_time] is explicitly false" do
-
- let(:chef_gem_compile_time) { false }
-
- before do
- expect(Chef::Log).not_to receive(:deprecation)
- end
-
- it "by default does not install at compile-time" do
- expect(resource).not_to receive(:run_action).with(:install)
- recipe.chef_gem "foo"
- end
-
- it "compile_time true installs at compile-time" do
- expect(resource).to receive(:run_action).with(:install)
- recipe.chef_gem "foo" do
- compile_time true
- end
+ it "compile_time true installs at compile-time" do
+ expect(resource).to receive(:run_action).with(:install)
+ recipe.chef_gem "foo" do
+ compile_time true
end
+ end
- it "compile_time false does not install at compile-time" do
- expect(resource).not_to receive(:run_action).with(:install)
- recipe.chef_gem "foo" do
- compile_time false
- end
+ it "compile_time false does not install at compile-time" do
+ expect(resource).not_to receive(:run_action).with(:install)
+ recipe.chef_gem "foo" do
+ compile_time false
end
end
end