kennel 1.147.0 → 1.149.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7aa3215e281ade43456180bbdbe048939052d0238b1303705842cad7145b5457
4
- data.tar.gz: ae9ec09767652ff2839da017731f7f7487e237cbea81d9cebb89f39351bd7cca
3
+ metadata.gz: dca468d8f965e5b3ed1e1bb74610a1f5fd9b66bca5269286f5edb48dbc7d552d
4
+ data.tar.gz: 91d9a7a9c1e0e9aefa052e3673fb1239d2a61bf3387c10c4c323094ba91faca0
5
5
  SHA512:
6
- metadata.gz: 0064bfa8723de2680d8a7dfd2d050018a040015efa8e57646039cbb825fb3278bbdf29ea8f60de4dc617d61b0ddc69bac4fa050fc125c10be413d1900eca7556
7
- data.tar.gz: 5a1dc95851d870c5d00ab6d2b17c357572b44ab058ae87d486e6b4786797211fede1e6ef7dc935fc2e743f0ada6a942556f8222a4dc4b931047ffb7dbb07dc74
6
+ metadata.gz: 7b72426c08a25c1c7fd86a7193420a5b1ca5f8fca102087d021f1944b688d8d9fdd58fe1f3feb23355ddf8eed9196b8b4a96b5284942e9755d01b3ce0d9bb201
7
+ data.tar.gz: 374585d70647bed669a87039cc96c01db509ceb5d953b526e47da8b1883a5f5e1ced444a289e73f1e602ba2f64f95984a1088c5f0f35ca35299fe993a42f8244
data/lib/kennel/api.rb CHANGED
@@ -5,6 +5,8 @@ module Kennel
5
5
  class Api
6
6
  CACHE_FILE = ENV.fetch("KENNEL_API_CACHE_FILE", "tmp/cache/details")
7
7
 
8
+ RateLimitParams = Data.define(:limit, :period, :remaining, :reset, :name)
9
+
8
10
  def self.tag(api_resource, reply)
9
11
  klass = Models::Record.api_resource_map[api_resource]
10
12
  return reply unless klass # do not blow up on unknown models
@@ -18,7 +20,7 @@ module Kennel
18
20
  def initialize(app_key = nil, api_key = nil)
19
21
  @app_key = app_key || ENV.fetch("DATADOG_APP_KEY")
20
22
  @api_key = api_key || ENV.fetch("DATADOG_API_KEY")
21
- url = Utils.path_to_url("", subdomain: "app")
23
+ url = Utils.path_to_url("")
22
24
  @client = Faraday.new(url: url) { |c| c.adapter :net_http_persistent }
23
25
  end
24
26
 
@@ -122,6 +124,23 @@ module Kennel
122
124
  end
123
125
  end
124
126
 
127
+ rate_limit = RateLimitParams.new(
128
+ limit: response.headers["x-ratelimit-limit"],
129
+ period: response.headers["x-ratelimit-period"],
130
+ remaining: response.headers["x-ratelimit-remaining"],
131
+ reset: response.headers["x-ratelimit-reset"],
132
+ name: response.headers["x-ratelimit-name"]
133
+ )
134
+
135
+ if response.status == 429
136
+ message = "Datadog rate limit #{rate_limit.name.inspect} hit"
137
+ message += " (#{rate_limit.limit} requests per #{rate_limit.period} seconds)"
138
+ message += "; sleeping #{rate_limit.reset} seconds before trying again"
139
+ Kennel.err.puts message
140
+ sleep rate_limit.reset.to_f
141
+ redo
142
+ end
143
+
125
144
  break if i == tries - 1 || method != :get || response.status < 500
126
145
  Kennel.err.puts "Retrying on server error #{response.status} for #{path}"
127
146
  end
@@ -96,7 +96,9 @@ module Kennel
96
96
  # strict: ignore Integer vs Float
97
97
  # similarity: show diff when not 100% similar
98
98
  # use_lcs: saner output
99
- Hashdiff.diff(actual, expected, use_lcs: false, strict: false, similarity: 1)
99
+ result = Hashdiff.diff(actual, expected, use_lcs: false, strict: false, similarity: 1)
100
+ raise "Empty diff detected: guard condition failed" if result.empty?
101
+ result
100
102
  end
101
103
 
102
104
  def tracking_id
@@ -22,11 +22,19 @@ module Kennel
22
22
 
23
23
  def print_changes(step, list, color)
24
24
  return if list.empty?
25
+
26
+ use_groups = ENV.key?("GITHUB_STEP_SUMMARY")
27
+
25
28
  list.each do |item|
29
+ # No trailing newline
30
+ Kennel.out.print "::group::" if item.class::TYPE == :update && use_groups
31
+
26
32
  Kennel.out.puts Console.color(color, "#{step} #{item.api_resource} #{item.tracking_id}")
27
33
  if item.class::TYPE == :update
28
34
  item.diff.each { |args| Kennel.out.puts @attribute_differ.format(*args) } # only for update
29
35
  end
36
+
37
+ Kennel.out.puts "::endgroup::" if item.class::TYPE == :update && use_groups
30
38
  end
31
39
  end
32
40
  end
data/lib/kennel/tasks.rb CHANGED
@@ -91,8 +91,8 @@ namespace :kennel do
91
91
 
92
92
  if bad.any?
93
93
  url = Kennel::Utils.path_to_url "/account/settings"
94
- Kennel.out.puts "Invalid mentions found, either ignore them by adding to `KNOWN` env var or add them via #{url}"
95
- bad.each { |f, v| Kennel.out.puts "Invalid mention #{v} in monitor message of #{f}" }
94
+ Kennel.err.puts "Invalid mentions found, either ignore them by adding to `KNOWN` env var or add them via #{url}"
95
+ bad.each { |f, v| Kennel.err.puts "Invalid mention #{v} in monitor message of #{f}" }
96
96
  Kennel::Tasks.abort ENV["KNOWN_WARNING"]
97
97
  end
98
98
  end
data/lib/kennel/utils.rb CHANGED
@@ -12,8 +12,8 @@ module Kennel
12
12
  result
13
13
  end
14
14
 
15
- def path_to_url(path, subdomain: nil)
16
- subdomain ||= (ENV["DATADOG_SUBDOMAIN"] || "app")
15
+ def path_to_url(path)
16
+ subdomain = (ENV["DATADOG_SUBDOMAIN"] || "app")
17
17
  "https://#{subdomain}.datadoghq.com#{path}"
18
18
  end
19
19
 
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Kennel
3
- VERSION = "1.147.0"
3
+ VERSION = "1.149.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.147.0
4
+ version: 1.149.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: 2023-11-02 00:00:00.000000000 Z
11
+ date: 2024-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: diff-lcs