summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoah Kantrowitz <noah@coderanger.net>2018-06-14 19:06:45 -0700
committerNoah Kantrowitz <noah@coderanger.net>2018-06-14 19:06:45 -0700
commitd67c911268263c710b79cb1bcf8c720d270deb8b (patch)
tree8224f5385f38f5dc98442b67dc1160d4ffb26e80
parente771309797f70ac5c37ba70c739db47902056513 (diff)
downloadchef-d67c911268263c710b79cb1bcf8c720d270deb8b.tar.gz
Switch map collisions to a dedicated deprecation type so they can be silenced easily.
Signed-off-by: Noah Kantrowitz <noah@coderanger.net>
-rw-r--r--lib/chef/deprecated.rb4
-rw-r--r--lib/chef/node_map.rb4
-rw-r--r--spec/unit/node_map_spec.rb14
3 files changed, 13 insertions, 9 deletions
diff --git a/lib/chef/deprecated.rb b/lib/chef/deprecated.rb
index d0665938f5..b490556ddc 100644
--- a/lib/chef/deprecated.rb
+++ b/lib/chef/deprecated.rb
@@ -202,6 +202,10 @@ class Chef
target 23
end
+ class MapCollision < Base
+ target 25
+ end
+
# id 3694 was deleted
# Returned when using the deprecated option on a property
diff --git a/lib/chef/node_map.rb b/lib/chef/node_map.rb
index 634786af93..3fa1f1b924 100644
--- a/lib/chef/node_map.rb
+++ b/lib/chef/node_map.rb
@@ -85,9 +85,9 @@ class Chef
klass.superclass.to_s
end
# For now, only log the warning.
- Chef.log_deprecation("Trying to register #{type_of_thing} #{key} on top of existing Chef core #{type_of_thing}. Check if a new version of the cookbook is available.")
+ Chef.deprecated(:map_collision, "Trying to register #{type_of_thing} #{key} on top of existing Chef core #{type_of_thing}. Check if a new version of the cookbook is available.")
# In 15.0, uncomment this and remove the log above.
- # Chef.log_deprecation("Rejecting attempt to register #{type_of_thing} #{key} on top of existing Chef core #{type_of_thing}. Check if a new version of the cookbook is available.")
+ # Chef.ldeprecated(:map_collision, "Rejecting attempt to register #{type_of_thing} #{key} on top of existing Chef core #{type_of_thing}. Check if a new version of the cookbook is available.")
# return
end
diff --git a/spec/unit/node_map_spec.rb b/spec/unit/node_map_spec.rb
index 7e4980219a..253486438b 100644
--- a/spec/unit/node_map_spec.rb
+++ b/spec/unit/node_map_spec.rb
@@ -213,7 +213,7 @@ describe Chef::NodeMap do
describe "locked mode" do
context "while unlocked" do
it "allows setting the same key twice" do
- expect(Chef).to_not receive(:log_deprecation)
+ expect(Chef).to_not receive(:deprecated)
node_map.set(:foo, FooResource)
node_map.set(:foo, BarResource)
expect(node_map.get(node, :foo)).to eql(BarResource)
@@ -223,7 +223,7 @@ describe Chef::NodeMap do
context "while locked" do
# Uncomment the commented `expect`s in 15.0.
it "rejects setting the same key twice" do
- expect(Chef).to receive(:log_deprecation).with("Trying to register resource foo on top of existing Chef core resource. Check if a new version of the cookbook is available.")
+ expect(Chef).to receive(:deprecated).with(:map_collision, /resource foo/)
node_map.set(:foo, FooResource)
node_map.lock!
node_map.set(:foo, BarResource)
@@ -231,7 +231,7 @@ describe Chef::NodeMap do
end
it "allows setting the same key twice when the first has allow_cookbook_override" do
- expect(Chef).to_not receive(:log_deprecation)
+ expect(Chef).to_not receive(:deprecated)
node_map.set(:foo, FooResource, allow_cookbook_override: true)
node_map.lock!
node_map.set(:foo, BarResource)
@@ -239,7 +239,7 @@ describe Chef::NodeMap do
end
it "allows setting the same key twice when the first has allow_cookbook_override with a future version" do
- expect(Chef).to_not receive(:log_deprecation)
+ expect(Chef).to_not receive(:deprecated)
node_map.set(:foo, FooResource, allow_cookbook_override: "< 100")
node_map.lock!
node_map.set(:foo, BarResource)
@@ -247,7 +247,7 @@ describe Chef::NodeMap do
end
it "rejects setting the same key twice when the first has allow_cookbook_override with a past version" do
- expect(Chef).to receive(:log_deprecation).with("Trying to register resource foo on top of existing Chef core resource. Check if a new version of the cookbook is available.")
+ expect(Chef).to receive(:deprecated).with(:map_collision, /resource foo/)
node_map.set(:foo, FooResource, allow_cookbook_override: "< 1")
node_map.lock!
node_map.set(:foo, BarResource)
@@ -255,7 +255,7 @@ describe Chef::NodeMap do
end
it "allows setting the same key twice when the second has __core_override__" do
- expect(Chef).to_not receive(:log_deprecation)
+ expect(Chef).to_not receive(:deprecated)
node_map.set(:foo, FooResource)
node_map.lock!
node_map.set(:foo, BarResource, __core_override__: true)
@@ -263,7 +263,7 @@ describe Chef::NodeMap do
end
it "rejects setting the same key twice for a provider" do
- expect(Chef).to receive(:log_deprecation).with("Trying to register provider foo on top of existing Chef core provider. Check if a new version of the cookbook is available.")
+ expect(Chef).to receive(:deprecated).with(:map_collision, /provider foo/)
node_map.set(:foo, FooProvider)
node_map.lock!
node_map.set(:foo, BarProvider)