From 00c401c4523632369b04078792ff88f0a9c8a9a6 Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Mon, 6 Jan 2025 16:39:04 +0100 Subject: [PATCH] Handle repos passed as an array for list format In 9876c31aff7e738c9d533c556192591f991aa4af the parameter repos was changed to no longer allow an empty string. It does allow an array, but that isn't specifically handled for the list format. Fixes: 9876c31aff7e ("Add support for deb822 APT sources (#1167)") --- manifests/source.pp | 2 ++ spec/defines/source_spec.rb | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/manifests/source.pp b/manifests/source.pp index 5082a89f21..8ad30aa7b8 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -139,6 +139,8 @@ if $release =~ Pattern[/\/$/] { $_components = $_release + } elsif $repos =~ Array { + $_components = join([$_release] + $repos, ' ') } else { $_components = "${_release} ${repos}" } diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 9c619439c0..450b850f47 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -36,6 +36,24 @@ it { expect(subject).to contain_apt__setting('list-my_source').with(ensure: 'present').without_content(%r{# my_source\ndeb-src hello.there wheezy main\n}) } + + context 'with repos' do + context 'as empty array' do + let(:params) { super().merge(repos: []) } + + it { + expect(subject).to contain_apt__setting('list-my_source').with(ensure: 'present').without_content(%r{# my_source\ndeb-src hello.there wheezy\n}) + } + end + + context 'as non-empty array' do + let(:params) { super().merge(repos: ['main', 'non-free', 'contrib']) } + + it { + expect(subject).to contain_apt__setting('list-my_source').with(ensure: 'present').without_content(%r{# my_source\ndeb-src hello.there wheezy main non-free contrib\n}) + } + end + end end end