secret_config 0.7.0 → 0.7.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 24792842f7d81af2c5d70eb431eae87ec96f190a52500c7e68267b6e875a4e09
4
- data.tar.gz: 29f1683c2be73597476f976860dd021476559d97ed94e04195789fadaf4fb7f8
3
+ metadata.gz: 4774ef1279f56c5ce70a89de9fdada0c661b4085afef81c6296aa56800da92fa
4
+ data.tar.gz: 8f16b3bf4a7193315a5c761f3ce39283a23851660c2aa61752b8d958b1798e20
5
5
  SHA512:
6
- metadata.gz: 89a0ecfab4bfb8263768ccf51ec56b987866cac08d23c2c9e34a69b9ba3210d9ed40198cfd525d72f54dcf4e6aa0f2c8965d30204ec96c4b825f1c61313c35b5
7
- data.tar.gz: c0047de74541f0589ebe2ad66a67133b73d6fa5635610d81b685394aca395d46dfadc4171ca655975296289292203dc004a977fe265c6b0d704ad4a894cc6983
6
+ metadata.gz: 0afe6dab591c52af29ecb7a95317c8da193e8220b0a89da8f4dbd8f641c9aa8848adf033aa32ffc15f7974c54ec245791914526b07f3a589dec1e562caa91e3b
7
+ data.tar.gz: feb776daefb9795da0ffabcec4cc3da4a6030bcc3d6043525eba24823e0d6051c072ebfb0ee019466eeadef03e491afdd5ed88a0ac552575a78351b1c456d5b9
@@ -10,7 +10,7 @@ module SecretConfig
10
10
  class CLI
11
11
  attr_reader :path, :region, :provider,
12
12
  :export, :no_filter,
13
- :import, :key_id, :key_alias, :random_size, :prune, :overwrite,
13
+ :import, :key_id, :key_alias, :random_size, :prune, :force,
14
14
  :diff_path, :import_path,
15
15
  :fetch_key, :delete_key, :set_key, :set_value, :delete_path,
16
16
  :copy_path, :diff,
@@ -46,6 +46,7 @@ module SecretConfig
46
46
  @delete_path = nil
47
47
  @diff_path = nil
48
48
  @import_path = nil
49
+ @force = false
49
50
 
50
51
  if argv.empty?
51
52
  puts parser
@@ -63,13 +64,13 @@ module SecretConfig
63
64
  elsif export
64
65
  run_export(export, path, filtered: !no_filter)
65
66
  elsif import
66
- run_import(import, path, prune)
67
+ run_import(import, path, prune, force)
67
68
  elsif import_path
68
- run_import_path(import_path, path, prune)
69
+ run_import_path(import_path, path, prune, force)
69
70
  elsif diff
70
71
  run_diff(diff, path)
71
72
  elsif diff_path
72
- run_diff_path(diff, path)
73
+ run_diff_path(diff_path, path)
73
74
  elsif set_key
74
75
  run_set(set_key, set_value)
75
76
  elsif fetch_key
@@ -152,6 +153,10 @@ module SecretConfig
152
153
  @prune = true
153
154
  end
154
155
 
156
+ opts.on "--force", "During import overwrite all values, not just the changed ones. Useful for changing the KMS key. Only applies to --import and --import-path." do
157
+ @force = true
158
+ end
159
+
155
160
  opts.on "--key_id KEY_ID", "Encrypt config settings with this AWS KMS key id. Default: AWS Default key." do |key_id|
156
161
  @key_id = key_id
157
162
  end
@@ -182,14 +187,15 @@ module SecretConfig
182
187
  private
183
188
 
184
189
  def provider_instance
185
- @provider_instance ||= begin
186
- case provider
187
- when :ssm
188
- Providers::Ssm.new(key_id: key_id, key_alias: key_alias)
189
- else
190
- raise ArgumentError, "Invalid provider: #{provider}"
190
+ @provider_instance ||=
191
+ begin
192
+ case provider
193
+ when :ssm
194
+ Providers::Ssm.new(key_id: key_id, key_alias: key_alias)
195
+ else
196
+ raise ArgumentError, "Invalid provider: #{provider}"
197
+ end
191
198
  end
192
- end
193
199
  end
194
200
 
195
201
  def run_export(file_name, path, filtered: true)
@@ -201,20 +207,20 @@ module SecretConfig
201
207
  puts("Exported #{path} from #{provider} to #{file_name}") if file_name.is_a?(String)
202
208
  end
203
209
 
204
- def run_import(file_name, path, prune = false)
210
+ def run_import(file_name, path, prune, force)
205
211
  raise(ArgumentError, "Missing required option --path") unless path
206
212
 
207
213
  config = read_config_file(file_name)
208
- import_config(config, path, prune)
214
+ import_config(config, path, prune, force)
209
215
 
210
216
  puts("Imported #{file_name} to #{path} on provider: #{provider}") if file_name.is_a?(String)
211
217
  end
212
218
 
213
- def run_import_path(source_path, path, prune = false)
219
+ def run_import_path(source_path, path, prune, force)
214
220
  raise(ArgumentError, "Missing required option --path") unless path
215
221
 
216
222
  config = fetch_config(source_path, filtered: false)
217
- import_config(config, path, prune)
223
+ import_config(config, path, prune, force)
218
224
 
219
225
  puts("Imported #{source_path} to #{path} on provider: #{provider}")
220
226
  end
@@ -236,10 +242,10 @@ module SecretConfig
236
242
  raise(ArgumentError, "Missing required option --path") unless path
237
243
 
238
244
  source_config = fetch_config(source_path, filtered: false)
239
- source = Utils.flatten(source_config, path)
245
+ source = Utils.flatten(source_config)
240
246
 
241
247
  target_config = fetch_config(path, filtered: false)
242
- target = Utils.flatten(target_config, path)
248
+ target = Utils.flatten(target_config)
243
249
 
244
250
  puts("Comparing #{source_path} to #{path} on provider: #{provider}")
245
251
  diff_config(source, target)
@@ -253,6 +259,15 @@ module SecretConfig
253
259
  provider_instance.delete(key)
254
260
  end
255
261
 
262
+ def run_delete_path(path)
263
+ source_config = fetch_config(path)
264
+ source = Utils.flatten(source_config, path)
265
+ source.each_key do |key|
266
+ puts("Deleting #{key}")
267
+ provider_instance.delete(key)
268
+ end
269
+ end
270
+
256
271
  def run_fetch(key)
257
272
  value = provider_instance.fetch(key)
258
273
  puts value if value
@@ -319,7 +334,7 @@ module SecretConfig
319
334
  end
320
335
  end
321
336
 
322
- def import_config(config, path, prune = false)
337
+ def import_config(config, path, prune, force)
323
338
  raise(ArgumentError, "Missing required option --path") unless path
324
339
 
325
340
  delete_keys = prune ? current_values.keys - Utils.flatten(config, path).keys : []
@@ -330,7 +345,7 @@ module SecretConfig
330
345
  sleep(5)
331
346
  end
332
347
 
333
- set_config(config, path, current_values)
348
+ set_config(config, path, force ? {} : current_values)
334
349
 
335
350
  delete_keys.each do |key|
336
351
  puts "Deleting: #{key}"
@@ -1,3 +1,3 @@
1
1
  module SecretConfig
2
- VERSION = "0.7.0".freeze
2
+ VERSION = "0.7.1".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: secret_config
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Reid Morrison
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-24 00:00:00.000000000 Z
11
+ date: 2020-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby