Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

(CAT-1483) - Enhancement of handling of apt::source's repos and release parameters #1138

Merged
merged 1 commit into from Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions manifests/source.pp
Expand Up @@ -94,6 +94,12 @@
$_release = $release
}

if $release =~ Pattern[/\/$/] {
$_components = $_release
} else {
$_components = "${_release} ${repos}"
}

if $ensure == 'present' {
if ! $location {
fail('cannot create a source entry without specifying a location')
Expand Down Expand Up @@ -151,8 +157,7 @@
},
),
'location' => $_location,
'release' => $_release,
'repos' => $repos,
'components' => $_components,
}
)

Expand Down
18 changes: 18 additions & 0 deletions spec/defines/source_spec.rb
Expand Up @@ -427,6 +427,24 @@
it { is_expected.to contain_apt__setting('list-my_source').with_content(%r{hello\.there main}) }
end

context 'with release is /' do
let(:params) { { location: 'hello.there', release: '/' } }

it { is_expected.to contain_apt__setting('list-my_source').with_content(%r{hello\.there /}) }
end

context 'with release is test/' do
let(:params) { { location: 'hello.there', release: 'test/' } }

it { is_expected.to contain_apt__setting('list-my_source').with_content(%r{hello\.there test/}) }
end

context 'with release is test/test' do
let(:params) { { location: 'hello.there', release: 'test/test' } }

it { is_expected.to contain_apt__setting('list-my_source').with_content(%r{hello\.there test/test main}) }
end

context 'with invalid pin' do
let :params do
{
Expand Down
6 changes: 3 additions & 3 deletions templates/source.list.epp
@@ -1,8 +1,8 @@
<%- | String $comment, Hash $includes, Hash $options, $location, $release, String $repos | -%>
<%- | String $comment, Hash $includes, Hash $options, $location, String $components | -%>
# <%= $comment %>
<%- if $includes['deb'] { -%>
deb <% if !$options.empty() { -%>[<%= $options.map |$key, $value| { if !$value.empty() { "${key}=${value}" } }.join(" ") %>] <% } -%> <%= $location %> <%= $release %> <%= $repos %>
deb <% if !$options.empty() { -%>[<%= $options.map |$key, $value| { if !$value.empty() { "${key}=${value}" } }.join(" ") %>] <% } -%> <%= $location %> <%= $components %>
<%- } -%>
<%- if $includes['src'] { -%>
deb-src <% if !$options.empty() { -%>[<%= $options.map |$key, $value| { if !$value.empty() { "${key}=${value}" } }.join(" ") %>] <% } -%> <%= $location %> <%= $release %> <%= $repos %>
deb-src <% if !$options.empty() { -%>[<%= $options.map |$key, $value| { if !$value.empty() { "${key}=${value}" } }.join(" ") %>] <% } -%> <%= $location %> <%= $components %>
<%- } -%>