Introduce an Apt::Proxy type to validate the hash
authorEwoud Kohl van Wijngaarden <ewoud@kohlvanwijngaarden.nl>
Thu, 26 Jul 2018 11:57:51 +0000 (13:57 +0200)
committerEwoud Kohl van Wijngaarden <ewoud@kohlvanwijngaarden.nl>
Thu, 26 Jul 2018 11:57:51 +0000 (13:57 +0200)
manifests/init.pp
types/proxy.pp [new file with mode: 0644]

index 06dc0acf458e07155db933198999552340489467..8aa8c6bb660367a61b3486eb2ada0f06901bb64f 100644 (file)
@@ -15,7 +15,7 @@ class apt (
   Hash $confs                   = $apt::params::confs,
   Hash $update                  = $apt::params::update,
   Hash $purge                   = $apt::params::purge,
-  Hash $proxy                   = $apt::params::proxy,
+  Apt::Proxy $proxy             = $apt::params::proxy,
   Hash $sources                 = $apt::params::sources,
   Hash $keys                    = $apt::params::keys,
   Hash $ppas                    = $apt::params::ppas,
@@ -67,23 +67,6 @@ class apt (
   }
 
   $_purge = merge($::apt::purge_defaults, $purge)
-
-  if $proxy['ensure'] {
-    assert_type(Enum['file', 'present', 'absent'], $proxy['ensure'])
-  }
-  if $proxy['host'] {
-    assert_type(String, $proxy['host'])
-  }
-  if $proxy['port'] {
-    assert_type(Integer, $proxy['port'])
-  }
-  if $proxy['https']{
-    assert_type(Boolean, $proxy['https'])
-  }
-  if $proxy['direct']{
-    assert_type(Boolean, $proxy['direct'])
-  }
-
   $_proxy = merge($apt::proxy_defaults, $proxy)
 
   $confheadertmp = epp('apt/_conf_header.epp')
diff --git a/types/proxy.pp b/types/proxy.pp
new file mode 100644 (file)
index 0000000..297bf1b
--- /dev/null
@@ -0,0 +1,9 @@
+type Apt::Proxy = Struct[
+  {
+    ensure => Optional[Enum['file', 'present', 'absent']],
+    host   => Optional[String],
+    port   => Optional[Integer[0, 65535]],
+    https  => Optional[Boolean],
+    direct => Optional[Boolean],
+  }
+]