class AwsAssumeRole::Cli::Actions::SetEnvironment
Constants
- CommandSchema
- SHELL_STRINGS
Public Instance Methods
act_on(config)
click to toggle source
# File lib/aws_assume_role/cli/actions/set_environment.rb, line 40 def act_on(config) credentials = try_for_credentials config.to_h shell_strings = SHELL_STRINGS[config.shell_type.to_sym] str = String.new("") [ [:access_key_id, "AWS_ACCESS_KEY_ID"], [:secret_access_key, "AWS_SECRET_ACCESS_KEY"], [:session_token, "AWS_SESSION_TOKEN"], ].each do |key| value = credentials.credentials.send key[0] next if value.blank? str << format(shell_strings[:env_command], key: key[1], value: value) end str << "# #{pastel.yellow t(shell_strings.fetch(:footer, 'commands.set_environment.shells.others'))}" puts str rescue KeyError, Aws::Errors::NoSuchProfileError error format(t("errors.NoSuchProfileError"), config.profile) raise rescue Aws::Errors::MissingCredentialsError error t("errors.MissingCredentialsError") raise end