Skip to content

Commit

Permalink
Merge pull request #873 from raphink/default_key_options
Browse files Browse the repository at this point in the history
Add apt::key_options for default apt::key options
  • Loading branch information
Erick Banks authored Aug 14, 2019
2 parents bfab353 + 0de37ff commit d871d7f
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
4 changes: 4 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
# Specifies a keyserver to provide the GPG key. Valid options: a string containing a domain name or a full URL (http://, https://, or
# hkp://).
#
# @param key_options
# Specifies the default options for apt::key resources.
#
# @param ppa_options
# Supplies options to be passed to the `add-apt-repository` command.
#
Expand Down Expand Up @@ -122,6 +125,7 @@
Hash $include_defaults = $apt::params::include_defaults,
String $provider = $apt::params::provider,
String $keyserver = $apt::params::keyserver,
Optional[String] $key_options = $apt::params::key_options,
Optional[String] $ppa_options = $apt::params::ppa_options,
Optional[String] $ppa_package = $apt::params::ppa_package,
Optional[Hash] $backports = $apt::params::backports,
Expand Down
2 changes: 1 addition & 1 deletion manifests/key.pp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
Optional[Pattern[/\Ahttps?:\/\//, /\Aftp:\/\//, /\A\/\w+/]] $source = undef,
Pattern[/\A((hkp|hkps|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?$/] $server = $::apt::keyserver,
Boolean $weak_ssl = false,
Optional[String] $options = undef,
Optional[String] $options = $::apt::key_options,
) {

case $ensure {
Expand Down
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
$preferences_d = "${root}/preferences.d"
$apt_conf_d = "${root}/apt.conf.d"
$keyserver = 'keyserver.ubuntu.com'
$key_options = undef
$confs = {}
$update = {}
$purge = {}
Expand Down
26 changes: 26 additions & 0 deletions spec/defines/key_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -379,4 +379,30 @@ def absent_apt_key(title)
end
end
end

describe 'defaults' do
context 'when setting keyserver on the apt class' do
let :pre_condition do
'class { "apt":
keyserver => "keyserver.example.com",
}'
end

it 'uses default keyserver' do
is_expected.to contain_apt_key(title).with_server('keyserver.example.com')
end
end

context 'when setting key_options on the apt class' do
let :pre_condition do
'class { "apt":
key_options => "http-proxy=http://proxy.example.com:8080",
}'
end

it 'uses default keyserver' do
is_expected.to contain_apt_key(title).with_options('http-proxy=http://proxy.example.com:8080')
end
end
end
end

0 comments on commit d871d7f

Please sign in to comment.