sensu-settings 9.0.0 → 9.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b950b91c23d3c11482819e912226b3b86ea4a34
|
4
|
+
data.tar.gz: 29c40cb6cca44e4b658c667e928ed4817256bdd3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71fe52ecfd5e5b7c5248d584dfb38d599db6641a3bd9fae6af2a43ddfd15589f9d21872b9fd0107cc991f8f62582d3abcb1efe47c031a1cdbd9cd4b58652b457
|
7
|
+
data.tar.gz: 30dd3f1dad803d23d0d213cc16697f25654eeefe67e14f752272171c0c03fad9a9b7dddd8ecd22f05827bbf51297d7e3fa7c147c331841809e888bc497b7819c
|
@@ -7,38 +7,42 @@ module Sensu
|
|
7
7
|
#
|
8
8
|
# @param definition [Hash] sensu definition.
|
9
9
|
# @param scope [String] definition scope to validate.
|
10
|
+
# @param attribute [String] definition attribute to validate.
|
10
11
|
# @param condition [Hash] to have begin and end validated.
|
11
|
-
def validate_time_window_condition(definition, scope, condition)
|
12
|
+
def validate_time_window_condition(definition, scope, attribute, condition)
|
12
13
|
if is_a_hash?(condition)
|
13
|
-
|
14
|
-
|
15
|
-
invalid(definition, "#{scope} begin and end times must be valid")
|
16
|
-
end
|
14
|
+
must_be_time(condition[:begin], condition[:end]) ||
|
15
|
+
invalid(definition, "#{scope} #{attribute} day time window begin and end times must be valid")
|
17
16
|
else
|
18
|
-
invalid(definition, "#{scope} must be a hash")
|
17
|
+
invalid(definition, "#{scope} #{attribute} day time window must be a hash")
|
19
18
|
end
|
20
19
|
end
|
21
20
|
|
22
|
-
# Validate time windows
|
21
|
+
# Validate time windows days
|
23
22
|
# Validates: days
|
24
23
|
#
|
25
24
|
# @param definition [Hash] sensu definition.
|
26
25
|
# @param scope [String] definition scope to validate.
|
26
|
+
# @param attribute [String] definition attribute to validate.
|
27
27
|
# @param days [String] time window days to validate.
|
28
|
-
def validate_time_windows_days(definition, scope, days)
|
28
|
+
def validate_time_windows_days(definition, scope, attribute, days)
|
29
29
|
valid_days = [:all, :sunday, :monday, :tuesday, :wednesday, :thursday, :friday, :saturday]
|
30
30
|
if must_be_either(valid_days, days.keys)
|
31
31
|
days.each do |day, conditions|
|
32
32
|
if is_an_array?(conditions)
|
33
|
-
conditions.
|
34
|
-
|
33
|
+
if !conditions.empty?
|
34
|
+
conditions.each do |condition|
|
35
|
+
validate_time_window_condition(definition, scope, attribute, condition)
|
36
|
+
end
|
37
|
+
else
|
38
|
+
invalid(definition, "#{scope} #{attribute} days #{day} must include at least one time window")
|
35
39
|
end
|
36
40
|
else
|
37
|
-
invalid(definition, "#{scope} #{
|
41
|
+
invalid(definition, "#{scope} #{attribute} days #{day} must be in an array")
|
38
42
|
end
|
39
43
|
end
|
40
44
|
else
|
41
|
-
invalid(definition, "#{scope} days must be valid days of the week or 'all'")
|
45
|
+
invalid(definition, "#{scope} #{attribute} days must be valid days of the week or 'all'")
|
42
46
|
end
|
43
47
|
end
|
44
48
|
|
@@ -47,16 +51,21 @@ module Sensu
|
|
47
51
|
#
|
48
52
|
# @param definition [Hash] sensu definition.
|
49
53
|
# @param scope [String] definition scope to validate.
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
invalid(definition, "#{scope} days must be a hash")
|
54
|
+
# @param attribute [String] definition attribute to validate.
|
55
|
+
def validate_time_windows(definition, scope, attribute)
|
56
|
+
if is_a_hash?(definition[attribute])
|
57
|
+
days = definition[attribute][:days]
|
55
58
|
if is_a_hash?(days)
|
56
|
-
|
59
|
+
if !days.empty?
|
60
|
+
validate_time_windows_days(definition, scope, attribute, days)
|
61
|
+
else
|
62
|
+
invalid(definition, "#{scope} #{attribute} days must include at least one day of the week or 'all'")
|
63
|
+
end
|
64
|
+
else
|
65
|
+
invalid(definition, "#{scope} #{attribute} days must be a hash")
|
57
66
|
end
|
58
67
|
else
|
59
|
-
invalid(definition, "#{scope} must be a hash")
|
68
|
+
invalid(definition, "#{scope} #{attribute} must be a hash")
|
60
69
|
end
|
61
70
|
end
|
62
71
|
end
|
data/sensu-settings.gemspec
CHANGED
data/spec/validator_spec.rb
CHANGED
@@ -278,7 +278,7 @@ describe "Sensu::Settings::Validator" do
|
|
278
278
|
:days => {}
|
279
279
|
}
|
280
280
|
@validator.validate_check(check)
|
281
|
-
expect(@validator.reset).to eq(
|
281
|
+
expect(@validator.reset).to eq(1)
|
282
282
|
check[:subdue] = {
|
283
283
|
:days => {
|
284
284
|
:nope => {}
|
@@ -306,7 +306,7 @@ describe "Sensu::Settings::Validator" do
|
|
306
306
|
}
|
307
307
|
}
|
308
308
|
@validator.validate_check(check)
|
309
|
-
expect(@validator.reset).to eq(
|
309
|
+
expect(@validator.reset).to eq(1)
|
310
310
|
check[:subdue] = {
|
311
311
|
:days => {
|
312
312
|
:all => [true]
|
@@ -314,6 +314,17 @@ describe "Sensu::Settings::Validator" do
|
|
314
314
|
}
|
315
315
|
@validator.validate_check(check)
|
316
316
|
expect(@validator.reset).to eq(1)
|
317
|
+
check[:subdue] = {
|
318
|
+
:days => {
|
319
|
+
:all => [
|
320
|
+
{
|
321
|
+
:begin => "5:00 PM"
|
322
|
+
}
|
323
|
+
]
|
324
|
+
}
|
325
|
+
}
|
326
|
+
@validator.validate_check(check)
|
327
|
+
expect(@validator.reset).to eq(1)
|
317
328
|
check[:subdue] = {
|
318
329
|
:days => {
|
319
330
|
:all => [
|
@@ -392,7 +403,7 @@ describe "Sensu::Settings::Validator" do
|
|
392
403
|
:days => {}
|
393
404
|
}
|
394
405
|
@validator.validate_filter(filter)
|
395
|
-
expect(@validator.reset).to eq(
|
406
|
+
expect(@validator.reset).to eq(1)
|
396
407
|
filter[:when] = {
|
397
408
|
:days => {
|
398
409
|
:nope => {}
|
@@ -420,7 +431,7 @@ describe "Sensu::Settings::Validator" do
|
|
420
431
|
}
|
421
432
|
}
|
422
433
|
@validator.validate_filter(filter)
|
423
|
-
expect(@validator.reset).to eq(
|
434
|
+
expect(@validator.reset).to eq(1)
|
424
435
|
filter[:when] = {
|
425
436
|
:days => {
|
426
437
|
:all => [true]
|
@@ -428,6 +439,17 @@ describe "Sensu::Settings::Validator" do
|
|
428
439
|
}
|
429
440
|
@validator.validate_filter(filter)
|
430
441
|
expect(@validator.reset).to eq(1)
|
442
|
+
filter[:when] = {
|
443
|
+
:days => {
|
444
|
+
:all => [
|
445
|
+
{
|
446
|
+
:begin => "5:00 PM"
|
447
|
+
}
|
448
|
+
]
|
449
|
+
}
|
450
|
+
}
|
451
|
+
@validator.validate_filter(filter)
|
452
|
+
expect(@validator.reset).to eq(1)
|
431
453
|
filter[:when] = {
|
432
454
|
:days => {
|
433
455
|
:all => [
|
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: 9.
|
4
|
+
version: 9.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-08-
|
11
|
+
date: 2016-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sensu-json
|