Skip to content

Commit cee47c6

Browse files
committed
Add backward-compatibility for deb822 sources
Convert string values to arrays where possible and warn the user.
1 parent 9d88e93 commit cee47c6

File tree

1 file changed

+43
-11
lines changed

1 file changed

+43
-11
lines changed

manifests/source.pp

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -313,30 +313,62 @@
313313
}
314314
}
315315
'sources': {
316+
$_file_suffix = $source_format
317+
316318
if $pin {
317-
fail('apt::source::pin parameter is not supported with deb822 format')
319+
warning('apt::source::pin parameter is not supported with deb822 format.')
318320
}
319-
if !$uris {
321+
322+
if !$location {
320323
fail('You must specify a list of URIs for the apt::source resource')
321324
}
322-
if !$suites {
323-
fail('You must specify a list of suites for the apt::source resource')
325+
if (type($location =~ String)) {
326+
warning('For deb822 sources, location must be specified as an array.')
327+
$_location = [$location]
324328
}
325-
if !$components {
326-
fail('You must specify a list of components for the apt::source resource')
329+
else {
330+
$_location = $location
327331
}
328-
$_file_suffix = $source_format
332+
333+
if !$release {
334+
if fact('os.distro.codename') {
335+
$_release = [fact('os.distro.codename')]
336+
} else {
337+
fail('os.distro.codename fact not available: release parameter required')
338+
}
339+
} else {
340+
if (type($release) =~ String) {
341+
warning("For deb822 sources, 'release' must be specified as an array. Converting to array.")
342+
$_release = [$release]
343+
}
344+
}
345+
346+
if (type($repos) =~ String) {
347+
warning("For deb822 sources, 'repos' must be specified as an array. Converting to array.")
348+
$_repos = split($repos, /\s+/)
349+
} else {
350+
$_repos = $repos
351+
}
352+
353+
if (type($architecture =~ String)) {
354+
warning("For deb822 sources, 'architecture' must be specified as an array. Converting to array.")
355+
$_architecture = split($architecture, '[,]')
356+
}
357+
else {
358+
$_architecture = $architecture
359+
}
360+
329361
case $ensure {
330362
'present': {
331363
$header = epp('apt/_header.epp')
332364
$source_content = epp('apt/source_deb822.epp', delete_undef_values({
333-
'uris' => $uris,
334-
'suites' => $suites,
335-
'components' => $components,
365+
'uris' => $_location,
366+
'suites' => $_release,
367+
'components' => $_repos,
336368
'types' => $types,
337369
'comment' => $comment,
338370
'enabled' => $enabled ? { true => 'yes', false => 'no' },
339-
'architectures' => $architectures,
371+
'architectures' => $_architecture,
340372
'allow_insecure' => $allow_insecure ? { true => 'yes', false => 'no', default => undef },
341373
'repo_trusted' => $repo_trusted ? { true => 'yes', false => 'no', default => undef },
342374
'check_valid_until' => $check_valid_until ? { true => 'yes', false => 'no', default => undef },

0 commit comments

Comments
 (0)