Skip to content

Commit 9f0415e

Browse files
committed
Initial testing for deb822 APT sources
1 parent 22ed8ab commit 9f0415e

File tree

5 files changed

+97
-1
lines changed

5 files changed

+97
-1
lines changed

manifests/params.pp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@
4444
'path' => $sources_list_d,
4545
'ext' => '.list',
4646
},
47+
'source' => {
48+
'path' => $sources_list_d,
49+
'ext' => '.sources',
50+
},
4751
}
4852

4953
$update_defaults = {

manifests/setting.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
}
5050
}
5151

52-
if ($setting_type == 'list') or ($setting_type == 'pref') {
52+
if ($setting_type == 'list') or ($setting_type == 'pref') or ($setting_type == 'source') {
5353
$_priority = ''
5454
} else {
5555
$_priority = $priority

manifests/source_deb822.pp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# @summary A short summary of the purpose of this defined type.
2+
#
3+
# A description of what this defined type does
4+
#
5+
# @example
6+
# apt::source_deb822 { 'namevar': }
7+
define apt::source_deb822 (
8+
Array[String] $uris,
9+
Array[String] $suites,
10+
Array[String] $components,
11+
Array[Enum['deb','deb-src'], 1, 2] $types = ['deb'],
12+
Enum['present','absent'] $ensure = 'present',
13+
String $comment = $name,
14+
Boolean $enabled = true,
15+
Boolean $notify_update = true,
16+
Optional[Array[String]] $architectures = undef,
17+
Optional[Boolean] $allow_insecure = undef,
18+
Optional[Boolean] $trusted = undef,
19+
Optional[Variant[Array[Stdlib::AbsolutePath], String]] $signed_by = undef,
20+
Optional[Boolean] $check_valid_until = undef,
21+
Optional[Hash] $options = undef
22+
) {
23+
$header = epp('apt/_header.epp')
24+
$source_content = epp('apt/source_deb822.epp')
25+
26+
apt::setting { "source-${name}":
27+
ensure => $ensure,
28+
content => "${header}${source_content}",
29+
notify_update => $notify_update,
30+
}
31+
}

spec/defines/source_deb822_spec.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# frozen_string_literal: true
2+
3+
require 'spec_helper'
4+
5+
describe 'apt::source_deb822' do
6+
let(:title) { 'namevar' }
7+
let(:params) do
8+
{}
9+
end
10+
11+
on_supported_os.each do |os, os_facts|
12+
context "on #{os}" do
13+
let(:facts) { os_facts }
14+
15+
it { is_expected.to compile }
16+
end
17+
end
18+
end

templates/source_deb822.epp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<% | String $comment,
2+
Enum['yes','no'] $enabled,
3+
Hash $types,Array[String] $uris,
4+
Array[String] $suites,
5+
Array[String] $components,
6+
Optional[Array] $architectures = undef,
7+
Optional[Enum['yes','no']] $allow_insecure = undef,
8+
Optional[Enum['yes','no']] $repo_trusted = undef,
9+
Optional[Enum['yes','no']] $check_valid_until = undef,
10+
Optional[Variant[Array[String], String]] $signed_by = undef,
11+
Optional[Hash] $options = undef
12+
| -%>
13+
# This file is managed by Puppet. DO NOT EDIT.
14+
# <%= $comment %>
15+
Enabled: <%= $enabled %>
16+
Types:<% if $types['deb'] { %> deb<% } %><% if $types['src'] { %> deb-src<% } %>
17+
URIs: <% $uris.each | String $uri | { -%> <%= $uri %> <% } %>
18+
Suites: <% $suites.each | String $suite | { -%> <%= $suite %> <% } %>
19+
Components: <% $components.each | String $component | { -%> <%= $component %> <% } %>
20+
<% if $architectures { -%>
21+
Architectures:<% $architectures.each | String $arch | { %> <%= $arch %><% } %>
22+
<%- } -%>
23+
<% if $allow_insecure { -%>
24+
Allow-Insecure: <%= $allow_insecure %>
25+
<% } -%>
26+
<% if $repo_trusted { -%>
27+
Trusted: <%= $repo_trusted %>
28+
<% } -%>
29+
<% if $check_valid_until { -%>
30+
Check-Valid-Until: <%= $check_valid_until %>
31+
<% } -%>
32+
<% if $signed_by { -%>
33+
Signed-By: <% if type($signed_by) =~ Type[Array] { -%><%- $signed_by.each |String $keyring| { -%><%= $keyring %> <% } %>
34+
<%- } -%>
35+
<%- elsif type($signed_by) =~ Type[String] { %>
36+
<%= $signed_by -%>
37+
<%- }} -%>
38+
<% if $options { -%>
39+
# Additional Options
40+
<% $options.each |$key, $value| {-%>
41+
<%= $key -%>: <%= $value %>
42+
<% } -%>
43+
<% } -%>

0 commit comments

Comments
 (0)