Merge pull request #95 from jhoblitt/fragment_params
deprecate concat::fragment mode, owner, & group params
This commit is contained in:
commit
0580e3f2a0
4 changed files with 113 additions and 81 deletions
|
@ -16,11 +16,11 @@
|
||||||
# [*ensure*]
|
# [*ensure*]
|
||||||
# Present/Absent or destination to a file to include another file
|
# Present/Absent or destination to a file to include another file
|
||||||
# [*mode*]
|
# [*mode*]
|
||||||
# Mode for the file
|
# Deprecated
|
||||||
# [*owner*]
|
# [*owner*]
|
||||||
# Owner of the file
|
# Deprecated
|
||||||
# [*group*]
|
# [*group*]
|
||||||
# Owner of the file
|
# Deprecated
|
||||||
# [*backup*]
|
# [*backup*]
|
||||||
# Deprecated
|
# Deprecated
|
||||||
#
|
#
|
||||||
|
@ -30,7 +30,7 @@ define concat::fragment(
|
||||||
$source = undef,
|
$source = undef,
|
||||||
$order = 10,
|
$order = 10,
|
||||||
$ensure = 'present',
|
$ensure = 'present',
|
||||||
$mode = '0640',
|
$mode = undef,
|
||||||
$owner = undef,
|
$owner = undef,
|
||||||
$group = undef,
|
$group = undef,
|
||||||
$backup = undef
|
$backup = undef
|
||||||
|
@ -40,9 +40,15 @@ define concat::fragment(
|
||||||
validate_string($content)
|
validate_string($content)
|
||||||
validate_string($source)
|
validate_string($source)
|
||||||
validate_string($order)
|
validate_string($order)
|
||||||
validate_string($mode)
|
if $mode {
|
||||||
validate_string($owner)
|
warning('The $mode parameter to concat::fragment is deprecated and has no effect')
|
||||||
validate_string($group)
|
}
|
||||||
|
if $owner {
|
||||||
|
warning('The $owner parameter to concat::fragment is deprecated and has no effect')
|
||||||
|
}
|
||||||
|
if $group {
|
||||||
|
warning('The $group parameter to concat::fragment is deprecated and has no effect')
|
||||||
|
}
|
||||||
if $backup {
|
if $backup {
|
||||||
warning('The $backup parameter to concat::fragment is deprecated and has no effect')
|
warning('The $backup parameter to concat::fragment is deprecated and has no effect')
|
||||||
}
|
}
|
||||||
|
@ -67,11 +73,12 @@ define concat::fragment(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# punt on group ownership until some point in the distant future when $::gid
|
||||||
|
# can be relied on to be present
|
||||||
file { "${fragdir}/fragments/${order}_${safe_name}":
|
file { "${fragdir}/fragments/${order}_${safe_name}":
|
||||||
ensure => $ensure,
|
ensure => $ensure,
|
||||||
mode => $mode,
|
owner => $::id,
|
||||||
owner => $owner,
|
mode => '0640',
|
||||||
group => $group,
|
|
||||||
source => $source,
|
source => $source,
|
||||||
content => $content,
|
content => $content,
|
||||||
backup => false,
|
backup => false,
|
||||||
|
|
|
@ -26,6 +26,45 @@ describe 'deprecation warnings' do
|
||||||
it_behaves_like 'has_warning', pp, w
|
it_behaves_like 'has_warning', pp, w
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'concat::fragment mode parameter' do
|
||||||
|
pp="
|
||||||
|
concat { '/tmp/file': }
|
||||||
|
concat::fragment { 'foo':
|
||||||
|
target => '/tmp/file',
|
||||||
|
mode => 'bar',
|
||||||
|
}
|
||||||
|
"
|
||||||
|
w = 'The $mode parameter to concat::fragment is deprecated and has no effect'
|
||||||
|
|
||||||
|
it_behaves_like 'has_warning', pp, w
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'concat::fragment owner parameter' do
|
||||||
|
pp="
|
||||||
|
concat { '/tmp/file': }
|
||||||
|
concat::fragment { 'foo':
|
||||||
|
target => '/tmp/file',
|
||||||
|
owner => 'bar',
|
||||||
|
}
|
||||||
|
"
|
||||||
|
w = 'The $owner parameter to concat::fragment is deprecated and has no effect'
|
||||||
|
|
||||||
|
it_behaves_like 'has_warning', pp, w
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'concat::fragment group parameter' do
|
||||||
|
pp="
|
||||||
|
concat { '/tmp/file': }
|
||||||
|
concat::fragment { 'foo':
|
||||||
|
target => '/tmp/file',
|
||||||
|
group => 'bar',
|
||||||
|
}
|
||||||
|
"
|
||||||
|
w = 'The $group parameter to concat::fragment is deprecated and has no effect'
|
||||||
|
|
||||||
|
it_behaves_like 'has_warning', pp, w
|
||||||
|
end
|
||||||
|
|
||||||
context 'concat::fragment backup parameter' do
|
context 'concat::fragment backup parameter' do
|
||||||
pp="
|
pp="
|
||||||
concat { '/tmp/file': }
|
concat { '/tmp/file': }
|
||||||
|
|
|
@ -10,19 +10,16 @@ describe 'concat::fragment', :type => :define do
|
||||||
:source => nil,
|
:source => nil,
|
||||||
:order => 10,
|
:order => 10,
|
||||||
:ensure => 'present',
|
:ensure => 'present',
|
||||||
:mode => '0640',
|
|
||||||
:owner => nil,
|
|
||||||
:group => nil,
|
|
||||||
:backup => 'puppet',
|
|
||||||
}.merge(params)
|
}.merge(params)
|
||||||
|
|
||||||
safe_name = title.gsub(/[\/\n]/, '_')
|
safe_name = title.gsub(/[\/\n]/, '_')
|
||||||
safe_target_name = p[:target].gsub(/[\/\n]/, '_')
|
safe_target_name = p[:target].gsub(/[\/\n]/, '_')
|
||||||
concatdir = '/var/lib/puppet/concat'
|
concatdir = '/var/lib/puppet/concat'
|
||||||
fragdir = "#{concatdir}/#{safe_target_name}"
|
fragdir = "#{concatdir}/#{safe_target_name}"
|
||||||
|
id = 'root'
|
||||||
|
|
||||||
let(:title) { title }
|
let(:title) { title }
|
||||||
let(:facts) {{ :concat_basedir => concatdir }}
|
let(:facts) {{ :concat_basedir => concatdir, :id => id }}
|
||||||
let(:params) { params }
|
let(:params) { params }
|
||||||
let(:pre_condition) do
|
let(:pre_condition) do
|
||||||
"concat{ '#{p[:target]}': }"
|
"concat{ '#{p[:target]}': }"
|
||||||
|
@ -33,9 +30,8 @@ describe 'concat::fragment', :type => :define do
|
||||||
should contain_concat(p[:target])
|
should contain_concat(p[:target])
|
||||||
should contain_file("#{fragdir}/fragments/#{p[:order]}_#{safe_name}").with({
|
should contain_file("#{fragdir}/fragments/#{p[:order]}_#{safe_name}").with({
|
||||||
:ensure => p[:ensure],
|
:ensure => p[:ensure],
|
||||||
:mode => p[:mode],
|
:owner => id,
|
||||||
:owner => p[:owner],
|
:mode => '0640',
|
||||||
:group => p[:group],
|
|
||||||
:source => p[:source],
|
:source => p[:source],
|
||||||
:content => p[:content],
|
:content => p[:content],
|
||||||
:alias => "concat_fragment_#{title}",
|
:alias => "concat_fragment_#{title}",
|
||||||
|
@ -156,21 +152,16 @@ describe 'concat::fragment', :type => :define do
|
||||||
end
|
end
|
||||||
end # order =>
|
end # order =>
|
||||||
|
|
||||||
|
describe 'deprecated parameter' do
|
||||||
context 'mode =>' do
|
context 'mode =>' do
|
||||||
context '1755' do
|
context '1755' do
|
||||||
it_behaves_like 'fragment', 'motd_header', {
|
it_behaves_like 'fragment', 'motd_header', {
|
||||||
:mode => '1755',
|
:mode => '1755',
|
||||||
:target => '/etc/motd',
|
:target => '/etc/motd',
|
||||||
}
|
}
|
||||||
end
|
|
||||||
|
|
||||||
context 'false' do
|
it 'should create a warning' do
|
||||||
let(:title) { 'motd_header' }
|
pending('rspec-puppet support for testing warning()')
|
||||||
let(:facts) {{ :concat_basedir => '/tmp' }}
|
|
||||||
let(:params) {{ :mode => false, :target => '/etc/motd' }}
|
|
||||||
|
|
||||||
it 'should fail' do
|
|
||||||
expect { should }.to raise_error(Puppet::Error, /is not a string/)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end # mode =>
|
end # mode =>
|
||||||
|
@ -181,15 +172,9 @@ describe 'concat::fragment', :type => :define do
|
||||||
:owner => 'apenny',
|
:owner => 'apenny',
|
||||||
:target => '/etc/motd',
|
:target => '/etc/motd',
|
||||||
}
|
}
|
||||||
end
|
|
||||||
|
|
||||||
context 'false' do
|
it 'should create a warning' do
|
||||||
let(:title) { 'motd_header' }
|
pending('rspec-puppet support for testing warning()')
|
||||||
let(:facts) {{ :concat_basedir => '/tmp' }}
|
|
||||||
let(:params) {{ :owner => false, :target => '/etc/motd' }}
|
|
||||||
|
|
||||||
it 'should fail' do
|
|
||||||
expect { should }.to raise_error(Puppet::Error, /is not a string/)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end # owner =>
|
end # owner =>
|
||||||
|
@ -200,28 +185,25 @@ describe 'concat::fragment', :type => :define do
|
||||||
:group => 'apenny',
|
:group => 'apenny',
|
||||||
:target => '/etc/motd',
|
:target => '/etc/motd',
|
||||||
}
|
}
|
||||||
end
|
|
||||||
|
|
||||||
context 'false' do
|
it 'should create a warning' do
|
||||||
let(:title) { 'motd_header' }
|
pending('rspec-puppet support for testing warning()')
|
||||||
let(:facts) {{ :concat_basedir => '/tmp' }}
|
|
||||||
let(:params) {{ :group => false, :target => '/etc/motd' }}
|
|
||||||
|
|
||||||
it 'should fail' do
|
|
||||||
expect { should }.to raise_error(Puppet::Error, /is not a string/)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end # group =>
|
end # group =>
|
||||||
|
|
||||||
# should raise a warning but rspec-puppet can't presently test for warning()
|
|
||||||
# we can only test for the existence of the parameter
|
|
||||||
context 'backup =>' do
|
context 'backup =>' do
|
||||||
context 'foo' do
|
context 'foo' do
|
||||||
it_behaves_like 'fragment', 'motd_header', {
|
it_behaves_like 'fragment', 'motd_header', {
|
||||||
:backup => 'foo',
|
:backup => 'foo',
|
||||||
:target => '/etc/motd',
|
:target => '/etc/motd',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
it 'should create a warning' do
|
||||||
|
pending('rspec-puppet support for testing warning()')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end # backup =>
|
end # backup =>
|
||||||
|
end # deprecated params
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -367,11 +367,15 @@ describe 'concat', :type => :define do
|
||||||
end
|
end
|
||||||
end # ensure_newline =>
|
end # ensure_newline =>
|
||||||
|
|
||||||
# should raise a warning but rspec-puppet can't presently test for warning()
|
describe 'deprecated parameter' do
|
||||||
# we can only test for the existence of the parameter
|
|
||||||
context 'gnu =>' do
|
context 'gnu =>' do
|
||||||
context 'foo' do
|
context 'foo' do
|
||||||
it_behaves_like 'concat', '/etc/foo.bar', { :gnu => 'foo'}
|
it_behaves_like 'concat', '/etc/foo.bar', { :gnu => 'foo'}
|
||||||
|
|
||||||
|
it 'should create a warning' do
|
||||||
|
pending('rspec-puppet support for testing warning()')
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue