Validate the concat::fragment order parameter as string||integer

This is to work around a validation issue that arises under the 3.x future
parser, as proper numeric types have been introduced (ie, not all scalar values
are strings).  Users have come to expect to to be able to pass in unquoted
integer values to the order parameter which will fail to validate as a string
when the future parser is enabled.
This commit is contained in:
Joshua Hoblitt 2014-05-23 10:02:00 -07:00
parent 705071343b
commit 8dedb6bffb
5 changed files with 9 additions and 5 deletions

View file

@ -2,6 +2,6 @@ fixtures:
repositories:
'stdlib':
repo: 'git://github.com/puppetlabs/puppetlabs-stdlib.git'
ref: '4.0.0'
ref: '4.2.0'
symlinks:
'concat': '#{source_dir}'

View file

@ -6,4 +6,4 @@ license 'Apache 2.0'
summary 'Concat module'
description 'Concat module'
project_page 'http://github.com/puppetlabs/puppetlabs-concat'
dependency 'puppetlabs/stdlib', '>= 4.0.0'
dependency 'puppetlabs/stdlib', '>= 4.2.0'

View file

@ -100,7 +100,7 @@ class motd {
}
# used by other modules to register themselves in the motd
define motd::register($content="", $order=10) {
define motd::register($content="", $order='10') {
if $content == "" {
$body = $name
} else {
@ -247,6 +247,8 @@ Order the fragments.
######Example
- order => '01'
Best practice is to pass a string to this parameter but integer values are accepted.
#####`ensure`
Control the file of fragment created.

View file

@ -40,7 +40,9 @@ define concat::fragment(
if !(is_string($source) or is_array($source)) {
fail('$source is not a string or an Array.')
}
validate_string($order)
if !(is_string($order) or is_integer($order)) {
fail('$order is not a string or integer.')
}
if $mode {
warning('The $mode parameter to concat::fragment is deprecated and has no effect')
}

View file

@ -152,7 +152,7 @@ describe 'concat::fragment', :type => :define do
let(:params) {{ :order => false, :target => '/etc/motd' }}
it 'should fail' do
expect { should }.to raise_error(Puppet::Error, /is not a string/)
expect { should }.to raise_error(Puppet::Error, /is not a string or integer/)
end
end
end # order =>