Skip to content

Commit 9935888

Browse files
author
Jeremy Carroll
committed
Added additional checks for existance testing
1 parent ed99cb7 commit 9935888

File tree

1 file changed

+21
-2
lines changed
  • lib/puppet/provider/sensu_check_config

1 file changed

+21
-2
lines changed

lib/puppet/provider/sensu_check_config/json.rb

+21-2
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,43 @@ def flush
2525
end
2626

2727
def create
28-
if resource.has_key?(:event)
28+
if resource[:event]
2929
conf['checks'] = {}
3030
conf['checks'][resource[:name]] = {}
3131
end
32+
self.event = resource[:event] unless resource[:event].nil?
33+
self.config = resource[:config] unless resource[:config].nil?
3234
end
3335

3436
def destroy
3537
conf = nil
3638
end
3739

3840
def exists?
39-
conf.has_key?(resource[:name]) or conf.has_key?('checks')
41+
if resource[:event] and resource[:config]
42+
conf.has_key?('checks') and conf['checks'].has_key?(resource[:name]) and conf.has_key?(resource[:name])
43+
else
44+
if resource[:event]
45+
conf.has_key?('checks') and conf['checks'].has_key?(resource[:name])
46+
end
47+
if resource[:config]
48+
conf.has_key?(resource[:name])
49+
end
50+
end
51+
end
52+
53+
def config
54+
conf[resource[:name]] = resource[:config] || {}
4055
end
4156

4257
def config=(value)
4358
conf[resource[:name]] = resource[:config]
4459
end
4560

61+
def event
62+
conf['checks'][resource[:name]] = resource[:event] || {}
63+
end
64+
4665
def event=(value)
4766
conf['checks'][resource[:name]] = resource[:event]
4867
end

0 commit comments

Comments
 (0)