lib/awskeyring_command.rb in awskeyring-1.9.0 vs lib/awskeyring_command.rb in awskeyring-1.9.1
- old
+ new
@@ -122,11 +122,12 @@
desc 'json ACCOUNT', I18n.t('json_desc')
method_option 'no-token', type: :boolean, aliases: '-n', desc: I18n.t('method_option.notoken'), default: false
# Print JSON for use with credential_process
def json(account)
account = ask_check(
- existing: account, message: I18n.t('message.account'), validator: Awskeyring.method(:account_exists)
+ existing: account, message: I18n.t('message.account'), validator: Awskeyring.method(:account_exists),
+ limited_to: Awskeyring.list_account_names
)
cred = age_check_and_get(account: account, no_token: options['no-token'])
expiry = Time.at(cred[:expiry]) unless cred[:expiry].nil?
puts Awskeyring::Awsapi.get_cred_json(
key: cred[:key],
@@ -174,14 +175,18 @@
desc 'exec ACCOUNT command...', I18n.t('exec_desc')
method_option 'no-token', type: :boolean, aliases: '-n', desc: I18n.t('method_option.notoken'), default: false
method_option 'no-bundle', type: :boolean, aliases: '-b', desc: I18n.t('method_option.nobundle'), default: false
# execute an external command with env set
- def exec(account, *command)
+ def exec(account, *command) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
if command.empty?
warn I18n.t('message.exec')
exit 1
end
+ account = ask_check(
+ existing: account, message: I18n.t('message.account'), validator: Awskeyring.method(:account_exists),
+ limited_to: Awskeyring.list_account_names
+ )
cred = age_check_and_get(account: account, no_token: options['no-token'])
env_vars = Awskeyring::Awsapi.get_env_array(cred)
unbundle if options['no-bundle']
begin
pid = Process.spawn(env_vars, command.join(' '))