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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1325abc55c593c6537608b629a7a98de7ce05487bc3a066782bb1be1164268dd
4
- data.tar.gz: 966282e916764aaaae5b6718a72d4070070d1ad3c2f6a43bbdf01c10e325d63c
3
+ metadata.gz: 15372f06919044f4751bb25a9aea5b965a16253145841c6b964ee8d109e14d26
4
+ data.tar.gz: 7f658ed4facabdf0100650a1298e83de855a35000b3ed4da8b12f23d7e108894
5
5
  SHA512:
6
- metadata.gz: fec764b934ecad2aa76a9282eb937ceef1774d19d50b56d1597846c04afd050dac9fcc51566618169929eb0da77c25d6eb3ac18c9993872229d5404b5d6e3127
7
- data.tar.gz: 85201a83ceed329e4bf71b4392ec086c3d18714d5f76eda00dbe2fa6a7e05482523b91e40405241241666f9982eddb5c167bd6b3bd9448a56d39f30392ccadba
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
  ![](template/github/screen.png?raw=true)
@@ -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` to your companies subdomain if you have one
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
- @client = Faraday.new(url: "https://app.datadoghq.com") { |c| c.adapter :net_http_persistent }
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 = {})
@@ -137,8 +137,8 @@ module Kennel
137
137
  pretty = convert_strings_to_heredoc(pretty)
138
138
 
139
139
  "\n#{pretty}\n "
140
- elsif k == :message
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 !@settings || @settings.include?(name)
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
- if subdomain = ENV["DATADOG_SUBDOMAIN"]
101
- "https://#{subdomain}.datadoghq.com#{path}"
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)
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Kennel
3
- VERSION = "1.103.0"
3
+ VERSION = "1.105.0"
4
4
  end
data/lib/kennel.rb CHANGED
@@ -2,7 +2,6 @@
2
2
  require "faraday"
3
3
  require "json"
4
4
  require "zeitwerk"
5
- require "shellwords"
6
5
  require "English"
7
6
 
8
7
  require "kennel/version"
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
  ![](github/screen.png?raw=true)
@@ -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.103.0
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: 2021-11-20 00:00:00.000000000 Z
11
+ date: 2022-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday