kennel 1.9.0 → 1.10.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/models/base.rb +30 -1
- data/lib/kennel/models/dash.rb +3 -3
- data/lib/kennel/models/monitor.rb +5 -5
- data/lib/kennel/models/screen.rb +2 -18
- 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: 572605900165245c9537fea47b745878290b7a4b7d8dd43bab4ca64734a0a896
|
4
|
+
data.tar.gz: 9c14dd660b67749199624c278e8a2e8560a1d3103cb01c07e96be67a591c7a8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b7cfe486cad42e6dfe9ff81f4d8f006f84c3778a3c5b9a13f57ec9039120721a2488cc00b7d4de196ed2e5d3e77e32b7f9bc35c74149276bca4a52c2f50e193
|
7
|
+
data.tar.gz: 44a0db2b5dd65255ff5eb030d0a2b21a6ba9e8e7a9c359742a0d71c4a6ba19571295e9c67fa56887f9a12a42ec3bbdd810476f3f731a9af7797406866ec942ae
|
data/lib/kennel/models/base.rb
CHANGED
@@ -9,6 +9,14 @@ module Kennel
|
|
9
9
|
:deleted, :matching_downtimes, :id, :created, :created_at, :creator, :org_id, :modified,
|
10
10
|
:overall_state_modified, :overall_state, :api_resource
|
11
11
|
].freeze
|
12
|
+
REQUEST_DEFAULTS = {
|
13
|
+
style: { width: "normal", palette: "dog_classic", type: "solid" },
|
14
|
+
conditional_formats: [],
|
15
|
+
aggregator: "avg"
|
16
|
+
}.freeze
|
17
|
+
|
18
|
+
class ValidationError < RuntimeError
|
19
|
+
end
|
12
20
|
|
13
21
|
class << self
|
14
22
|
include SubclassTracking
|
@@ -55,7 +63,8 @@ module Kennel
|
|
55
63
|
define_singleton_method name, &block
|
56
64
|
end
|
57
65
|
|
58
|
-
|
66
|
+
# need expand_path so it works wih rake and when run individually
|
67
|
+
@invocation_location = caller.detect { |l| File.expand_path(l).start_with?(Dir.pwd) }
|
59
68
|
end
|
60
69
|
|
61
70
|
def kennel_id
|
@@ -88,6 +97,26 @@ module Kennel
|
|
88
97
|
|
89
98
|
private
|
90
99
|
|
100
|
+
# discard styles/conditional_formats/aggregator if nothing would change when we applied (both are default or nil)
|
101
|
+
def ignore_request_defaults(expected, actual, level1, level2)
|
102
|
+
expected[level1].each_with_index do |e_w, wi|
|
103
|
+
(e_w.dig(level2, :requests) || []).each_with_index do |e_r, ri|
|
104
|
+
next unless a_r = actual.dig(level1, wi, level2, :requests, ri) # skip newly added widgets/requests
|
105
|
+
REQUEST_DEFAULTS.each do |key, default|
|
106
|
+
if [a_r, e_r].all? { |r| r[key].nil? || r[key] == default }
|
107
|
+
a_r.delete(key)
|
108
|
+
e_r.delete(key)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
# let users know which project/resource failed when something happens during diffing where the backtrace is hidden
|
116
|
+
def invalid!(message)
|
117
|
+
raise ValidationError, "#{tracking_id} #{message}"
|
118
|
+
end
|
119
|
+
|
91
120
|
def validate_options(options)
|
92
121
|
unless options.is_a?(Hash)
|
93
122
|
raise ArgumentError, "Expected #{self.class.name}.new options to be a Hash, got a #{options.class}"
|
data/lib/kennel/models/dash.rb
CHANGED
@@ -51,6 +51,7 @@ module Kennel
|
|
51
51
|
actual[:graphs].each do |g|
|
52
52
|
g[:definition].delete(:status)
|
53
53
|
end
|
54
|
+
ignore_request_defaults as_json, actual, :graphs, :definition
|
54
55
|
super
|
55
56
|
end
|
56
57
|
|
@@ -66,13 +67,13 @@ module Kennel
|
|
66
67
|
queries = data[:graphs].flat_map { |g| g[:definition][:requests].map { |r| r.fetch(:q) } }
|
67
68
|
bad = queries.grep_v(/(#{variables.map { |v| Regexp.escape(v) }.join("|")})\b/)
|
68
69
|
if bad.any?
|
69
|
-
|
70
|
+
invalid! "queries #{bad.join(", ")} must use the template variables #{variables.join(", ")}"
|
70
71
|
end
|
71
72
|
|
72
73
|
# check for fields that are unsettable
|
73
74
|
data[:graphs].each do |g|
|
74
75
|
if g[:definition].key?(:status)
|
75
|
-
|
76
|
+
invalid! "remove definition status, it is unsettable and will always produce a diff"
|
76
77
|
end
|
77
78
|
end
|
78
79
|
end
|
@@ -99,7 +100,6 @@ module Kennel
|
|
99
100
|
end + graphs
|
100
101
|
|
101
102
|
all.each do |g|
|
102
|
-
g[:definition][:requests].each { |r| r[:conditional_formats] ||= [] }
|
103
103
|
g[:definition][:autoscale] = true unless g[:definition].key?(:autoscale)
|
104
104
|
end
|
105
105
|
end
|
@@ -139,27 +139,27 @@ module Kennel
|
|
139
139
|
type = data.fetch(:type)
|
140
140
|
|
141
141
|
if type == "metric alert"
|
142
|
-
|
142
|
+
invalid! "type 'metric alert' is deprecated, do not set type to use the default 'query alert'"
|
143
143
|
end
|
144
144
|
|
145
145
|
if type == "service check" && [ok, warning, critical].compact.map(&:class).uniq != [Integer]
|
146
|
-
|
146
|
+
invalid! ":ok, :warning and :critical must be integers for service check type"
|
147
147
|
end
|
148
148
|
|
149
149
|
if query_value = data.fetch(:query)[/\s*[<>]\s*(\d+(\.\d+)?)\s*$/, 1]
|
150
150
|
if Float(query_value) != Float(data.dig(:options, :thresholds, :critical))
|
151
|
-
|
151
|
+
invalid! "critical and value used in query must match"
|
152
152
|
end
|
153
153
|
end
|
154
154
|
|
155
155
|
unless RENOTIFY_INTERVALS.include? data.dig(:options, :renotify_interval)
|
156
|
-
|
156
|
+
invalid! "renotify_interval must be one of #{RENOTIFY_INTERVALS.join(", ")}"
|
157
157
|
end
|
158
158
|
|
159
159
|
if ["metric alert", "query alert"].include?(type)
|
160
160
|
interval = data.fetch(:query)[/\(last_(\S+?)\)/, 1]
|
161
161
|
unless QUERY_INTERVALS.include?(interval)
|
162
|
-
|
162
|
+
invalid! "query interval was #{interval}, but must be one of #{QUERY_INTERVALS.join(", ")}"
|
163
163
|
end
|
164
164
|
end
|
165
165
|
end
|
data/lib/kennel/models/screen.rb
CHANGED
@@ -6,11 +6,6 @@ module Kennel
|
|
6
6
|
include OptionalValidations
|
7
7
|
|
8
8
|
API_LIST_INCOMPLETE = true
|
9
|
-
REQUEST_DEFAULTS = {
|
10
|
-
style: { width: "normal", palette: "dog_classic", type: "solid" },
|
11
|
-
conditional_formats: [],
|
12
|
-
aggregator: "avg"
|
13
|
-
}.freeze
|
14
9
|
|
15
10
|
settings :id, :board_title, :description, :widgets, :kennel_id
|
16
11
|
|
@@ -70,18 +65,7 @@ module Kennel
|
|
70
65
|
w.delete :isShared # copied value, can ignore
|
71
66
|
end
|
72
67
|
|
73
|
-
|
74
|
-
as_json[:widgets].each_with_index do |e_w, wi|
|
75
|
-
(e_w.dig(:tile_def, :requests) || []).each_with_index do |e_r, ri|
|
76
|
-
next unless a_r = actual.dig(:widgets, wi, :tile_def, :requests, ri) # skip newly added widgets/requests
|
77
|
-
REQUEST_DEFAULTS.each do |key, default|
|
78
|
-
if [a_r, e_r].all? { |r| r[key].nil? || r[key] == default }
|
79
|
-
a_r.delete(key)
|
80
|
-
e_r.delete(key)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
68
|
+
ignore_request_defaults as_json, actual, :widgets, :tile_def
|
85
69
|
|
86
70
|
super
|
87
71
|
end
|
@@ -97,7 +81,7 @@ module Kennel
|
|
97
81
|
data[:widgets].each do |w|
|
98
82
|
[:isShared, :board_id].each do |ignored|
|
99
83
|
if w.key?(ignored)
|
100
|
-
|
84
|
+
invalid! "remove definition #{ignored}, it is unsettable and will always produce a diff"
|
101
85
|
end
|
102
86
|
end
|
103
87
|
end
|
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.10.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: 2018-
|
11
|
+
date: 2018-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|