Sha256: fd7d26c217ecde859fc32ee8bb64484fb4ee24ab0efbcb62aaf0266770356063

Contents?: true

Size: 1.11 KB

Versions: 43

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

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

43 entries across 43 versions & 1 rubygems

Version Path
aws_assume_role-1.2.3-universal-freebsd lib/aws_assume_role/cli/actions/configure_profile.rb
aws_assume_role-1.2.3-universal-darwin lib/aws_assume_role/cli/actions/configure_profile.rb
aws_assume_role-1.2.3-universal-linux lib/aws_assume_role/cli/actions/configure_profile.rb
aws_assume_role-1.2.3-universal-openbsd lib/aws_assume_role/cli/actions/configure_profile.rb
aws_assume_role-1.2.3 lib/aws_assume_role/cli/actions/configure_profile.rb
aws_assume_role-1.2.3-linux lib/aws_assume_role/cli/actions/configure_profile.rb
aws_assume_role-1.2.2-universal-darwin lib/aws_assume_role/cli/actions/configure_profile.rb
aws_assume_role-1.2.2-universal-linux lib/aws_assume_role/cli/actions/configure_profile.rb
aws_assume_role-1.2.2-linux lib/aws_assume_role/cli/actions/configure_profile.rb
aws_assume_role-1.2.2-universal-openbsd lib/aws_assume_role/cli/actions/configure_profile.rb
aws_assume_role-1.2.2-universal-freebsd lib/aws_assume_role/cli/actions/configure_profile.rb
aws_assume_role-1.2.2 lib/aws_assume_role/cli/actions/configure_profile.rb
aws_assume_role-1.2.1 lib/aws_assume_role/cli/actions/configure_profile.rb
aws_assume_role-1.2.1-linux lib/aws_assume_role/cli/actions/configure_profile.rb
aws_assume_role-1.2.1-universal-openbsd lib/aws_assume_role/cli/actions/configure_profile.rb
aws_assume_role-1.2.1-universal-darwin lib/aws_assume_role/cli/actions/configure_profile.rb
aws_assume_role-1.2.1-universal-freebsd lib/aws_assume_role/cli/actions/configure_profile.rb
aws_assume_role-1.2.1-universal-linux lib/aws_assume_role/cli/actions/configure_profile.rb
aws_assume_role-1.2.0 lib/aws_assume_role/cli/actions/configure_profile.rb
aws_assume_role-1.2.0-linux lib/aws_assume_role/cli/actions/configure_profile.rb