awskeyring 0.7.1 → 0.7.2
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 +4 -4
- data/CHANGELOG.md +8 -0
- data/i18n/en.yml +1 -0
- data/lib/awskeyring.rb +12 -0
- data/lib/awskeyring/version.rb +1 -1
- data/lib/awskeyring_command.rb +28 -28
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26f6f9112f7dd321eb160034017bdcfde89c3ea9
|
4
|
+
data.tar.gz: 4d0c3eda8ef3301077925a69d1da7b6536c12229
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7e7822873229041ec91de08fc4c073cafc8aee5d1e98bb4cad0424954196985f4679f23d041f035fe228359b411b9e6a80dcc2ba7c2d89c97591106b3f960bd
|
7
|
+
data.tar.gz: de9945806b4a310e6ba60e486b00aeb40b1857a6649ff0e424cec36eb8710607a7e3abb77d01fbf486608b59e6c98a2c485c5d395bb60e5a0177feaf7d061e5d
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## [v0.7.2](https://github.com/vibrato/awskeyring/tree/v0.7.2) (2018-12-17)
|
4
|
+
[Full Changelog](https://github.com/vibrato/awskeyring/compare/v0.7.1...v0.7.2)
|
5
|
+
|
6
|
+
**Fixed bugs:**
|
7
|
+
|
8
|
+
- Validate that account doesn't already exists. [\#40](https://github.com/vibrato/awskeyring/pull/40) ([tristanmorgan](https://github.com/tristanmorgan))
|
9
|
+
- Check for COMMAND param to exec. [\#38](https://github.com/vibrato/awskeyring/pull/38) ([tristanmorgan](https://github.com/tristanmorgan))
|
10
|
+
|
3
11
|
## [v0.7.1](https://github.com/vibrato/awskeyring/tree/v0.7.1) (2018-12-03)
|
4
12
|
[Full Changelog](https://github.com/vibrato/awskeyring/compare/v0.7.0...v0.7.1)
|
5
13
|
|
data/i18n/en.yml
CHANGED
@@ -68,6 +68,7 @@ en:
|
|
68
68
|
delrole: '# Removing role %{role}'
|
69
69
|
deltoken: '# Removing token for account %{account}'
|
70
70
|
delexpired: '# Removing expired session credentials'
|
71
|
+
exec: '# COMMAND not provided'
|
71
72
|
missing: '# Config missing, run `%{bin} initialise` to recreate.'
|
72
73
|
rotate: '# You have two access keys for account %{account}'
|
73
74
|
temporary: '# Using temporary session credentials.'
|
data/lib/awskeyring.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'json'
|
2
2
|
require 'keychain'
|
3
|
+
require 'awskeyring/validate'
|
3
4
|
|
4
5
|
# Awskeyring Module,
|
5
6
|
# gives you an interface to access keychains and items.
|
@@ -284,8 +285,19 @@ module Awskeyring # rubocop:disable Metrics/ModuleLength
|
|
284
285
|
#
|
285
286
|
# @param [String] account_name the associated account name.
|
286
287
|
def self.account_exists(account_name)
|
288
|
+
Awskeyring::Validate.account_name(account_name)
|
287
289
|
raise 'Account does not exist' unless list_account_names.include?(account_name)
|
288
290
|
|
289
291
|
account_name
|
290
292
|
end
|
293
|
+
|
294
|
+
# Validate account does not exists
|
295
|
+
#
|
296
|
+
# @param [String] account_name the associated account name.
|
297
|
+
def self.account_not_exists(account_name)
|
298
|
+
Awskeyring::Validate.account_name(account_name)
|
299
|
+
raise 'Account already exists' if list_account_names.include?(account_name)
|
300
|
+
|
301
|
+
account_name
|
302
|
+
end
|
291
303
|
end
|
data/lib/awskeyring/version.rb
CHANGED
data/lib/awskeyring_command.rb
CHANGED
@@ -70,12 +70,7 @@ class AwskeyringCommand < Thor # rubocop:disable Metrics/ClassLength
|
|
70
70
|
existing: account, message: I18n.t('message.account'), validator: Awskeyring.method(:account_exists)
|
71
71
|
)
|
72
72
|
cred = age_check_and_get(account: account, no_token: options['no-token'])
|
73
|
-
put_env_string(
|
74
|
-
account: cred[:account],
|
75
|
-
key: cred[:key],
|
76
|
-
secret: cred[:secret],
|
77
|
-
token: cred[:token]
|
78
|
-
)
|
73
|
+
put_env_string(cred)
|
79
74
|
end
|
80
75
|
|
81
76
|
desc 'json ACCOUNT', I18n.t('json.desc')
|
@@ -99,15 +94,20 @@ class AwskeyringCommand < Thor # rubocop:disable Metrics/ClassLength
|
|
99
94
|
method_option 'no-token', type: :boolean, aliases: '-n', desc: I18n.t('method_option.notoken'), default: false
|
100
95
|
# execute an external command with env set
|
101
96
|
def exec(account, *command)
|
97
|
+
if command.empty?
|
98
|
+
warn I18n.t('message.exec')
|
99
|
+
exit 1
|
100
|
+
end
|
102
101
|
cred = age_check_and_get(account: account, no_token: options['no-token'])
|
103
|
-
env_vars = env_vars(
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
102
|
+
env_vars = env_vars(cred)
|
103
|
+
begin
|
104
|
+
pid = Process.spawn(env_vars, command.join(' '))
|
105
|
+
Process.wait pid
|
106
|
+
$CHILD_STATUS
|
107
|
+
rescue Errno::ENOENT => err
|
108
|
+
warn err.to_s
|
109
|
+
exit 1
|
110
|
+
end
|
111
111
|
end
|
112
112
|
|
113
113
|
desc 'add ACCOUNT', I18n.t('add.desc')
|
@@ -118,7 +118,7 @@ class AwskeyringCommand < Thor # rubocop:disable Metrics/ClassLength
|
|
118
118
|
# Add an Account
|
119
119
|
def add(account = nil) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
120
120
|
account = ask_check(
|
121
|
-
existing: account, message: I18n.t('message.account'), validator: Awskeyring
|
121
|
+
existing: account, message: I18n.t('message.account'), validator: Awskeyring.method(:account_not_exists)
|
122
122
|
)
|
123
123
|
key = ask_check(
|
124
124
|
existing: options[:key], message: I18n.t('message.key'), validator: Awskeyring::Validate.method(:access_key)
|
@@ -418,27 +418,27 @@ class AwskeyringCommand < Thor # rubocop:disable Metrics/ClassLength
|
|
418
418
|
self.class.all_commands[command].options.values.map(&:switch_name)
|
419
419
|
end
|
420
420
|
|
421
|
-
def env_vars(
|
421
|
+
def env_vars(cred)
|
422
422
|
env_var = {}
|
423
423
|
env_var['AWS_DEFAULT_REGION'] = 'us-east-1' unless Awskeyring::Awsapi.region
|
424
|
-
env_var['AWS_ACCOUNT_NAME'] = account
|
425
|
-
env_var['AWS_ACCESS_KEY_ID'] = key
|
426
|
-
env_var['AWS_ACCESS_KEY'] = key
|
427
|
-
env_var['AWS_SECRET_ACCESS_KEY'] = secret
|
428
|
-
env_var['AWS_SECRET_KEY'] = secret
|
429
|
-
if token
|
430
|
-
env_var['AWS_SECURITY_TOKEN'] = token
|
431
|
-
env_var['AWS_SESSION_TOKEN'] = token
|
424
|
+
env_var['AWS_ACCOUNT_NAME'] = cred[:account]
|
425
|
+
env_var['AWS_ACCESS_KEY_ID'] = cred[:key]
|
426
|
+
env_var['AWS_ACCESS_KEY'] = cred[:key]
|
427
|
+
env_var['AWS_SECRET_ACCESS_KEY'] = cred[:secret]
|
428
|
+
env_var['AWS_SECRET_KEY'] = cred[:secret]
|
429
|
+
if cred[:token]
|
430
|
+
env_var['AWS_SECURITY_TOKEN'] = cred[:token]
|
431
|
+
env_var['AWS_SESSION_TOKEN'] = cred[:token]
|
432
432
|
end
|
433
433
|
env_var
|
434
434
|
end
|
435
435
|
|
436
|
-
def put_env_string(
|
437
|
-
env_var = env_vars(
|
436
|
+
def put_env_string(cred)
|
437
|
+
env_var = env_vars(cred)
|
438
438
|
env_var.each { |var, value| puts "export #{var}=\"#{value}\"" }
|
439
439
|
|
440
|
-
puts 'unset AWS_SECURITY_TOKEN' unless token
|
441
|
-
puts 'unset AWS_SESSION_TOKEN' unless token
|
440
|
+
puts 'unset AWS_SECURITY_TOKEN' unless cred[:token]
|
441
|
+
puts 'unset AWS_SESSION_TOKEN' unless cred[:token]
|
442
442
|
end
|
443
443
|
|
444
444
|
def ask_check(existing:, message:, secure: false, optional: false, validator: nil)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awskeyring
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tristan Morgan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-12-
|
11
|
+
date: 2018-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-iam
|