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 bd4a693
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
17 changes: 17 additions & 0 deletions spec/defines/collectd_plugin_genericjmx_mbean_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,23 @@
it { is_expected.to contain_concat__fragment(concat_fragment_name).without_content(%r{(.*InstanceFrom.*){2,}}) }
end

context 'attribute array' do
let(:params) do
default_params.merge(attribute: %w(foo bar baz))
end

it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{Attribute "foo"\s+Attribute "bar"\s+Attribute "baz"}) }
end

context 'attribute string' do
let(:params) do
default_params.merge(attribute: 'bat')
end

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

let(:default_values_args) do
{
'mbean_type' => 'foo',
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 bd4a693

Please sign in to comment.