Skip to content

Commit 32f4d3b

Browse files
committed
Converted timeout to numeric
1 parent 75ed403 commit 32f4d3b

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

lib/puppet/provider/sensu_check/json.rb

+6-1
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,13 @@ def timeout
132132
conf['checks'][resource[:name]]['timeout'].to_s
133133
end
134134

135+
def trim num
136+
i, f = num.to_i, num.to_f
137+
i == f ? i : f
138+
end
139+
135140
def timeout=(value)
136-
conf['checks'][resource[:name]]['timeout'] = value.to_f
141+
conf['checks'][resource[:name]]['timeout'] = trim(value)
137142
end
138143

139144
def aggregate

manifests/check.pp

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
# Default: undef
4242
#
4343
# [*timeout*]
44-
# Integer. Check timeout in seconds, after it fails
44+
# Numeric. Check timeout in seconds, after it fails
4545
# Default: undef
4646
#
4747
# [*aggregate*]
@@ -86,8 +86,8 @@
8686
if $high_flap_threshold and !is_integer($high_flap_threshold) {
8787
fail("sensu::check{${name}}: high_flap_threshold must be an integer (got: ${high_flap_threshold})")
8888
}
89-
if $timeout and !is_float($timeout) {
90-
fail("sensu::check{${name}}: timeout must be an float (got: ${timeout})")
89+
if $timeout and !is_numeric($timeout) {
90+
fail("sensu::check{${name}}: timeout must be a numeric (got: ${timeout})")
9191
}
9292

9393
$check_name = regsubst(regsubst($name, ' ', '_', 'G'), '[\(\)]', '', 'G')

0 commit comments

Comments
 (0)