kennel 1.20.1 → 1.21.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: ca4b6718dd57977c3c0f6dc71f2afeb12e15c85f3a03d247b4352dbfc9b1595f
4
- data.tar.gz: 198eb908a346606cbc8afa98c9acab6a4d514fa6be785dd8c704015b79745584
3
+ metadata.gz: f1f69dd4a6316d9bcf55251a7a1242d4933f4e367db322b17d3a0f3a73f53739
4
+ data.tar.gz: 1c30f6568e29ff26e778f4da3f47db5272c1a7161bc0c03ca035ef8df6baf02c
5
5
  SHA512:
6
- metadata.gz: e6f5a46f56229a8d1d7dfaa49d4378c2521101af574853073a1cb725ff44468c8d6f1e93543fae84a49f66f5b40fb0640f918482606fb201bceebc6a91866505
7
- data.tar.gz: 7bd22fb1b7a09847da973357ce2634f0aebf88263e9400212f9d69e98c2918dd565ad4f9c5dabcdb3057b9e1e06e20427aae7dbe52aa0e9e21c949f75b264d9a
6
+ metadata.gz: e780b23f4d1bc971891df5bacf79e390d73d539ee2142d28f5f0b2b5418a5d0667eb8004ee5fc7d916571420e704547b40c157d284c253af90d58cf8a2794712
7
+ data.tar.gz: 02b6786dfbc2139cd8aae30204cb51062aa997124b4ebb1b0dd4f9f281b64a8520734c017fe1be2df70ca38b6c79ff79ca88bd291ce515eaaa9900f38cab7377
@@ -85,12 +85,13 @@ module Kennel
85
85
  end
86
86
 
87
87
  def resolve_linked_tracking_ids(id_map)
88
- uptime_widgets = as_json[:widgets].select { |w| w[:type] == "uptime" && w.dig(:monitor, :id).is_a?(String) }
89
- uptime_widgets.each do |uptime_widget|
90
- tracking = uptime_widget[:monitor][:id]
91
- uptime_widget[:monitor][:id] =
92
- id_map[tracking] ||
93
- warn("Unable to find #{tracking} in existing monitors (they need to be created first to link them)")
88
+ as_json[:widgets].each do |widget|
89
+ case widget[:type]
90
+ when "uptime"
91
+ resolve_link(widget, [:monitor, :id], id_map)
92
+ when "alert_graph"
93
+ resolve_link(widget, [:alert_id], id_map)
94
+ end
94
95
  end
95
96
  end
96
97
 
@@ -147,6 +148,21 @@ module Kennel
147
148
 
148
149
  basics.merge(custom)
149
150
  end
151
+
152
+ def resolve_link(widget, key, id_map)
153
+ id = widget.dig(*key)
154
+ return unless tracking_id?(id)
155
+
156
+ *id_path, id_key = key
157
+ monitor_path = (id_path.empty? ? widget : widget.dig(*id_path))
158
+ monitor_path[id_key] =
159
+ id_map[id] ||
160
+ warn("Unable to find #{id} in existing monitors (they need to be created first to link them)")
161
+ end
162
+
163
+ def tracking_id?(id)
164
+ id.is_a?(String) && !id.match?(/\A\d+\z/)
165
+ end
150
166
  end
151
167
  end
152
168
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Kennel
3
- VERSION = "1.20.1"
3
+ VERSION = "1.21.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.20.1
4
+ version: 1.21.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-01 00:00:00.000000000 Z
11
+ date: 2018-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday