summaryrefslogtreecommitdiff
path: root/lib/chef/platform/priority_map.rb
diff options
context:
space:
mode:
authorJay Mundrawala <jdmundrawala@gmail.com>2015-07-07 07:02:38 -0700
committerJay Mundrawala <jdmundrawala@gmail.com>2015-07-07 07:02:38 -0700
commit1dc20627aa5d742376269dc5b4d5c67f34d08008 (patch)
tree8f26017e7ce9e7168e010260a87c39b737ba5855 /lib/chef/platform/priority_map.rb
parent283b8d21e2f347afea5f8ce8c4366588295a845a (diff)
parent4245098873f2d5f6ec2759dda5b3238bf8f0dd8a (diff)
downloadchef-12.4.1.tar.gz
Merge pull request #3639 from chef/jdm/12.4.112.4.1
12.4.1
Diffstat (limited to 'lib/chef/platform/priority_map.rb')
-rw-r--r--lib/chef/platform/priority_map.rb51
1 files changed, 19 insertions, 32 deletions
diff --git a/lib/chef/platform/priority_map.rb b/lib/chef/platform/priority_map.rb
index d559eece78..0b050deb59 100644
--- a/lib/chef/platform/priority_map.rb
+++ b/lib/chef/platform/priority_map.rb
@@ -1,3 +1,21 @@
+#
+# Author:: John Keiser (<jkeiser@chef.io>)
+# Copyright:: Copyright (c) 2015 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
require 'chef/node_map'
class Chef
@@ -6,7 +24,7 @@ class Chef
def priority(resource_name, priority_array, *filter)
set_priority_array(resource_name.to_sym, priority_array, *filter)
end
-
+
# @api private
def get_priority_array(node, key)
get(node, key)
@@ -18,37 +36,6 @@ class Chef
set(key, priority_array, *filter, &block)
priority_array
end
-
- # @api private
- def list_handlers(node, key, **filters)
- list(node, key, **filters).flatten(1).uniq
- end
-
- #
- # Priority maps have one extra precedence: priority arrays override "provides,"
- # and "provides" lines with identical filters sort by class name (ascending).
- #
- def compare_matchers(key, new_matcher, matcher)
- # Priority arrays come before "provides"
- if new_matcher[:value].is_a?(Array) != matcher[:value].is_a?(Array)
- return new_matcher[:value].is_a?(Array) ? -1 : 1
- end
-
- cmp = super
- if cmp == 0
- # Sort by class name (ascending) as well, if all other properties
- # are exactly equal
- if new_matcher[:value].is_a?(Class) && !new_matcher[:override]
- cmp = compare_matcher_properties(new_matcher, matcher) { |m| m[:value].name }
- if cmp < 0
- Chef::Log.warn "You are overriding #{key} on #{new_matcher[:filters].inspect} with #{new_matcher[:value].inspect}: used to be #{matcher[:value].inspect}. Use override: true if this is what you intended."
- elsif cmp > 0
- Chef::Log.warn "You declared a new resource #{new_matcher[:value].inspect} for resource #{key}, but it comes alphabetically after #{matcher[:value].inspect} and has the same filters (#{new_matcher[:filters].inspect}), so it will not be used. Use override: true if you want to use it for #{key}."
- end
- end
- end
- cmp
- end
end
end
end