Skip to content

Commit 7db2842

Browse files
author
Jonathan Wright
committed
Fix issue with array checking when no array present.
The introduction of issync? in the sensu_check type for the handlers and dependencies properties introduced an assumption that the values sourced are always arrays, yet :array_matching is set. In the event that an empty array is passed to the property within Puppet, Puppet will match this against an non-existing (nil) value and so will not write out the key/value pair on flush. When re-reading the file to analyze for changes, a nil value is loaded in return, but a NilClass has no sort method and so compilation of the catalog fails. This change sets the defaults within the type's JSON provider to always return an empty array unless something else is configured, preventing the issync? method from raising an exception on NilClass's.
1 parent 800e208 commit 7db2842

File tree

1 file changed

+2
-2
lines changed
  • lib/puppet/provider/sensu_check

1 file changed

+2
-2
lines changed

lib/puppet/provider/sensu_check/json.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def interval=(value)
8282
end
8383

8484
def handlers
85-
conf['checks'][resource[:name]]['handlers']
85+
conf['checks'][resource[:name]]['handlers'] || []
8686
end
8787

8888
def handlers=(value)
@@ -113,7 +113,7 @@ def command=(value)
113113
end
114114

115115
def dependencies
116-
conf['checks'][resource[:name]]['dependencies']
116+
conf['checks'][resource[:name]]['dependencies'] || []
117117
end
118118

119119
def dependencies=(value)

0 commit comments

Comments
 (0)