secrets_cli 1.3.3 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/secrets +2 -0
- data/lib/secrets_cli/helpers.rb +12 -0
- data/lib/secrets_cli/vault/pull.rb +14 -1
- data/lib/secrets_cli/vault/push.rb +12 -1
- data/lib/secrets_cli/vault/read.rb +3 -2
- data/lib/secrets_cli/version.rb +1 -1
- data/lib/secrets_cli.rb +1 -0
- data/secrets_cli.gemspec +2 -1
- metadata +20 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16774bc319041eaa7626b8fa5d549e177fe32a7b
|
4
|
+
data.tar.gz: 9fe08ca8f65f426885b8c520f77b0eacb1384a9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 102a529eea123fae032c33f514ec6ac82acf1da7b26c093e488a2c7ec2bf40fdfda790db14d3dd197ac6e4e71d608b15dc227b69e19afe3761a09e6c837dc9e5
|
7
|
+
data.tar.gz: b2685901af34edf2ec657471648961b0b9034c9e27b75ccc291dcc4d07faad8d2d9697f905e0bdaed175204e3873e8993548e42d1316144895b3697346774896
|
data/exe/secrets
CHANGED
data/lib/secrets_cli/helpers.rb
CHANGED
@@ -25,5 +25,17 @@ module SecretsCli
|
|
25
25
|
def print_verbose(message)
|
26
26
|
puts pastel.cyan(message)
|
27
27
|
end
|
28
|
+
|
29
|
+
def pretty_diff(diff)
|
30
|
+
diff.each_line do |line|
|
31
|
+
case line[0]
|
32
|
+
when '+' then prompt.ok(line, newline: false)
|
33
|
+
when '-' then prompt.error(line, newline: false)
|
34
|
+
else
|
35
|
+
puts line
|
36
|
+
end
|
37
|
+
end
|
38
|
+
puts
|
39
|
+
end
|
28
40
|
end
|
29
41
|
end
|
@@ -14,9 +14,22 @@ module SecretsCli
|
|
14
14
|
|
15
15
|
def command
|
16
16
|
secrets = super
|
17
|
+
compare(secrets)
|
18
|
+
write(secrets)
|
19
|
+
secrets
|
20
|
+
end
|
21
|
+
|
22
|
+
def compare(secrets)
|
23
|
+
diff = TTY::File.diff(secrets_file, secrets, verbose: false)
|
24
|
+
return if diff == ''
|
25
|
+
prompt.ok("There are some differences between #{secrets_file} and vault:")
|
26
|
+
pretty_diff(diff)
|
27
|
+
exit 0 unless prompt.yes?("Are you sure you want to override #{secrets_file}?")
|
28
|
+
end
|
29
|
+
|
30
|
+
def write(secrets)
|
17
31
|
print_verbose("Writing to #{secrets_file}")
|
18
32
|
File.open(File.join(secrets_dir, secrets_file), 'w') { |file| file.write(secrets) }
|
19
|
-
secrets
|
20
33
|
end
|
21
34
|
end
|
22
35
|
end
|
@@ -13,6 +13,7 @@ module SecretsCli
|
|
13
13
|
|
14
14
|
def call
|
15
15
|
return if !options.without_prompt && !are_you_sure?
|
16
|
+
compare
|
16
17
|
super
|
17
18
|
end
|
18
19
|
|
@@ -23,8 +24,18 @@ module SecretsCli
|
|
23
24
|
secrets
|
24
25
|
end
|
25
26
|
|
27
|
+
def compare
|
28
|
+
secrets = ::Vault.logical.read(secrets_full_storage_key)
|
29
|
+
secrets = secrets.nil? ? ' ' : secrets.data[SECRETS_FIELD]
|
30
|
+
diff = TTY::File.diff(secrets, secrets_file, verbose: false)
|
31
|
+
return if diff == ''
|
32
|
+
prompt.ok("There are some differences between #{secrets_file} and vault:")
|
33
|
+
pretty_diff(diff)
|
34
|
+
exit 0 unless prompt.yes?("Are you sure you want to override #{secrets_full_storage_key}?")
|
35
|
+
end
|
36
|
+
|
26
37
|
def are_you_sure?
|
27
|
-
prompt.yes?("Are you sure you want to write #{secrets_file} to #{secrets_full_storage_key}"
|
38
|
+
prompt.yes?("Are you sure you want to write #{secrets_file} to #{secrets_full_storage_key}")
|
28
39
|
end
|
29
40
|
end
|
30
41
|
end
|
@@ -13,8 +13,9 @@ module SecretsCli
|
|
13
13
|
attr_reader :secrets_storage_key
|
14
14
|
|
15
15
|
def command
|
16
|
-
|
17
|
-
|
16
|
+
secrets = ::Vault.logical.read(secrets_full_storage_key)
|
17
|
+
error!("There are no secrets in #{secrets_full_storage_key}") if secrets.nil?
|
18
|
+
secrets.data[SECRETS_FIELD]
|
18
19
|
end
|
19
20
|
end
|
20
21
|
end
|
data/lib/secrets_cli/version.rb
CHANGED
data/lib/secrets_cli.rb
CHANGED
data/secrets_cli.gemspec
CHANGED
@@ -32,6 +32,7 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.add_development_dependency 'pry'
|
33
33
|
|
34
34
|
spec.add_runtime_dependency 'commander'
|
35
|
-
spec.add_runtime_dependency 'tty-prompt'
|
35
|
+
spec.add_runtime_dependency 'tty-prompt'
|
36
|
+
spec.add_runtime_dependency 'tty-file'
|
36
37
|
spec.add_runtime_dependency 'vault', '~> 0.5.0'
|
37
38
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: secrets_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stjepan Hadjic
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -84,16 +84,30 @@ dependencies:
|
|
84
84
|
name: tty-prompt
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0
|
89
|
+
version: '0'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: tty-file
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: vault
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|