diff options
Diffstat (limited to 'lib/chef')
-rw-r--r-- | lib/chef/platform.rb | 17 | ||||
-rw-r--r-- | lib/chef/version_class.rb | 2 |
2 files changed, 12 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 diff --git a/lib/chef/version_class.rb b/lib/chef/version_class.rb index e9879274ad..36ff05a46d 100644 --- a/lib/chef/version_class.rb +++ b/lib/chef/version_class.rb @@ -60,6 +60,8 @@ class Chef [ $1.to_i, $2.to_i, $3.to_i ] when /^(\d+)\.(\d+)$/ [ $1.to_i, $2.to_i, 0 ] + when /^(\d+)$/ + [ $1.to_i, 0, 0 ] else msg = "'#{str.to_s}' does not match 'x.y.z' or 'x.y'" raise Chef::Exceptions::InvalidCookbookVersion.new( msg ) |