kennel 1.103.0 → 1.105.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/Readme.md +8 -3
- data/lib/kennel/api.rb +2 -1
- data/lib/kennel/importer.rb +2 -2
- data/lib/kennel/models/dashboard.rb +1 -1
- data/lib/kennel/settings_as_methods.rb +1 -1
- data/lib/kennel/syncer.rb +0 -26
- data/lib/kennel/utils.rb +3 -6
- data/lib/kennel/version.rb +1 -1
- data/lib/kennel.rb +0 -1
- data/template/Readme.md +6 -2
- 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: 15372f06919044f4751bb25a9aea5b965a16253145841c6b964ee8d109e14d26
|
4
|
+
data.tar.gz: 7f658ed4facabdf0100650a1298e83de855a35000b3ed4da8b12f23d7e108894
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6bf58efda2f995a5903c52f3e0ed58f756638c28009d3e172b34b456f3fc64c494f0bdbb789d147f368ab30ad004453c7a969c6eb644e610557a3874c0c56da7
|
7
|
+
data.tar.gz: d1e3d4eca303de897dee30c357f0e0a03ac0ff7fee9a1de8904c1749c43eb093aa309b0063e7146782d19928664ea0d6e497da7ed8dc92ca0d87da437db97ed2
|
data/Readme.md
CHANGED
@@ -10,7 +10,7 @@ Manage Datadog Monitors / Dashboards / Slos as code
|
|
10
10
|
- No copy-pasting of ids to create new resources
|
11
11
|
- Automated cleanup when removing code
|
12
12
|
- [Helpers](#helpers) for automating common tasks
|
13
|
-
|
13
|
+
|
14
14
|
### Applying changes
|
15
15
|
|
16
16
|

|
@@ -49,8 +49,8 @@ class Bar < Kennel::Models::Project
|
|
49
49
|
)
|
50
50
|
end
|
51
51
|
```
|
52
|
-
|
53
52
|
<!-- NOT IN template/Readme.md -->
|
53
|
+
|
54
54
|
## Installation
|
55
55
|
- create a new private `kennel` repo for your organization (do not fork this repo)
|
56
56
|
- use the template folder as starting point:
|
@@ -74,6 +74,7 @@ end
|
|
74
74
|
|
75
75
|
## Workflows
|
76
76
|
<!-- ONLY IN template/Readme.md
|
77
|
+
|
77
78
|
### Setup
|
78
79
|
- clone the repo
|
79
80
|
- `gem install bundler && bundle install`
|
@@ -81,7 +82,7 @@ end
|
|
81
82
|
- open [Datadog API Settings](https://app.datadoghq.com/account/settings#api)
|
82
83
|
- create a `API Key` or get an existing one from an admin, then add it to `.env` as `DATADOG_API_KEY`
|
83
84
|
- open [Datadog API Settings](https://app.datadoghq.com/access/application-keys) and create a new key, then add it to `.env` as `DATADOG_APP_KEY=`
|
84
|
-
- change the `DATADOG_SUBDOMAIN=app` in `.env`
|
85
|
+
- if you have a custom subdomain, change the `DATADOG_SUBDOMAIN=app` in `.env`
|
85
86
|
- verify it works by running `rake plan`, it might show some diff, but should not crash
|
86
87
|
-->
|
87
88
|
|
@@ -148,6 +149,10 @@ end
|
|
148
149
|
- make a PR ... get reviewed ... merge
|
149
150
|
- datadog is updated by CI
|
150
151
|
|
152
|
+
### Deleting
|
153
|
+
|
154
|
+
Remove the code that created the resource. The next update will delete it (see above for PR workflow).
|
155
|
+
|
151
156
|
### Adding a new dashboard
|
152
157
|
- go to [datadog dashboard UI](https://app.datadoghq.com/dashboard/lists) and click on _New Dashboard_ to create a dashboard
|
153
158
|
- see below
|
data/lib/kennel/api.rb
CHANGED
@@ -8,7 +8,8 @@ module Kennel
|
|
8
8
|
def initialize(app_key, api_key)
|
9
9
|
@app_key = app_key
|
10
10
|
@api_key = api_key
|
11
|
-
|
11
|
+
url = Utils.path_to_url("", subdomain: "app")
|
12
|
+
@client = Faraday.new(url: url) { |c| c.adapter :net_http_persistent }
|
12
13
|
end
|
13
14
|
|
14
15
|
def show(api_resource, id, params = {})
|
data/lib/kennel/importer.rb
CHANGED
@@ -137,8 +137,8 @@ module Kennel
|
|
137
137
|
pretty = convert_strings_to_heredoc(pretty)
|
138
138
|
|
139
139
|
"\n#{pretty}\n "
|
140
|
-
elsif
|
141
|
-
"\n <<~TEXT\n#{v.each_line.map { |l| l.strip.empty? ? "\n" : " #{l}" }.join}\n \#{super()}\n TEXT\n "
|
140
|
+
elsif [:message, :description].include?(k)
|
141
|
+
"\n <<~TEXT\n#{v.to_s.each_line.map { |l| l.strip.empty? ? "\n" : " #{l}" }.join}\n \#{super()}\n TEXT\n "
|
142
142
|
elsif k == :tags
|
143
143
|
" super() + #{v.inspect} "
|
144
144
|
else
|
@@ -6,7 +6,7 @@ module Kennel
|
|
6
6
|
include OptionalValidations
|
7
7
|
|
8
8
|
READONLY_ATTRIBUTES = superclass::READONLY_ATTRIBUTES + [
|
9
|
-
:author_handle, :author_name, :modified_at, :url, :is_read_only, :notify_list, :restricted_roles
|
9
|
+
:author_handle, :author_name, :modified_at, :deleted_at, :url, :is_read_only, :notify_list, :restricted_roles
|
10
10
|
]
|
11
11
|
TRACKING_FIELD = :description
|
12
12
|
REQUEST_DEFAULTS = {
|
@@ -40,7 +40,7 @@ module Kennel
|
|
40
40
|
private
|
41
41
|
|
42
42
|
def validate_setting_exist(name)
|
43
|
-
return if
|
43
|
+
return if @settings.include?(name)
|
44
44
|
supported = @settings.map(&:inspect)
|
45
45
|
raise ArgumentError, "Unsupported setting #{name.inspect}, supported settings are #{supported.join(", ")}"
|
46
46
|
end
|
data/lib/kennel/syncer.rb
CHANGED
@@ -3,7 +3,6 @@ module Kennel
|
|
3
3
|
class Syncer
|
4
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
|
-
DEFAULT_BRANCH = "master"
|
7
6
|
|
8
7
|
def initialize(api, expected, project: nil)
|
9
8
|
@api = api
|
@@ -28,7 +27,6 @@ module Kennel
|
|
28
27
|
def confirm
|
29
28
|
return false if noop?
|
30
29
|
return true if ENV["CI"] || !STDIN.tty?
|
31
|
-
warn_about_deleting_resources_with_id if @project_filter
|
32
30
|
Utils.ask("Execute Plan ?")
|
33
31
|
end
|
34
32
|
|
@@ -61,30 +59,6 @@ module Kennel
|
|
61
59
|
|
62
60
|
private
|
63
61
|
|
64
|
-
# this is brittle/hacky since it relies on knowledge from the generation + git + branch knowledge
|
65
|
-
def warn_about_deleting_resources_with_id
|
66
|
-
@delete.each do |_, _, a|
|
67
|
-
tracking_id = a.fetch(:tracking_id)
|
68
|
-
api_resource = a.fetch(:klass).api_resource
|
69
|
-
|
70
|
-
file = "generated/#{tracking_id.sub(":", "/")}.json"
|
71
|
-
old = `true && git show #{DEFAULT_BRANCH}:#{file.shellescape} 2>&1` # true && to not crash on missing git
|
72
|
-
|
73
|
-
next unless $?.success?
|
74
|
-
old =
|
75
|
-
begin
|
76
|
-
JSON.parse(old)
|
77
|
-
rescue StandardError
|
78
|
-
false
|
79
|
-
end
|
80
|
-
next if !old || !old["id"]
|
81
|
-
|
82
|
-
Kennel.out.puts(
|
83
|
-
Utils.color(:red, "WARNING: deleting #{api_resource} #{tracking_id} will break #{DEFAULT_BRANCH} branch")
|
84
|
-
)
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
62
|
# loop over items until everything is resolved or crash when we get stuck
|
89
63
|
# this solves cases like composite monitors depending on each other or monitor->monitor slo->slo monitor chains
|
90
64
|
def each_resolved(list)
|
data/lib/kennel/utils.rb
CHANGED
@@ -96,12 +96,9 @@ module Kennel
|
|
96
96
|
result
|
97
97
|
end
|
98
98
|
|
99
|
-
def path_to_url(path)
|
100
|
-
|
101
|
-
|
102
|
-
else
|
103
|
-
path
|
104
|
-
end
|
99
|
+
def path_to_url(path, subdomain: nil)
|
100
|
+
subdomain ||= (ENV["DATADOG_SUBDOMAIN"] || "app")
|
101
|
+
"https://#{subdomain}.datadoghq.com#{path}"
|
105
102
|
end
|
106
103
|
|
107
104
|
def parallel(items, max: 10)
|
data/lib/kennel/version.rb
CHANGED
data/lib/kennel.rb
CHANGED
data/template/Readme.md
CHANGED
@@ -10,7 +10,7 @@ Manage Datadog Monitors / Dashboards / Slos as code
|
|
10
10
|
- No copy-pasting of ids to create new resources
|
11
11
|
- Automated cleanup when removing code
|
12
12
|
- [Helpers](#helpers) for automating common tasks
|
13
|
-
|
13
|
+
|
14
14
|
### Applying changes
|
15
15
|
|
16
16
|

|
@@ -50,7 +50,6 @@ class Bar < Kennel::Models::Project
|
|
50
50
|
end
|
51
51
|
```
|
52
52
|
|
53
|
-
|
54
53
|
## Structure
|
55
54
|
- `projects/` monitors/dashboards/etc scoped by project
|
56
55
|
- `teams/` team definitions
|
@@ -58,6 +57,7 @@ end
|
|
58
57
|
- `generated/` projects as json, to show current state and proposed changes in PRs
|
59
58
|
|
60
59
|
## Workflows
|
60
|
+
|
61
61
|
### Setup
|
62
62
|
- clone the repo
|
63
63
|
- `gem install bundler && bundle install`
|
@@ -131,6 +131,10 @@ end
|
|
131
131
|
- make a PR ... get reviewed ... merge
|
132
132
|
- datadog is updated by CI
|
133
133
|
|
134
|
+
### Deleting
|
135
|
+
|
136
|
+
Remove the code that created the resource. The next update will delete it (see above for PR workflow).
|
137
|
+
|
134
138
|
### Adding a new dashboard
|
135
139
|
- go to [datadog dashboard UI](https://app.datadoghq.com/dashboard/lists) and click on _New Dashboard_ to create a dashboard
|
136
140
|
- see below
|
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.105.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:
|
11
|
+
date: 2022-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|