kennel 1.159.0 → 1.160.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: afa96484d3351de6a715ca440d8a22d3eb81012866a08987b0ddce36b568ae48
4
- data.tar.gz: 5f8d189f4447e998711ae07a1ee245c56c0453569a5a43e12ca8a9e9c3184030
3
+ metadata.gz: 305e0eb2205f87e8f993c0a6d19936f8ab2b2bdffa20316cc54dd241932cdad0
4
+ data.tar.gz: aea7a8fe0cbb8981e777bf83cdcfdf07489581c0621140f299aa9ec4a3447ac3
5
5
  SHA512:
6
- metadata.gz: a3886ae264c55d8112de1f16e7d0af92b97d1ecbf470219ff7131cb45df6fa115ef14142cc3c31056e88a135bb2c4091d15fd9a160a624875f2758db23ad70d8
7
- data.tar.gz: 072d6d09e64c55e1a0c167ec884dfcf17102c05fdba614b5bbc1132e3c582cb5699c6bfdf1faf4d6a5d5d0b7b702adbc94b82753b20530d1d3d435593cea774a
6
+ metadata.gz: 19ebc04a7b038919f635a33fc9e8f9e94500c62d9e8c68f6a51df9d66d4d8bc9e4b0036cd48b04f1215cfaa23d28321982ac28f90b26fd091cbac6da671b1f22
7
+ data.tar.gz: cddea78b6c4050cfbb3b7de37346ea91022a00f72f3da62368870878c8630a2024988b894bb102be81e05f80002c0e9ffcf2ce1ae434673eca43fc342c902f44
data/lib/kennel/api.rb CHANGED
@@ -7,7 +7,7 @@ module Kennel
7
7
 
8
8
  RateLimitParams = Data.define(:limit, :period, :remaining, :reset, :name)
9
9
 
10
- def self.tag(api_resource, reply)
10
+ def self.with_tracking(api_resource, reply)
11
11
  klass = Models::Record.api_resource_map[api_resource]
12
12
  return reply unless klass # do not blow up on unknown models
13
13
 
@@ -28,7 +28,7 @@ module Kennel
28
28
  response = request :get, "/api/v1/#{api_resource}/#{id}", params: params
29
29
  response = response.fetch(:data) if api_resource == "slo"
30
30
  response[:id] = response.delete(:public_id) if api_resource == "synthetics/tests"
31
- self.class.tag(api_resource, response)
31
+ self.class.with_tracking(api_resource, response)
32
32
  end
33
33
 
34
34
  def list(api_resource, params = {})
@@ -44,7 +44,7 @@ module Kennel
44
44
  # ignore monitor synthetics create and that inherit the kennel_id, we do not directly manage them
45
45
  response.reject! { |m| m[:type] == "synthetics alert" } if api_resource == "monitor"
46
46
 
47
- response.map { |r| self.class.tag(api_resource, r) }
47
+ response.map { |r| self.class.with_tracking(api_resource, r) }
48
48
  end
49
49
  end
50
50
 
@@ -52,13 +52,13 @@ module Kennel
52
52
  response = request :post, "/api/v1/#{api_resource}", body: attributes
53
53
  response = response.fetch(:data).first if api_resource == "slo"
54
54
  response[:id] = response.delete(:public_id) if api_resource == "synthetics/tests"
55
- self.class.tag(api_resource, response)
55
+ self.class.with_tracking(api_resource, response)
56
56
  end
57
57
 
58
58
  def update(api_resource, id, attributes)
59
59
  response = request :put, "/api/v1/#{api_resource}/#{id}", body: attributes
60
60
  response[:id] = response.delete(:public_id) if api_resource == "synthetics/tests"
61
- self.class.tag(api_resource, response)
61
+ self.class.with_tracking(api_resource, response)
62
62
  end
63
63
 
64
64
  # - force=true to not dead-lock on dependent monitors+slos
@@ -14,10 +14,6 @@ module Kennel
14
14
  end
15
15
 
16
16
  def import(resource, id)
17
- if ["screen", "dash"].include?(resource)
18
- raise ArgumentError, "resource 'screen' and 'dash' are deprecated, use 'dashboard'"
19
- end
20
-
21
17
  model =
22
18
  Kennel::Models::Record.subclasses.detect { |c| c.api_resource == resource } ||
23
19
  raise(ArgumentError, "#{resource} is not supported")
@@ -34,7 +34,8 @@ module Kennel
34
34
  },
35
35
  time: {},
36
36
  title_align: "left",
37
- title_size: "16"
37
+ title_size: "16",
38
+ show_legend: true
38
39
  },
39
40
  "note" => {
40
41
  show_tick: false,
data/lib/kennel/syncer.rb CHANGED
@@ -91,21 +91,7 @@ module Kennel
91
91
  matching, unmatched_expected, unmatched_actual = MatchedExpected.partition(expected, actual)
92
92
  unmatched_actual.select! { |a| a.fetch(:tracking_id) } # ignore items that were never managed by kennel
93
93
 
94
- # if there is a new item that has the same name/title as a to be deleted item, we should just update it
95
- # careful with unmatched_expected being huge since it has all api resources
96
- unmatched_expected.reject! do |e|
97
- actual = unmatched_actual.detect do |a|
98
- a[:klass] == e.class &&
99
- Kennel::Models::Record::TITLE_FIELDS.any? { |f| (set = a[f]) && set == e.as_json.fetch(f) }
100
- end
101
- next false unless actual # keep in unmatched
102
-
103
- unmatched_actual.delete(actual)
104
- actual[:tracking_id] = e.tracking_id
105
- matching << [e, actual]
106
-
107
- true # remove from unmatched
108
- end
94
+ convert_replace_into_update!(matching, unmatched_actual, unmatched_expected)
109
95
 
110
96
  validate_expected_id_not_missing unmatched_expected
111
97
  fill_details! matching # need details to diff later
@@ -137,6 +123,32 @@ module Kennel
137
123
  end
138
124
  end
139
125
 
126
+ # if there is a new item that has the same name or title as an "to be deleted" item,
127
+ # update it instead to avoid old urls from becoming invalid
128
+ # - careful with unmatched_actual being huge since it has all api resources
129
+ # - don't do it when a monitor type is changing since that would block the update
130
+ def convert_replace_into_update!(matching, unmatched_actual, unmatched_expected)
131
+ unmatched_expected.reject! do |e|
132
+ e_field, e_value = Kennel::Models::Record::TITLE_FIELDS.detect do |field|
133
+ next unless (value = e.as_json[field])
134
+ break [field, value]
135
+ end
136
+ raise unless e_field # uncovered: should never happen ...
137
+ e_monitor_type = e.as_json[:type]
138
+
139
+ actual = unmatched_actual.detect do |a|
140
+ a[:klass] == e.class && a[e_field] == e_value && a[:type] == e_monitor_type
141
+ end
142
+ next false unless actual # keep in unmatched
143
+
144
+ # add as update and remove from unmatched
145
+ unmatched_actual.delete(actual)
146
+ actual[:tracking_id] = e.tracking_id
147
+ matching << [e, actual]
148
+ true
149
+ end
150
+ end
151
+
140
152
  # fill details of things we need to compare
141
153
  def fill_details!(details_needed)
142
154
  details_needed = details_needed.map { |e, a| a if e && e.class.api_resource == "dashboard" }.compact
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Kennel
3
- VERSION = "1.159.0"
3
+ VERSION = "1.160.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.159.0
4
+ version: 1.160.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: 2025-04-02 00:00:00.000000000 Z
11
+ date: 2025-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: diff-lcs