summaryrefslogtreecommitdiff
path: root/lib/chef/node_map.rb
diff options
context:
space:
mode:
authorJohn Keiser <john@johnkeiser.com>2015-05-09 19:46:20 -0700
committerJohn Keiser <john@johnkeiser.com>2015-06-02 09:53:41 -0700
commit6ca512d29ae8c271e3e506d80c66d3764f45f523 (patch)
treea4c48f7f2a92cf7940c8428590e7275d87c5ffc5 /lib/chef/node_map.rb
parent1afea6b5761cf10332397b5e3f7a7350356ad3f7 (diff)
downloadchef-6ca512d29ae8c271e3e506d80c66d3764f45f523.tar.gz
Add platform_version to supported filters
Diffstat (limited to 'lib/chef/node_map.rb')
-rw-r--r--lib/chef/node_map.rb16
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/chef/node_map.rb b/lib/chef/node_map.rb
index bfa884d6d7..fd284683bd 100644
--- a/lib/chef/node_map.rb
+++ b/lib/chef/node_map.rb
@@ -132,10 +132,24 @@ class Chef
whitelist.empty? || whitelist.any? { |v| v == :all || v == value }
end
+ def matches_version_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 if !filters[attribute]
+ filter_values = Array(filters[attribute])
+ value = node[attribute]
+
+ filter_values.empty? ||
+ Array(filter_values).any? do |v|
+ Chef::VersionConstraint::Platform.new(v).include?(value)
+ end
+ 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_black_white_list?(node, filters, :platform) &&
+ matches_version_list?(node, filters, :platform_version)
end
def block_matches?(node, block)