kennel 1.59.2 → 1.61.2
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 +3 -1
- data/lib/kennel/models/dashboard.rb +44 -14
- data/lib/kennel/models/record.rb +0 -24
- data/lib/kennel/syncer.rb +2 -8
- data/lib/kennel/template_variables.rb +4 -1
- data/lib/kennel/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dd27c1efc9afa4ba43482978f3be42ae2ff6301b1532ae3461c043d503fc82c3
|
|
4
|
+
data.tar.gz: cc6209799a8b73dd0aca242e8f9a29a8693a2701c888ca3487f8dea0dfb9d100
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 28398d5ef02978e71c877edd65a4eb6a462ff1886df46d0bfabac621d640eb67f876d73dacfd52ef2c906c8715de006a7fc9e60d6663f4323f28fcd948cf4f36
|
|
7
|
+
data.tar.gz: 49581fac6bd3c3112f0d13cae7465580af642a78135f5b49c4e053d27bd66138b9e88b090912a96e943428903c7bcd8e07960c6beb2b406ecc795a69f4348775
|
data/lib/kennel/api.rb
CHANGED
|
@@ -27,7 +27,9 @@ module Kennel
|
|
|
27
27
|
offset += limit
|
|
28
28
|
end
|
|
29
29
|
else
|
|
30
|
-
request :get, "/api/v1/#{api_resource}", params: params
|
|
30
|
+
result = request :get, "/api/v1/#{api_resource}", params: params
|
|
31
|
+
result = result.fetch(:dashboards) if api_resource == "dashboard"
|
|
32
|
+
result
|
|
31
33
|
end
|
|
32
34
|
end
|
|
33
35
|
|
|
@@ -13,6 +13,7 @@ module Kennel
|
|
|
13
13
|
REQUEST_DEFAULTS = {
|
|
14
14
|
style: { line_width: "normal", palette: "dog_classic", line_type: "solid" }
|
|
15
15
|
}.freeze
|
|
16
|
+
TIMESERIES_DEFAULTS = { show_legend: false, legend_size: "0" }.freeze
|
|
16
17
|
SUPPORTED_DEFINITION_OPTIONS = [:events, :markers, :precision].freeze
|
|
17
18
|
|
|
18
19
|
settings :title, :description, :definitions, :widgets, :layout_type
|
|
@@ -32,39 +33,68 @@ module Kennel
|
|
|
32
33
|
def normalize(expected, actual)
|
|
33
34
|
super
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
widgets_pairs(expected, actual).each do |pair|
|
|
36
37
|
# datadog always adds 2 to slo widget height
|
|
37
38
|
# need to check fir layout since some monitors have height/width in their definition
|
|
38
|
-
pair.
|
|
39
|
+
pair[1].each do |widget|
|
|
39
40
|
if widget.dig(:definition, :type) == "slo" && widget.dig(:layout, :height)
|
|
40
41
|
widget[:layout][:height] -= 2
|
|
41
42
|
end
|
|
42
43
|
end
|
|
43
44
|
|
|
44
45
|
# conditional_formats ordering is randomly changed by datadog, compare a stable ordering
|
|
45
|
-
pair.each do |
|
|
46
|
-
|
|
47
|
-
if formats =
|
|
48
|
-
|
|
46
|
+
pair.each do |widgets|
|
|
47
|
+
widgets.each do |widget|
|
|
48
|
+
if formats = widget.dig(:definition, :conditional_formats)
|
|
49
|
+
widget[:definition][:conditional_formats] = formats.sort_by(&:hash)
|
|
49
50
|
end
|
|
50
51
|
end
|
|
51
52
|
end
|
|
52
53
|
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
ignore_definition_defaults_for_type pair, "timeseries", TIMESERIES_DEFAULTS
|
|
55
|
+
|
|
56
|
+
ignore_request_defaults(*pair)
|
|
57
|
+
|
|
58
|
+
# ids are kinda random so we always discard them
|
|
59
|
+
pair.each { |widgets| widgets.each { |w| w.delete(:id) } }
|
|
55
60
|
end
|
|
56
61
|
end
|
|
57
62
|
|
|
58
63
|
private
|
|
59
64
|
|
|
65
|
+
def ignore_definition_defaults_for_type(pair, type, defaults)
|
|
66
|
+
pair.map(&:size).max.times do |i|
|
|
67
|
+
if pair.all? { |w| w.dig(i, :definition, :type) == type }
|
|
68
|
+
ignore_defaults(pair[0], pair[1], defaults, nesting: :definition)
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# discard styles/conditional_formats/aggregator if nothing would change when we applied (both are default or nil)
|
|
74
|
+
def ignore_request_defaults(expected, actual)
|
|
75
|
+
[expected.size, actual.size].max.times do |i|
|
|
76
|
+
a_r = actual.dig(i, :definition, :requests) || []
|
|
77
|
+
e_r = expected.dig(i, :definition, :requests) || []
|
|
78
|
+
ignore_defaults e_r, a_r, REQUEST_DEFAULTS
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def ignore_defaults(expected, actual, defaults, nesting: nil)
|
|
83
|
+
[expected.size, actual.size].max.times do |i|
|
|
84
|
+
e = expected.dig(i, *nesting) || {}
|
|
85
|
+
a = actual.dig(i, *nesting) || {}
|
|
86
|
+
ignore_default(e, a, defaults)
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
60
90
|
# expand nested widgets into expected/actual pairs for default resolution
|
|
61
|
-
# [a, e] -> [[a, e], [
|
|
62
|
-
def
|
|
63
|
-
result = [pair]
|
|
64
|
-
slots =
|
|
91
|
+
# [a, e] -> [[a-w, e-w], [a-w1-w1, e-w1-w1], ...]
|
|
92
|
+
def widgets_pairs(*pair)
|
|
93
|
+
result = [pair.map { |d| d[:widgets] || [] }]
|
|
94
|
+
slots = result[0].map(&:size).max
|
|
65
95
|
slots.times do |i|
|
|
66
|
-
nested = pair.map { |d| d.dig(:widgets, i, :definition) ||
|
|
67
|
-
result << nested if nested.any?
|
|
96
|
+
nested = pair.map { |d| d.dig(:widgets, i, :definition, :widgets) || [] }
|
|
97
|
+
result << nested if nested.any?(&:any?)
|
|
68
98
|
end
|
|
69
99
|
result
|
|
70
100
|
end
|
data/lib/kennel/models/record.rb
CHANGED
|
@@ -6,11 +6,6 @@ module Kennel
|
|
|
6
6
|
READONLY_ATTRIBUTES = [
|
|
7
7
|
:deleted, :id, :created, :created_at, :creator, :org_id, :modified, :modified_at, :api_resource
|
|
8
8
|
].freeze
|
|
9
|
-
REQUEST_DEFAULTS = {
|
|
10
|
-
style: { width: "normal", palette: "dog_classic", type: "solid" },
|
|
11
|
-
conditional_formats: [],
|
|
12
|
-
aggregator: "avg"
|
|
13
|
-
}.freeze
|
|
14
9
|
API_LIST_INCOMPLETE = false
|
|
15
10
|
|
|
16
11
|
settings :id, :kennel_id
|
|
@@ -22,25 +17,6 @@ module Kennel
|
|
|
22
17
|
self::READONLY_ATTRIBUTES.each { |k| actual.delete k }
|
|
23
18
|
end
|
|
24
19
|
|
|
25
|
-
# discard styles/conditional_formats/aggregator if nothing would change when we applied (both are default or nil)
|
|
26
|
-
def ignore_request_defaults(expected, actual, level1, level2)
|
|
27
|
-
actual = actual[level1] || {}
|
|
28
|
-
expected = expected[level1] || {}
|
|
29
|
-
[expected.size.to_i, actual.size.to_i].max.times do |i|
|
|
30
|
-
a_r = actual.dig(i, level2, :requests) || []
|
|
31
|
-
e_r = expected.dig(i, level2, :requests) || []
|
|
32
|
-
ignore_defaults e_r, a_r, self::REQUEST_DEFAULTS
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def ignore_defaults(expected, actual, defaults)
|
|
37
|
-
[expected&.size.to_i, actual&.size.to_i].max.times do |i|
|
|
38
|
-
e = expected[i] || {}
|
|
39
|
-
a = actual[i] || {}
|
|
40
|
-
ignore_default(e, a, defaults)
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
20
|
def ignore_default(expected, actual, defaults)
|
|
45
21
|
definitions = [actual, expected]
|
|
46
22
|
defaults.each do |key, default|
|
data/lib/kennel/syncer.rb
CHANGED
|
@@ -38,7 +38,6 @@ module Kennel
|
|
|
38
38
|
def update
|
|
39
39
|
@create.each do |_, e|
|
|
40
40
|
reply = @api.create e.class.api_resource, e.as_json
|
|
41
|
-
reply = unnest(e.class.api_resource, reply)
|
|
42
41
|
Kennel.out.puts "Created #{e.class.api_resource} #{tracking_id(e.as_json)} #{e.url(reply.fetch(:id))}"
|
|
43
42
|
end
|
|
44
43
|
|
|
@@ -101,21 +100,16 @@ module Kennel
|
|
|
101
100
|
end
|
|
102
101
|
end
|
|
103
102
|
|
|
104
|
-
#
|
|
103
|
+
# Make diff work even though we cannot mass-fetch definitions
|
|
105
104
|
def fill_details(a, cache)
|
|
106
105
|
resource = a.fetch(:api_resource)
|
|
107
106
|
args = [resource, a.fetch(:id)]
|
|
108
107
|
full = cache.fetch(args, a[:modified] || a.fetch(:modified_at)) do
|
|
109
|
-
|
|
108
|
+
@api.show(*args)
|
|
110
109
|
end
|
|
111
110
|
a.merge!(full)
|
|
112
111
|
end
|
|
113
112
|
|
|
114
|
-
# dashes are nested, others are not
|
|
115
|
-
def unnest(api_resource, result)
|
|
116
|
-
result[api_resource.to_sym] || result[:data] || result
|
|
117
|
-
end
|
|
118
|
-
|
|
119
113
|
def details_cache(&block)
|
|
120
114
|
cache = FileCache.new CACHE_FILE, Kennel::VERSION
|
|
121
115
|
cache.open(&block)
|
|
@@ -23,7 +23,10 @@ module Kennel
|
|
|
23
23
|
end.compact
|
|
24
24
|
bad = queries.grep_v(/(#{variables.map { |v| Regexp.escape(v) }.join("|")})\b/)
|
|
25
25
|
if bad.any?
|
|
26
|
-
invalid!
|
|
26
|
+
invalid!(
|
|
27
|
+
"queries #{bad.join(", ")} must use the template variables #{variables.join(", ")}\n" \
|
|
28
|
+
"If that is not possible, add `validate: -> { false } # query foo in bar does not have baz tag`"
|
|
29
|
+
)
|
|
27
30
|
end
|
|
28
31
|
end
|
|
29
32
|
|
data/lib/kennel/version.rb
CHANGED
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.
|
|
4
|
+
version: 1.61.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Michael Grosser
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-12-
|
|
11
|
+
date: 2019-12-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|