lbrt 0.1.5 → 0.1.6

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: b555b4fcdd3a4b7874718d2ac738a8f94662f34e
4
- data.tar.gz: 9cabe6071054fdf219e15d19cea1717ea6741bbf
3
+ metadata.gz: 4d03d5b56552be94562b237b4fa6b3b7bf728752
4
+ data.tar.gz: 42d9b29379fa6c2c417f2586129d3cef61255dcf
5
5
  SHA512:
6
- metadata.gz: 6f73a2df7ded73d26b0d95525103efe4051ec71347ceeb64881c30d96a768e16361ed3f81b55b7b68ac016ef9cc57cb6a3421201d580ff99418bfae88fbc9fdb
7
- data.tar.gz: c1655ea651077562dc8a3c14b6c6a73497d3ec5a44f51cbb6e054f6ae7f1023bc0c5da72c5092b887054224eb64d9003fca3f0efa56b6b953c9ecac3bc4443e3
6
+ metadata.gz: 4d7673a015e2f65b429bf6b212a0ea4dec840b5d36daf86f00f8e7fd61860c1a4877f661036aeae7472529261bf503e771bec0fc86b00126f079fd22b8fa1dab
7
+ data.tar.gz: aaba95b5b57a80243342ae91d31dce8d9da6137b44a02bf85a7e04a1997e25ff3d6af681e0f0610618e1062006562dd801f84b484aa6c672f237c416bdc2450f
data/README.md CHANGED
@@ -233,6 +233,31 @@ end
233
233
 
234
234
  You can use the template in the `alert` and `service`.
235
235
 
236
+ ```ruby
237
+ template "my alert" do
238
+ alert context.metric_name do
239
+ description "desc"
240
+ attributes "runbook_url"=>"http://url.com"
241
+ active true
242
+ rearm_seconds 600
243
+ rearm_per_signal false
244
+
245
+ condition do
246
+ type "below"
247
+ metric_name context.metric_name
248
+ source nil
249
+ threshold 4.0
250
+ summary_function "sum"
251
+ end
252
+
253
+ service "mail", "my email"
254
+ end
255
+ end
256
+
257
+ include_template "my alert", metric_name: 'login-delay'
258
+ include_template "my alert", metric_name: 'login-delay2'
259
+ ```
260
+
236
261
  ## Show resource by [peco](https://github.com/peco/peco)
237
262
 
238
263
  ```sh
data/lib/lbrt/utils.rb CHANGED
@@ -40,14 +40,17 @@ class Lbrt::Utils
40
40
  end
41
41
 
42
42
  module TemplateHelper
43
- def include_template(template_name)
43
+ def include_template(template_name, context = {})
44
44
  tmplt = @context.templates[template_name.to_s]
45
45
 
46
46
  unless tmplt
47
47
  raise "Template `#{template_name}` is not defined"
48
48
  end
49
49
 
50
+ context_orig = @context
51
+ @context = @context.merge(context)
50
52
  instance_eval(&tmplt)
53
+ @context = context_orig
51
54
  end
52
55
  end
53
56
 
data/lib/lbrt/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lbrt
2
- VERSION = '0.1.5'
2
+ VERSION = '0.1.6'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lbrt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genki Sugawara