sensu-settings 5.0.1 → 5.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sensu/settings/rules.rb +9 -1
- data/lib/sensu/settings/validators/check.rb +15 -0
- data/sensu-settings.gemspec +1 -1
- data/spec/validator_spec.rb +12 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b105b89c40f34934a546ccf394ae680e3c576ecb
|
4
|
+
data.tar.gz: 7761ac36a88894957b99509e3db28285dbe70d27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11439eb54a3e92cc7cbc6c38afad9daec1027c6df2738e0709e3ef4ad0da9097bfc55bfc47927eebe9d399569f26e2b14231209900c167083aca1abe1333a189
|
7
|
+
data.tar.gz: 6c2b3dd3773e45e87ad0669cf216a0cd5e5953dd339a71abe11d815e5f770860908ddb09b04f771ac3239db3b9e7f291f1bb0f89cee91848fdf36c3234bb4022
|
data/lib/sensu/settings/rules.rb
CHANGED
@@ -94,12 +94,20 @@ module Sensu
|
|
94
94
|
(value =~ regex) == 0
|
95
95
|
end
|
96
96
|
|
97
|
+
# Check if a value is boolean.
|
98
|
+
#
|
99
|
+
# @param value [Object] to check.
|
100
|
+
# @return [TrueClass, FalseClass]
|
101
|
+
def must_be_boolean(value)
|
102
|
+
!!value == value
|
103
|
+
end
|
104
|
+
|
97
105
|
# Check if a value is boolean, if set (no nil).
|
98
106
|
#
|
99
107
|
# @param value [Object] to check.
|
100
108
|
# @return [TrueClass, FalseClass]
|
101
109
|
def must_be_boolean_if_set(value)
|
102
|
-
value.nil? ? true : (
|
110
|
+
value.nil? ? true : must_be_boolean(value)
|
103
111
|
end
|
104
112
|
|
105
113
|
# Check that value items are all strings and not empty.
|
@@ -92,6 +92,20 @@ module Sensu
|
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
|
+
# Validate check aggregate.
|
96
|
+
# Validates: aggregate
|
97
|
+
#
|
98
|
+
# @param check [Hash] sensu check definition.
|
99
|
+
def validate_check_aggregate(check)
|
100
|
+
if is_a_string?(check[:aggregate])
|
101
|
+
must_match_regex(/\A[\w\.-]+\z/, check[:aggregate]) ||
|
102
|
+
invalid(check, "check aggregate cannot contain spaces or special characters")
|
103
|
+
else
|
104
|
+
must_be_boolean(check[:aggregate]) ||
|
105
|
+
invalid(check, "check aggregate must be a string (name) or boolean")
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
95
109
|
# Validate check flap detection.
|
96
110
|
# Validates: low_flap_threshold, high_flap_threshold
|
97
111
|
#
|
@@ -115,6 +129,7 @@ module Sensu
|
|
115
129
|
validate_check_scheduling(check)
|
116
130
|
validate_check_handling(check)
|
117
131
|
validate_check_ttl(check) if check[:ttl]
|
132
|
+
validate_check_aggregate(check) if check[:aggregate]
|
118
133
|
validate_check_flap_detection(check)
|
119
134
|
validate_subdue(check) if check[:subdue]
|
120
135
|
end
|
data/sensu-settings.gemspec
CHANGED
data/spec/validator_spec.rb
CHANGED
@@ -188,6 +188,18 @@ describe "Sensu::Settings::Validator" do
|
|
188
188
|
check[:ttl] = 1
|
189
189
|
@validator.validate_check(check)
|
190
190
|
expect(@validator.reset).to eq(0)
|
191
|
+
check[:aggregate] = 1
|
192
|
+
@validator.validate_check(check)
|
193
|
+
expect(@validator.reset).to eq(1)
|
194
|
+
check[:aggregate] = true
|
195
|
+
@validator.validate_check(check)
|
196
|
+
expect(@validator.reset).to eq(0)
|
197
|
+
check[:aggregate] = "$test"
|
198
|
+
@validator.validate_check(check)
|
199
|
+
expect(@validator.reset).to eq(1)
|
200
|
+
check[:aggregate] = "test"
|
201
|
+
@validator.validate_check(check)
|
202
|
+
expect(@validator.reset).to eq(0)
|
191
203
|
check[:low_flap_threshold] = "25"
|
192
204
|
@validator.validate_check(check)
|
193
205
|
expect(@validator.reset).to eq(2)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-settings
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0
|
4
|
+
version: 5.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Porter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sensu-json
|