Skip to content

Commit

Permalink
Merge pull request #390 from bovy89/master
Browse files Browse the repository at this point in the history
added subdue to sensu_handler type to handle properly subdue option
  • Loading branch information
jlambert121 committed Jul 28, 2015
2 parents 1cbd175 + 94103f6 commit 2535962
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/puppet/provider/sensu_handler/json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,12 @@ def type
def type=(value)
conf['handlers'][resource[:name]]['type'] = value
end
end

def subdue
conf['handlers'][resource[:name]]['subdue']
end

def subdue=(value)
conf['handlers'][resource[:name]]['subdue'] = value
end
end
4 changes: 4 additions & 0 deletions lib/puppet/type/sensu_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ def insync?(is)
desc "Handler specific config"
end

newproperty(:subdue) do
desc "Handler subdue"
end

autorequire(:package) do
['sensu']
end
Expand Down
5 changes: 5 additions & 0 deletions manifests/handler.pp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
# Hash. Handler specific config
# Default: undef
#
# [*subdue*]
# Hash. Handler subdue configuration
# Default: undef
#
define sensu::handler(
$ensure = 'present',
Expand All @@ -75,6 +78,7 @@
$install_path = '/etc/sensu/handlers',
# Handler specific config
$config = undef,
$subdue = undef,
) {

validate_re($ensure, ['^present$', '^absent$'] )
Expand Down Expand Up @@ -156,6 +160,7 @@
mutator => $mutator,
filters => $filters,
config => $config,
subdue => $subdue,
notify => $notify_services,
require => File['/etc/sensu/conf.d/handlers'],
}
Expand Down
15 changes: 15 additions & 0 deletions spec/defines/sensu_handler_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,19 @@
it { should contain_sensu_handler('myhandler').with_config( {'param' => 'value' } ) }
end

context 'subdue' do
let(:params) {
{
:command => 'mycommand.rb',
:type => 'pipe',
:subdue => {
'begin' => '09PM CEST',
'end' => '10PM CEST'
}
}
}

it { should contain_sensu_handler('myhandler').with_subdue( {'begin' => '09PM CEST', 'end' => '10PM CEST'} ) }
end

end

0 comments on commit 2535962

Please sign in to comment.