datadog_backup 2.0.1 → 2.0.2
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/.github/workflows/rspec_and_release.yml +1 -1
- data/CHANGELOG.md +7 -0
- data/Gemfile.lock +6 -6
- data/bin/datadog_backup +4 -5
- data/datadog_backup.gemspec +6 -6
- data/lib/datadog_backup/cli.rb +4 -5
- data/lib/datadog_backup/core.rb +3 -3
- data/lib/datadog_backup/dashboards.rb +2 -2
- data/lib/datadog_backup/deprecations.rb +11 -0
- data/lib/datadog_backup/local_filesystem.rb +1 -1
- data/lib/datadog_backup/options.rb +0 -4
- data/lib/datadog_backup/thread_pool.rb +5 -5
- data/lib/datadog_backup/version.rb +1 -1
- data/lib/datadog_backup.rb +4 -1
- data/spec/datadog_backup/cli_spec.rb +0 -1
- data/spec/datadog_backup/core_spec.rb +1 -2
- data/spec/datadog_backup/dashboards_spec.rb +1 -2
- data/spec/datadog_backup/deprecations_spec.rb +36 -0
- data/spec/datadog_backup/local_filesystem_spec.rb +2 -4
- data/spec/datadog_backup/monitors_spec.rb +1 -2
- data/spec/spec_helper.rb +7 -5
- metadata +15 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 985fb90b7482b78cf13ce586048eba798002d79aa0a00aa1475f2c9030fe5585
|
4
|
+
data.tar.gz: 34e55a0a46912ac13a06cf022f63e97474d576b28377b38695bae14606871388
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5783ab3fc1be9f27f99c9039f7ea3a1b0b3c5eae72278cdf99c2b954242c93dcf932bace845adaa825ed4481a4a6f39fe502ae2fedbb9a24973eed5b1b576f6c
|
7
|
+
data.tar.gz: 293c615e05587b9adf6af65e719e5ff3f8ab9f1441625904248c644a5b3ddaaad51cd5c265f8e99b784fbac6ba86fa41e71e5739a95049bedcc77d84dc575d53
|
@@ -12,7 +12,7 @@ jobs:
|
|
12
12
|
matrix:
|
13
13
|
os: [ubuntu-latest, macos-latest]
|
14
14
|
# Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
|
15
|
-
ruby: [2.7, '3.0', '3.1']
|
15
|
+
ruby: [2.6, 2.7, '3.0', '3.1']
|
16
16
|
runs-on: ${{ matrix.os }}
|
17
17
|
steps:
|
18
18
|
- uses: actions/checkout@v3
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## [2.0.2](https://github.com/scribd/datadog_backup/compare/v2.0.1...v2.0.2) (2022-08-11)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* Deprecate Ruby 2.6 and Drop support for Ruby 2.5 ([#132](https://github.com/scribd/datadog_backup/issues/132)) ([432cb2c](https://github.com/scribd/datadog_backup/commit/432cb2c0d8b12d89aef81cf35597aa90f77407eb))
|
7
|
+
|
1
8
|
## [2.0.1](https://github.com/scribd/datadog_backup/compare/v2.0.0...v2.0.1) (2022-08-11)
|
2
9
|
|
3
10
|
|
data/Gemfile.lock
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
datadog_backup (0.
|
5
|
-
amazing_print (
|
6
|
-
concurrent-ruby (
|
7
|
-
deepsort (
|
8
|
-
diffy (
|
9
|
-
dogapi (
|
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)
|
10
10
|
|
11
11
|
GEM
|
12
12
|
remote: https://rubygems.org/
|
data/bin/datadog_backup
CHANGED
@@ -5,13 +5,13 @@ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '../lib')
|
|
5
5
|
|
6
6
|
require 'logger'
|
7
7
|
require 'optparse'
|
8
|
+
$stdout.sync = $stderr.sync = true
|
9
|
+
LOGGER = Logger.new($stderr) unless defined?(LOGGER)
|
10
|
+
LOGGER.level = Logger::INFO
|
8
11
|
|
9
12
|
require 'datadog_backup'
|
10
13
|
require 'dogapi'
|
11
14
|
|
12
|
-
$stdout.sync = $stderr.sync = true
|
13
|
-
LOGGER = Logger.new($stderr) unless defined?(LOGGER)
|
14
|
-
LOGGER.level = Logger::INFO
|
15
15
|
|
16
16
|
def fatal(message)
|
17
17
|
LOGGER.fatal(message)
|
@@ -87,8 +87,7 @@ defaults = {
|
|
87
87
|
diff_format: :color,
|
88
88
|
resources: [DatadogBackup::Dashboards, DatadogBackup::Monitors],
|
89
89
|
output_format: :yaml,
|
90
|
-
force_restore: false
|
91
|
-
logger: LOGGER
|
90
|
+
force_restore: false
|
92
91
|
}
|
93
92
|
|
94
93
|
DatadogBackup::Cli.new(prereqs(defaults)).run!
|
data/datadog_backup.gemspec
CHANGED
@@ -19,13 +19,13 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.test_files = spec.files.grep(%r{^spec/})
|
20
20
|
spec.require_paths = ['lib']
|
21
21
|
|
22
|
-
spec.required_ruby_version = ['>= 2.
|
22
|
+
spec.required_ruby_version = ['>= 2.6']
|
23
23
|
|
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'
|
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'
|
29
29
|
|
30
30
|
spec.add_development_dependency 'bundler'
|
31
31
|
spec.add_development_dependency 'pry'
|
data/lib/datadog_backup/cli.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'optparse'
|
4
|
-
require 'logger'
|
5
4
|
require 'amazing_print'
|
6
5
|
|
7
6
|
module DatadogBackup
|
@@ -9,7 +8,7 @@ module DatadogBackup
|
|
9
8
|
include ::DatadogBackup::Options
|
10
9
|
|
11
10
|
def all_diff_futures
|
12
|
-
|
11
|
+
LOGGER.info("Starting diffs on #{::DatadogBackup::ThreadPool::TPOOL.max_length} threads")
|
13
12
|
any_resource_instance
|
14
13
|
.all_file_ids_for_selected_resources
|
15
14
|
.map do |id|
|
@@ -42,7 +41,7 @@ module DatadogBackup
|
|
42
41
|
|
43
42
|
def diffs
|
44
43
|
futures = all_diff_futures
|
45
|
-
::DatadogBackup::ThreadPool.watcher
|
44
|
+
::DatadogBackup::ThreadPool.watcher.join
|
46
45
|
|
47
46
|
format_diff_output(
|
48
47
|
Concurrent::Promises
|
@@ -102,7 +101,7 @@ module DatadogBackup
|
|
102
101
|
|
103
102
|
def restore
|
104
103
|
futures = all_diff_futures
|
105
|
-
watcher = ::DatadogBackup::ThreadPool.watcher
|
104
|
+
watcher = ::DatadogBackup::ThreadPool.watcher
|
106
105
|
|
107
106
|
futures.each do |future|
|
108
107
|
id, diff = *future.value!
|
@@ -138,7 +137,7 @@ module DatadogBackup
|
|
138
137
|
def run!
|
139
138
|
puts(send(action.to_sym))
|
140
139
|
rescue SystemExit, Interrupt
|
141
|
-
::DatadogBackup::ThreadPool.shutdown
|
140
|
+
::DatadogBackup::ThreadPool.shutdown
|
142
141
|
end
|
143
142
|
end
|
144
143
|
end
|
data/lib/datadog_backup/core.rb
CHANGED
@@ -30,7 +30,7 @@ module DatadogBackup
|
|
30
30
|
current = except(get_by_id(id)).deep_sort.to_yaml
|
31
31
|
filesystem = except(load_from_file_by_id(id)).deep_sort.to_yaml
|
32
32
|
result = ::Diffy::Diff.new(current, filesystem, include_plus_and_minus_in_html: true).to_s(diff_format)
|
33
|
-
|
33
|
+
LOGGER.debug("Compared ID #{id} and found #{result}")
|
34
34
|
result
|
35
35
|
end
|
36
36
|
|
@@ -82,7 +82,7 @@ module DatadogBackup
|
|
82
82
|
result = with_200 do
|
83
83
|
api_service.request(Net::HTTP::Post, "/api/#{api_version}/#{api_resource_name}", nil, body, true)
|
84
84
|
end
|
85
|
-
|
85
|
+
LOGGER.warn 'Successfully created in datadog.'
|
86
86
|
result
|
87
87
|
end
|
88
88
|
|
@@ -91,7 +91,7 @@ module DatadogBackup
|
|
91
91
|
result = with_200 do
|
92
92
|
api_service.request(Net::HTTP::Put, "/api/#{api_version}/#{api_resource_name}/#{id}", nil, body, true)
|
93
93
|
end
|
94
|
-
|
94
|
+
LOGGER.warn 'Successfully restored to datadog.'
|
95
95
|
result
|
96
96
|
end
|
97
97
|
|
@@ -20,7 +20,7 @@ module DatadogBackup
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def backup
|
23
|
-
|
23
|
+
LOGGER.info("Starting diffs on #{::DatadogBackup::ThreadPool::TPOOL.max_length} threads")
|
24
24
|
|
25
25
|
futures = all_boards.map do |board|
|
26
26
|
Concurrent::Promises.future_on(::DatadogBackup::ThreadPool::TPOOL, board) do |board|
|
@@ -29,7 +29,7 @@ module DatadogBackup
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
watcher = ::DatadogBackup::ThreadPool.watcher
|
32
|
+
watcher = ::DatadogBackup::ThreadPool.watcher
|
33
33
|
watcher.join if watcher.status
|
34
34
|
|
35
35
|
Concurrent::Promises.zip(*futures).value!
|
@@ -8,21 +8,21 @@ module DatadogBackup
|
|
8
8
|
fallback_policy: :abort
|
9
9
|
)
|
10
10
|
|
11
|
-
def self.watcher
|
11
|
+
def self.watcher
|
12
12
|
Thread.new(TPOOL) do |pool|
|
13
13
|
while pool.queue_length.positive?
|
14
14
|
sleep 2
|
15
|
-
|
15
|
+
LOGGER.info("#{pool.queue_length} tasks remaining for execution.")
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
def self.shutdown
|
21
|
-
|
20
|
+
def self.shutdown
|
21
|
+
LOGGER.fatal 'Shutdown signal caught. Performing orderly shut down of thread pool. Press Ctrl+C again to forcibly shut down, but be warned, DATA LOSS MAY OCCUR.'
|
22
22
|
TPOOL.shutdown
|
23
23
|
TPOOL.wait_for_termination
|
24
24
|
rescue SystemExit, Interrupt
|
25
|
-
|
25
|
+
LOGGER.fatal 'OK Nuking, DATA LOSS MAY OCCUR.'
|
26
26
|
TPOOL.kill
|
27
27
|
end
|
28
28
|
end
|
data/lib/datadog_backup.rb
CHANGED
@@ -6,13 +6,16 @@ require 'dogapi'
|
|
6
6
|
|
7
7
|
require_relative 'datadog_backup/local_filesystem'
|
8
8
|
require_relative 'datadog_backup/options'
|
9
|
-
|
10
9
|
require_relative 'datadog_backup/cli'
|
11
10
|
require_relative 'datadog_backup/core'
|
12
11
|
require_relative 'datadog_backup/dashboards'
|
13
12
|
require_relative 'datadog_backup/monitors'
|
14
13
|
require_relative 'datadog_backup/thread_pool'
|
15
14
|
require_relative 'datadog_backup/version'
|
15
|
+
require_relative 'datadog_backup/deprecations'
|
16
|
+
DatadogBackup::Deprecations.check
|
17
|
+
|
16
18
|
|
17
19
|
module DatadogBackup
|
18
20
|
end
|
21
|
+
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe DatadogBackup::Deprecations do
|
6
|
+
let(:logger) { double }
|
7
|
+
|
8
|
+
before do
|
9
|
+
stub_const('LOGGER', logger)
|
10
|
+
allow(logger).to receive(:warn)
|
11
|
+
end
|
12
|
+
|
13
|
+
%w[2.4.10 2.5.9 2.6.8].each do |ruby_version|
|
14
|
+
describe "#check#{ruby_version}" do
|
15
|
+
subject { described_class.check }
|
16
|
+
|
17
|
+
it 'does warn' do
|
18
|
+
stub_const('RUBY_VERSION', ruby_version)
|
19
|
+
expect(logger).to receive(:warn).with(/ruby-#{ruby_version} is deprecated./)
|
20
|
+
subject
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
%w[2.7.4 3.0.4 3.1.2 3.2.0-preview1].each do |ruby_version|
|
26
|
+
describe "#check#{ruby_version}" do
|
27
|
+
subject { described_class.check }
|
28
|
+
|
29
|
+
it 'does not warn' do
|
30
|
+
stub_const('RUBY_VERSION', ruby_version)
|
31
|
+
expect(logger).to_not receive(:warn).with(/ruby-#{ruby_version} is deprecated./)
|
32
|
+
subject
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -11,8 +11,7 @@ describe DatadogBackup::LocalFilesystem do
|
|
11
11
|
client: client_double,
|
12
12
|
backup_dir: tempdir,
|
13
13
|
resources: [DatadogBackup::Dashboards],
|
14
|
-
output_format: :json
|
15
|
-
logger: Logger.new('/dev/null')
|
14
|
+
output_format: :json
|
16
15
|
)
|
17
16
|
end
|
18
17
|
let(:core_yaml) do
|
@@ -21,8 +20,7 @@ describe DatadogBackup::LocalFilesystem do
|
|
21
20
|
client: client_double,
|
22
21
|
backup_dir: tempdir,
|
23
22
|
resources: [],
|
24
|
-
output_format: :yaml
|
25
|
-
logger: Logger.new('/dev/null')
|
23
|
+
output_format: :yaml
|
26
24
|
)
|
27
25
|
end
|
28
26
|
|
data/spec/spec_helper.rb
CHANGED
@@ -2,16 +2,18 @@
|
|
2
2
|
|
3
3
|
$LOAD_PATH.unshift(File.expand_path('../lib', File.dirname(__FILE__)))
|
4
4
|
|
5
|
-
require 'datadog_backup'
|
6
5
|
require 'logger'
|
7
|
-
require 'tmpdir'
|
8
|
-
require 'dogapi'
|
9
|
-
|
10
6
|
$stdout.sync = $stderr.sync = true
|
11
|
-
LOGGER = Logger.new(
|
7
|
+
LOGGER = Logger.new('/dev/null')
|
12
8
|
LOGGER.level = Logger::INFO
|
13
9
|
$stdout = File.new('/dev/null', 'w+')
|
14
10
|
|
11
|
+
require 'tmpdir'
|
12
|
+
require 'dogapi'
|
13
|
+
require 'datadog_backup'
|
14
|
+
|
15
|
+
|
16
|
+
|
15
17
|
SPEC_ROOT = __dir__
|
16
18
|
WORK_ROOT = File.expand_path(File.join(SPEC_ROOT, '..'))
|
17
19
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: datadog_backup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kamran Farhadi
|
@@ -15,70 +15,70 @@ dependencies:
|
|
15
15
|
name: amazing_print
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: 1.4.0
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- -
|
25
|
+
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: 1.4.0
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: concurrent-ruby
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: 1.1.10
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: 1.1.10
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: deepsort
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- -
|
46
|
+
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: 0.4.5
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: 0.4.5
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: diffy
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- -
|
60
|
+
- - "~>"
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: 3.4.2
|
63
63
|
type: :runtime
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: 3.4.2
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: dogapi
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
|
-
- -
|
74
|
+
- - "~>"
|
75
75
|
- !ruby/object:Gem::Version
|
76
76
|
version: 1.45.0
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
|
-
- -
|
81
|
+
- - "~>"
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: 1.45.0
|
84
84
|
- !ruby/object:Gem::Dependency
|
@@ -198,6 +198,7 @@ files:
|
|
198
198
|
- lib/datadog_backup/cli.rb
|
199
199
|
- lib/datadog_backup/core.rb
|
200
200
|
- lib/datadog_backup/dashboards.rb
|
201
|
+
- lib/datadog_backup/deprecations.rb
|
201
202
|
- lib/datadog_backup/local_filesystem.rb
|
202
203
|
- lib/datadog_backup/monitors.rb
|
203
204
|
- lib/datadog_backup/options.rb
|
@@ -207,6 +208,7 @@ files:
|
|
207
208
|
- spec/datadog_backup/cli_spec.rb
|
208
209
|
- spec/datadog_backup/core_spec.rb
|
209
210
|
- spec/datadog_backup/dashboards_spec.rb
|
211
|
+
- spec/datadog_backup/deprecations_spec.rb
|
210
212
|
- spec/datadog_backup/local_filesystem_spec.rb
|
211
213
|
- spec/datadog_backup/monitors_spec.rb
|
212
214
|
- spec/datadog_backup_bin_spec.rb
|
@@ -224,7 +226,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
224
226
|
requirements:
|
225
227
|
- - ">="
|
226
228
|
- !ruby/object:Gem::Version
|
227
|
-
version: '2.
|
229
|
+
version: '2.6'
|
228
230
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
229
231
|
requirements:
|
230
232
|
- - ">="
|
@@ -239,6 +241,7 @@ test_files:
|
|
239
241
|
- spec/datadog_backup/cli_spec.rb
|
240
242
|
- spec/datadog_backup/core_spec.rb
|
241
243
|
- spec/datadog_backup/dashboards_spec.rb
|
244
|
+
- spec/datadog_backup/deprecations_spec.rb
|
242
245
|
- spec/datadog_backup/local_filesystem_spec.rb
|
243
246
|
- spec/datadog_backup/monitors_spec.rb
|
244
247
|
- spec/datadog_backup_bin_spec.rb
|