Skip to content

Commit 39adff0

Browse files
authored
Merge pull request #1214 from ekohl/simplify-conditionals
Shorten the conditionals in apt::source
2 parents 966d39c + 762f688 commit 39adff0

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

manifests/source.pp

+10-18
Original file line numberDiff line numberDiff line change
@@ -288,11 +288,10 @@
288288
fail('cannot create a source entry without specifying a location')
289289
}
290290
}
291-
if (type($location, 'generalized') !~ Type[Array]) {
291+
if $location !~ Array {
292292
warning('For deb822 sources, location must be specified as an array.')
293293
$_location = [$location]
294-
}
295-
else {
294+
} else {
296295
$_location = $location
297296
}
298297

@@ -302,30 +301,23 @@
302301
} else {
303302
fail('os.distro.codename fact not available: release parameter required')
304303
}
304+
} elsif $release !~ Array {
305+
warning("For deb822 sources, 'release' must be specified as an array. Converting to array.")
306+
$_release = [$release]
305307
} else {
306-
if (type($release, 'generalized') !~ Type[Array]) {
307-
warning("For deb822 sources, 'release' must be specified as an array. Converting to array.")
308-
$_release = [$release]
309-
} else {
310-
$_release = $release
311-
}
308+
$_release = $release
312309
}
313310

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

321-
if $architecture != undef {
322-
if (type($architecture, 'generalized') !~ Type[Array]) {
323-
warning("For deb822 sources, 'architecture' must be specified as an array. Converting to array.")
324-
$_architecture = split($architecture, '[,]')
325-
}
326-
else {
327-
$_architecture = $architecture
328-
}
318+
if $architecture and $architecture !~ Array {
319+
warning("For deb822 sources, 'architecture' must be specified as an array. Converting to array.")
320+
$_architecture = split($architecture, '[,]')
329321
} else {
330322
$_architecture = $architecture
331323
}

0 commit comments

Comments
 (0)