kennel 1.91.3 → 1.92.3
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/models/dashboard.rb +0 -1
- data/lib/kennel/syncer.rb +26 -5
- data/lib/kennel/tasks.rb +1 -1
- 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: a3460bf3995d61817a7d7db0ad209012cb6cd51b1d5ba6767f4d20bc1766243f
|
4
|
+
data.tar.gz: 6a70c8e91c2bbf3e67db5f157e3c7f85d4025d2494d04026f9e7dc2007635217
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d3554ec738b404eb6ef6ff6e32120b86d3e65d399c7a5c0ff9c828e3beecf066fb441d941f077b9537c50347b1c5694b54d94e1c4f1d1ba19bacb5afcb1af57
|
7
|
+
data.tar.gz: d3eb584c0b15e04e38021324ce5e861740c2660f978cf9f413635a6a76fc8a4f82bba09a07343e12b0821f4b56f098fe39a8387013ffbb287065281b54bbeca5
|
@@ -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/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/tasks.rb
CHANGED
@@ -48,7 +48,7 @@ namespace :kennel do
|
|
48
48
|
url = Kennel::Utils.path_to_url "/account/settings"
|
49
49
|
puts "Invalid mentions found, either ignore them by adding to `KNOWN` env var or add them via #{url}"
|
50
50
|
bad.each { |f, v| puts "Invalid mention #{v} in monitor message of #{f}" }
|
51
|
-
Kennel::Tasks.abort
|
51
|
+
Kennel::Tasks.abort ENV["KNOWN_WARNING"]
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
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.3
|
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-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|