kennel 1.19.2 → 1.20.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5902d795641ca4b635575c1dda0c87943d3d2370479f604824a7b48861c13d03
4
- data.tar.gz: df6c5b00560993b650525ad2a634ddc26699728db6511112f626920e727fa1b5
3
+ metadata.gz: 80f76f0bd4a86149f2f04a65927a12c951ee2255907fd115e9b5749e7281665d
4
+ data.tar.gz: 8fb1fc45590b59fb8eaa4e46e93a0c4688897f27cb3e5f95a2167c53a99c07c5
5
5
  SHA512:
6
- metadata.gz: 6480156e2717545a37eaf9de3337a4ef0224f209139c6a984b8862fa93a3e17eca574ea6a8b062989bbcf2e906eec6f2cdec91748d519c19e325f3882a1ff509
7
- data.tar.gz: bf5906443199b2bf6acbd31ec1119fb02e0914ce61c57fac53e557b2d4e0caf2ceb732b9c699b6c7ee9b8d362cbf5083a989164d5cd2a8e801487f1dbaea6255
6
+ metadata.gz: 996c2a1b250f5a4f1c62122efa8c61abd6e2bfb08c1aecbccda32c412583dcc942a158eebe2ea0922e7626266e09e663eb6f3c3fbaa0612f22cb494ff56cda39
7
+ data.tar.gz: 5721558473ac63402c89e963f2a2dce6498f8f9c650daf1db9e15820a37ad58611b756edee04f8af05e270fc4ed51cd93fbf3884184e2c7924b0da725eb9725f
data/Readme.md CHANGED
@@ -175,6 +175,10 @@ Put returned definition into a project of your choice.
175
175
  Some validations might be too strict for your usecase or just wrong, please [open an issue](https://github.com/grosser/kennel/issues) and
176
176
  to unblock use the `validate: -> { false }` option.
177
177
 
178
+ ### Linking with kennel_ids
179
+
180
+ Screens `uptime` widgets can use `monitor: {id: "foo:bar"}` to link to existing monitors via their kennel_id
181
+
178
182
  ### Debugging locally
179
183
 
180
184
  - make sure to be on update `master` to not undo other changes
@@ -131,6 +131,9 @@ module Kennel
131
131
  raise NotImplementedError, "Use as_json"
132
132
  end
133
133
 
134
+ def resolve_linked_tracking_ids(*)
135
+ end
136
+
134
137
  private
135
138
 
136
139
  # let users know which project/resource failed when something happens during diffing where the backtrace is hidden
@@ -84,6 +84,16 @@ module Kennel
84
84
  Utils.path_to_url "/screen/#{id}"
85
85
  end
86
86
 
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)")
94
+ end
95
+ end
96
+
87
97
  private
88
98
 
89
99
  def validate_json(data)
data/lib/kennel/syncer.rb CHANGED
@@ -56,8 +56,11 @@ module Kennel
56
56
  def calculate_diff
57
57
  @update = []
58
58
  @delete = []
59
+
59
60
  actual = Progress.progress("Downloading definitions") { download_definitions }
60
61
 
62
+ resolve_linked_tracking_ids actual
63
+
61
64
  Progress.progress "Diffing" do
62
65
  filter_by_project! actual
63
66
 
@@ -177,6 +180,11 @@ module Kennel
177
180
  TEXT
178
181
  end
179
182
 
183
+ def resolve_linked_tracking_ids(actual)
184
+ map = actual.each_with_object({}) { |a, lookup| lookup[tracking_id(a)] = a.fetch(:id) }
185
+ @expected.each { |e| e.resolve_linked_tracking_ids(map) }
186
+ end
187
+
180
188
  def filter_by_project!(definitions)
181
189
  return unless @project_filter
182
190
  definitions.select! do |a|
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Kennel
3
- VERSION = "1.19.2"
3
+ VERSION = "1.20.0"
4
4
  end
data/template/Readme.md CHANGED
@@ -157,6 +157,10 @@ Put returned definition into a project of your choice.
157
157
  Some validations might be too strict for your usecase or just wrong, please [open an issue](https://github.com/grosser/kennel/issues) and
158
158
  to unblock use the `validate: -> { false }` option.
159
159
 
160
+ ### Linking with kennel_ids
161
+
162
+ Screens `uptime` widgets can use `monitor: {id: "foo:bar"}` to link to existing monitors via their kennel_id
163
+
160
164
  ### Debugging locally
161
165
 
162
166
  - make sure to be on update `master` to not undo other changes
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.19.2
4
+ version: 1.20.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-10-20 00:00:00.000000000 Z
11
+ date: 2018-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday