sensu-settings 7.0.0 → 8.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 +1 -0
- data/lib/sensu/settings/loader.rb +35 -7
- data/sensu-settings.gemspec +1 -1
- data/spec/loader_spec.rb +18 -0
- data/spec/settings_spec.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ecff7fd492c9359b7cd7acd1a5d96cbd58dbb4ba
|
4
|
+
data.tar.gz: c28ea05aada28e40f753142d7028a62106926ae2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd1cb0e18dfa49dd1eddc80ec674d63306b1ec546ea346ff68fdec00e5938d114cd6fb2f89838c80fac442e39f610df8a5efa0a7ad8388b32f244c0684b3450f
|
7
|
+
data.tar.gz: f27ce319271b20543fa332d1945ca064965f6ea27a2658461df5e6e452339925933c898c46178d4a3a1c31def07f6d3e4de536916daec878b18c1042c0b21ec1
|
data/lib/sensu/settings.rb
CHANGED
@@ -168,6 +168,24 @@ module Sensu
|
|
168
168
|
end
|
169
169
|
end
|
170
170
|
|
171
|
+
# Load Sensu client settings overrides. This method adds any overrides to
|
172
|
+
# the client definition. Overrides include:
|
173
|
+
#
|
174
|
+
# * Ensuring client subscriptions include a single subscription based on the
|
175
|
+
# client name, e.g "client:i-424242".
|
176
|
+
def load_client_overrides
|
177
|
+
@settings[:client][:subscriptions] ||= []
|
178
|
+
@settings[:client][:subscriptions] << "client:#{@settings[:client][:name]}"
|
179
|
+
@settings[:client][:subscriptions].uniq!
|
180
|
+
warning("applied sensu client overrides", :client => @settings[:client])
|
181
|
+
end
|
182
|
+
|
183
|
+
# Load overrides, i.e. settings which should always be present.
|
184
|
+
# Examples include client settings overrides which ensure a per-client subscription.
|
185
|
+
def load_overrides!
|
186
|
+
load_client_overrides
|
187
|
+
end
|
188
|
+
|
171
189
|
# Set Sensu settings related environment variables. This method
|
172
190
|
# sets `SENSU_LOADED_TEMPFILE` to a new temporary file path,
|
173
191
|
# a file containing the colon delimited list of loaded
|
@@ -260,12 +278,24 @@ module Sensu
|
|
260
278
|
end
|
261
279
|
end
|
262
280
|
|
263
|
-
# Load Sensu Redis settings from the environment.
|
264
|
-
#
|
265
|
-
#
|
266
|
-
#
|
281
|
+
# Load Sensu Redis settings from the environment.
|
282
|
+
#
|
283
|
+
# This method evaluates the REDIS_SENTINEL_URLS and REDIS_URL environment variables
|
284
|
+
# and configures the Redis settings accordingly.
|
285
|
+
#
|
286
|
+
# When REDIS_SENTINEL_URLS is provided as a list of one or more
|
287
|
+
# comma-separated URLs, e.g.
|
288
|
+
# "redis://10.0.0.1:26379,redis://10.0.0.2:26379" these URLs will take
|
289
|
+
# precedence over the value provided by REDIS_URL, if any.
|
290
|
+
#
|
291
|
+
# As the redis library accepts a URL string for options. This
|
292
|
+
# configuration applies to data storage and the redis transport, if used.
|
267
293
|
def load_redis_env
|
268
|
-
if ENV["
|
294
|
+
if ENV["REDIS_SENTINEL_URLS"]
|
295
|
+
@settings[:redis] = {:sentinels => ENV["REDIS_SENTINEL_URLS"]}
|
296
|
+
warning("using redis sentinel url environment variable", :sentinels => @settings[:redis][:sentinels])
|
297
|
+
@indifferent_access = false
|
298
|
+
elsif ENV["REDIS_URL"]
|
269
299
|
@settings[:redis] = ENV["REDIS_URL"]
|
270
300
|
warning("using redis url environment variable", :redis => @settings[:redis])
|
271
301
|
@indifferent_access = false
|
@@ -276,8 +306,6 @@ module Sensu
|
|
276
306
|
# loads client settings from several variables:
|
277
307
|
# `SENSU_CLIENT_NAME`, `SENSU_CLIENT_ADDRESS`, and
|
278
308
|
# `SENSU_CLIENT_SUBSCRIPTIONS`.
|
279
|
-
#
|
280
|
-
# The client subscriptions defaults to an empty array.
|
281
309
|
def load_client_env
|
282
310
|
@settings[:client][:name] = ENV["SENSU_CLIENT_NAME"] if ENV["SENSU_CLIENT_NAME"]
|
283
311
|
@settings[:client][:address] = ENV["SENSU_CLIENT_ADDRESS"] if ENV["SENSU_CLIENT_ADDRESS"]
|
data/sensu-settings.gemspec
CHANGED
data/spec/loader_spec.rb
CHANGED
@@ -60,6 +60,15 @@ describe "Sensu::Settings::Loader" do
|
|
60
60
|
ENV["REDIS_URL"] = nil
|
61
61
|
end
|
62
62
|
|
63
|
+
it "can load Redis Sentinel settings from the environment" do
|
64
|
+
ENV["REDIS_SENTINEL_URLS"] = "redis://10.0.0.1:26379,redis://:password@10.0.0.2:26379"
|
65
|
+
@loader.load_env
|
66
|
+
expect(@loader.warnings.size).to eq(1)
|
67
|
+
warning = @loader.warnings.shift
|
68
|
+
expect(warning[:sentinels]).to eq("redis://10.0.0.1:26379,redis://:password@10.0.0.2:26379")
|
69
|
+
ENV["REDIS_SENTINEL_URLS"] = nil
|
70
|
+
end
|
71
|
+
|
63
72
|
it "can load Sensu client settings with defaults from the environment" do
|
64
73
|
ENV["SENSU_CLIENT_NAME"] = "i-424242"
|
65
74
|
@loader.load_env
|
@@ -222,4 +231,13 @@ describe "Sensu::Settings::Loader" do
|
|
222
231
|
end
|
223
232
|
expect(handler[:type]).to eq("set")
|
224
233
|
end
|
234
|
+
|
235
|
+
it "can load settings overrides" do
|
236
|
+
@loader.load_file(@config_file)
|
237
|
+
@loader.load_overrides!
|
238
|
+
expect(@loader.warnings.size).to eq(2)
|
239
|
+
warning = @loader.warnings[1]
|
240
|
+
client = warning[:client]
|
241
|
+
expect(client[:subscriptions]).to include("client:i-424242")
|
242
|
+
end
|
225
243
|
end
|
data/spec/settings_spec.rb
CHANGED
@@ -60,8 +60,8 @@ describe "Sensu::Settings" do
|
|
60
60
|
it "can handle a nonexistent config.json" do
|
61
61
|
settings = Sensu::Settings.load(:config_file => "/tmp/bananaphone")
|
62
62
|
expect(settings.errors.length).to eq(0)
|
63
|
-
expect(settings.warnings.length).to eq(
|
64
|
-
warning = settings.warnings
|
63
|
+
expect(settings.warnings.length).to eq(3)
|
64
|
+
warning = settings.warnings[1]
|
65
65
|
expect(warning[:message]).to include("ignoring config file")
|
66
66
|
end
|
67
67
|
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: 8.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-08-
|
11
|
+
date: 2016-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sensu-json
|