secret_hub 0.1.2 → 0.1.3

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: 828e88613986422e9673539e45727e6de237e6697e596885a652851554236824
4
- data.tar.gz: dca45482c12ef6e81e8663407defd185c8f0cce831ef561872c81187af4e63e3
3
+ metadata.gz: 366ad9f9647c8e1cfbbd9496b99ee1209fcd3a24b9409a59a68e81a880cbe90c
4
+ data.tar.gz: 79b6bc712815818a9f322d2d7cead7698bfa11179f81c0fac99aa1c90abc5ecb
5
5
  SHA512:
6
- metadata.gz: 6d7bee2f48361069776dbc7709f9d9328c0991ae6c8e2c2a20764fab20d36ac50105b1eb61a7f08b8ff3e502fca1c0ef68a68b01d450b159de012141eff16124
7
- data.tar.gz: 79926a14f52b2fd06ccbae331fcc6ab863531896a8f8027deb53c12ad5d61f226beccf433e543bb195768311dcb0308cc29f42b95769a61706d0e7acd9e45bae
6
+ metadata.gz: 07b10bd5e5d859b3f732d40470fdf84005b7052ef08f1865f36c5539e9741a2e47736c9513d17d77fca14935d4e08db0aaf8628df5b16de2db81bc62a16a89e6
7
+ data.tar.gz: 755121d143ca3faf0ed16391b2563827cf7788eaa8ffeb83931c595fba3bed822fc5e8a1eb2d737e010ba404670c57712fc394c41800c66edfafc332d22c0462
@@ -40,13 +40,10 @@ module SecretHub
40
40
  end
41
41
 
42
42
  def show_command
43
- visible = args['--visible']
44
-
45
43
  config.each do |repo, secrets|
46
44
  say "!txtblu!#{repo}:"
47
45
  secrets.each do |key, value|
48
- value = value.obfuscate unless visible
49
- say " !txtpur!#{key}: !txtcyn!#{value}"
46
+ show_secret key, value, args['--visible']
50
47
  end
51
48
  end
52
49
  end
@@ -62,12 +59,15 @@ module SecretHub
62
59
 
63
60
  def save_command
64
61
  clean = args['--clean']
62
+ skipped = 0
65
63
 
66
64
  config.each do |repo, secrets|
67
65
  say "!txtblu!#{repo}"
68
- update_repo repo, secrets
66
+ skipped += update_repo repo, secrets
69
67
  clean_repo repo, secrets.keys if clean
70
68
  end
69
+
70
+ say "\nSkipped #{skipped} missing secrets" if skipped > 0
71
71
  end
72
72
 
73
73
  def clean_command
@@ -91,10 +91,28 @@ module SecretHub
91
91
  end
92
92
 
93
93
  def update_repo(repo, secrets)
94
+ skipped = 0
95
+
94
96
  secrets.each do |key, value|
95
97
  say "save !txtpur!#{key} "
96
- github.put_secret repo, key, value
97
- say "!txtgrn!OK"
98
+ if value
99
+ github.put_secret repo, key, value
100
+ say "!txtgrn!OK"
101
+ else
102
+ say "!txtred!MISSING"
103
+ skipped += 1
104
+ end
105
+ end
106
+
107
+ skipped
108
+ end
109
+
110
+ def show_secret(key, value, visible)
111
+ if value
112
+ value = value.obfuscate unless visible
113
+ say " !txtpur!#{key}: !txtcyn!#{value}"
114
+ else
115
+ say " !txtpur!#{key}: !txtred!*MISSING*"
98
116
  end
99
117
  end
100
118
 
@@ -40,15 +40,10 @@ module SecretHub
40
40
  secrets = [] unless secrets
41
41
 
42
42
  if secrets.is_a? Hash
43
- secrets.map { |key, value| [key, value || value_from_env(key)] }.to_h
43
+ secrets.map { |key, value| [key, value || ENV[key]] }.to_h
44
44
  elsif secrets.is_a? Array
45
- secrets.map { |key| [key, value_from_env(key)] }.to_h
45
+ secrets.map { |key| [key, ENV[key]] }.to_h
46
46
  end
47
-
48
- end
49
-
50
- def value_from_env(key)
51
- ENV[key] || raise(MissingSecretError, "Please set the #{key} environment variable")
52
47
  end
53
48
  end
54
49
  end
@@ -1,7 +1,6 @@
1
1
  module SecretHub
2
2
  SecretHubError = Class.new StandardError
3
3
  ConfigurationError = Class.new SecretHubError
4
- MissingSecretError = Class.new SecretHubError
5
4
 
6
5
  class APIError < SecretHubError
7
6
  attr_reader :response
@@ -1,3 +1,3 @@
1
1
  module SecretHub
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: secret_hub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danny Ben Shitrit