Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type is a reserved word in puppet 4 #435

Merged
merged 1 commit into from
Feb 21, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions manifests/setting.pp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
define apt::setting (
$type,
$setting_type,
$priority = 50,
$ensure = file,
$source = undef,
Expand All @@ -17,7 +17,7 @@
fail('apt::setting needs either of content or source')
}

validate_re($type, ['conf', 'pref', 'list'])
validate_re($setting_type, ['conf', 'pref', 'list'])
validate_re($ensure, ['file', 'present', 'absent'])

unless is_integer($priority) {
Expand All @@ -32,14 +32,14 @@
validate_string($content)
}

if $type == 'list' {
if $setting_type == 'list' {
$_priority = ''
} else {
$_priority = $priority
}

$_path = $::apt::config_files[$type]['path']
$_ext = $::apt::config_files[$type]['ext']
$_path = $::apt::config_files[$setting_type]['path']
$_ext = $::apt::config_files[$setting_type]['ext']

file { "${_path}/${_priority}${title}${_ext}":
ensure => $ensure,
Expand Down
24 changes: 12 additions & 12 deletions spec/defines/setting_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,39 @@
let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } }
let(:title) { 'teddybear' }

let(:default_params) { { :type => 'conf', :content => 'di' } }
let(:default_params) { { :setting_type => 'conf', :content => 'di' } }

describe 'when using the defaults' do
context 'without type' do
context 'without setting_type' do
it do
expect { should compile }.to raise_error(Puppet::Error, /Must pass type /)
expect { should compile }.to raise_error(Puppet::Error, /Must pass setting_type /)
end
end

context 'without source or content' do
let(:params) { { :type => 'conf' } }
let(:params) { { :setting_type => 'conf' } }
it do
expect { should compile }.to raise_error(Puppet::Error, /needs either of /)
end
end

context 'with type=conf' do
context 'with setting_type=conf' do
let(:params) { default_params }
it { should contain_file('/etc/apt/apt.conf.d/50teddybear') }
end

context 'with type=pref' do
let(:params) { { :type => 'pref', :content => 'di' } }
context 'with setting_type=pref' do
let(:params) { { :setting_type => 'pref', :content => 'di' } }
it { should contain_file('/etc/apt/preferences.d/50teddybear') }
end

context 'with type=list' do
let(:params) { { :type => 'list', :content => 'di' } }
context 'with setting_type=list' do
let(:params) { { :setting_type => 'list', :content => 'di' } }
it { should contain_file('/etc/apt/sources.list.d/teddybear.list') }
end

context 'with source' do
let(:params) { { :type => 'conf', :source => 'puppet:///la/die/dah' } }
let(:params) { { :setting_type => 'conf', :source => 'puppet:///la/die/dah' } }
it {
should contain_file('/etc/apt/apt.conf.d/50teddybear').with({
:ensure => 'file',
Expand Down Expand Up @@ -68,8 +68,8 @@
end
end

context 'with type=ext' do
let(:params) { default_params.merge({ :type => 'ext' }) }
context 'with setting_type=ext' do
let(:params) { default_params.merge({ :setting_type => 'ext' }) }
it do
expect { should compile }.to raise_error(Puppet::Error, /"ext" does not /)
end
Expand Down