summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJordan Evans <jordane@osuosl.org>2014-08-04 16:01:05 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2014-08-21 12:37:11 -0700
commit010c8273f5c7bbeccc1d5a625eac3872a38e25fd (patch)
tree9434a95a0b46c194fd68ad798471f3f987c5b17a /lib
parent2f69b6f047b71f0cec450d37ca3edacfc882f2e7 (diff)
downloadchef-010c8273f5c7bbeccc1d5a625eac3872a38e25fd.tar.gz
use Chef::VersionConstraint, not Gem in value_for_platform
Diffstat (limited to 'lib')
-rw-r--r--lib/chef/dsl/platform_introspection.rb20
1 files changed, 15 insertions, 5 deletions
diff --git a/lib/chef/dsl/platform_introspection.rb b/lib/chef/dsl/platform_introspection.rb
index a093b933e5..e4ee75b4c8 100644
--- a/lib/chef/dsl/platform_introspection.rb
+++ b/lib/chef/dsl/platform_introspection.rb
@@ -71,18 +71,28 @@ class Chef
begin
platform, version = node[:platform].to_s, node[:platform_version].to_s
return unless @values.key?(platform)
- node_version = Gem::Version.new(version)
+ node_version = Chef::Version::Platform.new(version)
keys = @values[platform].keys
keys.each do |k|
- if Gem::Requirement.new(k).satisfied_by?(node_version)
+ begin
+ if Chef::VersionConstraint.new(k).include?(node_version)
return @values[platform][k]
- break
+ end
+ rescue Chef::Exceptions::InvalidVersionConstraint => e
+ Chef::Log.debug "Caught InvalidVersionConstraint. This means that a key in value_for_platform cannot be interpreted as a Chef::VersionConstraint."
+ Chef::Log.debug(e)
end
end
return nil
- rescue ArgumentError
+ rescue Chef::Exceptions::InvalidCookbookVersion => e
# Lets not break because someone passes a weird string like 'default' :)
- return
+ Chef::Log.debug(e)
+ Chef::Log.debug "InvalidCookbookVersion exceptions are common and expected here: the generic constraint matcher attempted to match something which is not a constraint. Moving on to next version or constraint"
+ return nil
+ rescue Chef::Exceptions::InvalidPlatformVersion => e
+ Chef::Log.debug "Caught InvalidPlatformVersion, this means that Chef::Version::Platform does not know how to turn #{node_version} into an x.y.z format"
+ Chef::Log.debug(e)
+ return nil
end
end