datadog_backup 1.0.1.alpha.1 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +4 -5
- data/.github/workflows/rspec_and_release.yml +14 -9
- data/.gitignore +2 -0
- data/.rubocop.yml +78 -1
- data/CHANGELOG.md +34 -1
- data/Gemfile +0 -1
- data/Gemfile.lock +22 -27
- data/README.md +12 -0
- data/bin/datadog_backup +38 -30
- data/datadog_backup.gemspec +1 -2
- data/lib/datadog_backup.rb +0 -1
- data/lib/datadog_backup/cli.rb +1 -1
- data/lib/datadog_backup/core.rb +1 -0
- data/lib/datadog_backup/thread_pool.rb +0 -1
- data/lib/datadog_backup/version.rb +1 -1
- data/release.config.js +1 -8
- data/spec/datadog_backup/cli_spec.rb +30 -0
- data/spec/datadog_backup_bin_spec.rb +9 -9
- metadata +7 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 618459125bc84a9d8c48eb2ffb3256163378d26af4d80e92f2c1033110ae9467
|
4
|
+
data.tar.gz: 619212b26a22764af2050375426f19edba44563b867ded709d33a00384468fd9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e029e80229c35796bcd28432af89a7c39172b646c4e880dff8df9e1b5ccfb299706ee9b466fe1c5500126fbd03097dd3da4ef0da91d7ee77e256c8c2657c1a2c
|
7
|
+
data.tar.gz: 635beff60e9a93d5946c8e88f4a9ac8e11b56f08d0b03f045814ec0f799714eebc7f2b0d1fa665807151524469aebe024e7954cffd6a8b57a898d9da97f6d74c
|
data/.github/dependabot.yml
CHANGED
@@ -9,12 +9,11 @@ updates:
|
|
9
9
|
directory: "/" # Location of package manifests
|
10
10
|
schedule:
|
11
11
|
interval: "daily"
|
12
|
-
|
13
|
-
prefix: "
|
14
|
-
|
15
|
-
|
12
|
+
commit-message:
|
13
|
+
prefix: "fix"
|
14
|
+
prefix-development: "chore"
|
15
|
+
include: "scope"
|
16
16
|
- package-ecosystem: "github-actions"
|
17
17
|
directory: "/" # Location of package manifests
|
18
18
|
schedule:
|
19
19
|
interval: "daily"
|
20
|
-
|
@@ -7,27 +7,32 @@ on:
|
|
7
7
|
|
8
8
|
jobs:
|
9
9
|
rspec:
|
10
|
-
|
10
|
+
strategy:
|
11
|
+
fail-fast: false
|
12
|
+
matrix:
|
13
|
+
os: [ubuntu-latest, macos-latest]
|
14
|
+
# Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
|
15
|
+
ruby: [2.6, 2.7]
|
16
|
+
runs-on: ${{ matrix.os }}
|
11
17
|
steps:
|
12
|
-
- uses: actions/checkout@v2
|
13
|
-
- name: Set up Ruby
|
18
|
+
- uses: actions/checkout@v2.3.4
|
19
|
+
- name: Set up Ruby
|
14
20
|
uses: ruby/setup-ruby@v1
|
15
21
|
with:
|
16
|
-
ruby-version:
|
22
|
+
ruby-version: ${{ matrix.ruby }}
|
17
23
|
bundler-cache: true
|
18
24
|
- name: Test with Rspec
|
19
25
|
run: |
|
20
|
-
bundle exec rspec --format documentation
|
26
|
+
bundle exec rspec --format documentation --require spec_helper
|
21
27
|
release:
|
22
28
|
if: github.event_name == 'push'
|
23
29
|
needs: rspec
|
24
30
|
runs-on: ubuntu-latest
|
25
31
|
env:
|
26
|
-
|
27
|
-
BUNDLE_DEPLOYMENT: "true"
|
32
|
+
BUNDLE_DEPLOYMENT: true
|
28
33
|
steps:
|
29
|
-
- uses: actions/checkout@v2
|
30
|
-
- name: Set up Ruby
|
34
|
+
- uses: actions/checkout@v2.3.4
|
35
|
+
- name: Set up Ruby
|
31
36
|
uses: ruby/setup-ruby@v1
|
32
37
|
with:
|
33
38
|
ruby-version: 2.7
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1 +1,78 @@
|
|
1
|
-
require: rubocop-rspec
|
1
|
+
require: rubocop-rspec
|
2
|
+
|
3
|
+
Gemspec/DateAssignment: # (new in 1.10)
|
4
|
+
Enabled: true
|
5
|
+
Layout/LineEndStringConcatenationIndentation: # (new in 1.18)
|
6
|
+
Enabled: true
|
7
|
+
Layout/SpaceBeforeBrackets: # (new in 1.7)
|
8
|
+
Enabled: true
|
9
|
+
Lint/AmbiguousAssignment: # (new in 1.7)
|
10
|
+
Enabled: true
|
11
|
+
Lint/DeprecatedConstants: # (new in 1.8)
|
12
|
+
Enabled: true
|
13
|
+
Lint/DuplicateBranch: # (new in 1.3)
|
14
|
+
Enabled: true
|
15
|
+
Lint/DuplicateRegexpCharacterClassElement: # (new in 1.1)
|
16
|
+
Enabled: true
|
17
|
+
Lint/EmptyBlock: # (new in 1.1)
|
18
|
+
Enabled: true
|
19
|
+
Lint/EmptyClass: # (new in 1.3)
|
20
|
+
Enabled: true
|
21
|
+
Lint/EmptyInPattern: # (new in 1.16)
|
22
|
+
Enabled: true
|
23
|
+
Lint/LambdaWithoutLiteralBlock: # (new in 1.8)
|
24
|
+
Enabled: true
|
25
|
+
Lint/NoReturnInBeginEndBlocks: # (new in 1.2)
|
26
|
+
Enabled: true
|
27
|
+
Lint/NumberedParameterAssignment: # (new in 1.9)
|
28
|
+
Enabled: true
|
29
|
+
Lint/OrAssignmentToConstant: # (new in 1.9)
|
30
|
+
Enabled: true
|
31
|
+
Lint/RedundantDirGlobSort: # (new in 1.8)
|
32
|
+
Enabled: true
|
33
|
+
Lint/SymbolConversion: # (new in 1.9)
|
34
|
+
Enabled: true
|
35
|
+
Lint/ToEnumArguments: # (new in 1.1)
|
36
|
+
Enabled: true
|
37
|
+
Lint/TripleQuotes: # (new in 1.9)
|
38
|
+
Enabled: true
|
39
|
+
Lint/UnexpectedBlockArity: # (new in 1.5)
|
40
|
+
Enabled: true
|
41
|
+
Lint/UnmodifiedReduceAccumulator: # (new in 1.1)
|
42
|
+
Enabled: true
|
43
|
+
Naming/InclusiveLanguage: # (new in 1.18)
|
44
|
+
Enabled: true
|
45
|
+
Style/ArgumentsForwarding: # (new in 1.1)
|
46
|
+
Enabled: true
|
47
|
+
Style/CollectionCompact: # (new in 1.2)
|
48
|
+
Enabled: true
|
49
|
+
Style/DocumentDynamicEvalDefinition: # (new in 1.1)
|
50
|
+
Enabled: true
|
51
|
+
Style/EndlessMethod: # (new in 1.8)
|
52
|
+
Enabled: true
|
53
|
+
Style/HashConversion: # (new in 1.10)
|
54
|
+
Enabled: true
|
55
|
+
Style/HashExcept: # (new in 1.7)
|
56
|
+
Enabled: true
|
57
|
+
Style/IfWithBooleanLiteralBranches: # (new in 1.9)
|
58
|
+
Enabled: true
|
59
|
+
Style/InPatternThen: # (new in 1.16)
|
60
|
+
Enabled: true
|
61
|
+
Style/MultilineInPatternThen: # (new in 1.16)
|
62
|
+
Enabled: true
|
63
|
+
Style/NegatedIfElseCondition: # (new in 1.2)
|
64
|
+
Enabled: true
|
65
|
+
Style/NilLambda: # (new in 1.3)
|
66
|
+
Enabled: true
|
67
|
+
Style/QuotedSymbols: # (new in 1.16)
|
68
|
+
Enabled: true
|
69
|
+
Style/RedundantArgument: # (new in 1.4)
|
70
|
+
Enabled: true
|
71
|
+
Style/StringChars: # (new in 1.12)
|
72
|
+
Enabled: true
|
73
|
+
Style/SwapValues: # (new in 1.1)
|
74
|
+
Enabled: true
|
75
|
+
RSpec/IdenticalEqualityAssertion: # (new in 2.4)
|
76
|
+
Enabled: true
|
77
|
+
RSpec/Rails/AvoidSetupHook: # (new in 2.4)
|
78
|
+
Enabled: true
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,37 @@
|
|
1
|
-
## [1.0.
|
1
|
+
## [1.0.5](https://github.com/scribd/datadog_backup/compare/v1.0.4...v1.0.5) (2021-07-12)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* Add documentation for DATADOG_HOST usage ([69acc25](https://github.com/scribd/datadog_backup/commit/69acc2574d17310ee090486ec46cb06ab0f450db))
|
7
|
+
|
8
|
+
## [1.0.4](https://github.com/scribd/datadog_backup/compare/v1.0.3...v1.0.4) (2021-07-08)
|
9
|
+
|
10
|
+
|
11
|
+
### Bug Fixes
|
12
|
+
|
13
|
+
* remove max queue size limit ([b5ee79c](https://github.com/scribd/datadog_backup/commit/b5ee79cc587ef95cebf89bbd8efe9d829af63c8a))
|
14
|
+
|
15
|
+
## [1.0.3](https://github.com/scribd/datadog_backup/compare/v1.0.2...v1.0.3) (2021-06-10)
|
16
|
+
|
17
|
+
|
18
|
+
### Bug Fixes
|
19
|
+
|
20
|
+
* **deps:** update concurrent-ruby requirement from = 1.1.8 to = 1.1.9 ([31ccccb](https://github.com/scribd/datadog_backup/commit/31ccccbc890792670946923f51e5b883f4cf3e87))
|
21
|
+
|
22
|
+
## [1.0.2](https://github.com/scribd/datadog_backup/compare/v1.0.1...v1.0.2) (2021-05-06)
|
23
|
+
|
24
|
+
|
25
|
+
### Bug Fixes
|
26
|
+
|
27
|
+
* **deps:** bump rexml from 3.2.4 to 3.2.5 ([15efa8c](https://github.com/scribd/datadog_backup/commit/15efa8c58953d450311fc8e5f125bf7e12401af4))
|
28
|
+
|
29
|
+
## [1.0.1](https://github.com/scribd/datadog_backup/compare/v1.0.0...v1.0.1) (2021-03-26)
|
30
|
+
|
31
|
+
|
32
|
+
### Bug Fixes
|
33
|
+
|
34
|
+
* dependabot syntax for github ([4214001](https://github.com/scribd/datadog_backup/commit/42140015976ec2d0f4d2fce6e4c3214bb590c967))
|
2
35
|
|
3
36
|
# [1.0.0](https://github.com/scribd/datadog_backup/compare/v0.11.0...v1.0.0) (2021-03-02)
|
4
37
|
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -3,8 +3,7 @@ PATH
|
|
3
3
|
specs:
|
4
4
|
datadog_backup (0.6.0)
|
5
5
|
amazing_print (= 1.3.0)
|
6
|
-
concurrent-ruby (= 1.1.
|
7
|
-
concurrent-ruby-edge (= 0.6.0)
|
6
|
+
concurrent-ruby (= 1.1.9)
|
8
7
|
deepsort (= 0.4.5)
|
9
8
|
diffy (= 3.4.0)
|
10
9
|
dogapi (= 1.45.0)
|
@@ -14,19 +13,16 @@ GEM
|
|
14
13
|
specs:
|
15
14
|
amazing_print (1.3.0)
|
16
15
|
ast (2.4.2)
|
17
|
-
climate_control (1.0.0)
|
18
16
|
coderay (1.1.3)
|
19
|
-
concurrent-ruby (1.1.
|
20
|
-
concurrent-ruby-edge (0.6.0)
|
21
|
-
concurrent-ruby (~> 1.1.6)
|
17
|
+
concurrent-ruby (1.1.9)
|
22
18
|
deepsort (0.4.5)
|
23
19
|
diff-lcs (1.4.4)
|
24
20
|
diffy (3.4.0)
|
25
21
|
dogapi (1.45.0)
|
26
22
|
multi_json
|
27
|
-
ffi (1.
|
28
|
-
formatador (0.
|
29
|
-
guard (2.
|
23
|
+
ffi (1.15.3)
|
24
|
+
formatador (0.3.0)
|
25
|
+
guard (2.17.0)
|
30
26
|
formatador (>= 0.2.4)
|
31
27
|
listen (>= 2.7, < 4.0)
|
32
28
|
lumberjack (>= 1.0.12, < 2.0)
|
@@ -40,10 +36,10 @@ GEM
|
|
40
36
|
guard (~> 2.1)
|
41
37
|
guard-compat (~> 1.1)
|
42
38
|
rspec (>= 2.99.0, < 4.0)
|
43
|
-
listen (3.
|
39
|
+
listen (3.5.1)
|
44
40
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
45
41
|
rb-inotify (~> 0.9, >= 0.9.10)
|
46
|
-
lumberjack (1.2.
|
42
|
+
lumberjack (1.2.8)
|
47
43
|
method_source (1.0.0)
|
48
44
|
multi_json (1.15.0)
|
49
45
|
nenv (0.3.0)
|
@@ -51,47 +47,47 @@ GEM
|
|
51
47
|
nenv (~> 0.1)
|
52
48
|
shellany (~> 0.0)
|
53
49
|
parallel (1.20.1)
|
54
|
-
parser (3.0.
|
50
|
+
parser (3.0.2.0)
|
55
51
|
ast (~> 2.4.1)
|
56
|
-
pry (0.14.
|
52
|
+
pry (0.14.1)
|
57
53
|
coderay (~> 1.1)
|
58
54
|
method_source (~> 1.0)
|
59
55
|
rainbow (3.0.0)
|
60
|
-
rb-fsevent (0.
|
56
|
+
rb-fsevent (0.11.0)
|
61
57
|
rb-inotify (0.10.1)
|
62
58
|
ffi (~> 1.0)
|
63
59
|
regexp_parser (2.1.1)
|
64
|
-
rexml (3.2.
|
60
|
+
rexml (3.2.5)
|
65
61
|
rspec (3.10.0)
|
66
62
|
rspec-core (~> 3.10.0)
|
67
63
|
rspec-expectations (~> 3.10.0)
|
68
64
|
rspec-mocks (~> 3.10.0)
|
69
|
-
rspec-core (3.10.
|
65
|
+
rspec-core (3.10.1)
|
70
66
|
rspec-support (~> 3.10.0)
|
71
|
-
rspec-expectations (3.10.
|
67
|
+
rspec-expectations (3.10.1)
|
72
68
|
diff-lcs (>= 1.2.0, < 2.0)
|
73
69
|
rspec-support (~> 3.10.0)
|
74
|
-
rspec-mocks (3.10.
|
70
|
+
rspec-mocks (3.10.2)
|
75
71
|
diff-lcs (>= 1.2.0, < 2.0)
|
76
72
|
rspec-support (~> 3.10.0)
|
77
|
-
rspec-support (3.10.
|
78
|
-
rubocop (1.
|
73
|
+
rspec-support (3.10.2)
|
74
|
+
rubocop (1.18.3)
|
79
75
|
parallel (~> 1.10)
|
80
76
|
parser (>= 3.0.0.0)
|
81
77
|
rainbow (>= 2.2.2, < 4.0)
|
82
78
|
regexp_parser (>= 1.8, < 3.0)
|
83
79
|
rexml
|
84
|
-
rubocop-ast (>= 1.
|
80
|
+
rubocop-ast (>= 1.7.0, < 2.0)
|
85
81
|
ruby-progressbar (~> 1.7)
|
86
82
|
unicode-display_width (>= 1.4.0, < 3.0)
|
87
|
-
rubocop-ast (1.
|
88
|
-
parser (>=
|
89
|
-
rubocop-rspec (2.
|
83
|
+
rubocop-ast (1.7.0)
|
84
|
+
parser (>= 3.0.1.1)
|
85
|
+
rubocop-rspec (2.4.0)
|
90
86
|
rubocop (~> 1.0)
|
91
87
|
rubocop-ast (>= 1.1.0)
|
92
88
|
ruby-progressbar (1.11.0)
|
93
89
|
shellany (0.0.1)
|
94
|
-
thor (1.0
|
90
|
+
thor (1.1.0)
|
95
91
|
unicode-display_width (2.0.0)
|
96
92
|
|
97
93
|
PLATFORMS
|
@@ -99,7 +95,6 @@ PLATFORMS
|
|
99
95
|
|
100
96
|
DEPENDENCIES
|
101
97
|
bundler
|
102
|
-
climate_control
|
103
98
|
datadog_backup!
|
104
99
|
guard-rspec
|
105
100
|
pry
|
@@ -108,4 +103,4 @@ DEPENDENCIES
|
|
108
103
|
rubocop-rspec
|
109
104
|
|
110
105
|
BUNDLED WITH
|
111
|
-
2.
|
106
|
+
2.2.21
|
data/README.md
CHANGED
@@ -49,6 +49,18 @@ datadog_backup diffs --backup-dir optional/path/to/backupdir
|
|
49
49
|
datadog_backup restore --backup-dir optional/path/to/backupdir
|
50
50
|
```
|
51
51
|
|
52
|
+
## Environment variables
|
53
|
+
|
54
|
+
The following environment variables can be set in order to further customize datadog_backup:
|
55
|
+
|
56
|
+
environment variable | description | default
|
57
|
+
---------------------|--------------------------------------------------------------------------------|--------------------------
|
58
|
+
DATADOG_HOST | Describe the API endpoint to connect to (https://api.datadoghq.eu for example) | https://api.datadoghq.com
|
59
|
+
http_proxy | Instruct Dogapi to connect via a differnt proxy address | none
|
60
|
+
https_proxy | same as http_proxy | none
|
61
|
+
dd_proxy_https | same as http_proxy | none
|
62
|
+
|
63
|
+
|
52
64
|
### Usage in a Github repo
|
53
65
|
|
54
66
|
See [example/](https://github.com/scribd/datadog_backup/tree/master/example) for an example implementation as a repo that backs up your Datadog dashboards hourly.
|
data/bin/datadog_backup
CHANGED
@@ -13,25 +13,24 @@ $stdout.sync = $stderr.sync = true
|
|
13
13
|
LOGGER = Logger.new($stderr) unless defined?(LOGGER)
|
14
14
|
LOGGER.level = Logger::INFO
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
force_restore: false,
|
27
|
-
logger: LOGGER
|
28
|
-
}
|
16
|
+
def fatal(message)
|
17
|
+
LOGGER.fatal(message)
|
18
|
+
exit 1
|
19
|
+
end
|
20
|
+
|
21
|
+
def options_valid?(options)
|
22
|
+
%w[backup diffs restore].include?(options[:action]) &&
|
23
|
+
options[:datadog_api_key] &&
|
24
|
+
options[:datadog_app_key]
|
25
|
+
end
|
29
26
|
|
30
|
-
def prereqs
|
27
|
+
def prereqs(defaults)
|
31
28
|
ARGV << '--help' if ARGV.empty?
|
32
29
|
|
30
|
+
result = defaults.dup
|
31
|
+
|
33
32
|
options = OptionParser.new do |opts|
|
34
|
-
opts.banner = "Usage: #{File.basename($PROGRAM_NAME)} <backup|diffs|restore>"
|
33
|
+
opts.banner = "Usage: DATADOG_API_KEY=abc123 DATADOG_APP_KEY=abc123 #{File.basename($PROGRAM_NAME)} <backup|diffs|restore>"
|
35
34
|
opts.separator ''
|
36
35
|
opts.on_tail('-h', '--help', 'Show this message') do
|
37
36
|
puts opts
|
@@ -47,40 +46,49 @@ def prereqs
|
|
47
46
|
LOGGER.level = Logger::ERROR
|
48
47
|
end
|
49
48
|
opts.on('--backup-dir PATH', '`backup` by default') do |path|
|
50
|
-
|
49
|
+
result[:backup_dir] = path
|
51
50
|
end
|
52
51
|
opts.on('--monitors-only') do
|
53
|
-
|
52
|
+
result[:resources] = [DatadogBackup::Monitors]
|
54
53
|
end
|
55
54
|
opts.on('--dashboards-only') do
|
56
|
-
|
55
|
+
result[:resources] = [DatadogBackup::Dashboards]
|
57
56
|
end
|
58
57
|
opts.on(
|
59
58
|
'--json',
|
60
59
|
'format backups as JSON instead of YAML. Does not impact `diffs` nor `restore`, but do not mix formats in the same backup-dir.'
|
61
60
|
) do
|
62
|
-
|
61
|
+
result[:output_format] = :json
|
63
62
|
end
|
64
63
|
opts.on('--no-color', 'removes colored output from diff format') do
|
65
|
-
|
64
|
+
result[:diff_format] = nil
|
66
65
|
end
|
67
66
|
opts.on('--diff-format FORMAT', 'one of `color`, `html_simple`, `html`') do |format|
|
68
|
-
|
67
|
+
result[:diff_format] = format.to_sym
|
69
68
|
end
|
70
69
|
opts.on('--force-restore', 'force restore to Datadog') do
|
71
|
-
|
70
|
+
result[:force_restore] = true
|
72
71
|
end
|
73
72
|
end
|
74
73
|
options.parse!
|
75
74
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
puts options
|
80
|
-
exit 0
|
81
|
-
end
|
75
|
+
result[:action] = ARGV.first
|
76
|
+
fatal(options) unless options_valid?(result)
|
77
|
+
result
|
82
78
|
end
|
83
79
|
|
84
|
-
|
80
|
+
##
|
81
|
+
# Default parameters
|
82
|
+
defaults = {
|
83
|
+
action: nil,
|
84
|
+
datadog_api_key: ENV.fetch('DATADOG_API_KEY', nil),
|
85
|
+
datadog_app_key: ENV.fetch('DATADOG_APP_KEY', nil),
|
86
|
+
backup_dir: File.join(ENV.fetch('PWD'), 'backup'),
|
87
|
+
diff_format: :color,
|
88
|
+
resources: [DatadogBackup::Dashboards, DatadogBackup::Monitors],
|
89
|
+
output_format: :yaml,
|
90
|
+
force_restore: false,
|
91
|
+
logger: LOGGER
|
92
|
+
}
|
85
93
|
|
86
|
-
DatadogBackup::Cli.new(
|
94
|
+
DatadogBackup::Cli.new(prereqs(defaults)).run!
|
data/datadog_backup.gemspec
CHANGED
@@ -20,8 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.require_paths = ['lib']
|
21
21
|
|
22
22
|
spec.add_dependency 'amazing_print', '1.3.0'
|
23
|
-
spec.add_dependency 'concurrent-ruby', '1.1.
|
24
|
-
spec.add_dependency 'concurrent-ruby-edge', '0.6.0'
|
23
|
+
spec.add_dependency 'concurrent-ruby', '1.1.9'
|
25
24
|
spec.add_dependency 'deepsort', '0.4.5'
|
26
25
|
spec.add_dependency 'diffy', '3.4.0'
|
27
26
|
spec.add_dependency 'dogapi', '1.45.0'
|
data/lib/datadog_backup.rb
CHANGED
data/lib/datadog_backup/cli.rb
CHANGED
data/lib/datadog_backup/core.rb
CHANGED
data/release.config.js
CHANGED
@@ -1,13 +1,6 @@
|
|
1
1
|
module.exports = {
|
2
2
|
"plugins": [
|
3
|
-
|
4
|
-
"@semantic-release/commit-analyzer",
|
5
|
-
{
|
6
|
-
"releaseRules": [
|
7
|
-
{"type": "deps", "release": "patch"}
|
8
|
-
]
|
9
|
-
}
|
10
|
-
],
|
3
|
+
"@semantic-release/commit-analyzer",
|
11
4
|
"@semantic-release/release-notes-generator",
|
12
5
|
[
|
13
6
|
"@semantic-release/changelog",
|
@@ -26,6 +26,36 @@ describe DatadogBackup::Cli do
|
|
26
26
|
allow(cli).to receive(:resource_instances).and_return([dashboards])
|
27
27
|
end
|
28
28
|
|
29
|
+
describe '#initialize_client' do
|
30
|
+
subject { described_class.new({ datadog_api_key: 1, datadog_app_key: 1 }).initialize_client }
|
31
|
+
|
32
|
+
it { is_expected.to be_a(Dogapi::Client) }
|
33
|
+
|
34
|
+
context 'when the environment variable DATADOG_HOST is set to a custom host like https://api.datadoghq.eu' do
|
35
|
+
before do
|
36
|
+
stub_const('ENV', 'DATADOG_HOST' => 'https://api.datadoghq.eu')
|
37
|
+
end
|
38
|
+
|
39
|
+
describe 'then #datadog_host is https://api.datadoghq.eu' do
|
40
|
+
subject { described_class.new({ datadog_api_key: 1, datadog_app_key: 1 }).initialize_client.datadog_host }
|
41
|
+
|
42
|
+
it { is_expected.to eq('https://api.datadoghq.eu') }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'when the environment variable DATADOG_HOST is not set' do
|
47
|
+
before do
|
48
|
+
stub_const('ENV', {})
|
49
|
+
end
|
50
|
+
|
51
|
+
describe 'then #datadog_host is https://api.datadoghq.eu' do
|
52
|
+
subject { described_class.new({ datadog_api_key: 1, datadog_app_key: 1 }).initialize_client.datadog_host }
|
53
|
+
|
54
|
+
it { is_expected.to eq('https://api.datadoghq.com') }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
29
59
|
describe '#backup' do
|
30
60
|
context 'when dashboards are deleted in datadog' do
|
31
61
|
let(:all_boards) do
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'open3'
|
4
|
-
require 'climate_control'
|
5
4
|
require 'timeout'
|
6
5
|
|
7
6
|
describe 'bin/datadog_backup' do
|
@@ -18,13 +17,13 @@ describe 'bin/datadog_backup' do
|
|
18
17
|
i.close
|
19
18
|
end
|
20
19
|
|
21
|
-
Timeout.timeout(
|
20
|
+
Timeout.timeout(2.0) do
|
22
21
|
oe.each do |v|
|
23
22
|
output += v
|
24
23
|
end
|
25
24
|
end
|
26
25
|
rescue Timeout::Error
|
27
|
-
LOGGER.warn "Timing out #{t.inspect} after
|
26
|
+
LOGGER.warn "Timing out #{t.inspect} after 2 second"
|
28
27
|
Process.kill(15, pid)
|
29
28
|
ensure
|
30
29
|
status = t.value
|
@@ -37,23 +36,24 @@ describe 'bin/datadog_backup' do
|
|
37
36
|
DATADOG_APP_KEY
|
38
37
|
]
|
39
38
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
end
|
39
|
+
env = {}
|
40
|
+
required_vars.each do |v|
|
41
|
+
env[v] = v.downcase
|
44
42
|
end
|
45
43
|
|
44
|
+
|
46
45
|
required_vars.map do |v|
|
47
46
|
it "dies unless given ENV[#{v}]" do
|
48
|
-
|
47
|
+
stub_const('ENV', env.dup.tap { |h| h.delete(v) })
|
49
48
|
_, status = run_bin('backup')
|
50
49
|
expect(status).not_to be_success
|
51
50
|
end
|
52
51
|
end
|
53
52
|
|
54
53
|
it 'supplies help' do
|
54
|
+
stub_const('ENV', env)
|
55
55
|
out_err, status = run_bin('--help')
|
56
|
-
expect(out_err).to match(/Usage:
|
56
|
+
expect(out_err).to match(/Usage: DATADOG_API_KEY=/)
|
57
57
|
expect(status).to be_success
|
58
58
|
end
|
59
59
|
end
|
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: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kamran Farhadi
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-
|
12
|
+
date: 2021-07-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: amazing_print
|
@@ -31,28 +31,14 @@ dependencies:
|
|
31
31
|
requirements:
|
32
32
|
- - '='
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: 1.1.
|
34
|
+
version: 1.1.9
|
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
|
-
version: 1.1.
|
42
|
-
- !ruby/object:Gem::Dependency
|
43
|
-
name: concurrent-ruby-edge
|
44
|
-
requirement: !ruby/object:Gem::Requirement
|
45
|
-
requirements:
|
46
|
-
- - '='
|
47
|
-
- !ruby/object:Gem::Version
|
48
|
-
version: 0.6.0
|
49
|
-
type: :runtime
|
50
|
-
prerelease: false
|
51
|
-
version_requirements: !ruby/object:Gem::Requirement
|
52
|
-
requirements:
|
53
|
-
- - '='
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
version: 0.6.0
|
41
|
+
version: 1.1.9
|
56
42
|
- !ruby/object:Gem::Dependency
|
57
43
|
name: deepsort
|
58
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -184,11 +170,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
184
170
|
version: '0'
|
185
171
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
186
172
|
requirements:
|
187
|
-
- - "
|
173
|
+
- - ">="
|
188
174
|
- !ruby/object:Gem::Version
|
189
|
-
version:
|
175
|
+
version: '0'
|
190
176
|
requirements: []
|
191
|
-
rubygems_version: 3.1.
|
177
|
+
rubygems_version: 3.1.6
|
192
178
|
signing_key:
|
193
179
|
specification_version: 4
|
194
180
|
summary: A utility to backup and restore Datadog accounts
|