Skip to content

Commit

Permalink
Merge pull request #1214 from ekohl/simplify-conditionals
Browse files Browse the repository at this point in the history
Shorten the conditionals in apt::source
  • Loading branch information
bastelfreak authored Jan 6, 2025
2 parents 966d39c + 762f688 commit 39adff0
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions manifests/source.pp
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,10 @@
fail('cannot create a source entry without specifying a location')
}
}
if (type($location, 'generalized') !~ Type[Array]) {
if $location !~ Array {
warning('For deb822 sources, location must be specified as an array.')
$_location = [$location]
}
else {
} else {
$_location = $location
}

Expand All @@ -302,30 +301,23 @@
} else {
fail('os.distro.codename fact not available: release parameter required')
}
} elsif $release !~ Array {
warning("For deb822 sources, 'release' must be specified as an array. Converting to array.")
$_release = [$release]
} else {
if (type($release, 'generalized') !~ Type[Array]) {
warning("For deb822 sources, 'release' must be specified as an array. Converting to array.")
$_release = [$release]
} else {
$_release = $release
}
$_release = $release
}

if (type($repos, 'generalized') !~ Type[Array]) {
if $repos !~ Array {
warning("For deb822 sources, 'repos' must be specified as an array. Converting to array.")
$_repos = split($repos, /\s+/)
} else {
$_repos = $repos
}

if $architecture != undef {
if (type($architecture, 'generalized') !~ Type[Array]) {
warning("For deb822 sources, 'architecture' must be specified as an array. Converting to array.")
$_architecture = split($architecture, '[,]')
}
else {
$_architecture = $architecture
}
if $architecture and $architecture !~ Array {
warning("For deb822 sources, 'architecture' must be specified as an array. Converting to array.")
$_architecture = split($architecture, '[,]')
} else {
$_architecture = $architecture
}
Expand Down

0 comments on commit 39adff0

Please sign in to comment.