kennel 1.90.0 → 1.91.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kennel.rb +1 -0
- data/lib/kennel/api.rb +13 -1
- data/lib/kennel/importer.rb +4 -5
- data/lib/kennel/models/synthetic_test.rb +63 -0
- data/lib/kennel/syncer.rb +1 -1
- data/lib/kennel/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c4072608bea0464722665eacf42705148b1167be7841eed87f062927592ecaa
|
4
|
+
data.tar.gz: 32cbe46724d73f66355241c3c60776285129a94fd4c5a56ec5d70af8a7fa62d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90ba6d96631fb40a3576238b2b4e5bb07f630f702e7d04d29d957790fdfd91a6b919391d0c6e0cfec353ce492b83d514146e21a539d7b880c3d20a1e51374e23
|
7
|
+
data.tar.gz: da85a013a71a13da279085656ff767736f5fa317dfb567da609abe91de46d145f204eb51d310e4346ce3561f3aae65af7a26bc7efa407dd152aec2c6dbe3093d
|
data/lib/kennel.rb
CHANGED
data/lib/kennel/api.rb
CHANGED
@@ -14,6 +14,7 @@ module Kennel
|
|
14
14
|
def show(api_resource, id, params = {})
|
15
15
|
response = request :get, "/api/v1/#{api_resource}/#{id}", params: params
|
16
16
|
response = response.fetch(:data) if api_resource == "slo"
|
17
|
+
response[:id] = response.delete(:public_id) if api_resource == "synthetics/tests"
|
17
18
|
response
|
18
19
|
end
|
19
20
|
|
@@ -22,6 +23,14 @@ module Kennel
|
|
22
23
|
response = request :get, "/api/v1/#{api_resource}", params: paginated_params
|
23
24
|
response = response.fetch(:dashboards) if api_resource == "dashboard"
|
24
25
|
response = response.fetch(:data) if api_resource == "slo"
|
26
|
+
if api_resource == "synthetics/tests"
|
27
|
+
response = response.fetch(:tests)
|
28
|
+
response.each { |r| r[:id] = r.delete(:public_id) }
|
29
|
+
end
|
30
|
+
|
31
|
+
# ignore monitor synthetics create and that inherit the kennel_id, we do not directly manage them
|
32
|
+
response.reject! { |m| m[:type] == "synthetics alert" } if api_resource == "monitor"
|
33
|
+
|
25
34
|
response
|
26
35
|
end
|
27
36
|
end
|
@@ -29,11 +38,14 @@ module Kennel
|
|
29
38
|
def create(api_resource, attributes)
|
30
39
|
response = request :post, "/api/v1/#{api_resource}", body: attributes
|
31
40
|
response = response.fetch(:data).first if api_resource == "slo"
|
41
|
+
response[:id] = response.delete(:public_id) if api_resource == "synthetics/tests"
|
32
42
|
response
|
33
43
|
end
|
34
44
|
|
35
45
|
def update(api_resource, id, attributes)
|
36
|
-
request :put, "/api/v1/#{api_resource}/#{id}", body: attributes
|
46
|
+
response = request :put, "/api/v1/#{api_resource}/#{id}", body: attributes
|
47
|
+
response[:id] = response.delete(:public_id) if api_resource == "synthetics/tests"
|
48
|
+
response
|
37
49
|
end
|
38
50
|
|
39
51
|
# - force=true to not dead-lock on dependent monitors+slos
|
data/lib/kennel/importer.rb
CHANGED
@@ -15,11 +15,8 @@ module Kennel
|
|
15
15
|
end
|
16
16
|
|
17
17
|
model =
|
18
|
-
|
19
|
-
|
20
|
-
rescue NameError
|
21
|
-
raise ArgumentError, "#{resource} is not supported"
|
22
|
-
end
|
18
|
+
Kennel::Models::Record.subclasses.detect { |c| c.api_resource == resource } ||
|
19
|
+
raise(ArgumentError, "#{resource} is not supported")
|
23
20
|
|
24
21
|
data = @api.show(model.api_resource, id)
|
25
22
|
id = data.fetch(:id) # keep native value
|
@@ -70,6 +67,8 @@ module Kennel
|
|
70
67
|
dry_up_widget_metadata!(widget)
|
71
68
|
(widget.dig(:definition, :markers) || []).each { |m| m[:label]&.delete! " " }
|
72
69
|
end
|
70
|
+
when "synthetics/tests"
|
71
|
+
data[:locations] = :all if data[:locations].sort == Kennel::Models::SyntheticTest::LOCATIONS.sort
|
73
72
|
else
|
74
73
|
# noop
|
75
74
|
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Kennel
|
3
|
+
module Models
|
4
|
+
class SyntheticTest < Record
|
5
|
+
TRACKING_FIELD = :message
|
6
|
+
DEFAULTS = {
|
7
|
+
}.freeze
|
8
|
+
READONLY_ATTRIBUTES = superclass::READONLY_ATTRIBUTES + [:status, :monitor_id]
|
9
|
+
LOCATIONS = ["aws:ca-central-1", "aws:eu-north-1", "aws:eu-west-1", "aws:eu-west-3", "aws:eu-west-2", "aws:ap-south-1", "aws:us-west-2", "aws:us-west-1", "aws:sa-east-1", "aws:us-east-2", "aws:ap-northeast-1", "aws:ap-northeast-2", "aws:eu-central-1", "aws:ap-southeast-2", "aws:ap-southeast-1"].freeze
|
10
|
+
|
11
|
+
settings :tags, :config, :message, :subtype, :type, :name, :locations, :options
|
12
|
+
|
13
|
+
defaults(
|
14
|
+
id: -> { nil },
|
15
|
+
tags: -> { @project.tags },
|
16
|
+
message: -> { "\n\n#{project.mention}" }
|
17
|
+
)
|
18
|
+
|
19
|
+
def as_json
|
20
|
+
return @as_json if @as_json
|
21
|
+
locations = locations()
|
22
|
+
data = {
|
23
|
+
message: message,
|
24
|
+
tags: tags,
|
25
|
+
config: config,
|
26
|
+
type: type,
|
27
|
+
subtype: subtype,
|
28
|
+
options: options,
|
29
|
+
name: name,
|
30
|
+
locations: locations == :all ? LOCATIONS : locations
|
31
|
+
}
|
32
|
+
|
33
|
+
if v = id
|
34
|
+
data[:id] = v
|
35
|
+
end
|
36
|
+
|
37
|
+
@as_json = data
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.api_resource
|
41
|
+
"synthetics/tests"
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.url(id)
|
45
|
+
Utils.path_to_url "/synthetics/details/#{id}"
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.parse_url(url)
|
49
|
+
url[/\/synthetics\/details\/([a-z\d-]{11,})/, 1] # id format is 1ab-2ab-3ab
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.normalize(expected, actual)
|
53
|
+
super
|
54
|
+
|
55
|
+
# tags come in a semi-random order and order is never updated
|
56
|
+
expected[:tags]&.sort!
|
57
|
+
actual[:tags].sort!
|
58
|
+
|
59
|
+
ignore_default(expected, actual, DEFAULTS)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
data/lib/kennel/syncer.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module Kennel
|
3
3
|
class Syncer
|
4
|
-
DELETE_ORDER = ["dashboard", "slo", "monitor"].freeze # dashboards references monitors + slos, slos reference monitors
|
4
|
+
DELETE_ORDER = ["dashboard", "slo", "monitor", "synthetics/tests"].freeze # dashboards references monitors + slos, slos reference monitors
|
5
5
|
LINE_UP = "\e[1A\033[K" # go up and clear
|
6
6
|
|
7
7
|
def initialize(api, expected, project: nil)
|
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.91.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: 2021-07-
|
11
|
+
date: 2021-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -70,6 +70,7 @@ files:
|
|
70
70
|
- lib/kennel/models/project.rb
|
71
71
|
- lib/kennel/models/record.rb
|
72
72
|
- lib/kennel/models/slo.rb
|
73
|
+
- lib/kennel/models/synthetic_test.rb
|
73
74
|
- lib/kennel/models/team.rb
|
74
75
|
- lib/kennel/optional_validations.rb
|
75
76
|
- lib/kennel/progress.rb
|