summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2017-02-24 16:06:48 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2017-02-28 11:19:48 -0800
commitd8a2bc810381f58eeb4ecd4db7ff104038f8f97c (patch)
tree0da0dc718023f41e27bd948fb00af2e878ce4d75
parent0ba7833fb61c4183faa506ca513715d00e65857d (diff)
downloadchef-d8a2bc810381f58eeb4ecd4db7ff104038f8f97c.tar.gz
fix recipes to always have duplicated default recipes
IMO this is what users really want. It looks like we never really fixed it right though. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r--lib/chef/run_list/versioned_recipe_list.rb14
-rw-r--r--spec/unit/run_list/versioned_recipe_list_spec.rb11
2 files changed, 15 insertions, 10 deletions
diff --git a/lib/chef/run_list/versioned_recipe_list.rb b/lib/chef/run_list/versioned_recipe_list.rb
index ccd7351eeb..ad769ee952 100644
--- a/lib/chef/run_list/versioned_recipe_list.rb
+++ b/lib/chef/run_list/versioned_recipe_list.rb
@@ -1,7 +1,7 @@
#
# Author:: Stephen Delano (<stephen@chef.io>)
# Author:: Seth Falcon (<seth@chef.io>)
-# Copyright:: Copyright 2010-2016, Chef Software, Inc.
+# Copyright:: Copyright 2010-2017, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -83,17 +83,19 @@ class Chef
end
end
- # Get an array of strings of both fully-qualified and unexpanded recipe names
- # in response to chef/chef#3767
- # Chef-13 will revert to the behaviour of just including the fully-qualified name
+ # For "foo::default" also include "foo", for "foo" also include "foo::default", for
+ # "foo::bar" just return "foo::bar". This makes it easier for people to search on
+ # default recipe names.
#
# @return [Array] Array of strings with fully-qualified and unexpanded recipe names
def with_duplicate_names
map do |recipe_name|
- if recipe_name.include?("::")
+ if recipe_name.end_with?("::default")
+ [ recipe_name.sub(/::default$/, ""), recipe_name ]
+ elsif recipe_name.include?("::")
recipe_name
else
- [recipe_name, "#{recipe_name}::default"]
+ [ recipe_name, "#{recipe_name}::default" ]
end
end.flatten
end
diff --git a/spec/unit/run_list/versioned_recipe_list_spec.rb b/spec/unit/run_list/versioned_recipe_list_spec.rb
index 91c601b294..859fee75ec 100644
--- a/spec/unit/run_list/versioned_recipe_list_spec.rb
+++ b/spec/unit/run_list/versioned_recipe_list_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Stephen Delano (<stephen@chef.io>)
-# Copyright:: Copyright 2010-2016, Chef Software Inc.
+# Copyright:: Copyright 2010-2017, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -186,9 +186,12 @@ describe Chef::RunList::VersionedRecipeList do
end
end
- context "with duplicated names", chef: ">= 13" do
- it "should fail in Chef 13" do
- expect(list).to_not respond_to(:with_duplicate_names)
+ context "with duplicate names" do
+ let(:fq_names) { list.with_duplicate_names }
+ let(:recipes) { %w{ foo bar::default } }
+
+ it "expands default recipes" do
+ expect(fq_names).to eq(%w{foo foo::default bar bar::default})
end
end
end