secret_config 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/secret_config.rb +0 -1
- data/lib/secret_config/cli.rb +38 -18
- data/lib/secret_config/providers/ssm.rb +1 -1
- data/lib/secret_config/registry.rb +4 -0
- data/lib/secret_config/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f0d63fa6c5c401060b46f0295181765357cd8f9ec6627d005566db84b84ee36
|
4
|
+
data.tar.gz: d4985e50bfc36057932f30734ae16f48583eaddcee7b8d5d69a3e5721493d88a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35e03c3cd275db6e03a3719aaae155b3a9c12f31a1f01c0d37f320a50a589a4e582139ead7befc16b52510eca57833a2be09128647b6a6666ef86b941680e6bf
|
7
|
+
data.tar.gz: 202df652fdaca983f8f2736df883957891043a42fe6751914175145af99a43699f0e18e6883b677a25e08b3bef48fc218294f7cc9526f8d6f355e8b4ccf837c5
|
data/lib/secret_config.rb
CHANGED
@@ -31,7 +31,6 @@ module SecretConfig
|
|
31
31
|
# Which provider to use along with any arguments
|
32
32
|
# The path will be overriden by env var `SECRET_CONFIG_PATH` if present.
|
33
33
|
def self.use(provider, path: nil, **args)
|
34
|
-
path ||= ENV["SECRET_CONFIG_PATH"]
|
35
34
|
@registry = SecretConfig::Registry.new(path: path, provider: provider, provider_args: args)
|
36
35
|
end
|
37
36
|
|
data/lib/secret_config/cli.rb
CHANGED
@@ -83,11 +83,11 @@ module SecretConfig
|
|
83
83
|
@import = file_name || STDIN
|
84
84
|
end
|
85
85
|
|
86
|
-
opts.on '
|
86
|
+
opts.on '--copy SOURCE_PATH', 'Import configuration from a file or stdin if no file_name supplied.' do |path|
|
87
87
|
@copy_path = path
|
88
88
|
end
|
89
89
|
|
90
|
-
opts.on '
|
90
|
+
opts.on '--diff [FILE_NAME]', 'Compare configuration from a file or stdin if no file_name supplied.' do |file_name|
|
91
91
|
@diff = file_name
|
92
92
|
end
|
93
93
|
|
@@ -99,27 +99,35 @@ module SecretConfig
|
|
99
99
|
@path = path
|
100
100
|
end
|
101
101
|
|
102
|
-
opts.on '
|
102
|
+
opts.on '--provider PROVIDER', 'Provider to use. [ssm | file]. Default: ssm' do |provider|
|
103
103
|
@provider = provider.to_sym
|
104
104
|
end
|
105
105
|
|
106
|
-
opts.on '
|
106
|
+
opts.on '--no-filter', 'Do not filter passwords and keys.' do
|
107
107
|
@no_filter = true
|
108
108
|
end
|
109
109
|
|
110
|
-
opts.on '
|
110
|
+
opts.on '--prune', 'During import delete all existing keys for which there is no key in the import file.' do
|
111
111
|
@prune = true
|
112
112
|
end
|
113
113
|
|
114
|
-
opts.on '
|
114
|
+
opts.on '--key_id KEY_ID', 'Encrypt config settings with this AWS KMS key id. Default: AWS Default key.' do |key_id|
|
115
115
|
@key_id = key_id
|
116
116
|
end
|
117
117
|
|
118
|
-
opts.on '
|
118
|
+
opts.on '--key_alias KEY_ALIAS', 'Encrypt config settings with this AWS KMS alias.' do |key_alias|
|
119
|
+
if key_alias =~ /^alias\//
|
120
|
+
@key_id = key_alias
|
121
|
+
else
|
122
|
+
@key_id = "alias/#{key_alias}"
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
opts.on '--region REGION', 'AWS Region to use. Default: AWS_REGION env var.' do |region|
|
119
127
|
@region = region
|
120
128
|
end
|
121
129
|
|
122
|
-
opts.on '
|
130
|
+
opts.on '--random_size INTEGER', Integer, 'Size to use when generating random values. Whenever $random is encountered during an import. Default: 32' do |region|
|
123
131
|
@random_size = random_size
|
124
132
|
end
|
125
133
|
|
@@ -168,7 +176,7 @@ module SecretConfig
|
|
168
176
|
|
169
177
|
unless delete_keys.empty?
|
170
178
|
puts "Going to delete the following keys:"
|
171
|
-
delete_keys.each {|key| puts " #{key}"}
|
179
|
+
delete_keys.each { |key| puts " #{key}" }
|
172
180
|
sleep(5)
|
173
181
|
end
|
174
182
|
|
@@ -250,7 +258,8 @@ module SecretConfig
|
|
250
258
|
|
251
259
|
def fetch_config(path, filtered: true)
|
252
260
|
registry = Registry.new(path: path, provider: provider_instance)
|
253
|
-
filtered ? registry.configuration : registry.configuration(filters: nil)
|
261
|
+
config = filtered ? registry.configuration : registry.configuration(filters: nil)
|
262
|
+
sort_hash_by_key!(config)
|
254
263
|
end
|
255
264
|
|
256
265
|
def read_file(file_name_or_io)
|
@@ -280,14 +289,16 @@ module SecretConfig
|
|
280
289
|
end
|
281
290
|
|
282
291
|
def parse(data, format)
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
292
|
+
config =
|
293
|
+
case format
|
294
|
+
when :yml
|
295
|
+
YAML.load(ERB.new(data).result)
|
296
|
+
when :json
|
297
|
+
JSON.parse(data)
|
298
|
+
else
|
299
|
+
raise ArgumentError, "Invalid format: #{format.inspect}"
|
300
|
+
end
|
301
|
+
sort_hash_by_key!(config)
|
291
302
|
end
|
292
303
|
|
293
304
|
def file_format(file_name)
|
@@ -306,5 +317,14 @@ module SecretConfig
|
|
306
317
|
def random_password
|
307
318
|
SecureRandom.urlsafe_base64(random_size)
|
308
319
|
end
|
320
|
+
|
321
|
+
def sort_hash_by_key!(h)
|
322
|
+
h.keys.sort.each do |key|
|
323
|
+
value = h[key] = h.delete(key)
|
324
|
+
sort_hash_by_key!(value) if value.is_a?(Hash)
|
325
|
+
end
|
326
|
+
h
|
327
|
+
end
|
328
|
+
|
309
329
|
end
|
310
330
|
end
|
@@ -10,7 +10,7 @@ module SecretConfig
|
|
10
10
|
class Ssm < Provider
|
11
11
|
attr_reader :client, :key_id
|
12
12
|
|
13
|
-
def initialize(key_id:
|
13
|
+
def initialize(key_id: ENV["AWS_ACCESS_KEY_ID"])
|
14
14
|
@key_id = key_id
|
15
15
|
logger = SemanticLogger['Aws::SSM'] if defined?(SemanticLogger)
|
16
16
|
@client = Aws::SSM::Client.new(logger: logger)
|
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.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Reid Morrison
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|