Skip to content

Commit

Permalink
plugin::genericjmx::connection - Use data types
Browse files Browse the repository at this point in the history
- Breaking change: collect now only accepts an array, not either an
  array or string
  • Loading branch information
juniorsysadmin committed Nov 12, 2017
1 parent d06acc6 commit 87b0a46
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions manifests/plugin/genericjmx/connection.pp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# https://collectd.org/wiki/index.php/Plugin:GenericJMX
define collectd::plugin::genericjmx::connection (
$collect,
$service_url,
$host = undef,
$user = undef,
$password = undef,
$instance_prefix = undef,
Array $collect,
String $service_url,
Optional[String] $host = undef,
Optional[String] $user = undef,
Optional[String] $password = undef,
Optional[String] $instance_prefix = undef,
) {

include ::collectd
Expand Down
6 changes: 3 additions & 3 deletions spec/defines/collectd_plugin_genericjmx_connection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,17 @@
it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{Host "bar\.example\.com"}) }
end

context 'collect array' do
context 'with a collect array of multiple values' do
let(:params) do
default_params.merge(collect: %w[foo bar baz])
end

it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{Collect "foo".*Collect "bar".*Collect "baz"}m) }
end

context 'collect string' do
context 'with a collect array of one value' do
let(:params) do
default_params.merge(collect: 'bat')
default_params.merge(collect: %w[bat])
end

it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{Collect "bat"}) }
Expand Down
2 changes: 1 addition & 1 deletion templates/plugin/genericjmx/connection.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Host "<%= @host %>"
<% end -%>
ServiceURL "<%= @service_url %>"
<% Array(@collect).each do |collect| -%>
<% @collect.each do |collect| -%>
Collect "<%= collect %>"
<% end -%>
<% if @user -%>
Expand Down

0 comments on commit 87b0a46

Please sign in to comment.