Skip to content

Commit

Permalink
Allow multiple genericjmx mbean attribute entries
Browse files Browse the repository at this point in the history
  • Loading branch information
crimpy88 committed Nov 16, 2016
1 parent 4a3843c commit e1a1f0a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
19 changes: 19 additions & 0 deletions spec/defines/collectd_plugin_genericjmx_mbean_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,25 @@
it { is_expected.to contain_concat__fragment(concat_fragment_name).without_content(%r{InstancePrefix}) }
end

context 'value section attribute array' do
let(:params) do
default_params.merge(values: [default_values_args.merge('attribute' => %w(alice bob carol))])
end

it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{Attribute "alice"}) }
it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{Attribute "bob"}) }
it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{Attribute "carol"}) }
end

context 'value section attribute string' do
let(:params) do
default_params.merge(values: [default_values_args.merge('attribute' => 'dave')])
end

it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{Attribute "dave"}) }
it { is_expected.to contain_concat__fragment(concat_fragment_name).without_content(%r{(.*Attribute.*){2,}}) }
end

context 'value section table true-like' do
['true', true].each do |truthy|
let(:params) do
Expand Down
4 changes: 3 additions & 1 deletion templates/plugin/genericjmx/mbean.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
<% end -%>
<% end -%>
Table <%= scope.function_str2bool([value['table'] || false ]) ? 'true' : 'false' %>
Attribute "<%= value['attribute'] %>"
<% Array(value['attribute']).each do |attribute_item| -%>
Attribute "<%= attribute_item %>"
<% end -%>
</Value>
<% end -%>
</MBean>

0 comments on commit e1a1f0a

Please sign in to comment.