kennel 2.21.1 → 2.22.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 +4 -4
- data/lib/kennel/api.rb +29 -0
- data/lib/kennel/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b931b9c2d75d6e0d69967e3088795e72d8a5f3f558ff1dd1b6de03efde7aabf8
|
|
4
|
+
data.tar.gz: '081dde24122f351f92c7dc8f16e7877ec3dcd1f7226bd1e4fc126abd3044798d'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ffd01589e499c34d72dd477f5e3e00369582c42cacbf7eae19493e791b84ecbac42c48c5bf34e3d8c8a6245f555d29f62e3cb879cc2e24892b555766f9b5ffcc
|
|
7
|
+
data.tar.gz: 7a95114123013fd90a64993f86f217b5f4379e0d3dc6b19d876d2ac42f404b4907ef35b2396c811c4291838ca8183073523090bb2d89882dbbffa6972b40bb38
|
data/lib/kennel/api.rb
CHANGED
|
@@ -55,6 +55,8 @@ module Kennel
|
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
def update(api_resource, id, attributes)
|
|
58
|
+
restore_widget_ids(id, attributes) if api_resource == "dashboard"
|
|
59
|
+
|
|
58
60
|
response = request :put, "/api/v1/#{api_resource}/#{id}", body: attributes
|
|
59
61
|
response[:id] = response.delete(:public_id) if api_resource == "synthetics/tests"
|
|
60
62
|
self.class.with_tracking(api_resource, response)
|
|
@@ -86,6 +88,33 @@ module Kennel
|
|
|
86
88
|
|
|
87
89
|
private
|
|
88
90
|
|
|
91
|
+
# keep widget ids stable so stored dashboard urls that point at a widget do not break on every update
|
|
92
|
+
# widget ids are dropped when diffing since they change on every update, but that also changes them in datadog
|
|
93
|
+
# and breaks stored urls that point at a specific widget, so restore the previous ids by matching widget titles
|
|
94
|
+
def restore_widget_ids(id, attributes)
|
|
95
|
+
return unless (widgets = attributes[:widgets])
|
|
96
|
+
return unless (current = show("dashboard", id, {}, ignore_404: true))
|
|
97
|
+
|
|
98
|
+
ids = {}
|
|
99
|
+
each_widget_with_key(current[:widgets]) { |key, widget| ids[key] = widget[:id] }
|
|
100
|
+
each_widget_with_key(widgets) do |key, widget|
|
|
101
|
+
next unless (id = ids[key])
|
|
102
|
+
widget[:id] ||= id # do not set nil, that breaks updates
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# yield each widget with a key built from its (optional) group title and its own title
|
|
107
|
+
def each_widget_with_key(widgets, prefix: nil, &block)
|
|
108
|
+
widgets.each do |widget|
|
|
109
|
+
title = widget.dig(:definition, :title)
|
|
110
|
+
key = [prefix, title].compact.join("-")
|
|
111
|
+
yield key, widget
|
|
112
|
+
if (nested = widget.dig(:definition, :widgets))
|
|
113
|
+
each_widget_with_key(nested, prefix: title, &block)
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
89
118
|
def with_pagination(enabled, params)
|
|
90
119
|
return yield params unless enabled
|
|
91
120
|
raise ArgumentError if params[:limit] || params[:offset]
|
data/lib/kennel/version.rb
CHANGED