Skip to content

Commit

Permalink
Merge pull request #957 from VtG242/patch-1
Browse files Browse the repository at this point in the history
Fix `ignoreselected` typo in protocols.conf.erb template
  • Loading branch information
alexjfisher authored Sep 25, 2020
2 parents 15af15c + 03c2c23 commit f9f2e7d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
6 changes: 3 additions & 3 deletions manifests/plugin/protocols.pp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# See http://collectd.org/documentation/manpages/collectd.conf.5.shtml#plugin_protocols
class collectd::plugin::protocols (
$ensure = 'present',
Boolean $ignoreselected = false,
Array $values = []
$ensure = 'present',
Optional[Boolean] $ignoreselected = undef,
Array $values = []
) {
include collectd

Expand Down
24 changes: 24 additions & 0 deletions spec/classes/collectd_plugin_protocols_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,30 @@
end
end

describe 'ignoreselected' do
context ':ignoreselected => false' do
let :params do
{
values: %w[protocol1 protocol2],
ignoreselected: false
}
end

it { is_expected.to contain_file('protocols.load').with_content(%r{<Plugin "protocols">\n\s*Value "protocol1"\n\s*Value "protocol2"\n\s*IgnoreSelected false\n</Plugin>}) }
end

context ':ignoreselected => true' do
let :params do
{
values: %w[protocol1 protocol2],
ignoreselected: true
}
end

it { is_expected.to contain_file('protocols.load').with_content(%r{<Plugin "protocols">\n\s*Value "protocol1"\n\s*Value "protocol2"\n\s*IgnoreSelected true\n</Plugin>}) }
end
end

context ':ensure => absent' do
let :params do
{ ensure: 'absent' }
Expand Down
8 changes: 4 additions & 4 deletions templates/plugin/protocols.conf.erb
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<% if @values -%>
<Plugin "protocols">
<%
<%
if @values
@values.each do |value|
@values.each do |value|
-%>
Value "<%= value %>"
<%
end
end
-%>
<% if @ignore_selected != nil -%>
IgnoreSelected <%= @ignore_selected %>
<% unless @ignoreselected == nil -%>
IgnoreSelected <%= @ignoreselected %>
<% end -%>
</Plugin>
<% end -%>

0 comments on commit f9f2e7d

Please sign in to comment.