Skip to content

Commit d85c270

Browse files
committed
Exclude brackets from the name as this makes sensu barf
1 parent 3cf0363 commit d85c270

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

manifests/check.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
$custom = undef,
1919
) {
2020

21-
$check_name = regsubst($name, ' ', '_', 'G')
21+
$check_name = regsubst(regsubst($name, ' ', '_', 'G'), '[\(\)]', '', 'G')
2222

2323
file { "/etc/sensu/conf.d/checks/${check_name}.json":
2424
ensure => $ensure,

spec/defines/sensu_check_spec.rb

+16
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,23 @@
6464
it { should contain_file('/etc/sensu/conf.d/checks/mycheck_foobar.json') }
6565

6666
end
67+
end
68+
69+
context 'with brackets in name' do
70+
let(:title) { 'mycheck (foo) bar' }
71+
context 'defaults' do
72+
let(:params) { { :command => '/etc/sensu/somecommand.rb' } }
73+
74+
it { should contain_sensu_check('mycheck_foo_bar').with(
75+
'command' => '/etc/sensu/somecommand.rb',
76+
'handlers' => '',
77+
'interval' => '60',
78+
'subscribers' => ''
79+
) }
6780

81+
it { should contain_file('/etc/sensu/conf.d/checks/mycheck_foo_bar.json') }
82+
end
6883
end
6984

7085
end
86+

0 commit comments

Comments
 (0)