sensu-settings 9.8.0 → 9.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 417045b32942806ce02f52f28dcab9ee41c3c8d9
4
- data.tar.gz: f6ae85f63436e637984525ebfa974d67c146e614
3
+ metadata.gz: ad6aa38a2670cc323faf4d9c9e44cf378808181c
4
+ data.tar.gz: b1329ce300073a6efee7bc5f2a9eed8a495db24b
5
5
  SHA512:
6
- metadata.gz: 9b043f5ea045abdc56a4aec630f19d95d6212ed32b6973d898dcc49e354303e6dd245d53263faaecd5ea64304910ba54b9e54cd14b3cf1989960f4d780936307
7
- data.tar.gz: 3e6d844a34c4fb67ba6beccda5117ef08481cb5ac02540a223cc8f049794533b7cce7632ea57d08f51b3307798bfe9c095bfe8842ca50b2ff31c7c7423ed1d75
6
+ metadata.gz: 4933d28d1f7319626868f186e3d796cebb3e6b3510154ddb717ddfada7c188bf26124d8c8541a9482876c15703f7a280869996aa82b2616010163b490ac933e9
7
+ data.tar.gz: 2122cf394f8eb98b23376586c801e4b0248a636c7a0bd2e2b17f2983c780a960fd6a72ac650992a03aef81cefb438a73931ff3ed3baee4c7a8f6149ea83a6c57
@@ -1,3 +1,5 @@
1
+ require "parse-cron"
2
+
1
3
  module Sensu
2
4
  module Settings
3
5
  module Validators
@@ -41,16 +43,35 @@ module Sensu
41
43
  end
42
44
  end
43
45
 
46
+ # Validate check cron.
47
+ # Validates: cron
48
+ #
49
+ # @param check [Hash] sensu check definition.
50
+ def validate_check_cron(check)
51
+ must_be_a_string(check[:cron]) ||
52
+ invalid(check, "check cron must be a string")
53
+ begin
54
+ cron_parser = CronParser.new(check[:cron])
55
+ cron_parser.next(Time.now)
56
+ rescue ArgumentError
57
+ invalid(check, "check cron string must use the cron syntax")
58
+ end
59
+ end
60
+
44
61
  # Validate check scheduling.
45
- # Validates: interval, standalone, subscribers
62
+ # Validates: publish, interval, standalone, subscribers
46
63
  #
47
64
  # @param check [Hash] sensu check definition.
48
65
  def validate_check_scheduling(check)
49
66
  must_be_boolean_if_set(check[:publish]) ||
50
67
  invalid(check, "check publish must be boolean")
51
68
  unless check[:publish] == false
52
- (must_be_an_integer(check[:interval]) && check[:interval] > 0) ||
53
- invalid(check, "check interval must be an integer greater than 0")
69
+ if check[:cron]
70
+ validate_check_cron(check)
71
+ else
72
+ (must_be_an_integer(check[:interval]) && check[:interval] > 0) ||
73
+ invalid(check, "check interval must be an integer greater than 0")
74
+ end
54
75
  end
55
76
  must_be_boolean_if_set(check[:standalone]) ||
56
77
  invalid(check, "check standalone must be boolean")
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "sensu-settings"
5
- spec.version = "9.8.0"
5
+ spec.version = "9.9.0"
6
6
  spec.authors = ["Sean Porter"]
7
7
  spec.email = ["portertech@gmail.com"]
8
8
  spec.summary = "The Sensu settings library, loader and validator"
@@ -16,6 +16,7 @@ Gem::Specification.new do |spec|
16
16
  spec.require_paths = ["lib"]
17
17
 
18
18
  spec.add_dependency "sensu-json", ">= 1.1.0"
19
+ spec.add_dependency "parse-cron"
19
20
 
20
21
  spec.add_development_dependency "bundler", "~> 1.6"
21
22
  spec.add_development_dependency "rake"
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.8.0
4
+ version: 9.9.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: 2017-02-16 00:00:00.000000000 Z
11
+ date: 2017-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-json
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.1.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: parse-cron
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement