Sha256: b545b4af6d2f40498487fbc80f1d2f42c41539c2da39cf70c6c424ecad439c61

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

require_relative "abstract_action"
require_relative "../../store/shared_config_with_keyring"

class AwsAssumeRole::Cli::Actions::ConfigureProfile < AwsAssumeRole::Cli::Actions::AbstractAction
    CommandSchema = proc do
        required(:profile)
        optional(:region) { filled? > format?(REGION_REGEX) }
        optional(:mfa_serial)
        optional(:profile_name)
        optional(:yubikey_oath_name)
    end

    def act_on(config)
        new_hash = config.to_h
        profile = config.profile || prompt_for_option(:profile_name, "profile", proc { filled? })
        new_hash[:region] = prompt_for_option(:region, "region", proc { filled? > format?(REGION_REGEX) })
        new_hash[:aws_access_key_id] = prompt_for_option(:aws_access_key_id, "aws_access_key_id", ACCESS_KEY_VALIDATOR)
        new_hash[:aws_secret_access_key] = prompt_for_option(:aws_secret_access_key, "aws_secret_access_key", proc { filled? })
        AwsAssumeRole.shared_config.save_profile(profile, new_hash)
        out format(t("commands.configure.saved"), profile, AwsAssumeRole.shared_config.config_path)
    end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
aws_assume_role-0.2.2 lib/aws_assume_role/cli/actions/configure_profile.rb
aws_assume_role-0.2.0 lib/aws_assume_role/cli/actions/configure_profile.rb