datadog_backup 1.0.4 → 1.1.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 +6 -6
- data/.gitignore +2 -0
- data/.rubocop.yml +78 -1
- data/CHANGELOG.md +28 -0
- data/Gemfile +0 -1
- data/Gemfile.lock +23 -29
- data/README.md +34 -11
- data/bin/datadog_backup +39 -31
- data/datadog_backup.gemspec +3 -2
- data/lib/datadog_backup/cli.rb +1 -1
- data/lib/datadog_backup/core.rb +1 -0
- data/lib/datadog_backup/local_filesystem.rb +1 -1
- data/lib/datadog_backup/version.rb +1 -1
- data/lib/datadog_backup.rb +0 -1
- data/spec/datadog_backup/cli_spec.rb +30 -0
- data/spec/datadog_backup_bin_spec.rb +6 -7
- metadata +5 -19
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 56ff82a616154e19aa71e5a9f552dae87569483259a6d7a9ab1e5e8ca19e6e81
|
|
4
|
+
data.tar.gz: 987f889873b25ae4addb9f0e8a6867828519d00268fa989b3af585438ae09494
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 577e5a1ea30a389246313f6a1837fa2e2951536d18af16673379ca066c8d97c526e81b2f21456e43ef8ebe08fe70b4f1bcfa6e3831f26099f1bfe9165c85734e
|
|
7
|
+
data.tar.gz: 4554302c678bfd9ccdbce6e5606ebcc8ef74676aae47513bfefdb761664b5b488f7776b741d144080a65e9fc37d8b9a46bd8cc939d57eb2e1695769ff87464e3
|
|
@@ -12,10 +12,10 @@ 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.6, 2.7]
|
|
15
|
+
ruby: [2.5, 2.6, 2.7, '3.0']
|
|
16
16
|
runs-on: ${{ matrix.os }}
|
|
17
17
|
steps:
|
|
18
|
-
- uses: actions/checkout@v2.
|
|
18
|
+
- uses: actions/checkout@v2.4.0
|
|
19
19
|
- name: Set up Ruby
|
|
20
20
|
uses: ruby/setup-ruby@v1
|
|
21
21
|
with:
|
|
@@ -31,7 +31,7 @@ jobs:
|
|
|
31
31
|
env:
|
|
32
32
|
BUNDLE_DEPLOYMENT: true
|
|
33
33
|
steps:
|
|
34
|
-
- uses: actions/checkout@v2.
|
|
34
|
+
- uses: actions/checkout@v2.4.0
|
|
35
35
|
- name: Set up Ruby
|
|
36
36
|
uses: ruby/setup-ruby@v1
|
|
37
37
|
with:
|
|
@@ -49,6 +49,6 @@ jobs:
|
|
|
49
49
|
with:
|
|
50
50
|
semantic_version: 17
|
|
51
51
|
extra_plugins: |
|
|
52
|
-
@semantic-release/changelog
|
|
53
|
-
@semantic-release/git
|
|
54
|
-
semantic-release-rubygem
|
|
52
|
+
@semantic-release/changelog@5
|
|
53
|
+
@semantic-release/git@9
|
|
54
|
+
semantic-release-rubygem@1
|
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,3 +1,31 @@
|
|
|
1
|
+
## [1.1.2](https://github.com/scribd/datadog_backup/compare/v1.1.1...v1.1.2) (2022-02-01)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* pin semantic release plugins ([5e92303](https://github.com/scribd/datadog_backup/commit/5e9230362f0b112de190fb1458fc9a3f32423c63))
|
|
7
|
+
|
|
8
|
+
## [1.1.1](https://github.com/scribd/datadog_backup/compare/v1.1.0...v1.1.1) (2021-10-26)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **deps:** update amazing_print requirement from = 1.3.0 to = 1.4.0 ([b7e0ca6](https://github.com/scribd/datadog_backup/commit/b7e0ca61f0fb5acbeb541d3b173aa526a0edcf3d))
|
|
14
|
+
|
|
15
|
+
# [1.1.0](https://github.com/scribd/datadog_backup/compare/v1.0.5...v1.1.0) (2021-07-14)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* Add support for ruby 2.5 and 3.0 ([#89](https://github.com/scribd/datadog_backup/issues/89)) ([a181dbc](https://github.com/scribd/datadog_backup/commit/a181dbcfd55220e2fd7ce92d384738f71c50baa8))
|
|
21
|
+
|
|
22
|
+
## [1.0.5](https://github.com/scribd/datadog_backup/compare/v1.0.4...v1.0.5) (2021-07-12)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Bug Fixes
|
|
26
|
+
|
|
27
|
+
* Add documentation for DATADOG_HOST usage ([69acc25](https://github.com/scribd/datadog_backup/commit/69acc2574d17310ee090486ec46cb06ab0f450db))
|
|
28
|
+
|
|
1
29
|
## [1.0.4](https://github.com/scribd/datadog_backup/compare/v1.0.3...v1.0.4) (2021-07-08)
|
|
2
30
|
|
|
3
31
|
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -2,9 +2,8 @@ PATH
|
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
4
|
datadog_backup (0.6.0)
|
|
5
|
-
amazing_print (= 1.
|
|
5
|
+
amazing_print (= 1.4.0)
|
|
6
6
|
concurrent-ruby (= 1.1.9)
|
|
7
|
-
concurrent-ruby-edge (= 0.6.0)
|
|
8
7
|
deepsort (= 0.4.5)
|
|
9
8
|
diffy (= 3.4.0)
|
|
10
9
|
dogapi (= 1.45.0)
|
|
@@ -12,21 +11,18 @@ PATH
|
|
|
12
11
|
GEM
|
|
13
12
|
remote: https://rubygems.org/
|
|
14
13
|
specs:
|
|
15
|
-
amazing_print (1.
|
|
14
|
+
amazing_print (1.4.0)
|
|
16
15
|
ast (2.4.2)
|
|
17
|
-
climate_control (1.0.1)
|
|
18
16
|
coderay (1.1.3)
|
|
19
17
|
concurrent-ruby (1.1.9)
|
|
20
|
-
concurrent-ruby-edge (0.6.0)
|
|
21
|
-
concurrent-ruby (~> 1.1.6)
|
|
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,66 +36,64 @@ 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)
|
|
50
46
|
notiffany (0.1.3)
|
|
51
47
|
nenv (~> 0.1)
|
|
52
48
|
shellany (~> 0.0)
|
|
53
|
-
parallel (1.
|
|
54
|
-
parser (3.0.
|
|
49
|
+
parallel (1.21.0)
|
|
50
|
+
parser (3.0.3.2)
|
|
55
51
|
ast (~> 2.4.1)
|
|
56
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
|
-
regexp_parser (2.
|
|
59
|
+
regexp_parser (2.2.0)
|
|
64
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.22.2)
|
|
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.12.0, < 2.0)
|
|
85
81
|
ruby-progressbar (~> 1.7)
|
|
86
82
|
unicode-display_width (>= 1.4.0, < 3.0)
|
|
87
|
-
rubocop-ast (1.
|
|
83
|
+
rubocop-ast (1.15.0)
|
|
88
84
|
parser (>= 3.0.1.1)
|
|
89
|
-
rubocop-rspec (2.
|
|
90
|
-
rubocop (~> 1.
|
|
91
|
-
rubocop-ast (>= 1.1.0)
|
|
85
|
+
rubocop-rspec (2.7.0)
|
|
86
|
+
rubocop (~> 1.19)
|
|
92
87
|
ruby-progressbar (1.11.0)
|
|
93
88
|
shellany (0.0.1)
|
|
94
|
-
thor (1.0
|
|
95
|
-
unicode-display_width (2.
|
|
89
|
+
thor (1.1.0)
|
|
90
|
+
unicode-display_width (2.1.0)
|
|
96
91
|
|
|
97
92
|
PLATFORMS
|
|
98
93
|
ruby
|
|
99
94
|
|
|
100
95
|
DEPENDENCIES
|
|
101
96
|
bundler
|
|
102
|
-
climate_control
|
|
103
97
|
datadog_backup!
|
|
104
98
|
guard-rspec
|
|
105
99
|
pry
|
|
@@ -108,4 +102,4 @@ DEPENDENCIES
|
|
|
108
102
|
rubocop-rspec
|
|
109
103
|
|
|
110
104
|
BUNDLED WITH
|
|
111
|
-
2.
|
|
105
|
+
2.2.21
|
data/README.md
CHANGED
|
@@ -16,12 +16,6 @@ Additional features may be built out over time.
|
|
|
16
16
|
```
|
|
17
17
|
gem install datadog_backup
|
|
18
18
|
```
|
|
19
|
-
or
|
|
20
|
-
|
|
21
|
-
```
|
|
22
|
-
gem build datadog_backup.gemspec
|
|
23
|
-
gem install datadog_backup-*.gem
|
|
24
|
-
```
|
|
25
19
|
|
|
26
20
|
## Usage
|
|
27
21
|
|
|
@@ -36,18 +30,47 @@ gem install datadog_backup
|
|
|
36
30
|
export DATADOG_API_KEY=abc123
|
|
37
31
|
export DATADOG_APP_KEY=abc123
|
|
38
32
|
|
|
39
|
-
# Perform backup to
|
|
40
|
-
datadog_backup backup
|
|
33
|
+
# Perform backup to `./backup/` using YAML encoding
|
|
34
|
+
datadog_backup backup
|
|
41
35
|
|
|
42
36
|
# Make some changes
|
|
43
37
|
|
|
44
38
|
# Just review the changes since last backup
|
|
45
|
-
datadog_backup diffs
|
|
39
|
+
datadog_backup diffs
|
|
46
40
|
|
|
47
|
-
# Review and apply local changes to datadog
|
|
41
|
+
# Review the changes since last backup and apply local changes to datadog
|
|
48
42
|
|
|
49
|
-
datadog_backup restore
|
|
43
|
+
datadog_backup restore
|
|
50
44
|
```
|
|
45
|
+
## Parameters
|
|
46
|
+
|
|
47
|
+
Supply the following parameters in order to customize datadog_backup:
|
|
48
|
+
|
|
49
|
+
parameter | description | default
|
|
50
|
+
---------------------|-------------------------------------------------------------------------------------------------------------------------------|--------------------------
|
|
51
|
+
--debug | log debug and above | info
|
|
52
|
+
--shh | log warnings and above | info
|
|
53
|
+
--shhh | log errors and above | info
|
|
54
|
+
--backup-dir PATH | path to the directory to backup to or restore from | `./backup/`
|
|
55
|
+
--monitors-only | only backup monitors | backup monitors and dashboards
|
|
56
|
+
--dashboards-only | only backup dashboards | backup monitors and dashboards
|
|
57
|
+
--json | format backups as JSON instead of YAML. Does not impact `diffs` nor `restore`, but do not mix formats in the same backup-dir. | YAML
|
|
58
|
+
--no-color | removes colored output from diff format
|
|
59
|
+
--diff-format FORMAT | one of `color`, `html_simple`, `html` | `color`
|
|
60
|
+
--force-restore | Force restore to Datadog. Do not ask to validate. Non-interactive.
|
|
61
|
+
--h, --help | help
|
|
62
|
+
|
|
63
|
+
## Environment variables
|
|
64
|
+
|
|
65
|
+
The following environment variables can be set in order to further customize datadog_backup:
|
|
66
|
+
|
|
67
|
+
environment variable | description | default
|
|
68
|
+
---------------------|--------------------------------------------------------------------------------|--------------------------
|
|
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
|
|
73
|
+
|
|
51
74
|
|
|
52
75
|
### Usage in a Github repo
|
|
53
76
|
|
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
|
-
opts.on('--force-restore', '
|
|
71
|
-
|
|
69
|
+
opts.on('--force-restore', 'Force restore to Datadog. Do not ask to validate. Non-interactive.') do
|
|
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
|
@@ -19,9 +19,10 @@ 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.
|
|
22
|
+
spec.required_ruby_version = ['>= 2.5']
|
|
23
|
+
|
|
24
|
+
spec.add_dependency 'amazing_print', '1.4.0'
|
|
23
25
|
spec.add_dependency 'concurrent-ruby', '1.1.9'
|
|
24
|
-
spec.add_dependency 'concurrent-ruby-edge', '0.6.0'
|
|
25
26
|
spec.add_dependency 'deepsort', '0.4.5'
|
|
26
27
|
spec.add_dependency 'diffy', '3.4.0'
|
|
27
28
|
spec.add_dependency 'dogapi', '1.45.0'
|
data/lib/datadog_backup/cli.rb
CHANGED
data/lib/datadog_backup/core.rb
CHANGED
data/lib/datadog_backup.rb
CHANGED
|
@@ -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
|
|
@@ -37,23 +36,23 @@ 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
|
|
|
46
44
|
required_vars.map do |v|
|
|
47
45
|
it "dies unless given ENV[#{v}]" do
|
|
48
|
-
|
|
46
|
+
stub_const('ENV', env.dup.tap { |h| h.delete(v) })
|
|
49
47
|
_, status = run_bin('backup')
|
|
50
48
|
expect(status).not_to be_success
|
|
51
49
|
end
|
|
52
50
|
end
|
|
53
51
|
|
|
54
52
|
it 'supplies help' do
|
|
53
|
+
stub_const('ENV', env)
|
|
55
54
|
out_err, status = run_bin('--help')
|
|
56
|
-
expect(out_err).to match(/Usage:
|
|
55
|
+
expect(out_err).to match(/Usage: DATADOG_API_KEY=/)
|
|
57
56
|
expect(status).to be_success
|
|
58
57
|
end
|
|
59
58
|
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.
|
|
4
|
+
version: 1.1.2
|
|
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:
|
|
12
|
+
date: 2022-02-01 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: amazing_print
|
|
@@ -17,14 +17,14 @@ dependencies:
|
|
|
17
17
|
requirements:
|
|
18
18
|
- - '='
|
|
19
19
|
- !ruby/object:Gem::Version
|
|
20
|
-
version: 1.
|
|
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
|
-
version: 1.
|
|
27
|
+
version: 1.4.0
|
|
28
28
|
- !ruby/object:Gem::Dependency
|
|
29
29
|
name: concurrent-ruby
|
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -39,20 +39,6 @@ dependencies:
|
|
|
39
39
|
- - '='
|
|
40
40
|
- !ruby/object:Gem::Version
|
|
41
41
|
version: 1.1.9
|
|
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
|
|
56
42
|
- !ruby/object:Gem::Dependency
|
|
57
43
|
name: deepsort
|
|
58
44
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -181,7 +167,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
181
167
|
requirements:
|
|
182
168
|
- - ">="
|
|
183
169
|
- !ruby/object:Gem::Version
|
|
184
|
-
version: '
|
|
170
|
+
version: '2.5'
|
|
185
171
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
186
172
|
requirements:
|
|
187
173
|
- - ">="
|