From: Erick Banks Date: Wed, 14 Aug 2019 20:59:35 +0000 (-0700) Subject: Merge pull request #873 from raphink/default_key_options X-Git-Tag: v7.2.0~9 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=d871d7f81d2de0071490be201bc90419083c25b8;hp=bfab353ff609b0cc725a212a879ad6f7a7e4e8de;p=puppet-modules%2Fpuppetlabs-apt.git Merge pull request #873 from raphink/default_key_options Add apt::key_options for default apt::key options --- diff --git a/manifests/init.pp b/manifests/init.pp index 9c6a44b..f205b3e 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -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. # @@ -122,6 +125,7 @@ class apt ( 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, diff --git a/manifests/key.pp b/manifests/key.pp index 1f9a495..41e78e6 100644 --- a/manifests/key.pp +++ b/manifests/key.pp @@ -42,7 +42,7 @@ define apt::key ( 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 { diff --git a/manifests/params.pp b/manifests/params.pp index 65219fe..b0c367c 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -18,6 +18,7 @@ class apt::params { $preferences_d = "${root}/preferences.d" $apt_conf_d = "${root}/apt.conf.d" $keyserver = 'keyserver.ubuntu.com' + $key_options = undef $confs = {} $update = {} $purge = {} diff --git a/spec/defines/key_spec.rb b/spec/defines/key_spec.rb index 68d5fce..ad715d6 100644 --- a/spec/defines/key_spec.rb +++ b/spec/defines/key_spec.rb @@ -379,4 +379,30 @@ describe 'apt::key' do 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