kennel 1.91.2 → 1.92.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kennel/github_reporter.rb +8 -5
- data/lib/kennel/importer.rb +2 -1
- data/lib/kennel/models/dashboard.rb +0 -1
- data/lib/kennel/syncer.rb +26 -5
- data/lib/kennel/version.rb +1 -1
- data/lib/kennel.rb +1 -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: 1e94541bcdef70aa7074e902576e22ffff456e11f04c55bed2567f2074273f38
|
4
|
+
data.tar.gz: 2eb1d620e5a4dfe57041e8252d06746ff5bb067aa6d0e375093278218e09662a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3404e5804b142f2f96b35ceaf9d51f3e7fb5c6e29c2573ef603f090e04653d77cd201081147c272d0648f0fac24f532b3a648d356755faa3973364997193367a
|
7
|
+
data.tar.gz: d8dcc7f3ea50824d6cbff9c3e29b83ecfd59559f25345e2ad7b468dea30f8423703879b9517823bc565d4e15b3a2fbb55f6c88a4727a20b98292f12958a17e3f
|
@@ -8,13 +8,15 @@ module Kennel
|
|
8
8
|
class << self
|
9
9
|
def report(token, &block)
|
10
10
|
return yield unless token
|
11
|
-
new(token
|
11
|
+
new(token).report(&block)
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
def initialize(token,
|
15
|
+
def initialize(token, ref: "HEAD")
|
16
16
|
@token = token
|
17
|
-
|
17
|
+
commit = Utils.capture_sh("git show #{ref}")
|
18
|
+
@sha = commit[/^Merge: \S+ (\S+)/, 1] || commit[/\Acommit (\S+)/, 1] || raise("Unable to find commit")
|
19
|
+
@pr = commit[/^\s+.*\(#(\d+)\)/, 1] # from squash
|
18
20
|
@repo_part = ENV["GITHUB_REPOSITORY"] || begin
|
19
21
|
origin = ENV["PROJECT_REPOSITORY"] || Utils.capture_sh("git remote -v").split("\n").first
|
20
22
|
origin[%r{github\.com[:/](\S+?)(\.git|$)}, 1] || raise("no origin found in #{origin}")
|
@@ -37,13 +39,14 @@ module Kennel
|
|
37
39
|
body = body.byteslice(0, MAX_COMMENT_SIZE - TRUNCATED_MSG.bytesize) + TRUNCATED_MSG
|
38
40
|
end
|
39
41
|
|
40
|
-
|
42
|
+
path = (@pr ? "/repos/#{@repo_part}/issues/#{@pr}/comments" : "/repos/#{@repo_part}/commits/#{@sha}/comments")
|
43
|
+
post path, body: body
|
41
44
|
end
|
42
45
|
|
43
46
|
private
|
44
47
|
|
45
48
|
def post(path, data)
|
46
|
-
url = "https://api.github.com
|
49
|
+
url = "https://api.github.com#{path}"
|
47
50
|
response = Faraday.post(url, data.to_json, authorization: "token #{@token}")
|
48
51
|
raise "failed to POST to github:\n#{url} -> #{response.status}\n#{response.body}" unless response.status == 201
|
49
52
|
end
|
data/lib/kennel/importer.rb
CHANGED
@@ -106,10 +106,11 @@ module Kennel
|
|
106
106
|
end
|
107
107
|
|
108
108
|
# new api format is very verbose, so use old dry format when possible
|
109
|
+
# dd randomly chooses query0 or query1
|
109
110
|
def convert_widget_to_compact_format!(widget)
|
110
111
|
(widget.dig(:definition, :requests) || []).each do |request|
|
111
112
|
next unless request.is_a?(Hash)
|
112
|
-
next if request[:formulas] &&
|
113
|
+
next if request[:formulas] && ![[{ formula: "query1" }], [{ formula: "query0" }]].include?(request[:formulas])
|
113
114
|
next if request[:queries]&.size != 1
|
114
115
|
next if request[:queries].any? { |q| q[:data_source] != "metrics" }
|
115
116
|
next if widget.dig(:definition, :type) != request[:response_format]
|
data/lib/kennel/syncer.rb
CHANGED
@@ -3,6 +3,7 @@ module Kennel
|
|
3
3
|
class Syncer
|
4
4
|
DELETE_ORDER = ["dashboard", "slo", "monitor", "synthetics/tests"].freeze # dashboards references monitors + slos, slos reference monitors
|
5
5
|
LINE_UP = "\e[1A\033[K" # go up and clear
|
6
|
+
DEFAULT_BRANCH = "master"
|
6
7
|
|
7
8
|
def initialize(api, expected, project: nil)
|
8
9
|
@api = api
|
@@ -26,11 +27,7 @@ module Kennel
|
|
26
27
|
def confirm
|
27
28
|
return false if noop?
|
28
29
|
return true if ENV["CI"] || !STDIN.tty?
|
29
|
-
if @
|
30
|
-
Kennel.out.puts(
|
31
|
-
Utils.color(:red, "WARNING: deleting resources that had `id: -> { ...` breaks master branch")
|
32
|
-
)
|
33
|
-
end
|
30
|
+
warn_about_deleting_resources_with_id if @project_filter
|
34
31
|
Utils.ask("Execute Plan ?")
|
35
32
|
end
|
36
33
|
|
@@ -63,6 +60,30 @@ module Kennel
|
|
63
60
|
|
64
61
|
private
|
65
62
|
|
63
|
+
# this is brittle/hacky since it relies on knowledge from the generation + git + branch knowledge
|
64
|
+
def warn_about_deleting_resources_with_id
|
65
|
+
@delete.each do |_, _, a|
|
66
|
+
tracking_id = a.fetch(:tracking_id)
|
67
|
+
api_resource = a.fetch(:klass).api_resource
|
68
|
+
|
69
|
+
file = "generated/#{tracking_id.sub(":", "/")}.json"
|
70
|
+
old = `true && git show #{DEFAULT_BRANCH}:#{file.shellescape} 2>&1` # true && to not crash on missing git
|
71
|
+
|
72
|
+
next unless $?.success?
|
73
|
+
old =
|
74
|
+
begin
|
75
|
+
JSON.parse(old)
|
76
|
+
rescue StandardError
|
77
|
+
false
|
78
|
+
end
|
79
|
+
next if !old || !old["id"]
|
80
|
+
|
81
|
+
Kennel.out.puts(
|
82
|
+
Utils.color(:red, "WARNING: deleting #{api_resource} #{tracking_id} will break #{DEFAULT_BRANCH} branch")
|
83
|
+
)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
66
87
|
# loop over items until everything is resolved or crash when we get stuck
|
67
88
|
# this solves cases like composite monitors depending on each other or monitor->monitor slo->slo monitor chains
|
68
89
|
def each_resolved(list)
|
data/lib/kennel/version.rb
CHANGED
data/lib/kennel.rb
CHANGED
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.92.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Grosser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|