Skip to content

Commit 4f07c03

Browse files
committed
type runscript can be specified as array with hashes
1 parent 1e93248 commit 4f07c03

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

lib/puppet/parser/functions/bareos_settings.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module Puppet::Parser::Functions
1616
raise 'Name of directive config key is invalid' unless directive =~ %r{^[a-zA-z ]+$}
1717

1818
# check array if allowed
19-
values = if (type == 'acl' || type =~ %r{[_-]list$}) && value_setting.is_a?(Array)
19+
values = if (%w[acl runscript].include?(type) || type =~ %r{[_-]list$}) && value_setting.is_a?(Array)
2020
value_setting
2121
else
2222
[value_setting]

spec/functions/bareos_settings_spec.rb

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@
133133
end
134134
end
135135
end
136-
# add include_exclude_time / hash
136+
137137
context 'type is an hashed value' do
138138
%w[include_exclude_item runscript hash].each do |type|
139139
it 'runs with compatible values' do
@@ -364,4 +364,34 @@
364364
end
365365
end
366366
end
367+
368+
context 'value can be an array' do
369+
it 'any type with _list suffix' do
370+
val = %w[first second]
371+
result = "#{indent_default}Test = first
372+
#{indent_default}Test = second"
373+
is_expected.to run.with_params([val, 'Test', 'string_noquote_list', true]).and_return(result)
374+
end
375+
376+
it 'type is acl' do
377+
val = %w[first second]
378+
result = "#{indent_default}Test = first
379+
#{indent_default}Test = second"
380+
is_expected.to run.with_params([val, 'Test', 'acl', true]).and_return(result)
381+
end
382+
383+
it 'type is runcsript' do
384+
val = [
385+
{ 'Test A' => 'value' },
386+
{ 'Test B' => 'value' }
387+
]
388+
result = "#{indent_default}Test {
389+
#{indent_default}#{indent_default}Test A = value
390+
#{indent_default}}
391+
#{indent_default}Test {
392+
#{indent_default}#{indent_default}Test B = value
393+
#{indent_default}}"
394+
is_expected.to run.with_params([val, 'Test', 'runscript', true]).and_return(result)
395+
end
396+
end
367397
end

0 commit comments

Comments
 (0)