Skip to content

Commit 3d23b03

Browse files
feat!: release 3.0 (#136)
* feat!: release 3.0 BREAKING CHANGE: DATADOG_API_KEY and DATADOG_APP_KEY are no longer the environment variables used to authenticate to Datadog. Instead, set the environment variables DD_API_KEY and DD_APP_KEY. BREAKING CHANGE: ruby 2.6 is no longer supported. Please upgrade to ruby 2.7 or higher. BREAKING CHANGE: The options `--ssh` and `--ssshh` are no longer supported. Instead, please use `--quiet` to supress logging. `--debug` remains supported. BREAKING CHANGE: The environment variable `DATADOG_HOST` is no longer supported. Instead, please use `DD_SITE_URL`. refactor: The legacy [dogapi-rb ](https://github.com/DataDog/dogapi-rb) gem is replaced with [faraday](https://lostisland.github.io/faraday/). The [official client library](https://github.com/DataDog/datadog-api-client-ruby) was considered, but was not adopted as I had a hard time grok-ing it. * chore: permit logging from tests, but only error+ Co-authored-by: semantic-release-bot <[email protected]>
1 parent 46e2774 commit 3d23b03

21 files changed

+222
-273
lines changed

.github/workflows/rspec_and_release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
matrix:
1313
os: [ubuntu-latest, macos-latest]
1414
# Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
15-
ruby: [2.6, 2.7, '3.0', '3.1']
15+
ruby: [2.7, '3.0', '3.1']
1616
runs-on: ${{ matrix.os }}
1717
steps:
1818
- uses: actions/checkout@v3

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
# [3.0.0-alpha.2](https://github.com/scribd/datadog_backup/compare/v3.0.0-alpha.1...v3.0.0-alpha.2) (2022-08-25)
2+
3+
4+
### Bug Fixes
5+
6+
* remove development pry ([611d0a6](https://github.com/scribd/datadog_backup/commit/611d0a6dd5899b0046fc00233cf679834b275089))
7+
8+
# [3.0.0-alpha.1](https://github.com/scribd/datadog_backup/compare/v2.0.2...v3.0.0-alpha.1) (2022-08-24)
9+
10+
11+
* feat!: release 3.0 ([d09d9e6](https://github.com/scribd/datadog_backup/commit/d09d9e6c845edb35c49cbb19ec6b35878304a078))
12+
13+
14+
### BREAKING CHANGES
15+
16+
* DATADOG_API_KEY and DATADOG_APP_KEY are no longer the environment variables used to authenticate to Datadog. Instead, set the environment variables DD_API_KEY and DD_APP_KEY.
17+
* ruby 2.6 is no longer supported. Please upgrade to ruby 2.7 or higher.
18+
* The options `--ssh` and `--ssshh` are no longer supported. Instead, please use `--quiet` to supress logging. `--debug` remains supported.
19+
* The environment variable `DATADOG_HOST` is no longer supported. Instead, please use `DD_SITE_URL`.
20+
21+
refactor: The legacy [dogapi-rb ](https://github.com/DataDog/dogapi-rb) gem is replaced with [faraday](https://lostisland.github.io/faraday/). The [official client library](https://github.com/DataDog/datadog-api-client-ruby) was considered, but was not adopted as I had a hard time grok-ing it.
22+
123
## [2.0.2](https://github.com/scribd/datadog_backup/compare/v2.0.1...v2.0.2) (2022-08-11)
224

325

Gemfile.lock

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,31 @@
11
PATH
22
remote: .
33
specs:
4-
datadog_backup (2.0.1)
5-
amazing_print (~> 1.4.0)
6-
concurrent-ruby (~> 1.1.10)
7-
deepsort (~> 0.4.5)
8-
diffy (~> 3.4.2)
9-
dogapi (~> 1.45.0)
4+
datadog_backup (3.0.0.alpha.1)
5+
amazing_print
6+
concurrent-ruby
7+
deepsort
8+
diffy
9+
faraday
10+
faraday-retry
1011

1112
GEM
1213
remote: https://rubygems.org/
1314
specs:
1415
amazing_print (1.4.0)
1516
ast (2.4.2)
17+
byebug (11.1.3)
1618
coderay (1.1.3)
1719
concurrent-ruby (1.1.10)
1820
deepsort (0.4.5)
1921
diff-lcs (1.5.0)
2022
diffy (3.4.2)
21-
dogapi (1.45.0)
22-
multi_json
23+
faraday (2.5.2)
24+
faraday-net_http (>= 2.0, < 3.1)
25+
ruby2_keywords (>= 0.0.4)
26+
faraday-net_http (3.0.0)
27+
faraday-retry (2.0.0)
28+
faraday (~> 2.0)
2329
ffi (1.15.5)
2430
formatador (1.1.0)
2531
guard (2.18.0)
@@ -42,7 +48,6 @@ GEM
4248
rb-inotify (~> 0.9, >= 0.9.10)
4349
lumberjack (1.2.8)
4450
method_source (1.0.0)
45-
multi_json (1.15.0)
4651
nenv (0.3.0)
4752
notiffany (0.1.3)
4853
nenv (~> 0.1)
@@ -53,6 +58,9 @@ GEM
5358
pry (0.14.1)
5459
coderay (~> 1.1)
5560
method_source (~> 1.0)
61+
pry-byebug (3.10.1)
62+
byebug (~> 11.0)
63+
pry (>= 0.13, < 0.15)
5664
rainbow (3.1.1)
5765
rb-fsevent (0.11.1)
5866
rb-inotify (0.10.1)
@@ -72,36 +80,39 @@ GEM
7280
diff-lcs (>= 1.2.0, < 2.0)
7381
rspec-support (~> 3.11.0)
7482
rspec-support (3.11.0)
75-
rubocop (1.34.1)
83+
rubocop (1.35.1)
7684
json (~> 2.3)
7785
parallel (~> 1.10)
7886
parser (>= 3.1.2.1)
7987
rainbow (>= 2.2.2, < 4.0)
8088
regexp_parser (>= 1.8, < 3.0)
8189
rexml (>= 3.2.5, < 4.0)
82-
rubocop-ast (>= 1.20.0, < 2.0)
90+
rubocop-ast (>= 1.20.1, < 2.0)
8391
ruby-progressbar (~> 1.7)
8492
unicode-display_width (>= 1.4.0, < 3.0)
8593
rubocop-ast (1.21.0)
8694
parser (>= 3.1.1.0)
8795
rubocop-rspec (2.12.1)
8896
rubocop (~> 1.31)
8997
ruby-progressbar (1.11.0)
98+
ruby2_keywords (0.0.5)
9099
shellany (0.0.1)
91100
thor (1.2.1)
92101
unicode-display_width (2.2.0)
93102

94103
PLATFORMS
95104
ruby
105+
x86_64-linux
96106

97107
DEPENDENCIES
98108
bundler
99109
datadog_backup!
100110
guard-rspec
101111
pry
112+
pry-byebug
102113
rspec
103114
rubocop
104115
rubocop-rspec
105116

106117
BUNDLED WITH
107-
2.3.19
118+
2.3.20

README.md

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,20 @@ Currently supports
1111

1212
Additional features may be built out over time.
1313

14+
# v3 Migration
15+
16+
## Breaking Changes
17+
v3 is a backwards incompatible change.
18+
19+
- [] DATADOG_API_KEY and DATADOG_APP_KEY are no longer the environment variables used to authenticate to Datadog. Instead, set the environment variables DD_API_KEY and DD_APP_KEY.
20+
- [ ] ruby 2.6 is no longer supported. Please upgrade to ruby 2.7 or higher.
21+
- [ ] The options `--ssh` and `--ssshh` are no longer supported. Instead, please use `--quiet` to supress logging. `--debug` remains supported.
22+
- [ ] The environment variable `DATADOG_HOST` is no longer supported. Instead, please use `DD_SITE_URL`.
23+
24+
## Misc
25+
- [ ] The legacy [dogapi-rb ](https://github.com/DataDog/dogapi-rb) gem is replaced with [faraday](https://lostisland.github.io/faraday/). The [official client library](https://github.com/DataDog/datadog-api-client-ruby) was considered, but was not adopted as I had a hard time grok-ing it.
26+
27+
1428
## Installation
1529

1630
```
@@ -22,13 +36,13 @@ gem install datadog_backup
2236
![demo](images/demo.gif)
2337

2438
```
25-
DATADOG_API_KEY=example123 DATADOG_APP_KEY=example123 datadog_backup <backup|diffs|restore> [--backup-dir /path/to/backups] [--debug] [--monitors-only] [--dashboards-only] [--diff-format color|html|html_simple] [--no-color] [--json]
39+
DD_API_KEY=example123 DD_APP_KEY=example123 datadog_backup <backup|diffs|restore> [--backup-dir /path/to/backups] [--debug] [--monitors-only] [--dashboards-only] [--diff-format color|html|html_simple] [--no-color] [--json]
2640
```
2741

2842
```
2943
gem install datadog_backup
30-
export DATADOG_API_KEY=abc123
31-
export DATADOG_APP_KEY=abc123
44+
export DD_API_KEY=abc123
45+
export DD_APP_KEY=abc123
3246
3347
# Perform backup to `./backup/` using YAML encoding
3448
datadog_backup backup
@@ -49,8 +63,7 @@ Supply the following parameters in order to customize datadog_backup:
4963
parameter | description | default
5064
---------------------|-------------------------------------------------------------------------------------------------------------------------------|--------------------------
5165
--debug | log debug and above | info
52-
--shh | log warnings and above | info
53-
--shhh | log errors and above | info
66+
--quiet | only show errors and above | info
5467
--backup-dir PATH | path to the directory to backup to or restore from | `./backup/`
5568
--monitors-only | only backup monitors | backup monitors and dashboards
5669
--dashboards-only | only backup dashboards | backup monitors and dashboards
@@ -66,10 +79,9 @@ The following environment variables can be set in order to further customize dat
6679

6780
environment variable | description | default
6881
---------------------|--------------------------------------------------------------------------------|--------------------------
69-
DATADOG_HOST | Describe the API endpoint to connect to (https://api.datadoghq.eu for example) | https://api.datadoghq.com
70-
http_proxy | Instruct Dogapi to connect via a differnt proxy address | none
71-
https_proxy | Same as `http_proxy` | none
72-
dd_proxy_https | Same as `http_proxy` | none
82+
DD_SITE_URL | Describe the API endpoint to connect to (https://api.datadoghq.eu for example) | https://api.datadoghq.com
83+
DD_API_KEY | The API key for the Datadog account | none
84+
DD_API_KEY | The Application key for the Datadog account | none
7385

7486

7587
### Usage in a Github repo

bin/datadog_backup

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ LOGGER = Logger.new($stderr) unless defined?(LOGGER)
1010
LOGGER.level = Logger::INFO
1111

1212
require 'datadog_backup'
13-
require 'dogapi'
1413

1514

1615
def fatal(message)
@@ -19,9 +18,8 @@ def fatal(message)
1918
end
2019

2120
def options_valid?(options)
22-
%w[backup diffs restore].include?(options[:action]) &&
23-
options[:datadog_api_key] &&
24-
options[:datadog_app_key]
21+
%w[backup diffs restore].include?(options[:action])
22+
%w[DD_API_KEY DD_APP_KEY].all? { |key| ENV[key] }
2523
end
2624

2725
def prereqs(defaults)
@@ -30,7 +28,7 @@ def prereqs(defaults)
3028
result = defaults.dup
3129

3230
options = OptionParser.new do |opts|
33-
opts.banner = "Usage: DATADOG_API_KEY=abc123 DATADOG_APP_KEY=abc123 #{File.basename($PROGRAM_NAME)} <backup|diffs|restore>"
31+
opts.banner = "Usage: DD_API_KEY=abc123 DD_APP_KEY=abc123 #{File.basename($PROGRAM_NAME)} <backup|diffs|restore>"
3432
opts.separator ''
3533
opts.on_tail('-h', '--help', 'Show this message') do
3634
puts opts
@@ -39,10 +37,7 @@ def prereqs(defaults)
3937
opts.on('--debug', 'log debug and above') do
4038
LOGGER.level = Logger::DEBUG
4139
end
42-
opts.on('--shh', 'log warnings and above') do
43-
LOGGER.level = Logger::WARN
44-
end
45-
opts.on('--shhh', 'log errors and above') do
40+
opts.on('--quiet', 'log errors and above') do
4641
LOGGER.level = Logger::ERROR
4742
end
4843
opts.on('--backup-dir PATH', '`backup` by default') do |path|
@@ -73,21 +68,19 @@ def prereqs(defaults)
7368
options.parse!
7469

7570
result[:action] = ARGV.first
76-
fatal(options) unless options_valid?(result)
71+
fatal(options.banner) unless options_valid?(result)
7772
result
7873
end
7974

8075
##
8176
# Default parameters
8277
defaults = {
8378
action: nil,
84-
datadog_api_key: ENV.fetch('DATADOG_API_KEY', nil),
85-
datadog_app_key: ENV.fetch('DATADOG_APP_KEY', nil),
8679
backup_dir: File.join(ENV.fetch('PWD'), 'backup'),
8780
diff_format: :color,
8881
resources: [DatadogBackup::Dashboards, DatadogBackup::Monitors],
8982
output_format: :yaml,
9083
force_restore: false
9184
}
9285

93-
DatadogBackup::Cli.new(prereqs(defaults)).run!
86+
DatadogBackup::Cli.new(prereqs(defaults)).run!

datadog_backup.gemspec

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,19 @@ Gem::Specification.new do |spec|
1919
spec.test_files = spec.files.grep(%r{^spec/})
2020
spec.require_paths = ['lib']
2121

22-
spec.required_ruby_version = ['>= 2.6']
22+
spec.required_ruby_version = ['>= 2.7']
23+
24+
spec.add_dependency 'amazing_print'
25+
spec.add_dependency 'concurrent-ruby'
26+
spec.add_dependency 'deepsort'
27+
spec.add_dependency 'diffy'
28+
spec.add_dependency 'faraday'
29+
spec.add_dependency 'faraday-retry'
2330

24-
spec.add_dependency 'amazing_print', '~> 1.4.0'
25-
spec.add_dependency 'concurrent-ruby', '~> 1.1.10'
26-
spec.add_dependency 'deepsort', '~> 0.4.5'
27-
spec.add_dependency 'diffy', '~> 3.4.2'
28-
spec.add_dependency 'dogapi', '~> 1.45.0'
2931

3032
spec.add_development_dependency 'bundler'
3133
spec.add_development_dependency 'pry'
34+
spec.add_development_dependency 'pry-byebug'
3235
spec.add_development_dependency 'guard-rspec'
3336
spec.add_development_dependency 'rspec'
3437
spec.add_development_dependency 'rubocop'

example/.github/workflows/backup.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ jobs:
1717
ruby-version: 2.7.1
1818
- name: perform backup
1919
env:
20-
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
21-
DATADOG_APP_KEY: ${{ secrets.DATADOG_APP_KEY }}
20+
DD_API_KEY: ${{ secrets.DD_API_KEY }}
21+
DD_APP_KEY: ${{ secrets.DD_APP_KEY }}
2222
run: |
2323
gem install --no-document bundler
2424
bundle install --jobs 4 --retry 3

lib/datadog_backup.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
require 'concurrent'
44

5-
require 'dogapi'
6-
75
require_relative 'datadog_backup/local_filesystem'
86
require_relative 'datadog_backup/options'
97
require_relative 'datadog_backup/cli'

lib/datadog_backup/cli.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,6 @@ def backup
2828
any_resource_instance.all_files
2929
end
3030

31-
def initialize_client
32-
@options[:client] ||= Dogapi::Client.new(
33-
datadog_api_key,
34-
datadog_app_key
35-
)
36-
end
37-
3831
def definitive_resource_instance(id)
3932
matching_resource_instance(any_resource_instance.class_from_id(id))
4033
end
@@ -86,7 +79,6 @@ def format_diff_output(diff_output)
8679

8780
def initialize(options)
8881
@options = options
89-
initialize_client
9082
end
9183

9284
def matching_resource_instance(klass)

0 commit comments

Comments
 (0)