Skip to content

Commit 8ff6af5

Browse files
committed
Stop sources format and ensure => absent failing
Currently the following produces a compile error every time. ```puppet apt::source{ ensure => absent, source_format => sources, } ``` ``` Puppet::PreformattedError: Evaluation Error: Error while evaluating a Resource Statement, Apt::Setting[sources-my_source]: parameter 'content' expects a value of type Undef or String[1], got String (file: /home/steve/GIT/puppetlabs-apt/spec/fixtures/modules/apt/manifests/source.pp, line: 363) on node legion.lan ```
1 parent 677b2b3 commit 8ff6af5

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

manifests/source.pp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,9 +360,14 @@
360360
fail("Unexpected APT source format: ${source_format}")
361361
}
362362
}
363+
364+
$_combined = ($header or $source_content) ? {
365+
true => "${header}${source_content}",
366+
default => undef,
367+
}
363368
apt::setting { "${_file_suffix}-${name}":
364369
ensure => $ensure,
365-
content => "${header}${source_content}",
370+
content => $_combined,
366371
notify_update => $notify_update,
367372
}
368373
}

spec/defines/source_spec.rb

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,5 +516,36 @@
516516

517517
it { is_expected.to contain_apt__setting("sources-#{title}").with_notify_update(true) }
518518
end
519+
520+
context 'absent deb822 source' do
521+
let :params do
522+
super().merge(
523+
{
524+
ensure: 'absent',
525+
},
526+
)
527+
end
528+
529+
it { is_expected.to contain_apt__setting("sources-#{title}").with_ensure('absent') }
530+
end
531+
532+
context 'absent complex deb822 source' do
533+
let :params do
534+
super().merge(
535+
{
536+
ensure: 'absent',
537+
types: ['deb', 'deb-src'],
538+
location: ['http://fr.debian.org/debian', 'http://de.debian.org/debian'],
539+
release: ['stable', 'stable-updates', 'stable-backports'],
540+
repos: ['main', 'contrib', 'non-free'],
541+
architecture: ['amd64', 'i386'],
542+
allow_unsigned: true,
543+
notify_update: false
544+
},
545+
)
546+
end
547+
548+
it { is_expected.to contain_apt__setting("sources-#{title}").with_ensure('absent') }
549+
end
519550
end
520551
end

0 commit comments

Comments
 (0)