Skip to content

Commit

Permalink
(CAT-1483) - Generating expected source list based on inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramesh7 committed Sep 28, 2023
1 parent 6ab5dc4 commit 3373a52
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
9 changes: 7 additions & 2 deletions manifests/source.pp
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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/test1' 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
Original file line number Diff line number Diff line change
@@ -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 %>
<%- } -%>

0 comments on commit 3373a52

Please sign in to comment.