]> review.fuel-infra Code Review - puppet-modules/puppetlabs-apt.git/commitdiff
Change behavior with port in URI location 49/14449/1 2.2.0-mos 2.2.0-rc1
authorSergii Golovatiuk <sgolovatiuk@mirantis.com>
Sat, 5 Dec 2015 01:04:36 +0000 (02:04 +0100)
committerBartłomiej Piotrowski <bpiotrowski@mirantis.com>
Mon, 7 Dec 2015 10:05:53 +0000 (11:05 +0100)
When location contains port in URI, pinning policy are set to default
(500) even if config has higher value. This patch strips port from URI
leaving Host only.

Pull request: https://github.com/puppetlabs/puppetlabs-apt/pull/574
Related-bug: 1508486

Change-Id: I5f3804f1f8929c0741dd639271961d543f8c557f

manifests/source.pp
spec/defines/source_spec.rb

index 1307a3a552be523dfd02f988066eccf47ced7b2a..d4f5b83b497237d97fb3da272c0ff2777fa30367 100644 (file)
@@ -123,12 +123,12 @@ define apt::source(
       $_pin = merge($pin, { 'ensure' => $ensure, 'before' => $_before })
     } elsif (is_numeric($pin) or is_string($pin)) {
       $url_split = split($location, '/')
-      $host      = $url_split[2]
+      $host      = split($url_split[2], ':')
       $_pin = {
         'ensure'   => $ensure,
         'priority' => $pin,
         'before'   => $_before,
-        'origin'   => $host,
+        'origin'   => $host[0],
       }
     } else {
       fail('Received invalid value for pin parameter')
index 8a2cfcc7475698bb477061131c885475eb15ea28..8f322527f99256e54bc1d614722e873f3053246f 100644 (file)
@@ -81,6 +81,22 @@ describe 'apt::source' do
       }
     end
 
+    context 'with complex location' do
+      let :params do
+        {
+          :comment  => 'foo',
+          :location => 'http://10.0.0.1:8000/debian/',
+          :release  => 'sid',
+          :repos    => 'testing',
+          :pin      => '1050',
+        }
+      end
+      it { is_expected.to contain_apt__pin('my_source').with({
+        :origin   => '10.0.0.1',
+      })
+      }
+    end
+
     context 'with simple key' do
       let :params do
         {