From 29740a171f9daa073942791a38363140751755e9 Mon Sep 17 00:00:00 2001 From: Alejandro Figueroa Date: Tue, 2 Aug 2016 14:55:55 -0400 Subject: [PATCH] Allow undef handlers and subscribers This commit fixes the error message: `undefined method `sort' for nil:NilClass`. This error message can be seen when either the handlers or subscribers parameters are passed in as `undef` in the check.pp manifest. The PRs that looks like they introduced this behavior are: https://github.com/sensu/sensu-puppet/pull/285 https://github.com/sensu/sensu-puppet/pull/303 --- lib/puppet/type/sensu_check.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/puppet/type/sensu_check.rb b/lib/puppet/type/sensu_check.rb index 2bfed73de3..c495949e1b 100644 --- a/lib/puppet/type/sensu_check.rb +++ b/lib/puppet/type/sensu_check.rb @@ -45,7 +45,8 @@ def insync?(is) newproperty(:handlers, :array_matching => :all) do desc "List of handlers that responds to this check" def insync?(is) - is.sort == should.sort + return is.sort == should.sort if is.is_a?(Array) && should.is_a?(Array) + is == should end end @@ -81,7 +82,8 @@ def insync?(is) newproperty(:subscribers, :array_matching => :all) do desc "Who is subscribed to this check" def insync?(is) - is.sort == should.sort + return is.sort == should.sort if is.is_a?(Array) && should.is_a?(Array) + is == should end end