Details
-
New Feature
-
Status: Resolved
-
Normal
-
Resolution: Fixed
-
None
-
Night's Watch
-
1
-
NW - 2020-03-04, NW - 2020-04-01, NW - 2020-04-15
-
Enhancement
-
Add support for range intersection (min,max such as: >=A <=B) specified in the :ensure manifest field. This will install a version that satisfies the provided range.
-
Needs Assessment
Description
Implement SemVerRange type support for the gem provider.
Sample manifest with a range passed for a gem:
package { 'rake':
|
# this will be parsed as: >= 13.0.0 < 13.1.0
|
ensure => SemVerRange('~> 13.0')
|
}
|
|
package { 'rake':
|
ensure => SemVerRange('>= 12')
|
}
|
|
package { 'rake':
|
ensure => SemVerRange('< 10')
|
}
|
|
package { 'rake':
|
# this is a valid range, but we should not support it
|
ensure => SemVerRange('~> 13.0 || ~> 15.0')
|
}
|
This value should be handled inside the gem provider code, and should be munged into a valid string for the gem install command. We should also make sure we don't take additional actions if the range is already satisfied (i.e. puppet apply with a SemVerRange should be idempotent)
Sample code on how the ensure property can be treated inside the provider:
if @resource.should(:ensure).is_a?(SemanticPuppet::VersionRange)
|
version = @resource.should(:ensure).ranges.first
|
|
case version
|
when SemanticPuppet::VersionRange::MinMaxRange
|
# gem requires min/max ranges to be separated by a comma
|
version.to_s.tr(' ', ',')
|
else
|
version.to_s
|
end
|
end
|
Example gem install with a version range:
gem install rake -v ">= 13.0.0,< 13.1.0"
|