Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-10295

Add SemVerRange support to gem package provider

    XMLWordPrintable

Details

    • 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"

      Attachments

        Activity

          People

            luchian.nemes Luchian Nemes
            gabriel.nagy Gabriel Nagy
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Zendesk Support