Skip to content

Commit b1d1a97

Browse files
jps-helpjamesps-ebi
authored andcommitted
Add backward-compatibility for deb822 sources
Convert string values to arrays where possible and warn the user.
1 parent ebe5ee2 commit b1d1a97

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
@@ -316,30 +316,62 @@
316316
}
317317
}
318318
'sources': {
319+
$_file_suffix = $source_format
320+
319321
if $pin {
320-
fail('apt::source::pin parameter is not supported with deb822 format')
322+
warning('apt::source::pin parameter is not supported with deb822 format.')
321323
}
322-
if !$uris {
324+
325+
if !$location {
323326
fail('You must specify a list of URIs for the apt::source resource')
324327
}
325-
if !$suites {
326-
fail('You must specify a list of suites for the apt::source resource')
328+
if (type($location =~ String)) {
329+
warning('For deb822 sources, location must be specified as an array.')
330+
$_location = [$location]
327331
}
328-
if !$components {
329-
fail('You must specify a list of components for the apt::source resource')
332+
else {
333+
$_location = $location
330334
}
331-
$_file_suffix = $source_format
335+
336+
if !$release {
337+
if fact('os.distro.codename') {
338+
$_release = [fact('os.distro.codename')]
339+
} else {
340+
fail('os.distro.codename fact not available: release parameter required')
341+
}
342+
} else {
343+
if (type($release) =~ String) {
344+
warning("For deb822 sources, 'release' must be specified as an array. Converting to array.")
345+
$_release = [$release]
346+
}
347+
}
348+
349+
if (type($repos) =~ String) {
350+
warning("For deb822 sources, 'repos' must be specified as an array. Converting to array.")
351+
$_repos = split($repos, /\s+/)
352+
} else {
353+
$_repos = $repos
354+
}
355+
356+
if (type($architecture =~ String)) {
357+
warning("For deb822 sources, 'architecture' must be specified as an array. Converting to array.")
358+
$_architecture = split($architecture, '[,]')
359+
}
360+
else {
361+
$_architecture = $architecture
362+
}
363+
332364
case $ensure {
333365
'present': {
334366
$header = epp('apt/_header.epp')
335367
$source_content = epp('apt/source_deb822.epp', delete_undef_values({
336-
'uris' => $uris,
337-
'suites' => $suites,
338-
'components' => $components,
368+
'uris' => $_location,
369+
'suites' => $_release,
370+
'components' => $_repos,
339371
'types' => $types,
340372
'comment' => $comment,
341373
'enabled' => $enabled ? { true => 'yes', false => 'no' },
342-
'architectures' => $architectures,
374+
'architectures' => $_architecture,
343375
'allow_insecure' => $allow_insecure ? { true => 'yes', false => 'no', default => undef },
344376
'repo_trusted' => $repo_trusted ? { true => 'yes', false => 'no', default => undef },
345377
'check_valid_until' => $check_valid_until ? { true => 'yes', false => 'no', default => undef },

0 commit comments

Comments
 (0)