sensu-settings 9.10.0 → 10.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.rb +11 -12
- data/lib/sensu/settings/loader.rb +28 -0
- data/sensu-settings.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72b9dcbda492b08e982b281b94f65be601ef4e5e
|
4
|
+
data.tar.gz: 6dc42379262f05d750e47313827550f6987c82ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7bbd5259d726402435eead658c1d828c1aa468c6749c75792e101ccad16cc3717b94ed0a29142a12259b752efbb6c7d565a9c073c8949e295de324d54a745b41
|
7
|
+
data.tar.gz: 8769f81d864f075f38c25a38819f07500e53b1cac93ebda165e384ca8362fe04a068aedc2454b32274bc9209ae9d8ac2b19906ed851de6a6f7ed89f6ebc518dd
|
data/lib/sensu/settings.rb
CHANGED
@@ -3,6 +3,8 @@ require "sensu/settings/loader"
|
|
3
3
|
module Sensu
|
4
4
|
module Settings
|
5
5
|
class << self
|
6
|
+
attr_accessor :loader
|
7
|
+
|
6
8
|
# Load Sensu settings.
|
7
9
|
#
|
8
10
|
# Settings are loaded in following order, prior to validation:
|
@@ -16,26 +18,23 @@ module Sensu
|
|
16
18
|
# @option options [Array] :config_dirs to load.
|
17
19
|
# @return [Loader] a loaded instance of Loader.
|
18
20
|
def load(options={})
|
19
|
-
|
20
|
-
|
21
|
+
loader = Loader.new
|
22
|
+
loader.load_env
|
21
23
|
if options[:config_file]
|
22
|
-
|
24
|
+
loader.load_file(options[:config_file], false)
|
23
25
|
end
|
24
26
|
if options[:config_dir]
|
25
|
-
|
27
|
+
loader.load_directory(options[:config_dir])
|
26
28
|
end
|
27
29
|
if options[:config_dirs]
|
28
30
|
options[:config_dirs].each do |directory|
|
29
|
-
|
31
|
+
loader.load_directory(directory)
|
30
32
|
end
|
31
33
|
end
|
32
|
-
|
33
|
-
|
34
|
-
@loader.set_env!
|
35
|
-
end
|
36
|
-
@loader
|
34
|
+
loader.load_overrides!
|
35
|
+
loader
|
37
36
|
rescue Loader::Error
|
38
|
-
|
37
|
+
loader
|
39
38
|
end
|
40
39
|
|
41
40
|
# Retrieve the current loaded settings loader or load one up if
|
@@ -45,7 +44,7 @@ module Sensu
|
|
45
44
|
# @param [Hash] options to pass to load().
|
46
45
|
# @return [Loader] instance of a loaded loader.
|
47
46
|
def get(options={})
|
48
|
-
@loader || load(options)
|
47
|
+
@loader || @loader = load(options)
|
49
48
|
end
|
50
49
|
end
|
51
50
|
end
|
@@ -2,6 +2,7 @@ require "sensu/settings/validator"
|
|
2
2
|
require "sensu/json"
|
3
3
|
require "tmpdir"
|
4
4
|
require "socket"
|
5
|
+
require "digest"
|
5
6
|
|
6
7
|
module Sensu
|
7
8
|
module Settings
|
@@ -91,6 +92,7 @@ module Sensu
|
|
91
92
|
def to_hash
|
92
93
|
unless @indifferent_access
|
93
94
|
indifferent_access!
|
95
|
+
@hexdigest = nil
|
94
96
|
end
|
95
97
|
@settings
|
96
98
|
end
|
@@ -104,6 +106,31 @@ module Sensu
|
|
104
106
|
to_hash[key]
|
105
107
|
end
|
106
108
|
|
109
|
+
# Create a SHA256 hex digest for the settings Hash object. The
|
110
|
+
# client definition scope is ignored when the current process is
|
111
|
+
# not a Sensu client, as it is essentially ignored and it will
|
112
|
+
# likely cause a sum mismatch between two Sensu service systems.
|
113
|
+
# This method will not recalculate the hex digest, unless the
|
114
|
+
# settings have been altered, determine by the values of
|
115
|
+
# `@hexdigest` and `@indifferent_access`.
|
116
|
+
#
|
117
|
+
# @return [String] SHA256 hex digest.
|
118
|
+
def hexdigest
|
119
|
+
if @hexdigest && @indifferent_access
|
120
|
+
@hexdigest
|
121
|
+
else
|
122
|
+
hash = case sensu_service_name
|
123
|
+
when "client", "rspec"
|
124
|
+
to_hash
|
125
|
+
else
|
126
|
+
to_hash.reject do |key, value|
|
127
|
+
key.to_s == "client"
|
128
|
+
end
|
129
|
+
end
|
130
|
+
@hexdigest = Digest::SHA256.hexdigest(hash.to_s)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
107
134
|
# Load settings from the environment.
|
108
135
|
#
|
109
136
|
# Loads: SENSU_TRANSPORT_NAME, RABBITMQ_URL, REDIS_URL,
|
@@ -180,6 +207,7 @@ module Sensu
|
|
180
207
|
@settings[:client][:subscriptions] << "client:#{@settings[:client][:name]}"
|
181
208
|
@settings[:client][:subscriptions].uniq!
|
182
209
|
warning("applied sensu client overrides", :client => @settings[:client])
|
210
|
+
@indifferent_access = false
|
183
211
|
else
|
184
212
|
warning("unable to apply sensu client overrides", {
|
185
213
|
:reason => "client subscriptions is not an array",
|
data/sensu-settings.gemspec
CHANGED