Details
-
New Feature
-
Status: Resolved
-
Normal
-
Resolution: Fixed
-
None
-
Night's Watch
-
5
-
NW - 2020-03-04, NW - 2020-03-17, NW - 2020-04-01
-
Enhancement
-
-
Needs Assessment
Description
Implement SemVerRange type support for the pip provider.
Sample manifest with a range passed for a package:
package { 'Flask':
|
# this will be parsed as: >= 1.0.0 < 1.1.0
|
ensure => SemVerRange('~> 1.0')
|
}
|
|
package { 'Flask':
|
ensure => SemVerRange('>= 1')
|
}
|
|
package { 'Flask':
|
ensure => SemVerRange('< 1')
|
}
|
|
package { 'Flask':
|
# this is a valid range, but we should not support it in this provider
|
ensure => SemVerRange('~> 0.5 || ~> 1.0')
|
}
|
This value should be handled inside the pip provider code, and should be munged into a valid string for the pip 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
|
# pip requires min/max ranges to be separated by a comma
|
version.to_s.tr(' ', ',')
|
else
|
version.to_s
|
end
|
end
|
Example pip install with a version range (note the double quotes):
pip install "Flask>=1.0.0,<1.1.0"
|