kennel 1.121.0 → 1.122.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Readme.md +8 -0
- data/lib/kennel/github_reporter.rb +1 -1
- data/lib/kennel/importer.rb +14 -0
- data/lib/kennel/progress.rb +22 -3
- data/lib/kennel/projects_provider.rb +8 -10
- data/lib/kennel/syncer.rb +1 -1
- data/lib/kennel/tasks.rb +11 -0
- data/lib/kennel/utils.rb +4 -6
- data/lib/kennel/version.rb +1 -1
- data/template/Readme.md +8 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43b746ea91f86217a6fc43383a3368ccd654c89936c44003088054380be8c36d
|
4
|
+
data.tar.gz: 5fcd75471c8d0152236d032b023b4769975251047bc276f00219df3b1e60964d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9ce639cdd5748f689eeb352da8ea9c14a2a4243350368574b8b3c1b52534dbf470ca3e969ad96ecd685d8df93d368e7e4d5f5c98da2af7e5cc843ccbc8053ce
|
7
|
+
data.tar.gz: 7039072c9129311145694b53823cab5c11263e972ae8f6c586e0b86063a8ab9d375c2ecd1069bd2812f626ce631f2940fe55ca9a018033b435df63bcbef1d355
|
data/Readme.md
CHANGED
@@ -406,6 +406,14 @@ https://foo.datadog.com/monitor/123
|
|
406
406
|
### Find all monitors with No-Data
|
407
407
|
`rake kennel:nodata TAG=team:foo`
|
408
408
|
|
409
|
+
### Finding the tracking id of a resource
|
410
|
+
|
411
|
+
When trying to link resources together, this avoids having to go through datadog UI.
|
412
|
+
|
413
|
+
```Bash
|
414
|
+
rake kennel:tracking_id ID=123 RESOURCE=monitor
|
415
|
+
```
|
416
|
+
|
409
417
|
<!-- NOT IN template/Readme.md -->
|
410
418
|
|
411
419
|
## Development
|
data/lib/kennel/importer.rb
CHANGED
@@ -60,6 +60,8 @@ module Kennel
|
|
60
60
|
data[:critical] = data[:critical].to_i if data[:type] == "event alert"
|
61
61
|
|
62
62
|
data[:type] = "query alert" if data[:type] == "metric alert"
|
63
|
+
|
64
|
+
link_composite_monitors(data)
|
63
65
|
when "dashboard"
|
64
66
|
widgets = data[:widgets]&.flat_map { |widget| widget.dig(:definition, :widgets) || [widget] }
|
65
67
|
widgets&.each do |widget|
|
@@ -91,6 +93,18 @@ module Kennel
|
|
91
93
|
|
92
94
|
private
|
93
95
|
|
96
|
+
def link_composite_monitors(data)
|
97
|
+
if data[:type] == "composite"
|
98
|
+
data[:query].gsub!(/\d+/) do |id|
|
99
|
+
object = Kennel.send(:api).show("monitor", id)
|
100
|
+
tracking_id = Kennel::Models::Monitor.parse_tracking_id(object)
|
101
|
+
tracking_id ? "%{#{tracking_id}}" : id
|
102
|
+
rescue StandardError # monitor not found
|
103
|
+
id # keep the id
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
94
108
|
# reduce duplication in imports by using dry `q: :metadata` when possible
|
95
109
|
def dry_up_widget_metadata!(widget)
|
96
110
|
(widget.dig(:definition, :requests) || []).each do |request|
|
data/lib/kennel/progress.rb
CHANGED
@@ -4,7 +4,9 @@ require "benchmark"
|
|
4
4
|
module Kennel
|
5
5
|
class Progress
|
6
6
|
# print what we are doing and a spinner until it is done ... then show how long it took
|
7
|
-
def self.progress(name)
|
7
|
+
def self.progress(name, interval: 0.2, &block)
|
8
|
+
return progress_no_tty(name, &block) unless Kennel.err.tty?
|
9
|
+
|
8
10
|
Kennel.err.print "#{name} ... "
|
9
11
|
|
10
12
|
stop = false
|
@@ -16,15 +18,20 @@ module Kennel
|
|
16
18
|
loop do
|
17
19
|
break if stop
|
18
20
|
Kennel.err.print animation[count % animation.size]
|
19
|
-
sleep
|
21
|
+
sleep interval
|
20
22
|
Kennel.err.print "\b"
|
21
23
|
count += 1
|
22
24
|
end
|
23
25
|
end
|
24
26
|
|
25
|
-
time = Benchmark.realtime { result =
|
27
|
+
time = Benchmark.realtime { result = block.call }
|
26
28
|
|
27
29
|
stop = true
|
30
|
+
begin
|
31
|
+
spinner.run # wake thread, so it stops itself
|
32
|
+
rescue ThreadError
|
33
|
+
# thread was already dead, but we can't check with .alive? since it's a race condition
|
34
|
+
end
|
28
35
|
spinner.join
|
29
36
|
Kennel.err.print "#{time.round(2)}s\n"
|
30
37
|
|
@@ -32,5 +39,17 @@ module Kennel
|
|
32
39
|
ensure
|
33
40
|
stop = true # make thread stop without killing it
|
34
41
|
end
|
42
|
+
|
43
|
+
class << self
|
44
|
+
private
|
45
|
+
|
46
|
+
def progress_no_tty(name)
|
47
|
+
Kennel.err.puts "#{name} ..."
|
48
|
+
result = nil
|
49
|
+
time = Benchmark.realtime { result = yield }
|
50
|
+
Kennel.err.puts "#{name} ... #{time.round(2)}s"
|
51
|
+
result
|
52
|
+
end
|
53
|
+
end
|
35
54
|
end
|
36
55
|
end
|
@@ -8,17 +8,15 @@ module Kennel
|
|
8
8
|
|
9
9
|
private
|
10
10
|
|
11
|
+
# load_all's purpose is to "require" all the .rb files under './projects',
|
12
|
+
# while allowing them to resolve reference to ./teams and ./parts via autoload
|
11
13
|
def load_all
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
# somewhat one-way: we're not providing any mechanism to *un*load things.
|
19
|
-
# As long as the contents of `./projects`, `./teams` and `./parts` doesn't
|
20
|
-
# change between calls, then simply by no-op'ing subsequent calls to `load_all`
|
21
|
-
# we can have `load_all` appear to be idempotent.
|
14
|
+
# Zeitwerk rejects second and subsequent calls.
|
15
|
+
# Even if we skip over the Zeitwerk part, the nature of 'require' is
|
16
|
+
# one-way: ruby does not provide a mechanism to *un*require things.
|
17
|
+
return if defined?(@@load_all) && @@load_all
|
18
|
+
@@load_all = true
|
19
|
+
|
22
20
|
loader = Zeitwerk::Loader.new
|
23
21
|
Dir.exist?("teams") && loader.push_dir("teams", namespace: Teams)
|
24
22
|
Dir.exist?("parts") && loader.push_dir("parts")
|
data/lib/kennel/syncer.rb
CHANGED
data/lib/kennel/tasks.rb
CHANGED
@@ -233,6 +233,17 @@ namespace :kennel do
|
|
233
233
|
end
|
234
234
|
end
|
235
235
|
|
236
|
+
desc "Resolve given id to kennel tracking-id RESOURCE= ID="
|
237
|
+
task tracking_id: "kennel:environment" do
|
238
|
+
resource = ENV.fetch("RESOURCE")
|
239
|
+
id = ENV.fetch("ID")
|
240
|
+
klass =
|
241
|
+
Kennel::Models::Record.subclasses.detect { |s| s.api_resource == resource } ||
|
242
|
+
raise("resource #{resource} not know")
|
243
|
+
object = Kennel.send(:api).show(resource, id)
|
244
|
+
Kennel.out.puts klass.parse_tracking_id(object)
|
245
|
+
end
|
246
|
+
|
236
247
|
task :environment do
|
237
248
|
Kennel::Tasks.load_environment
|
238
249
|
end
|
data/lib/kennel/utils.rb
CHANGED
@@ -42,7 +42,7 @@ module Kennel
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def ask(question)
|
45
|
-
Kennel.err.printf color(:red, "#{question} - press 'y' to continue: ")
|
45
|
+
Kennel.err.printf color(:red, "#{question} - press 'y' to continue: ", force: true)
|
46
46
|
begin
|
47
47
|
STDIN.gets.chomp == "y"
|
48
48
|
rescue Interrupt # do not show a backtrace if user decides to Ctrl+C here
|
@@ -51,12 +51,10 @@ module Kennel
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
def color(color, text)
|
55
|
-
|
56
|
-
end
|
54
|
+
def color(color, text, force: false)
|
55
|
+
return text unless force || Kennel.out.tty?
|
57
56
|
|
58
|
-
|
59
|
-
text.gsub(/\e\[\d+m(.*?)\e\[0m/, "\\1").gsub(/.#{Regexp.escape("\b")}/, "")
|
57
|
+
"\e[#{COLORS.fetch(color)}m#{text}\e[0m"
|
60
58
|
end
|
61
59
|
|
62
60
|
def capture_stdout
|
data/lib/kennel/version.rb
CHANGED
data/template/Readme.md
CHANGED
@@ -388,3 +388,11 @@ https://foo.datadog.com/monitor/123
|
|
388
388
|
### Find all monitors with No-Data
|
389
389
|
`rake kennel:nodata TAG=team:foo`
|
390
390
|
|
391
|
+
### Finding the tracking id of a resource
|
392
|
+
|
393
|
+
When trying to link resources together, this avoids having to go through datadog UI.
|
394
|
+
|
395
|
+
```Bash
|
396
|
+
rake kennel:tracking_id ID=123 RESOURCE=monitor
|
397
|
+
```
|
398
|
+
|
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.
|
4
|
+
version: 1.122.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: 2022-
|
11
|
+
date: 2022-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: diff-lcs
|