From 32f4d3ba14618c5c2443f92fda4950ebbd1fd11b Mon Sep 17 00:00:00 2001 From: Zdenek Janda Date: Tue, 11 Feb 2014 16:32:58 +0100 Subject: [PATCH] Converted timeout to numeric --- lib/puppet/provider/sensu_check/json.rb | 7 ++++++- manifests/check.pp | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/puppet/provider/sensu_check/json.rb b/lib/puppet/provider/sensu_check/json.rb index d7bbc936b0..061f4a7c6e 100644 --- a/lib/puppet/provider/sensu_check/json.rb +++ b/lib/puppet/provider/sensu_check/json.rb @@ -132,8 +132,13 @@ def timeout conf['checks'][resource[:name]]['timeout'].to_s end + def trim num + i, f = num.to_i, num.to_f + i == f ? i : f + end + def timeout=(value) - conf['checks'][resource[:name]]['timeout'] = value.to_f + conf['checks'][resource[:name]]['timeout'] = trim(value) end def aggregate diff --git a/manifests/check.pp b/manifests/check.pp index 6d44e7c5ea..802f956bf5 100644 --- a/manifests/check.pp +++ b/manifests/check.pp @@ -41,7 +41,7 @@ # Default: undef # # [*timeout*] -# Integer. Check timeout in seconds, after it fails +# Numeric. Check timeout in seconds, after it fails # Default: undef # # [*aggregate*] @@ -86,8 +86,8 @@ if $high_flap_threshold and !is_integer($high_flap_threshold) { fail("sensu::check{${name}}: high_flap_threshold must be an integer (got: ${high_flap_threshold})") } - if $timeout and !is_float($timeout) { - fail("sensu::check{${name}}: timeout must be an float (got: ${timeout})") + if $timeout and !is_numeric($timeout) { + fail("sensu::check{${name}}: timeout must be a numeric (got: ${timeout})") } $check_name = regsubst(regsubst($name, ' ', '_', 'G'), '[\(\)]', '', 'G')