sensu-settings 1.3.0 → 1.4.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 +1 -0
- data/lib/sensu/settings/validators/check.rb +15 -5
- data/sensu-settings.gemspec +1 -1
- data/spec/validator_spec.rb +3 -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: d07bac3d033762f1692fc77a8ee78cfa93b8af23
|
4
|
+
data.tar.gz: d51b987e700c9aaa9da75d4486e875acdecbd35f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: abf335edc0f6cb4174bf52c1c2a9c3241cca29db316e6ce27d19bcd948d981ff5d5fc20da4cc7314ec39f8d3ea5a7d49d7b12d97d2b0b1d633819af29b76804b
|
7
|
+
data.tar.gz: 440a5744b1bcc636f4ed3b59582918c94c24714c165a62d74b668416c2bfcb68d869d08d12f38cb62a39c2f90fefdda1502ad7e5bb682471a67229d8df13d608
|
data/lib/sensu/settings/rules.rb
CHANGED
@@ -2,6 +2,19 @@ module Sensu
|
|
2
2
|
module Settings
|
3
3
|
module Validators
|
4
4
|
module Check
|
5
|
+
# Validate check source.
|
6
|
+
# Validates: source
|
7
|
+
#
|
8
|
+
# @param check [Hash] sensu check definition.
|
9
|
+
def validate_check_source(check)
|
10
|
+
if is_a_string?(check[:source])
|
11
|
+
must_match_regex(/^[\w\.-]+$/, check[:source]) ||
|
12
|
+
invalid(check, "check source cannot contain spaces or special characters")
|
13
|
+
else
|
14
|
+
invalid(check, "check source must be a string")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
5
18
|
# Validate check scheduling.
|
6
19
|
# Validates: interval, standalone, subscribers
|
7
20
|
#
|
@@ -69,14 +82,11 @@ module Sensu
|
|
69
82
|
invalid(check, "either check command or extension must be set")
|
70
83
|
must_be_a_numeric_if_set(check[:timeout]) ||
|
71
84
|
invalid(check, "check timeout must be numeric")
|
72
|
-
|
73
|
-
invalid(check, "check source must be a string")
|
85
|
+
validate_check_source(check) if check[:source]
|
74
86
|
validate_check_scheduling(check)
|
75
87
|
validate_check_handling(check)
|
76
88
|
validate_check_flap_detection(check)
|
77
|
-
if check[:subdue]
|
78
|
-
validate_subdue(check)
|
79
|
-
end
|
89
|
+
validate_subdue(check) if check[:subdue]
|
80
90
|
end
|
81
91
|
end
|
82
92
|
end
|
data/sensu-settings.gemspec
CHANGED
data/spec/validator_spec.rb
CHANGED
@@ -145,6 +145,9 @@ describe "Sensu::Settings::Validator" do
|
|
145
145
|
expect(@validator.reset).to eq(1)
|
146
146
|
check[:source] = "switch-%42%"
|
147
147
|
@validator.validate_check(check)
|
148
|
+
expect(@validator.reset).to eq(1)
|
149
|
+
check[:source] = "switch-42"
|
150
|
+
@validator.validate_check(check)
|
148
151
|
expect(@validator.reset).to eq(0)
|
149
152
|
check[:extension] = 'foo'
|
150
153
|
@validator.validate_check(check)
|
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: 1.
|
4
|
+
version: 1.4.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: 2015-
|
11
|
+
date: 2015-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|