Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions manifests/source.pp
Original file line number Diff line number Diff line change
Expand Up @@ -310,10 +310,10 @@
$_release = $release
}

# The deb822 format requires that if the Suite ($release) is a path (contains a /) that
# the Components field be absent. Check the original
$_releasefilter = $_release.any |$item| { $item.index('/') != undef }
if $_releasefilter {
# The deb822 format requires that if all Suite ($release) values end with a slash (/),
# the Components field must be omitted. Otherwise, Components is required.
$_all_suites_end_with_slash = $_release.all |$item| { $item =~ /\/$/ }
if $_all_suites_end_with_slash {
$_repos = undef
} elsif $repos !~ Array {
warning("For deb822 sources, 'repos' must be specified as an array. Converting to array.")
Expand Down
60 changes: 60 additions & 0 deletions spec/defines/source_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,66 @@
end

describe 'deb822 sources' do

context 'suite contains a slash but does not end with slash (should require Components)' do
let :params do
super().merge(
{
location: ['http://repo.mongodb.org/apt/debian'],
release: ['bookworm/mongodb-org/6.0'],
repos: ['main'],
keyring: '/etc/apt/keyrings/mongodb.gpg',
},
)
end
it { is_expected.to contain_apt__setting("sources-#{title}").with_content(%r{Suites: bookworm/mongodb-org/6.0}) }
it { is_expected.to contain_apt__setting("sources-#{title}").with_content(%r{Components: main}) }
end

context 'suite ends with slash (should omit Components)' do
let :params do
super().merge(
{
location: ['https://pkg.jenkins.io/debian-stable'],
release: ['binary/'],
repos: [],
keyring: '/etc/apt/keyrings/jenkins-keyring.asc',
},
)
end
it { is_expected.to contain_apt__setting("sources-#{title}").with_content(%r{Suites: binary/}) }
it { is_expected.to contain_apt__setting("sources-#{title}").without_content(%r{Components:}) }
end

context 'multiple suites, all end with slash (should omit Components)' do
let :params do
super().merge(
{
location: ['https://example.com/debian'],
release: ['foo/', 'bar/'],
repos: ['main'],
keyring: '/etc/apt/keyrings/example.gpg',
},
)
end
it { is_expected.to contain_apt__setting("sources-#{title}").with_content(%r{Suites: foo/ bar/}) }
it { is_expected.to contain_apt__setting("sources-#{title}").without_content(%r{Components:}) }
end

context 'multiple suites, not all end with slash (should require Components)' do
let :params do
super().merge(
{
location: ['https://example.com/debian'],
release: ['foo/', 'bar'],
repos: ['main'],
keyring: '/etc/apt/keyrings/example.gpg',
},
)
end
it { is_expected.to contain_apt__setting("sources-#{title}").with_content(%r{Suites: foo/ bar}) }
it { is_expected.to contain_apt__setting("sources-#{title}").with_content(%r{Components: main}) }
end
let :params do
{
source_format: 'sources',
Expand Down