kennel 1.90.0 → 1.91.3
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.rb +1 -0
- data/lib/kennel/api.rb +19 -2
- data/lib/kennel/importer.rb +6 -6
- data/lib/kennel/models/synthetic_test.rb +63 -0
- data/lib/kennel/syncer.rb +9 -2
- 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: 7a85c311024f48c14e9e346eb863a47fbb67239f5d83cd82eddea6f53742ec74
|
|
4
|
+
data.tar.gz: 672ef53f76ee577f9f976ee9432f06f1e56d426bef74020d50850863e851635a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8407d6564013f12ce1e00e1394eb742b7f721fe9302396d821c8c3441c62e4e30781b9681f430dcedb96e3c757a740b9604a2c56194afabdabd69ed52f8c1a27
|
|
7
|
+
data.tar.gz: efceaa72bc4ff084e1d8bd54ed79dbcaa021d6a95897fa66465dbec686b0712f05a153198b3c882029df08812b93353ed3061c34c5f4c5f1303b826bc3d17711
|
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,18 +38,26 @@ 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
|
|
40
52
|
# external dependency on kennel managed resources is their problem, we don't block on it
|
|
41
53
|
# (?force=true did not work, force for dashboard is not documented but does not blow up)
|
|
42
54
|
def delete(api_resource, id)
|
|
43
|
-
|
|
55
|
+
if api_resource == "synthetics/tests"
|
|
56
|
+
# https://docs.datadoghq.com/api/latest/synthetics/#delete-tests
|
|
57
|
+
request :post, "/api/v1/#{api_resource}/delete", body: { public_ids: [id] }, ignore_404: true
|
|
58
|
+
else
|
|
59
|
+
request :delete, "/api/v1/#{api_resource}/#{id}", params: { force: "true" }, ignore_404: true
|
|
60
|
+
end
|
|
44
61
|
end
|
|
45
62
|
|
|
46
63
|
def fill_details!(api_resource, list)
|
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
|
|
@@ -107,10 +106,11 @@ module Kennel
|
|
|
107
106
|
end
|
|
108
107
|
|
|
109
108
|
# new api format is very verbose, so use old dry format when possible
|
|
109
|
+
# dd randomly chooses query0 or query1
|
|
110
110
|
def convert_widget_to_compact_format!(widget)
|
|
111
111
|
(widget.dig(:definition, :requests) || []).each do |request|
|
|
112
112
|
next unless request.is_a?(Hash)
|
|
113
|
-
next if request[:formulas] &&
|
|
113
|
+
next if request[:formulas] && ![[{ formula: "query1" }], [{ formula: "query0" }]].include?(request[:formulas])
|
|
114
114
|
next if request[:queries]&.size != 1
|
|
115
115
|
next if request[:queries].any? { |q| q[:data_source] != "metrics" }
|
|
116
116
|
next if widget.dig(:definition, :type) != request[:response_format]
|
|
@@ -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)
|
|
@@ -24,7 +24,14 @@ module Kennel
|
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
def confirm
|
|
27
|
-
|
|
27
|
+
return false if noop?
|
|
28
|
+
return true if ENV["CI"] || !STDIN.tty?
|
|
29
|
+
if @delete.any? && @project_filter
|
|
30
|
+
Kennel.out.puts(
|
|
31
|
+
Utils.color(:red, "WARNING: deleting resources that had `id: -> { ...` breaks master branch")
|
|
32
|
+
)
|
|
33
|
+
end
|
|
34
|
+
Utils.ask("Execute Plan ?")
|
|
28
35
|
end
|
|
29
36
|
|
|
30
37
|
def update
|
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.3
|
|
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-17 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
|