(FM-7320) - Removed assert_type statements
[puppet-modules/puppetlabs-apt.git] / manifests / key.pp
index 8f9d66bcc9a1bf2b45742fec5007a9a849a98f31..7eaf4d9f6515902c007d0ccb7cf21300e34cb6da 100644 (file)
@@ -1,22 +1,12 @@
 # == Define: apt::key
 define apt::key (
-    String $id                           = $title,
-    Enum['present', 'absent'] $ensure    = present,
-    Optional[String] $content            = undef,
-    Optional[String] $source             = undef,
-    String $server                       = $::apt::keyserver,
-    Optional[String] $options            = undef,
-    ) {
-
-  validate_re($id, ['\A(0x)?[0-9a-fA-F]{8}\Z', '\A(0x)?[0-9a-fA-F]{16}\Z', '\A(0x)?[0-9a-fA-F]{40}\Z'])
-
-  if $source {
-    validate_re($source, ['\Ahttps?:\/\/', '\Aftp:\/\/', '\A\/\w+'])
-  }
-
-  if $server {
-    validate_re($server,['\A((hkp|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?$'])
-  }
+  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'] $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,
+  ) {
 
   case $ensure {
     present: {
@@ -36,17 +26,15 @@ define apt::key (
 
         case $facts['os']['name'] {
           'Debian': {
-            if versioncmp($facts['os']['release']['full'], '9.0') >= 0 {
-              Apt::Key<| title == $title |> {
-                require => Package['dirmngr']
-              }
+            if versioncmp($facts['os']['release']['major'], '9') >= 0 {
+              ensure_packages(['dirmngr'])
+              Apt::Key<| title == $title |>
             }
           }
           'Ubuntu': {
             if versioncmp($facts['os']['release']['full'], '17.04') >= 0 {
-              Apt::Key<| title == $title |> {
-                require => Package['dirmngr']
-              }
+              ensure_packages(['dirmngr'])
+              Apt::Key<| title == $title |>
             }
           }
           default: { }