class AwsAssumeRole::Credentials::Providers::SharedKeyringCredentials

Attributes

region[R]
role_arn[R]

Public Class Methods

new(options = {}) click to toggle source
# File lib/aws_assume_role/credentials/providers/shared_keyring_credentials.rb, line 10
def initialize(options = {})
    logger.debug "SharedKeyringCredentials initiated with #{options}"
    @path = options[:path]
    @path ||= AwsAssumeRole.shared_config.credentials_path
    @profile_name = options[:profile_name] ||= options[:profile]
    @profile_name ||= ENV["AWS_PROFILE"]
    @profile_name ||= AwsAssumeRole.shared_config.profile_name
    logger.debug "SharedKeyringCredentials resolved profile name #{@profile_name}"
    config = determine_config(@path, @profile_name)
    @role_arn = config.profile_hash(@profile_name)
    @region = config.profile_region(@profile_name)
    @role_arn = config.profile_role(@profile_name)
    attempted_credential = config.credentials(options)
    return unless attempted_credential && attempted_credential.set?
    @credentials = attempted_credential
end

Private Instance Methods

determine_config(path, profile_name) click to toggle source
# File lib/aws_assume_role/credentials/providers/shared_keyring_credentials.rb, line 29
def determine_config(path, profile_name)
    if path && path == AwsAssumeRole.shared_config.credentials_path
        logger.debug "SharedKeyringCredentials found shared credential path"
        AwsAssumeRole.shared_config
    else
        logger.debug "SharedKeyringCredentials found custom credential path"
        AwsAssumeRole::Store::SharedConfigWithKeyring.new(
            credentials_path: path,
            profile_name: profile_name,
        )
    end
end