From 77f96c14282870fd72be7dde3f3021b85a71c3c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Fri, 9 Jan 2026 10:34:42 -1000 Subject: [PATCH 1/4] Fix epp parameter tag --- templates/source_deb822.epp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/templates/source_deb822.epp b/templates/source_deb822.epp index 3666148e2e..859e6b56ca 100644 --- a/templates/source_deb822.epp +++ b/templates/source_deb822.epp @@ -1,4 +1,5 @@ -<% | String $comment, +<%- | + String $comment, Enum['yes','no'] $enabled, Array[String] $types, Array[String] $uris, From cb3bdb2e7e1c74375fb1d08e0d3e2170a521a3eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Wed, 11 Dec 2024 11:57:05 -1000 Subject: [PATCH 2/4] Improve template consistency and make it more concise --- templates/source_deb822.epp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/templates/source_deb822.epp b/templates/source_deb822.epp index 859e6b56ca..8fb0bc44eb 100644 --- a/templates/source_deb822.epp +++ b/templates/source_deb822.epp @@ -13,15 +13,15 @@ | -%> # <%= $comment %> Enabled: <%= $enabled %> -Types: <% $types.each |String $type| { -%> <%= $type %> <% } %> -URIs: <% $uris.each | String $uri | { -%> <%= $uri %> <% } %> -Suites: <% $suites.each | String $suite | { -%> <%= $suite %> <% } %> +Types: <%= $types.join(' ') %> +URIs: <%= $uris.join(' ') %> +Suites: <%= $suites.join(' ') %> <% if $components { -%> -Components: <% $components.each | String $component | { -%> <%= $component %> <% } %> -<%- } -%> +Components: <%= $components.join(' ') %> +<% } -%> <% if $architectures { -%> -Architectures:<% $architectures.each | String $arch | { %> <%= $arch %><% } %> -<%- } -%> +Architectures: <%= $architectures.join(' ') %> +<% } -%> <% if $allow_insecure { -%> Allow-Insecure: <%= $allow_insecure %> <% } -%> @@ -32,8 +32,5 @@ Trusted: <%= $repo_trusted %> Check-Valid-Until: <%= $check_valid_until %> <% } -%> <% if $signed_by { -%> -Signed-By: <% if type($signed_by) =~ Type[Array] { -%><%- $signed_by.each |String $keyring| { -%><%= $keyring %> <% } -%> -<%- } -%> -<%- elsif type($signed_by) =~ Type[String] { -%> -<%= $signed_by -%> -<%- }} %> +Signed-By: <%= [$signed_by].flatten.join(' ') %> +<% } -%> From 2444cdc4b27a6ca465c8911cfe1303396e645b42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Thu, 19 Dec 2024 11:44:56 -1000 Subject: [PATCH 3/4] Improve validation of provided data. --- templates/source_deb822.epp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/templates/source_deb822.epp b/templates/source_deb822.epp index 8fb0bc44eb..91e70a5300 100644 --- a/templates/source_deb822.epp +++ b/templates/source_deb822.epp @@ -1,15 +1,15 @@ <%- | - String $comment, + String[1] $comment, Enum['yes','no'] $enabled, - Array[String] $types, - Array[String] $uris, - Array[String] $suites, - Optional[Array[String]] $components = undef, - Optional[Array] $architectures = undef, + Array[String[1]] $types, + Array[String[1]] $uris, + Array[String[1]] $suites, + Optional[Array[String[1]]] $components = undef, + Optional[Array[String[1]]] $architectures = undef, Optional[Enum['yes','no']] $allow_insecure = undef, Optional[Enum['yes','no']] $repo_trusted = undef, Optional[Enum['yes','no']] $check_valid_until = undef, - Optional[Variant[Stdlib::AbsolutePath,Array[String]]] $signed_by = undef, + Optional[Variant[Stdlib::AbsolutePath,Array[String[1]]]] $signed_by = undef, | -%> # <%= $comment %> Enabled: <%= $enabled %> From 1d1f94fa54df59d52ef1c06471f779b3c6903cb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Thu, 19 Dec 2024 11:47:58 -1000 Subject: [PATCH 4/4] Improve tests Test the generated content as a whole instead of part of line by part of line, add add missing parameters to improve coverage. --- spec/defines/source_spec.rb | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index be25caa564..76c294a000 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -453,31 +453,51 @@ end it { is_expected.to contain_apt__setting("sources-#{title}").with_notify_update(true) } + it { is_expected.to contain_apt__setting("sources-#{title}").with_content(<<~SOURCE) } + # This file is managed by Puppet. DO NOT EDIT. + # my_source + Enabled: yes + Types: deb + URIs: http://debian.mirror.iweb.ca/debian/ + Suites: stretch + Components: main contrib non-free + SOURCE end context 'complex deb822 source' do let :params do super().merge( { + enabled: false, types: ['deb', 'deb-src'], location: ['http://fr.debian.org/debian', 'http://de.debian.org/debian'], release: ['stable', 'stable-updates', 'stable-backports'], repos: ['main', 'contrib', 'non-free'], architecture: ['amd64', 'i386'], allow_unsigned: true, - notify_update: false + allow_insecure: true, + notify_update: false, + check_valid_until: false, + keyring: '/foo' }, ) end it { is_expected.to contain_apt__setting("sources-#{title}").with_notify_update(false) } - it { is_expected.to contain_apt__setting("sources-#{title}").with_content(%r{Enabled: yes}) } - it { is_expected.to contain_apt__setting("sources-#{title}").with_content(%r{Types: deb deb-src}) } - it { is_expected.to contain_apt__setting("sources-#{title}").with_content(%r{URIs: http://fr.debian.org/debian http://de.debian.org/debian}) } - it { is_expected.to contain_apt__setting("sources-#{title}").with_content(%r{Suites: stable stable-updates stable-backports}) } - it { is_expected.to contain_apt__setting("sources-#{title}").with_content(%r{Components: main contrib non-free}) } - it { is_expected.to contain_apt__setting("sources-#{title}").with_content(%r{Architectures: amd64 i386}) } - it { is_expected.to contain_apt__setting("sources-#{title}").with_content(%r{Trusted: yes}) } + it { is_expected.to contain_apt__setting("sources-#{title}").with_content(<<~SOURCE) } + # This file is managed by Puppet. DO NOT EDIT. + # my_source + Enabled: no + Types: deb deb-src + URIs: http://fr.debian.org/debian http://de.debian.org/debian + Suites: stable stable-updates stable-backports + Components: main contrib non-free + Architectures: amd64 i386 + Allow-Insecure: yes + Trusted: yes + Check-Valid-Until: no + Signed-By: /foo + SOURCE end context 'path based deb822 source' do