From: Sergii Golovatiuk Date: Sat, 5 Dec 2015 01:04:36 +0000 (+0100) Subject: Change behavior with port in URI location X-Git-Tag: 2.2.0-rc1^0 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=19583b8a85744f914a0690060576cd189fd12dbf;p=puppet-modules%2Fpuppetlabs-apt.git Change behavior with port in URI location 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 --- diff --git a/manifests/source.pp b/manifests/source.pp index 1307a3a..d4f5b83 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -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') diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 8a2cfcc..8f32252 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -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 {