From 3454627d0c8b7c6763c7f5d10bddace6847ec170 Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Thu, 26 Jul 2018 13:57:51 +0200 Subject: [PATCH] Introduce an Apt::Proxy type to validate the hash --- manifests/init.pp | 19 +------------------ types/proxy.pp | 9 +++++++++ 2 files changed, 10 insertions(+), 18 deletions(-) create mode 100644 types/proxy.pp diff --git a/manifests/init.pp b/manifests/init.pp index 06dc0ac..8aa8c6b 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -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 index 0000000..297bf1b --- /dev/null +++ b/types/proxy.pp @@ -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], + } +] -- 2.32.3