datadog_backup 3.1.1 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 332899376b51dd8ad98dda7a3528b7a7c80ca8cbbd2c4bbe9c2cb9976a1c7024
4
- data.tar.gz: 68b89a77b5148006b16388c7a93241ca50fcecb6bc4edc09ab36cf34a80d92e8
3
+ metadata.gz: c069dccdefa9573c4fcd1e0e49292813203455a7b76e670c156a47936aa82b32
4
+ data.tar.gz: 17c9f91c0de0a2a3975525c01f843f30bba77b43676c903a02472a1c576953ca
5
5
  SHA512:
6
- metadata.gz: ab35b9e6a6152cc22ff3de7714ed60f2bca54c056a510d5726e5d33921a0f54d088195bfd7b992494545ccdfa8350e99e097c19155cfde4f7396049aeaad9650
7
- data.tar.gz: 4f2f791146658c9a9e4185ef3bda43180a5ef46938dd6b2754aa493bcac9949f19a53f70b972a125ae51ad7b71f6f8c309767d83654e40a4d7d5f4be70e6c39c
6
+ metadata.gz: 7200fc88e53d944655028f91455d015a788ab4529f6cf21739dc23631ba168945d664bbcf9c000b81ce44be85ce33f2c6d964a1aa40625cbf93a601dec5d0df1
7
+ data.tar.gz: b570dc952f7a9b93817970a2f897b005c6e81c1abb2d99988c32567cc7380a6042af3fb8a6e0e8d858a4d4447d681da762e389e434ee51446e7427b0d6864181
@@ -10,7 +10,7 @@ jobs:
10
10
  runs-on: ubuntu-20.04
11
11
  steps:
12
12
  - name: Validate PR Title
13
- uses: amannn/action-semantic-pull-request@v4
13
+ uses: amannn/action-semantic-pull-request@v5.0.2
14
14
  env:
15
15
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16
16
  with:
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [3.2.0](https://github.com/scribd/datadog_backup/compare/v3.1.1...v3.2.0) (2023-02-10)
2
+
3
+
4
+ ### Features
5
+
6
+ * Deepsort skip sorting arrays ([d9cba97](https://github.com/scribd/datadog_backup/commit/d9cba97015d1af636ca9c03605ef14fa8dcb6d21))
7
+
1
8
  ## [3.1.1](https://github.com/scribd/datadog_backup/compare/v3.1.0...v3.1.1) (2022-09-01)
2
9
 
3
10
 
data/README.md CHANGED
@@ -71,6 +71,7 @@ parameter | description
71
71
  --no-color | removes colored output from diff format
72
72
  --diff-format FORMAT | one of `color`, `html_simple`, `html` | `color`
73
73
  --force-restore | Force restore to Datadog. Do not ask to validate. Non-interactive.
74
+ --disable-array-sort | Do not sort array elements, to preserver order of dashboard widgets.
74
75
  --h, --help | help
75
76
 
76
77
  ## Environment variables
data/bin/datadog_backup CHANGED
@@ -66,6 +66,9 @@ def prereqs(defaults) # rubocop:disable Metrics/AbcSize
66
66
  opts.on('--force-restore', 'Force restore to Datadog. Do not ask to validate. Non-interactive.') do
67
67
  result[:force_restore] = true
68
68
  end
69
+ opts.on('--disable-array-sort', 'Do not sort array elements, to preserver order of dashboard widgets.') do
70
+ result[:disable_array_sort] = true
71
+ end
69
72
  end
70
73
  options.parse!
71
74
 
@@ -82,7 +85,8 @@ defaults = {
82
85
  diff_format: :color,
83
86
  resources: [DatadogBackup::Dashboards, DatadogBackup::Monitors, DatadogBackup::Synthetics],
84
87
  output_format: :yaml,
85
- force_restore: false
88
+ force_restore: false,
89
+ disable_array_sort: false
86
90
  }
87
91
 
88
92
  DatadogBackup::Cli.new(prereqs(defaults)).run!
@@ -32,9 +32,9 @@ module DatadogBackup
32
32
  def dump(object)
33
33
  case output_format
34
34
  when :json
35
- JSON.pretty_generate(object.deep_sort)
35
+ JSON.pretty_generate(object.deep_sort(array: disable_array_sort ? false : true))
36
36
  when :yaml
37
- YAML.dump(object.deep_sort)
37
+ YAML.dump(object.deep_sort(array: disable_array_sort ? false : true))
38
38
  else
39
39
  raise 'invalid output_format specified or not specified'
40
40
  end
@@ -31,5 +31,9 @@ module DatadogBackup
31
31
  def force_restore
32
32
  @options[:force_restore]
33
33
  end
34
+
35
+ def disable_array_sort
36
+ @options[:disable_array_sort]
37
+ end
34
38
  end
35
39
  end
@@ -26,8 +26,8 @@ module DatadogBackup
26
26
  # Returns the diffy diff.
27
27
  # Optionally, supply an array of keys to remove from comparison
28
28
  def diff(id)
29
- current = except(get_by_id(id)).deep_sort.to_yaml
30
- filesystem = except(load_from_file_by_id(id)).deep_sort.to_yaml
29
+ current = except(get_by_id(id)).deep_sort(array: disable_array_sort ? false : true).to_yaml
30
+ filesystem = except(load_from_file_by_id(id)).deep_sort(array: disable_array_sort ? false : true).to_yaml
31
31
  result = ::Diffy::Diff.new(current, filesystem, include_plus_and_minus_in_html: true).to_s(diff_format)
32
32
  LOGGER.debug("Compared ID #{id} and found filesystem: #{filesystem} <=> current: #{current} == result: #{result}")
33
33
  result.chomp
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DatadogBackup
4
- VERSION = '3.1.1'
4
+ VERSION = '3.2.0'
5
5
  end
@@ -20,6 +20,15 @@ describe DatadogBackup::LocalFilesystem do
20
20
  output_format: :yaml
21
21
  )
22
22
  end
23
+ let(:resources_disable_array_sort) do
24
+ DatadogBackup::Resources.new(
25
+ action: 'backup',
26
+ backup_dir: tempdir,
27
+ resources: [DatadogBackup::Dashboards],
28
+ output_format: :json,
29
+ disable_array_sort: true
30
+ )
31
+ end
23
32
 
24
33
  describe '#all_files' do
25
34
  subject { resources.all_files }
@@ -79,6 +88,18 @@ describe DatadogBackup::LocalFilesystem do
79
88
 
80
89
  it { is_expected.to eq(%(---\na: b\n)) }
81
90
  end
91
+
92
+ context 'when array sorting is enabled' do
93
+ subject { resources.dump({ a: [ :c, :b ] }) }
94
+
95
+ it { is_expected.to eq(%({\n \"a\": [\n \"b\",\n \"c\"\n ]\n})) }
96
+ end
97
+
98
+ context 'when array sorting is disabled' do
99
+ subject { resources_disable_array_sort.dump({ a: [ :c, :b ] }) }
100
+
101
+ it { is_expected.to eq(%({\n \"a\": [\n \"c\",\n \"b\"\n ]\n})) }
102
+ end
82
103
  end
83
104
 
84
105
  describe '#filename' do
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: 3.1.1
4
+ version: 3.2.0
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: 2022-09-01 00:00:00.000000000 Z
12
+ date: 2023-02-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: amazing_print