kennel 1.112.0 → 1.113.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: d0daaf865eea8c23b97ab763827ecf7a7addbe7cc3f8683d9c2ec0ba2b5115d5
4
- data.tar.gz: ffbffb714491fae59ef58738fb90dea0533571b1694a372cfd99269a9c74c321
3
+ metadata.gz: b199d98b445f146f6e5ac3a2746d715c4286a75da4ddd9cf2268875e41a4f7f4
4
+ data.tar.gz: cc748229520b855819210413905525b962b7ea21ff13053258a011f59abaf001
5
5
  SHA512:
6
- metadata.gz: d59cbb2e220bfc906d3842618704ddd09ed1636eab7923985efd75d5631b9c8a065f5026ec74a77b4da4112190b8798675aa538a6b97a2aecf96d0c90611a532
7
- data.tar.gz: 7e55958dc660217e230f5b1670c890d81619b042b181d29f68288115a4f05cf5d7aff9571aabf8937886379c30cb74188d139bbdbc9d7420e3f27c5faad939ec
6
+ metadata.gz: a26a733f32e1b0c167d950d4da1c8deb69717306e6428636e2b5ab03b450eb6db6f6797eb3a054a66083b91d351a6ca875703255cea2adec62f6022452d1e90c
7
+ data.tar.gz: cedb46594f03b8e2ebf89915f4bd8945f0378b51808e36460b5af8c7b44266e1661de771acb6febaffa2ca1226b88a533fccbea870e47e025b30677b7f91f5a4
data/Readme.md CHANGED
@@ -307,7 +307,8 @@ https://foo.datadog.com/monitor/123
307
307
  ## Development
308
308
 
309
309
  ### Benchmarking
310
- Setting `FORCE_GET_CACHE=true` will cache all get requests, which makes benchmarking improvements more reliable.
310
+ - Setting `FORCE_GET_CACHE=true` will cache all get requests, which makes benchmarking improvements more reliable.
311
+ - Setting `STORE=false` will make `rake plan` not update the files on disk and save a bit of time
311
312
 
312
313
  ### Integration testing
313
314
  ```Bash
@@ -109,11 +109,8 @@ module Kennel
109
109
  private
110
110
 
111
111
  def resolve(value, type, id_map, force:)
112
- if tracking_id?(value)
113
- return resolve_link(value, type, id_map, force: force)
114
- end
115
-
116
- value
112
+ return value unless tracking_id?(value)
113
+ resolve_link(value, type, id_map, force: force)
117
114
  end
118
115
 
119
116
  def tracking_id?(id)
@@ -68,8 +68,8 @@ module Kennel
68
68
  end
69
69
 
70
70
  def resolve_linked_tracking_ids!(id_map, **args)
71
- return unless as_json[:monitor_ids] # ignore_default can remove it
72
- as_json[:monitor_ids] = as_json[:monitor_ids].map do |id|
71
+ return unless ids = as_json[:monitor_ids] # ignore_default can remove it
72
+ as_json[:monitor_ids] = ids.map do |id|
73
73
  resolve(id, :monitor, id_map, **args) || id
74
74
  end
75
75
  end
data/lib/kennel/syncer.rb CHANGED
@@ -7,7 +7,7 @@ module Kennel
7
7
  def initialize(api, expected, project_filter: nil)
8
8
  @api = api
9
9
  @project_filter = project_filter
10
- @expected = expected
10
+ @expected = Set.new expected # need set to speed up deletion
11
11
  calculate_diff
12
12
  validate_plan
13
13
  prevent_irreversible_partial_updates
@@ -110,9 +110,10 @@ module Kennel
110
110
 
111
111
  @expected.each(&:add_tracking_id) # avoid diff with actual
112
112
 
113
+ lookup_map = matching_expected_lookup_map
113
114
  items = actual.map do |a|
114
- e = matching_expected(a)
115
- if e && @expected.delete(e)
115
+ e = matching_expected(a, lookup_map)
116
+ if e && @expected.delete?(e)
116
117
  [e, a]
117
118
  else
118
119
  [nil, a]
@@ -127,7 +128,7 @@ module Kennel
127
128
  items.each do |e, a|
128
129
  id = a.fetch(:id)
129
130
  if e
130
- diff = e.diff(a)
131
+ diff = e.diff(a) # slow ...
131
132
  @update << [id, e, a, diff] if diff.any?
132
133
  elsif a.fetch(:tracking_id) # was previously managed
133
134
  @delete << [id, nil, a]
@@ -166,9 +167,9 @@ module Kennel
166
167
  end
167
168
  end
168
169
 
169
- def matching_expected(a)
170
- # index list by all the thing we look up by: tracking id and actual id
171
- @lookup_map ||= @expected.each_with_object({}) do |e, all|
170
+ # index list by all the thing we look up by: tracking id and actual id
171
+ def matching_expected_lookup_map
172
+ @expected.each_with_object({}) do |e, all|
172
173
  keys = [e.tracking_id]
173
174
  keys << "#{e.class.api_resource}:#{e.id}" if e.id
174
175
  keys.compact.each do |key|
@@ -176,9 +177,11 @@ module Kennel
176
177
  all[key] = e
177
178
  end
178
179
  end
180
+ end
179
181
 
182
+ def matching_expected(a, map)
180
183
  klass = a.fetch(:klass)
181
- @lookup_map["#{klass.api_resource}:#{a.fetch(:id)}"] || @lookup_map[a.fetch(:tracking_id)]
184
+ map["#{klass.api_resource}:#{a.fetch(:id)}"] || map[a.fetch(:tracking_id)]
182
185
  end
183
186
 
184
187
  def print_plan(step, list, color)
data/lib/kennel/utils.rb CHANGED
@@ -149,7 +149,7 @@ module Kennel
149
149
  # TODO: use awesome-print or similar, but it has too many monkey-patches
150
150
  # https://github.com/amazing-print/amazing_print/issues/36
151
151
  def pretty_inspect(object)
152
- string = object.inspect
152
+ string = object.inspect.dup
153
153
  string.gsub!(/:([a-z_]+)=>/, "\\1: ")
154
154
  10.times do
155
155
  string.gsub!(/{(\S.*?\S)}/, "{ \\1 }") || break
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Kennel
3
- VERSION = "1.112.0"
3
+ VERSION = "1.113.0"
4
4
  end
data/lib/kennel.rb CHANGED
@@ -47,7 +47,9 @@ module Kennel
47
47
  attr_accessor :out, :err, :strict_imports
48
48
 
49
49
  def generate
50
- store generated
50
+ out = generated
51
+ store out if ENV["STORE"] != "false" # quicker when debugging
52
+ out
51
53
  end
52
54
 
53
55
  def plan
@@ -127,6 +129,11 @@ module Kennel
127
129
  use a different `kennel_id` when defining multiple projects/monitors/dashboards to avoid this conflict
128
130
  ERROR
129
131
  end
132
+
133
+ # trigger json caching here so it counts into generating
134
+ # somehow threading helps reduce this ~25%
135
+ Utils.parallel(parts, &:as_json)
136
+
130
137
  parts
131
138
  end
132
139
  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.112.0
4
+ version: 1.113.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-04-22 00:00:00.000000000 Z
11
+ date: 2022-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
117
  - !ruby/object:Gem::Version
118
118
  version: '0'
119
119
  requirements: []
120
- rubygems_version: 3.2.16
120
+ rubygems_version: 3.0.3
121
121
  signing_key:
122
122
  specification_version: 4
123
123
  summary: Keep datadog monitors/dashboards/etc in version control, avoid chaotic management