X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=manifests%2Fsource.pp;h=a95bc592f98d03749076786faae1f0932ff5da35;hb=90f5fdbce44d5fe61a70fb2129e01785e95c3218;hp=be743eb26ca207fc9a3c2b09f82a52caff3ae494;hpb=a541b4ee32ea39f3eb23d4ffa3311daba61d1118;p=puppet-modules%2Fpuppetlabs-apt.git diff --git a/manifests/source.pp b/manifests/source.pp index be743eb..a95bc59 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -1,17 +1,17 @@ # source.pp # add an apt source define apt::source( - Optional[String] $location = undef, - String $comment = $name, - String $ensure = present, - Optional[String] $release = undef, - String $repos = 'main', - Optional[Variant[Hash]] $include = {}, - Optional[Variant[String, Hash]] $key = undef, - $pin = undef, - Optional[String] $architecture = undef, - Boolean $allow_unsigned = false, - Boolean $notify_update = true, + Optional[String] $location = undef, + String $comment = $name, + String $ensure = present, + Optional[String] $release = undef, + String $repos = 'main', + Optional[Variant[Hash]] $include = {}, + Optional[Variant[String, Hash]] $key = undef, + Optional[Variant[Hash, Numeric, String]] $pin = undef, + Optional[String] $architecture = undef, + Boolean $allow_unsigned = false, + Boolean $notify_update = true, ) { # This is needed for compat with 1.8.x @@ -36,14 +36,13 @@ define apt::source( $includes = merge($::apt::include_defaults, $include) if $key { - if is_hash($key) { + if $key =~ Hash { unless $key['id'] { fail('key hash must contain at least an id entry') } $_key = merge($::apt::source_key_defaults, $key) } else { - validate_legacy(String, 'validate_string', $key) - $_key = { 'id' => $key } + $_key = { 'id' => assert_type(String[1], $key) } } } @@ -66,9 +65,9 @@ define apt::source( } if $pin { - if is_hash($pin) { + if $pin =~ Hash { $_pin = merge($pin, { 'ensure' => $ensure, 'before' => $_before }) - } elsif (is_numeric($pin) or is_string($pin)) { + } elsif ($pin =~ Numeric or $pin =~ String) { $url_split = split($location, '[:\/]+') $host = $url_split[1] $_pin = { @@ -85,7 +84,7 @@ define apt::source( # We do not want to remove keys when the source is absent. if $key and ($ensure == 'present') { - if is_hash($_key) { + if $_key =~ Hash { apt::key { "Add key: ${$_key['id']} from Apt::Source ${title}": ensure => present, id => $_key['id'],