Skip to content

Commit ce8e484

Browse files
committed
(CAT-1483) - Generating expected source list based on inputs
1 parent 6ab5dc4 commit ce8e484

File tree

3 files changed

+28
-5
lines changed

3 files changed

+28
-5
lines changed

manifests/source.pp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@
9494
$_release = $release
9595
}
9696

97+
if $release =~ Pattern[/\/$/] {
98+
$_components = $_release
99+
} else {
100+
$_components = "${_release} ${repos}"
101+
}
102+
97103
if $ensure == 'present' {
98104
if ! $location {
99105
fail('cannot create a source entry without specifying a location')
@@ -151,8 +157,7 @@
151157
},
152158
),
153159
'location' => $_location,
154-
'release' => $_release,
155-
'repos' => $repos,
160+
'components' => $_components,
156161
}
157162
)
158163

spec/defines/source_spec.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,24 @@
427427
it { is_expected.to contain_apt__setting('list-my_source').with_content(%r{hello\.there main}) }
428428
end
429429

430+
context 'with release is /' do
431+
let(:params) { { location: 'hello.there', release: '/' } }
432+
433+
it { is_expected.to contain_apt__setting('list-my_source').with_content(%r{hello\.there /}) }
434+
end
435+
436+
context 'with release is test/' do
437+
let(:params) { { location: 'hello.there', release: 'test/' } }
438+
439+
it { is_expected.to contain_apt__setting('list-my_source').with_content(%r{hello\.there test/}) }
440+
end
441+
442+
context 'with release is test/test' do
443+
let(:params) { { location: 'hello.there', release: 'test/test' } }
444+
445+
it { is_expected.to contain_apt__setting('list-my_source').with_content(%r{hello\.there test/test main}) }
446+
end
447+
430448
context 'with invalid pin' do
431449
let :params do
432450
{

templates/source.list.epp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
<%- | String $comment, Hash $includes, Hash $options, $location, $release, String $repos | -%>
1+
<%- | String $comment, Hash $includes, Hash $options, $location, String $components | -%>
22
# <%= $comment %>
33
<%- if $includes['deb'] { -%>
4-
deb <% if !$options.empty() { -%>[<%= $options.map |$key, $value| { if !$value.empty() { "${key}=${value}" } }.join(" ") %>] <% } -%> <%= $location %> <%= $release %> <%= $repos %>
4+
deb <% if !$options.empty() { -%>[<%= $options.map |$key, $value| { if !$value.empty() { "${key}=${value}" } }.join(" ") %>] <% } -%> <%= $location %> <%= $components %>
55
<%- } -%>
66
<%- if $includes['src'] { -%>
7-
deb-src <% if !$options.empty() { -%>[<%= $options.map |$key, $value| { if !$value.empty() { "${key}=${value}" } }.join(" ") %>] <% } -%> <%= $location %> <%= $release %> <%= $repos %>
7+
deb-src <% if !$options.empty() { -%>[<%= $options.map |$key, $value| { if !$value.empty() { "${key}=${value}" } }.join(" ") %>] <% } -%> <%= $location %> <%= $components %>
88
<%- } -%>

0 commit comments

Comments
 (0)