summaryrefslogtreecommitdiff
path: root/lib/chef/node_map.rb
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2020-06-11 11:28:04 -0700
committerTim Smith <tsmith84@gmail.com>2020-07-23 14:38:50 -0700
commit859e4bdee9d636b51b38537889ad9c2c484e87b9 (patch)
treee4c9d2dceabb7b297227a82ca1d089963a370bcb /lib/chef/node_map.rb
parent2c3895bb2bb44988a41350d09b351ab02f259a2b (diff)
downloadchef-859e4bdee9d636b51b38537889ad9c2c484e87b9.tar.gz
Rename Attribute Whitelist/Blacklist to Allowlist/Blocklist
This is an overdue change. These are not terms we should be using as a company or community. To quote our Code of Conduct (https://community.chef.io/code-of-conduct/). "Be careful in the words that you choose. Be kind to others. Practice empathy." This change aims to do exactly that, while maintaining a level of backwards compatibility so we can transition existing users off the legacy configs. Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'lib/chef/node_map.rb')
-rw-r--r--lib/chef/node_map.rb32
1 files changed, 16 insertions, 16 deletions
diff --git a/lib/chef/node_map.rb b/lib/chef/node_map.rb
index dcf6e8969c..30a0ed6c4e 100644
--- a/lib/chef/node_map.rb
+++ b/lib/chef/node_map.rb
@@ -212,7 +212,7 @@ class Chef
# - no negative matches (!value)
# - at least one positive match (value or :all), or no positive filters
#
- def matches_black_white_list?(node, filters, attribute)
+ def matches_block_allow_list?(node, filters, attribute)
# It's super common for the filter to be nil. Catch that so we don't
# spend any time here.
return true unless filters[attribute]
@@ -220,21 +220,21 @@ class Chef
filter_values = Array(filters[attribute])
value = node[attribute]
- # Split the blacklist and whitelist
- blacklist, whitelist = filter_values.partition { |v| v.is_a?(String) && v.start_with?("!") }
+ # Split the blocklist and allowlist
+ blocklist, allowlist = filter_values.partition { |v| v.is_a?(String) && v.start_with?("!") }
if attribute == :platform_family
- # If any blacklist value matches, we don't match
- return false if blacklist.any? { |v| v[1..-1] == value || platform_family_query_helper?(node, v[1..-1]) }
+ # If any blocklist value matches, we don't match
+ return false if blocklist.any? { |v| v[1..-1] == value || platform_family_query_helper?(node, v[1..-1]) }
- # If the whitelist is empty, or anything matches, we match.
- whitelist.empty? || whitelist.any? { |v| v == :all || v == value || platform_family_query_helper?(node, v) }
+ # If the allowlist is empty, or anything matches, we match.
+ allowlist.empty? || allowlist.any? { |v| v == :all || v == value || platform_family_query_helper?(node, v) }
else
- # If any blacklist value matches, we don't match
- return false if blacklist.any? { |v| v[1..-1] == value }
+ # If any blocklist value matches, we don't match
+ return false if blocklist.any? { |v| v[1..-1] == value }
- # If the whitelist is empty, or anything matches, we match.
- whitelist.empty? || whitelist.any? { |v| v == :all || v == value }
+ # If the allowlist is empty, or anything matches, we match.
+ allowlist.empty? || allowlist.any? { |v| v == :all || v == value }
end
end
@@ -263,9 +263,9 @@ class Chef
end
def filters_match?(node, filters)
- matches_black_white_list?(node, filters, :os) &&
- matches_black_white_list?(node, filters, :platform_family) &&
- matches_black_white_list?(node, filters, :platform) &&
+ matches_block_allow_list?(node, filters, :os) &&
+ matches_block_allow_list?(node, filters, :platform_family) &&
+ matches_block_allow_list?(node, filters, :platform) &&
matches_version_list?(node, filters, :platform_version) &&
matches_target_mode?(filters)
end
@@ -314,8 +314,8 @@ class Chef
return -1 if !b && a
return 0 if !a && !b
- # Check for blacklists ('!windows'). Those always come *after* positive
- # whitelists.
+ # Check for blocklists ('!windows'). Those always come *after* positive
+ # allowlists.
a_negated = Array(a).any? { |f| f.is_a?(String) && f.start_with?("!") }
b_negated = Array(b).any? { |f| f.is_a?(String) && f.start_with?("!") }
return 1 if a_negated && !b_negated