kennel 2.23.0 → 2.25.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 -10
- data/lib/kennel/models/dashboard.rb +19 -2
- data/lib/kennel/models/monitor.rb +3 -1
- data/lib/kennel/models/slo.rb +7 -0
- data/lib/kennel/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: eb2b34e31aea05805acb7cdc2785752b777a4a86e7779af063f6b0872e654aec
|
|
4
|
+
data.tar.gz: '08206487f025d5b1a717282b1afc89c2951f9d5649cba8f8b0a84b5cc2619927'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6979f6b80a91db3d10c0d8afc53d7586731a58f656a1eeb61c4877ce6a19d5f89c88fddb19636837db2c4f6eac62e4814d1f8258bf82c910ebbecc67a5e8de21
|
|
7
|
+
data.tar.gz: ea8e6e81dc3a262b88f8820072821357557f564933050ca31fa74719676cbbd4b3a6c1b5bcd6dd3d48b712e65571f36dadfb93fa7320bb0bde35a85c4f7abb4c
|
data/lib/kennel/api.rb
CHANGED
|
@@ -88,30 +88,49 @@ module Kennel
|
|
|
88
88
|
|
|
89
89
|
private
|
|
90
90
|
|
|
91
|
-
# keep widget ids stable so stored dashboard urls that point at a widget do not break on every update
|
|
92
|
-
#
|
|
93
|
-
# and breaks stored urls that point at a specific widget, so restore the previous ids by matching widget titles
|
|
91
|
+
# keep widget + tab ids stable so stored dashboard urls that point at a widget or tab do not break on every update
|
|
92
|
+
# ids are dropped when diffing since storing them would be ugly, so restore the previous ids by matching widget titles
|
|
94
93
|
def restore_widget_ids(id, attributes)
|
|
95
94
|
return unless (widgets = attributes[:widgets])
|
|
96
95
|
return unless (current = show("dashboard", id, {}, ignore_404: true))
|
|
97
96
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
97
|
+
# backfill widget ids
|
|
98
|
+
widget_title_to_id = {}
|
|
99
|
+
each_widget_with_title(current[:widgets]) { |title, widget| widget_title_to_id[title] = widget[:id] }
|
|
100
|
+
each_widget_with_title(widgets) do |title, widget|
|
|
101
|
+
next unless (id = widget_title_to_id[title])
|
|
102
102
|
widget[:id] ||= id # do not set nil, that breaks updates
|
|
103
103
|
end
|
|
104
|
+
|
|
105
|
+
return unless (tabs = attributes[:tabs])
|
|
106
|
+
|
|
107
|
+
# backfill tag ids ... first by name, then just whatever we got left
|
|
108
|
+
# not setting nils so we get the proper `{"errors":["Required parameter 'id' is missing"]}` error
|
|
109
|
+
tab_name_to_id = {}
|
|
110
|
+
current[:tabs]&.each do |tab|
|
|
111
|
+
tab_name_to_id[tab[:name]] = tab[:id] # collect old tab names
|
|
112
|
+
end
|
|
113
|
+
tabs.each do |tab|
|
|
114
|
+
next if tab[:id]
|
|
115
|
+
next unless (id = tab_name_to_id.delete(tab[:name])) # reused moved tabs so links keep working
|
|
116
|
+
tab[:id] = id
|
|
117
|
+
end
|
|
118
|
+
tabs.each do |tab|
|
|
119
|
+
next if tab[:id]
|
|
120
|
+
next unless (id = tab_name_to_id.delete(tab_name_to_id.keys.first)) # reuse renamed tabs so links keep working
|
|
121
|
+
tab[:id] ||= id
|
|
122
|
+
end
|
|
104
123
|
end
|
|
105
124
|
|
|
106
125
|
# yield each widget with a key built from its group optional title/position and its own title/position
|
|
107
|
-
def
|
|
126
|
+
def each_widget_with_title(widgets, prefix: nil, &block)
|
|
108
127
|
widgets.each_with_index do |widget, i|
|
|
109
128
|
title = widget.dig(:definition, :title)
|
|
110
129
|
title = i.to_s if title.to_s.empty?
|
|
111
|
-
key = [prefix, title]
|
|
130
|
+
key = prefix ? [prefix, title] : [title]
|
|
112
131
|
yield key, widget
|
|
113
132
|
if (nested = widget.dig(:definition, :widgets))
|
|
114
|
-
|
|
133
|
+
each_widget_with_title(nested, prefix: title, &block)
|
|
115
134
|
end
|
|
116
135
|
end
|
|
117
136
|
end
|
|
@@ -77,7 +77,7 @@ module Kennel
|
|
|
77
77
|
|
|
78
78
|
settings(
|
|
79
79
|
:title, :description, :definitions, :widgets, :layout_type, :template_variable_presets, :reflow_type,
|
|
80
|
-
:tags
|
|
80
|
+
:tags, :tabs, :default_timeframe
|
|
81
81
|
)
|
|
82
82
|
|
|
83
83
|
defaults(
|
|
@@ -86,7 +86,9 @@ module Kennel
|
|
|
86
86
|
widgets: -> { [] },
|
|
87
87
|
template_variable_presets: -> { DEFAULTS.fetch(:template_variable_presets) },
|
|
88
88
|
reflow_type: -> { layout_type == "ordered" ? "auto" : nil },
|
|
89
|
-
tags: -> { project.tags }
|
|
89
|
+
tags: -> { project.tags },
|
|
90
|
+
tabs: -> { nil },
|
|
91
|
+
default_timeframe: -> { nil }
|
|
90
92
|
)
|
|
91
93
|
|
|
92
94
|
class << self
|
|
@@ -100,6 +102,8 @@ module Kennel
|
|
|
100
102
|
ignore_default expected, actual, DEFAULTS
|
|
101
103
|
ignore_default expected, actual, reflow_type: "auto" if expected[:layout_type] == "ordered"
|
|
102
104
|
|
|
105
|
+
dry_up_dashboard_tabs(actual)
|
|
106
|
+
|
|
103
107
|
widgets_pairs(expected, actual).each do |pair|
|
|
104
108
|
pair.each { |w| sort_conditional_formats w }
|
|
105
109
|
ignore_widget_defaults(*pair)
|
|
@@ -110,6 +114,11 @@ module Kennel
|
|
|
110
114
|
|
|
111
115
|
private
|
|
112
116
|
|
|
117
|
+
def dry_up_dashboard_tabs(dashboard)
|
|
118
|
+
return unless (tabs = dashboard[:tabs])
|
|
119
|
+
tabs.each { |t| t.delete :id } # we never want to update that, see api.rb
|
|
120
|
+
end
|
|
121
|
+
|
|
113
122
|
# conditional_formats ordering is randomly changed by datadog, compare a stable ordering
|
|
114
123
|
def sort_conditional_formats(widget)
|
|
115
124
|
if (formats = widget&.dig(:definition, :conditional_formats))
|
|
@@ -163,6 +172,14 @@ module Kennel
|
|
|
163
172
|
tags: tags.grep(TAG_PREFIX)
|
|
164
173
|
)
|
|
165
174
|
|
|
175
|
+
if (value = tabs)
|
|
176
|
+
json[:tabs] = value
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
if (value = default_timeframe)
|
|
180
|
+
json[:default_timeframe] = value
|
|
181
|
+
end
|
|
182
|
+
|
|
166
183
|
json[:reflow_type] = reflow_type if reflow_type # setting nil breaks create with "ordered"
|
|
167
184
|
|
|
168
185
|
json
|
|
@@ -377,7 +377,9 @@ module Kennel
|
|
|
377
377
|
return unless (match = data.fetch(:query).match(/(?:{([^}]*)}\s*)?by\s*[({]([^})]+)[})]/))
|
|
378
378
|
|
|
379
379
|
allowed =
|
|
380
|
-
match[1].to_s.split(/\s*,\s*/)
|
|
380
|
+
match[1].to_s.split(/\s*,\s*/)
|
|
381
|
+
.reject { |k| k.start_with?("!") } # {!a:b} does not pin a value, so a.name is not available
|
|
382
|
+
.map { |k| k.split(":", 2)[-2] } + # {a:b} -> a TODO: does not work for service check
|
|
381
383
|
match[2].to_s.gsub(/["']/, "").split(/\s*,\s*/) # by {a} -> a
|
|
382
384
|
|
|
383
385
|
return if allowed.include?("*")
|
data/lib/kennel/models/slo.rb
CHANGED
|
@@ -79,6 +79,13 @@ module Kennel
|
|
|
79
79
|
url[/[?&]slo_id=([a-z\d]{10,})/, 1] || url[/\/slo\/([a-z\d]{10,})(:?\/edit)?(\?|$)/, 1]
|
|
80
80
|
end
|
|
81
81
|
|
|
82
|
+
# datadog rejects changing the type in place, so force a re-create
|
|
83
|
+
def allowed_update_error(actual)
|
|
84
|
+
actual_type = actual[:type]
|
|
85
|
+
return if actual_type == type
|
|
86
|
+
"cannot update type from #{actual_type} to #{type}"
|
|
87
|
+
end
|
|
88
|
+
|
|
82
89
|
def resolve_linked_tracking_ids!(id_map, **args)
|
|
83
90
|
return unless (ids = as_json[:monitor_ids]) # ignore_default can remove it
|
|
84
91
|
as_json[:monitor_ids] = ids.map do |id|
|
data/lib/kennel/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: kennel
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.25.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Michael Grosser
|
|
@@ -151,7 +151,7 @@ require_paths:
|
|
|
151
151
|
- lib
|
|
152
152
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
153
153
|
requirements:
|
|
154
|
-
- - "
|
|
154
|
+
- - "~>"
|
|
155
155
|
- !ruby/object:Gem::Version
|
|
156
156
|
version: 4.0.0
|
|
157
157
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
@@ -160,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
160
160
|
- !ruby/object:Gem::Version
|
|
161
161
|
version: '0'
|
|
162
162
|
requirements: []
|
|
163
|
-
rubygems_version: 4.0.
|
|
163
|
+
rubygems_version: 4.0.20
|
|
164
164
|
specification_version: 4
|
|
165
165
|
summary: Keep datadog monitors/dashboards/etc in version control, avoid chaotic management
|
|
166
166
|
via UI
|