kennel 1.91.0 → 1.92.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: 3c4072608bea0464722665eacf42705148b1167be7841eed87f062927592ecaa
4
- data.tar.gz: 32cbe46724d73f66355241c3c60776285129a94fd4c5a56ec5d70af8a7fa62d5
3
+ metadata.gz: 9c49a8d3df01c51505bd27350f74dde6f4211fe576a97857e68f27f5d86aae4d
4
+ data.tar.gz: 72641a908961fe238b70a59d3e952abfccc83bd9522c12757f0d436993f73263
5
5
  SHA512:
6
- metadata.gz: 90ba6d96631fb40a3576238b2b4e5bb07f630f702e7d04d29d957790fdfd91a6b919391d0c6e0cfec353ce492b83d514146e21a539d7b880c3d20a1e51374e23
7
- data.tar.gz: da85a013a71a13da279085656ff767736f5fa317dfb567da609abe91de46d145f204eb51d310e4346ce3561f3aae65af7a26bc7efa407dd152aec2c6dbe3093d
6
+ metadata.gz: 1789814bea2d153d1428a751ce1b56dbdbd89714cc81608e4a133ae05377a55c724a26809419c995224f5f669387f5116926eb558646307a3415cb0672b10da5
7
+ data.tar.gz: 69ea27ba49933d745bf5cf362cb4361bee0bdf74cd4934fad6616b5ec9ba52216e4a5e365723550792c64a866d114b328c3c61483cce5b7b5ec0d2b21cdc476b
data/lib/kennel/api.rb CHANGED
@@ -52,7 +52,12 @@ module Kennel
52
52
  # external dependency on kennel managed resources is their problem, we don't block on it
53
53
  # (?force=true did not work, force for dashboard is not documented but does not blow up)
54
54
  def delete(api_resource, id)
55
- request :delete, "/api/v1/#{api_resource}/#{id}", params: { force: "true" }, ignore_404: true
55
+ if api_resource == "synthetics/tests"
56
+ # https://docs.datadoghq.com/api/latest/synthetics/#delete-tests
57
+ request :post, "/api/v1/#{api_resource}/delete", body: { public_ids: [id] }, ignore_404: true
58
+ else
59
+ request :delete, "/api/v1/#{api_resource}/#{id}", params: { force: "true" }, ignore_404: true
60
+ end
56
61
  end
57
62
 
58
63
  def fill_details!(api_resource, list)
@@ -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, Utils.capture_sh("git rev-parse HEAD").strip).report(&block)
11
+ new(token).report(&block)
12
12
  end
13
13
  end
14
14
 
15
- def initialize(token, git_sha)
15
+ def initialize(token, ref: "HEAD")
16
16
  @token = token
17
- @git_sha = git_sha
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
- post "commits/#{@git_sha}/comments", body: body
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/repos/#{@repo_part}/#{path}"
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
@@ -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] && request[:formulas] != [{ formula: "query1" }]
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
@@ -24,7 +24,14 @@ module Kennel
24
24
  end
25
25
 
26
26
  def confirm
27
- ENV["CI"] || !STDIN.tty? || Utils.ask("Execute Plan ?") unless noop?
27
+ return false if noop?
28
+ return true if ENV["CI"] || !STDIN.tty?
29
+ if @delete.any? && @project_filter
30
+ Kennel.out.puts(
31
+ Utils.color(:red, "WARNING: deleting resources that had `id: -> { ...` breaks master branch")
32
+ )
33
+ end
34
+ Utils.ask("Execute Plan ?")
28
35
  end
29
36
 
30
37
  def update
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Kennel
3
- VERSION = "1.91.0"
3
+ VERSION = "1.92.0"
4
4
  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.91.0
4
+ version: 1.92.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: 2021-07-09 00:00:00.000000000 Z
11
+ date: 2021-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday