]> review.fuel-infra Code Review - puppet-modules/puppetlabs-apt.git/commitdiff
Merge pull request #819 from rodjek/epp-files-lf
authordavid22swan <david.swan@puppet.com>
Fri, 2 Nov 2018 12:22:43 +0000 (12:22 +0000)
committerGitHub <noreply@github.com>
Fri, 2 Nov 2018 12:22:43 +0000 (12:22 +0000)
(maint) Prefer LF over CRLF line endings for .epp files

REFERENCE.md
lib/puppet/type/apt_key.rb
manifests/key.pp
spec/acceptance/apt_key_provider_spec.rb

index faef86cab89fc48b340810d79f04813d04ce46f1..081866dcd89c67be39c737977c75bae1748030ca 100644 (file)
@@ -65,8 +65,8 @@ Default value: $apt::params::provider
 
 Data type: `String`
 
-Specifies a keyserver to provide the GPG key. Valid options: a string containing a domain name or a full URL (http://, https://, or
-hkp://).
+Specifies a keyserver to provide the GPG key. Valid options: a string containing a domain name or a full URL (http://, https://,
+hkp:// or hkps://). The hkps:// protocol is currently only supported on Ubuntu 18.04.
 
 Default value: $apt::params::keyserver
 
@@ -481,10 +481,10 @@ Default value: `undef`
 
 ##### `server`
 
-Data type: `Pattern[/\A((hkp|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?$/]`
+Data type: `Pattern[/\A((hkp|hkps|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?$/]`
 
-Specifies a keyserver to provide the GPG key. Valid options: a string containing a domain name or a full URL (http://, https://, or
-hkp://).
+Specifies a keyserver to provide the GPG key. Valid options: a string containing a domain name or a full URL (http://, https://,
+hkp:// or hkps://). The hkps:// protocol is currently only supported on Ubuntu 18.04.
 
 Default value: $::apt::keyserver
 
index 72f56fa1c3708a6afc927693a4a05d66f9bf65ef..467f568af4a74ff475fb2ed77da0e2c31298dc16 100644 (file)
@@ -68,7 +68,7 @@ Puppet::Type.newtype(:apt_key) do
     desc 'The key server to fetch the key from based on the ID. It can either be a domain name or url.'
     defaultto :'keyserver.ubuntu.com'
 
-    newvalues(%r{\A((hkp|http|https)://)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?$})
+    newvalues(%r{\A((hkp|hkps|http|https)://)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?$})
   end
 
   newparam(:options) do
index 9387899ad954d473a3fd8da5cfce7c93644f1ae2..13b477060d679786677697db0fab9a1b60dc61d5 100644 (file)
 #   an absolute path.
 #
 # @param server
-#   Specifies a keyserver to provide the GPG key. Valid options: a string containing a domain name or a full URL (http://, https://, or 
-#   hkp://).
+#   Specifies a keyserver to provide the GPG key. Valid options: a string containing a domain name or a full URL (http://, https://,
+#   hkp:// or hkps://). The hkps:// protocol is currently only supported on Ubuntu 18.04.
 #
 # @param options
 #   Passes additional options to `apt-key adv --keyserver-options`.
 #
 define apt::key (
-  Pattern[/\A(0x)?[0-9a-fA-F]{8}\Z/, /\A(0x)?[0-9a-fA-F]{16}\Z/, /\A(0x)?[0-9a-fA-F]{40}\Z/] $id = $title,
-  Enum['present', 'absent', 'refreshed'] $ensure                                                 = present,
-  Optional[String] $content                                                                      = undef,
-  Optional[Pattern[/\Ahttps?:\/\//, /\Aftp:\/\//, /\A\/\w+/]] $source                            = undef,
-  Pattern[/\A((hkp|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?$/] $server  = $::apt::keyserver,
-  Optional[String] $options                                                                      = undef,
+  Pattern[/\A(0x)?[0-9a-fA-F]{8}\Z/, /\A(0x)?[0-9a-fA-F]{16}\Z/, /\A(0x)?[0-9a-fA-F]{40}\Z/] $id     = $title,
+  Enum['present', 'absent', 'refreshed'] $ensure                                                     = present,
+  Optional[String] $content                                                                          = undef,
+  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,
+  Optional[String] $options                                                                          = undef,
   ) {
 
   case $ensure {
index ae278fb6a94bf730f88391c206eaaff83398c3d5..43ddf9a406bd3d3f6b793e4de69b194d7b105c83 100644 (file)
@@ -478,6 +478,19 @@ hkp_pool_pp = <<-MANIFEST
         }
   MANIFEST
 
+hkps_protocol_supported = fact('operatingsystem') =~ %r{Ubuntu} && \
+                          fact('operatingsystemrelease') =~ %r{^18\.04}
+
+if hkps_protocol_supported
+  hkps_ubuntu_pp = <<-MANIFEST
+          apt_key { 'puppetlabs':
+            id     => '#{PUPPETLABS_GPG_KEY_LONG_ID}',
+            ensure => 'present',
+            server => 'hkps://keyserver.ubuntu.com',
+          }
+    MANIFEST
+end
+
 nonexistant_key_server_pp = <<-MANIFEST
         apt_key { 'puppetlabs':
           id     => '#{PUPPETLABS_GPG_KEY_LONG_ID}',
@@ -786,6 +799,19 @@ describe 'apt_key' do
       end
     end
 
+    if hkps_protocol_supported
+      context 'with hkps://keyserver.ubuntu.com' do
+        it 'works' do
+          retry_on_error_matching do
+            apply_manifest(hkps_ubuntu_pp, catch_failures: true)
+          end
+
+          apply_manifest(hkps_ubuntu_pp, catch_changes: true)
+          shell(PUPPETLABS_KEY_CHECK_COMMAND)
+        end
+      end
+    end
+
     context 'with nonexistant.key.server' do
       it 'fails' do
         apply_manifest(nonexistant_key_server_pp, expect_failures: true) do |r|