Skip to content

Commit

Permalink
Merge pull request #4 from bastelfreak/validate
Browse files Browse the repository at this point in the history
replace legacy is_array/is_string with native datatype checks
  • Loading branch information
bastelfreak committed Feb 27, 2024
2 parents bb0f467 + 9b9f4c7 commit 3c96da3
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions manifests/mirror.pp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Default: []
define aptly::mirror (
String $location,
Variant[String, Hash] $key = {},
Variant[String[1], Hash[String[1],Variant[Integer[1],String[1]]]] $key = {},
String $keyring = '/etc/apt/trusted.gpg',
String $filter = '',
String $release = $::lsbdistcodename,
Expand Down Expand Up @@ -100,12 +100,10 @@
# $::aptly::key_server will be used as default key server
# key in hash format
if $key =~ Hash and $key[id] {
if is_array($key[id]) {
if $key[id] =~ Array {
$key_string = join($key[id], "' '")
} elsif is_string($key[id]) or is_integer($key[id]) {
$key_string = $key[id]
} else {
fail('$key[id] is neither a string nor an array!')
$key_string = $key[id]
}
if $key[server] {
$key_server = $key[server]
Expand All @@ -114,15 +112,9 @@
}

# key in string/array format
}elsif is_string($key) or is_array($key) {
} elsif $key =~ String {
$key_server = $::aptly::key_server
if is_array($key) {
$key_string = join($key, "' '")
} elsif is_string($key) or is_integer($key) {
$key_string = $key
} else {
fail('$key is neither a string nor an array!')
}
$key_string = $key
}

# no GPG key
Expand Down

0 comments on commit 3c96da3

Please sign in to comment.