Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proxy_* params were removed from class apt #443

Merged
merged 1 commit into from
Feb 26, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/proxy.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# TODO
5 changes: 5 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
}
}

$proxy = {
'host' => undef,
'port' => 8080,
}

$file_defaults = {
'owner' => 'root',
'group' => 'root',
Expand Down
7 changes: 5 additions & 2 deletions manifests/ppa.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
$options = $::apt::ppa_options,
$package_name = $::apt::ppa_package,
$package_manage = false,
$proxy = {},
) {
if ! $release {
fail('lsbdistcodename fact not available: release parameter required')
Expand All @@ -19,6 +20,8 @@
$filename_without_ppa = regsubst($filename_without_dots, '^ppa:', '', 'G')
$sources_list_d_filename = "${filename_without_ppa}-${release}.list"

$_proxy = merge($apt::proxy, $proxy)

if $ensure == 'present' {
if $package_manage {
package { $package_name: }
Expand All @@ -28,12 +31,12 @@
$_require = File['sources.list.d']
}

case $::apt::proxy_host {
case $_proxy['host'] {
false, '', undef: {
$_proxy_env = []
}
default: {
$_proxy_env = ["http_proxy=http://${::apt::proxy_host}:${::apt::proxy_port}", "https_proxy=http://${::apt::proxy_host}:${::apt::proxy_port}"]
$_proxy_env = ["http_proxy=http://${_proxy['host']}:${_proxy['port']}", "https_proxy=http://${_proxy['host']}:${_proxy['port']}"]
}
}

Expand Down
64 changes: 64 additions & 0 deletions spec/defines/ppa_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,70 @@
}
end

describe 'apt included, proxy host' do
let :pre_condition do
'class { "apt": }'
end
let :facts do
{
:lsbdistrelease => '14.04',
:lsbdistcodename => 'trusty',
:operatingsystem => 'Ubuntu',
:lsbdistid => 'Ubuntu',
:osfamily => 'Debian',
}
end
let :params do
{
'options' => '',
'package_manage' => true,
'proxy' => { 'host' => 'localhost', }
}
end
let(:title) { 'ppa:foo' }
it { is_expected.to contain_package('software-properties-common') }
it { is_expected.to contain_exec('add-apt-repository-ppa:foo').that_notifies('Exec[apt_update]').with({
'environment' => ['http_proxy=http://localhost:8080', 'https_proxy=http://localhost:8080'],
'command' => '/usr/bin/add-apt-repository ppa:foo',
'unless' => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list',
'user' => 'root',
'logoutput' => 'on_failure',
})
}
end

describe 'apt included, proxy host and port' do
let :pre_condition do
'class { "apt": }'
end
let :facts do
{
:lsbdistrelease => '14.04',
:lsbdistcodename => 'trusty',
:operatingsystem => 'Ubuntu',
:lsbdistid => 'Ubuntu',
:osfamily => 'Debian',
}
end
let :params do
{
'options' => '',
'package_manage' => true,
'proxy' => { 'host' => 'localhost', 'port' => 8180, }
}
end
let(:title) { 'ppa:foo' }
it { is_expected.to contain_package('software-properties-common') }
it { is_expected.to contain_exec('add-apt-repository-ppa:foo').that_notifies('Exec[apt_update]').with({
'environment' => ['http_proxy=http://localhost:8180', 'https_proxy=http://localhost:8180'],
'command' => '/usr/bin/add-apt-repository ppa:foo',
'unless' => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list',
'user' => 'root',
'logoutput' => 'on_failure',
})
}
end

describe 'ensure absent' do
let :pre_condition do
'class { "apt": }'
Expand Down