sensu-settings 5.0.1 → 5.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: 365f93ccdb13c600eb978fd62feae6253b2b4647
4
- data.tar.gz: bbaba4c2380b990a7d36eac82b0f8f5d4f7b18e0
3
+ metadata.gz: b105b89c40f34934a546ccf394ae680e3c576ecb
4
+ data.tar.gz: 7761ac36a88894957b99509e3db28285dbe70d27
5
5
  SHA512:
6
- metadata.gz: ed41c6a0c689f47259cd2d446225f913b2302c56a3a6f077880c978cb0983deca7b22a45edae2119d2cb9662b7dcd67050d38ae499eaa3ef745cb3ce01dcecc3
7
- data.tar.gz: a79fd4c4779b0ec8bba923d41b6049f93c28205d4eba8ddf9bf3ab523d6ff1d74e52802f7903e6fe00edbc09abc4c6d4f58e7634af24fe8ac16c55daeb676bf7
6
+ metadata.gz: 11439eb54a3e92cc7cbc6c38afad9daec1027c6df2738e0709e3ef4ad0da9097bfc55bfc47927eebe9d399569f26e2b14231209900c167083aca1abe1333a189
7
+ data.tar.gz: 6c2b3dd3773e45e87ad0669cf216a0cd5e5953dd339a71abe11d815e5f770860908ddb09b04f771ac3239db3b9e7f291f1bb0f89cee91848fdf36c3234bb4022
@@ -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 : (!!value == value)
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "sensu-settings"
5
- spec.version = "5.0.1"
5
+ spec.version = "5.1.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"
@@ -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.1
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-30 00:00:00.000000000 Z
11
+ date: 2016-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-json