kennel 1.27.3 → 1.28.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
  SHA256:
3
- metadata.gz: 7aada5b08dc60f3cae84385963ff9148abb524ca9de028ef05693d69d6cd81fd
4
- data.tar.gz: 77fd2e3a6f33beeeb2d700a05ca0bc1a2d491ee6e1f50f80898a538b8293a97f
3
+ metadata.gz: 839ed976a8811de64729eb9c011c7a52b6495aa229dc836da17927ea850c48ab
4
+ data.tar.gz: 85974f47c3060dd451d3e34c9c43392e49fcc5b553751f57549320dab77e8ae5
5
5
  SHA512:
6
- metadata.gz: 12a0223469d614fd1ff97ee31118d3f06dfa66b59989082eaaa94db6036f15fdc2a86d38d811922f32bf79eff7d3c5f058146708489ccc595bffa1c7bec6c404
7
- data.tar.gz: 63713ab11c23fa4d73192318ae806d2daf05552897e854d50b93b34205f63570faa53de4897d4e1d27dd69956ef9c3a83ecb21cf70f2861ee90e5ee89e5b7709
6
+ metadata.gz: a8e84ef685a62a24528f52c29defe99c12ffe61770a3233bd03e43acbe0a7601b7ce3b123bb0b425d611f4d45f506d9086a5c4c64728698838b147f1f7cd89f0
7
+ data.tar.gz: 58a4a25124dbfc0e197cf3732672b991f7ea34370b99465e2ee18a063c5ab9c9006a3ff41ae74703575b82ce1bbf38c3fc8c785b4d1730ff9bbfa74a829eb663
data/Readme.md CHANGED
@@ -198,6 +198,7 @@ module Monitors
198
198
  defaults(
199
199
  name: -> { "#{project.name} load too high" },
200
200
  message: -> { "Shut it down!" },
201
+ type: -> { "query alert" },
201
202
  query: -> { "avg(last_5m):avg:system.load.5{hostgroup:#{project.kennel_id}} by {pod} > #{critical}" }
202
203
  )
203
204
  end
@@ -31,7 +31,8 @@ module Kennel
31
31
  names.each do |name|
32
32
  next if method_defined?(name)
33
33
  define_method name do
34
- raise ArgumentError, "Trying to call #{name} for #{self.class} but it was never set or passed as option"
34
+ message = "Trying to call #{name} for #{self.class} but it was never set or passed as option"
35
+ raise_with_location ArgumentError, message
35
36
  end
36
37
  end
37
38
  end
@@ -96,16 +97,18 @@ module Kennel
96
97
  end
97
98
 
98
99
  # need expand_path so it works wih rake and when run individually
99
- @invocation_location = caller.detect { |l| File.expand_path(l).start_with?(Dir.pwd) }
100
+ pwd = /^#{Regexp.escape(Dir.pwd)}\//
101
+ @invocation_location = caller.detect do |l|
102
+ if found = File.expand_path(l).sub!(pwd, "")
103
+ break found
104
+ end
105
+ end
100
106
  end
101
107
 
102
108
  def kennel_id
103
109
  name = self.class.name
104
110
  if name.start_with?("Kennel::")
105
- message = +"Set :kennel_id"
106
- message << " for project #{project.kennel_id}" if defined?(project)
107
- message << " on #{@invocation_location}" if @invocation_location
108
- raise ArgumentError, message
111
+ raise_with_location ArgumentError, "Set :kennel_id"
109
112
  end
110
113
  @kennel_id ||= Utils.snake_case name
111
114
  end
@@ -141,6 +144,13 @@ module Kennel
141
144
  raise ValidationError, "#{tracking_id} #{message}"
142
145
  end
143
146
 
147
+ def raise_with_location(error, message)
148
+ message = message.dup
149
+ message << " for project #{project.kennel_id}" if defined?(project)
150
+ message << " on #{@invocation_location}" if @invocation_location
151
+ raise error, message
152
+ end
153
+
144
154
  def validate_options(options)
145
155
  unless options.is_a?(Hash)
146
156
  raise ArgumentError, "Expected #{self.class.name}.new options to be a Hash, got a #{options.class}"
@@ -23,7 +23,6 @@ module Kennel
23
23
  defaults(
24
24
  message: -> { "\n\n@slack-#{project.slack}" },
25
25
  escalation_message: -> { "" },
26
- type: -> { "query alert" },
27
26
  renotify_interval: -> { 120 },
28
27
  warning: -> { nil },
29
28
  ok: -> { nil },
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Kennel
3
- VERSION = "1.27.3"
3
+ VERSION = "1.28.0"
4
4
  end
data/template/Readme.md CHANGED
@@ -180,6 +180,7 @@ module Monitors
180
180
  defaults(
181
181
  name: -> { "#{project.name} load too high" },
182
182
  message: -> { "Shut it down!" },
183
+ type: -> { "query alert" },
183
184
  query: -> { "avg(last_5m):avg:system.load.5{hostgroup:#{project.kennel_id}} by {pod} > #{critical}" }
184
185
  )
185
186
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kennel
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.27.3
4
+ version: 1.28.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-31 00:00:00.000000000 Z
11
+ date: 2019-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday