sensu-settings 6.0.0 → 7.0.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/constants.rb +1 -1
- data/lib/sensu/settings/validators.rb +2 -0
- data/lib/sensu/settings/validators/extension.rb +18 -0
- data/sensu-settings.gemspec +1 -1
- data/spec/validator_spec.rb +51 -10
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8c362827e20c190a2ddd55390d79cdde36f6718
|
4
|
+
data.tar.gz: 2352416fa30ab53d50d7732b6d627705e2c693a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 244ed09a606bca423b6a34436e91ae46213bec523286e1ac64c6976f1f293417a9df433f0b35c14d3f7a9e1551154d5c39a4d51b5250852556efc583e6bf869d
|
7
|
+
data.tar.gz: 8f293750efc58b389685bd767e736bc472a258506a9a53bd9f1fdb1c22417ea5508e917ab7935dd00b52076561e3c9581b416cc32aeb6db2a383cb11220541eb
|
@@ -7,6 +7,7 @@ require "sensu/settings/validators/mutator"
|
|
7
7
|
require "sensu/settings/validators/handler"
|
8
8
|
require "sensu/settings/validators/client"
|
9
9
|
require "sensu/settings/validators/api"
|
10
|
+
require "sensu/settings/validators/extension"
|
10
11
|
|
11
12
|
module Sensu
|
12
13
|
module Settings
|
@@ -20,6 +21,7 @@ module Sensu
|
|
20
21
|
include Handler
|
21
22
|
include Client
|
22
23
|
include API
|
24
|
+
include Extension
|
23
25
|
end
|
24
26
|
end
|
25
27
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Sensu
|
2
|
+
module Settings
|
3
|
+
module Validators
|
4
|
+
module Extension
|
5
|
+
# Validate a Sensu extension definition.
|
6
|
+
# Validates: gem, version
|
7
|
+
#
|
8
|
+
# @param filter [Hash] sensu extension definition.
|
9
|
+
def validate_extension(extension)
|
10
|
+
must_be_a_string_if_set(extension[:gem]) ||
|
11
|
+
invalid(extension, "extension gem must be a string")
|
12
|
+
must_be_a_string_if_set(extension[:version]) ||
|
13
|
+
invalid(extension, "extension version must be a string")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/sensu-settings.gemspec
CHANGED
data/spec/validator_spec.rb
CHANGED
@@ -21,7 +21,8 @@ describe "Sensu::Settings::Validator" do
|
|
21
21
|
expect(reasons).to include("filters must be a hash")
|
22
22
|
expect(reasons).to include("mutators must be a hash")
|
23
23
|
expect(reasons).to include("handlers must be a hash")
|
24
|
-
expect(reasons
|
24
|
+
expect(reasons).to include("extensions must be a hash")
|
25
|
+
expect(reasons.size).to eq(7)
|
25
26
|
end
|
26
27
|
|
27
28
|
it "can validate a sensu definition" do
|
@@ -57,10 +58,10 @@ describe "Sensu::Settings::Validator" do
|
|
57
58
|
}
|
58
59
|
}
|
59
60
|
@validator.run(settings)
|
60
|
-
expect(@validator.reset).to eq(
|
61
|
+
expect(@validator.reset).to eq(7)
|
61
62
|
settings[:sensu][:spawn][:limit] = 20
|
62
63
|
@validator.run(settings)
|
63
|
-
expect(@validator.reset).to eq(
|
64
|
+
expect(@validator.reset).to eq(6)
|
64
65
|
end
|
65
66
|
|
66
67
|
it "can validate a transport definition" do
|
@@ -91,10 +92,10 @@ describe "Sensu::Settings::Validator" do
|
|
91
92
|
}
|
92
93
|
}
|
93
94
|
@validator.run(settings)
|
94
|
-
expect(@validator.reset).to eq(
|
95
|
+
expect(@validator.reset).to eq(7)
|
95
96
|
settings[:transport][:name] = "rabbitmq"
|
96
97
|
@validator.run(settings)
|
97
|
-
expect(@validator.reset).to eq(
|
98
|
+
expect(@validator.reset).to eq(6)
|
98
99
|
end
|
99
100
|
|
100
101
|
it "can validate an empty check definition" do
|
@@ -333,10 +334,10 @@ describe "Sensu::Settings::Validator" do
|
|
333
334
|
}
|
334
335
|
}
|
335
336
|
@validator.run(settings)
|
336
|
-
expect(@validator.reset).to eq(
|
337
|
+
expect(@validator.reset).to eq(7)
|
337
338
|
settings[:checks][:foo][:interval] = 1
|
338
339
|
@validator.run(settings)
|
339
|
-
expect(@validator.reset).to eq(
|
340
|
+
expect(@validator.reset).to eq(6)
|
340
341
|
end
|
341
342
|
|
342
343
|
it "can validate a filter definition" do
|
@@ -746,10 +747,10 @@ describe "Sensu::Settings::Validator" do
|
|
746
747
|
}
|
747
748
|
}
|
748
749
|
@validator.run(settings, "client")
|
749
|
-
expect(@validator.reset).to eq(
|
750
|
+
expect(@validator.reset).to eq(8)
|
750
751
|
settings[:client][:subscriptions] = ["bar"]
|
751
752
|
@validator.run(settings, "client")
|
752
|
-
expect(@validator.reset).to eq(
|
753
|
+
expect(@validator.reset).to eq(7)
|
753
754
|
end
|
754
755
|
|
755
756
|
it "can validate an api definition" do
|
@@ -795,9 +796,49 @@ describe "Sensu::Settings::Validator" do
|
|
795
796
|
}
|
796
797
|
}
|
797
798
|
@validator.run(settings, "api")
|
798
|
-
expect(@validator.reset).to eq(
|
799
|
+
expect(@validator.reset).to eq(8)
|
799
800
|
settings[:api][:port] = 4567
|
800
801
|
@validator.run(settings, "api")
|
802
|
+
expect(@validator.reset).to eq(7)
|
803
|
+
end
|
804
|
+
|
805
|
+
it "can validate a extension definition" do
|
806
|
+
extension = {}
|
807
|
+
@validator.validate_extension(extension)
|
808
|
+
expect(@validator.reset).to eq(0)
|
809
|
+
extension[:gem] = 1
|
810
|
+
@validator.validate_extension(extension)
|
811
|
+
expect(@validator.reset).to eq(1)
|
812
|
+
extension[:gem] = true
|
813
|
+
@validator.validate_extension(extension)
|
814
|
+
expect(@validator.reset).to eq(1)
|
815
|
+
extension[:gem] = "test"
|
816
|
+
@validator.validate_extension(extension)
|
817
|
+
expect(@validator.reset).to eq(0)
|
818
|
+
extension[:version] = 1
|
819
|
+
@validator.validate_extension(extension)
|
820
|
+
expect(@validator.reset).to eq(1)
|
821
|
+
extension[:version] = false
|
822
|
+
@validator.validate_extension(extension)
|
823
|
+
expect(@validator.reset).to eq(1)
|
824
|
+
extension[:version] = "1.0.0"
|
825
|
+
@validator.validate_extension(extension)
|
826
|
+
expect(@validator.reset).to eq(0)
|
827
|
+
end
|
828
|
+
|
829
|
+
it "can run, validating extensions" do
|
830
|
+
settings = {
|
831
|
+
:extensions => {
|
832
|
+
:foo => {
|
833
|
+
:gem => "sensu-extensions-test",
|
834
|
+
:version => 1
|
835
|
+
}
|
836
|
+
}
|
837
|
+
}
|
838
|
+
@validator.run(settings)
|
839
|
+
expect(@validator.reset).to eq(7)
|
840
|
+
settings[:extensions][:foo][:version] = "1.0.0"
|
841
|
+
@validator.run(settings)
|
801
842
|
expect(@validator.reset).to eq(6)
|
802
843
|
end
|
803
844
|
end
|
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:
|
4
|
+
version: 7.0.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-
|
11
|
+
date: 2016-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sensu-json
|
@@ -102,6 +102,7 @@ files:
|
|
102
102
|
- lib/sensu/settings/validators/api.rb
|
103
103
|
- lib/sensu/settings/validators/check.rb
|
104
104
|
- lib/sensu/settings/validators/client.rb
|
105
|
+
- lib/sensu/settings/validators/extension.rb
|
105
106
|
- lib/sensu/settings/validators/filter.rb
|
106
107
|
- lib/sensu/settings/validators/handler.rb
|
107
108
|
- lib/sensu/settings/validators/mutator.rb
|