summaryrefslogtreecommitdiff
path: root/lib/chef/platform.rb
diff options
context:
space:
mode:
authorXabier de Zuazo <xabier@zuazo.org>2013-02-08 11:59:54 +0100
committerBryan McLellan <btm@opscode.com>2013-04-11 13:04:33 -0700
commit66d5485de8342a1e6f719547222c98dd6012908a (patch)
treef6b1487de8dce80f12bbc7c481a01a837cf81af7 /lib/chef/platform.rb
parentdcfeebe24ab048d555fd70ff5f22fae868548ab4 (diff)
downloadchef-66d5485de8342a1e6f719547222c98dd6012908a.tar.gz
[CHEF-3919] Added support for setting ">", "<", "<=" ... versions in Chef::Platform
Diffstat (limited to 'lib/chef/platform.rb')
-rw-r--r--lib/chef/platform.rb17
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/chef/platform.rb b/lib/chef/platform.rb
index b176e9c731..f7c94072a1 100644
--- a/lib/chef/platform.rb
+++ b/lib/chef/platform.rb
@@ -19,6 +19,7 @@
require 'chef/config'
require 'chef/log'
require 'chef/mixin/params_validate'
+require 'chef/version_constraint'
# This file depends on nearly every provider in chef, but requiring them
# directly causes circular requires resulting in uninitialized constant errors.
@@ -344,15 +345,17 @@ class Chef
end
if platforms.has_key?(name_sym)
- if platforms[name_sym].has_key?(version)
- Chef::Log.debug("Platform #{name.to_s} version #{version} found")
- if platforms[name_sym].has_key?(:default)
- provider_map.merge!(platforms[name_sym][:default])
- end
- provider_map.merge!(platforms[name_sym][version])
- elsif platforms[name_sym].has_key?(:default)
+ platform_versions = platforms[name_sym].select {|k, v| k != :default }
+ if platforms[name_sym].has_key?(:default)
provider_map.merge!(platforms[name_sym][:default])
end
+ platform_versions.each do |platform_version, provider|
+ version_constraint = Chef::VersionConstraint.new(platform_version)
+ if version_constraint.include?(version)
+ Chef::Log.debug("Platform #{name.to_s} version #{version} found")
+ provider_map.merge!(provider)
+ end
+ end
else
Chef::Log.debug("Platform #{name} not found, using all defaults. (Unsupported platform?)")
end