Skip to content

Commit 2fb1ed7

Browse files
committed
Fix deb822 backward compatibility
Correctly compare data type when generating deb822 sources Remove unused class parameters and descriptions
1 parent 57d70a7 commit 2fb1ed7

File tree

1 file changed

+23
-47
lines changed

1 file changed

+23
-47
lines changed

manifests/source.pp

Lines changed: 23 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@
3939
# @param types
4040
# DEB822: The package types this source manages.
4141
#
42-
# @param uris
43-
# DEB822: A list of URIs for the APT source.
44-
#
4542
# @param enabled
4643
# DEB822: Enable or Disable the APT source.
4744
#
@@ -54,15 +51,9 @@
5451
# @param release
5552
# Specifies a distribution of the Apt repository.
5653
#
57-
# @param suites
58-
# DEB822: A list of suites for the APT source ('jammy-updates', 'bookworm', 'stable', etc.).
59-
#
6054
# @param repos
6155
# Specifies a component of the Apt repository.
6256
#
63-
# @param components
64-
# DEB822: A list of components for the APT source ('main', 'contrib', 'non-free', etc.).
65-
#
6657
# @param include
6758
# Configures include options. Valid options: a hash of available keys.
6859
#
@@ -85,9 +76,6 @@
8576
# This is not necessary if the key is installed with `key` param above.
8677
# See https://wiki.debian.org/DebianRepository/UseThirdParty for details.
8778
#
88-
# @param signed_by
89-
# DEB822: Either an absolute path to a PGP keyring file used to sign this repository OR a list of key fingerprints to trust.
90-
#
9179
# @param pin
9280
# Creates a declaration of the apt::pin defined type. Valid options: a number or string to be passed to the `id` parameter of the
9381
# `apt::pin` defined type, or a hash of `parameter => value` pairs to be passed to `apt::pin`'s corresponding parameters.
@@ -97,15 +85,9 @@
9785
# separated by commas (e.g., 'i386' or 'i386,alpha,powerpc').
9886
# (if unspecified, Apt downloads information for all architectures defined in the Apt::Architectures option)
9987
#
100-
# @param architectures
101-
# DEB822: A list of supported architectures for the APT source ('amd64', 'i386', etc.).
102-
#
10388
# @param allow_unsigned
10489
# Specifies whether to authenticate packages from this release, even if the Release file is not signed or the signature can't be checked.
10590
#
106-
# @param repo_trusted
107-
# DEB822: Consider the APT source trusted, even if authentication checks fail.
108-
#
10991
# @param allow_insecure
11092
# Specifies whether to allow downloads from insecure repositories.
11193
#
@@ -116,29 +98,23 @@
11698
# Specifies whether to check if the package release date is valid.
11799
#
118100
define apt::source (
119-
Enum['list', 'sources'] $source_format = 'list',
120-
Array[Enum['deb','deb-src'], 1, 2] $types = ['deb'],
121-
Optional[String] $location = undef,
122-
Optional[Array[String]] $uris = undef, # deb822
123-
Boolean $enabled = true, # deb822
124-
String $comment = $name,
125-
String $ensure = present,
126-
Optional[String] $release = undef,
127-
Optional[Array[String]] $suites = undef, # deb822
128-
String $repos = 'main',
129-
Optional[Array[String]] $components = undef, # deb822
130-
Variant[Hash] $include = {},
131-
Optional[Variant[String, Hash]] $key = undef,
132-
Optional[Stdlib::AbsolutePath] $keyring = undef,
133-
Optional[Variant[Stdlib::AbsolutePath,Array[String]]] $signed_by = undef, # deb822
134-
Optional[Variant[Hash, Numeric, String]] $pin = undef,
135-
Optional[String] $architecture = undef,
136-
Optional[Array[String]] $architectures = undef, # deb822
137-
Optional[Boolean] $allow_unsigned = undef,
138-
Optional[Boolean] $repo_trusted = undef, # deb822
139-
Optional[Boolean] $allow_insecure = undef,
140-
Optional[Boolean] $check_valid_until = undef,
141-
Boolean $notify_update = true,
101+
Enum['list', 'sources'] $source_format = 'list',
102+
Array[Enum['deb','deb-src'], 1, 2] $types = ['deb'],
103+
Optional[Variant[String, Array[String]]] $location = undef,
104+
Boolean $enabled = true, # deb822
105+
String $comment = $name,
106+
String $ensure = present,
107+
Optional[Variant[String, Array[String]]] $release = undef,
108+
Variant[String, Array[String]] $repos = 'main',
109+
Variant[Hash] $include = {},
110+
Optional[Variant[String, Hash]] $key = undef,
111+
Optional[Stdlib::AbsolutePath] $keyring = undef,
112+
Optional[Variant[Hash, Numeric, String]] $pin = undef,
113+
Optional[Variant[String, Array[String]]] $architecture = undef,
114+
Optional[Boolean] $allow_unsigned = undef,
115+
Optional[Boolean] $allow_insecure = undef,
116+
Optional[Boolean] $check_valid_until = undef,
117+
Boolean $notify_update = true,
142118
) {
143119
include apt
144120

@@ -305,7 +281,7 @@
305281
if !$location {
306282
fail('You must specify a list of URIs for the apt::source resource')
307283
}
308-
if (type($location =~ String)) {
284+
if (type($location, 'generalized') !~ Type[Array]) {
309285
warning('For deb822 sources, location must be specified as an array.')
310286
$_location = [$location]
311287
}
@@ -320,23 +296,23 @@
320296
fail('os.distro.codename fact not available: release parameter required')
321297
}
322298
} else {
323-
if (type($release) =~ String) {
299+
if (type($release, 'generalized') !~ Type[Array]) {
324300
warning("For deb822 sources, 'release' must be specified as an array. Converting to array.")
325301
$_release = [$release]
326302
} else {
327303
$_release = $release
328304
}
329305
}
330306

331-
if (type($repos) =~ String) {
307+
if (type($repos, 'generalized') !~ Type[Array]) {
332308
warning("For deb822 sources, 'repos' must be specified as an array. Converting to array.")
333309
$_repos = split($repos, /\s+/)
334310
} else {
335311
$_repos = $repos
336312
}
337313

338314
if $architecture != undef {
339-
if (type($architecture =~ String)) {
315+
if (type($architecture, 'generalized') !~ Type[Array]) {
340316
warning("For deb822 sources, 'architecture' must be specified as an array. Converting to array.")
341317
$_architecture = split($architecture, '[,]')
342318
}
@@ -358,9 +334,9 @@
358334
'enabled' => $enabled ? { true => 'yes', false => 'no' },
359335
'architectures' => $_architecture,
360336
'allow_insecure' => $allow_insecure ? { true => 'yes', false => 'no', default => undef },
361-
'repo_trusted' => $repo_trusted ? { true => 'yes', false => 'no', default => undef },
337+
'repo_trusted' => $allow_unsigned ? { true => 'yes', false => 'no', default => undef },
362338
'check_valid_until' => $check_valid_until ? { true => 'yes', false => 'no', default => undef },
363-
'signed_by' => $signed_by,
339+
'signed_by' => $keyring,
364340
}
365341
)
366342
)

0 commit comments

Comments
 (0)