Class: AwsAssumeRole::Credentials::Factories::DefaultChainProvider

Inherits:
Dry::Struct
  • Object
show all
Includes:
AwsAssumeRole::Credentials::Factories, Logging
Defined in:
lib/aws_assume_role/credentials/factories/default_chain_provider.rb

Constant Summary

Constants included from AwsAssumeRole::Credentials::Factories

Types

Constants included from AwsAssumeRole

AwsAssumeRole::Config, DefaultProvider, VERSION

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Logging

included

Methods included from AwsAssumeRole

shared_config

Class Method Details

.finalize_instance(options) ⇒ Object


47
48
49
50
51
52
53
54
# File 'lib/aws_assume_role/credentials/factories/default_chain_provider.rb', line 47

def self.finalize_instance(options)
    new_opts = options.to_h
    new_opts[:profile_name] ||= new_opts[:profile]
    new_opts[:original_profile] = new_opts[:profile_name]
    instance = allocate
    instance.send(:initialize, new_opts)
    instance
end

.new(options) ⇒ Object


39
40
41
42
43
44
45
# File 'lib/aws_assume_role/credentials/factories/default_chain_provider.rb', line 39

def self.new(options)
    if options.respond_to? :resolve
        finalize_instance new_with_seahorse(options)
    else
        finalize_instance(options)
    end
end

.new_with_seahorse(resolver) ⇒ Object


56
57
58
59
60
61
62
# File 'lib/aws_assume_role/credentials/factories/default_chain_provider.rb', line 56

def self.new_with_seahorse(resolver)
    keys = resolver.resolve
    options = keys.map do |k|
        [k, resolver.send(k)]
    end
    finalize_instance(options.to_h)
end

Instance Method Details

#resolve(nil_with_role_not_set: false, explicit_default_profile: false) ⇒ Object


64
65
66
67
68
69
70
71
# File 'lib/aws_assume_role/credentials/factories/default_chain_provider.rb', line 64

def resolve(nil_with_role_not_set: false, explicit_default_profile: false)
    resolve_final_credentials(explicit_default_profile)    # nil_creds = Aws::Credentials.new(nil, nil, nil)

    return nil if (nil_with_role_not_set &&
                         @role_arn &&
                         @credentials.credentials.session_token.nil?) || @credentials.nil?
    @credentials
end

#to_hObject


73
74
75
# File 'lib/aws_assume_role/credentials/factories/default_chain_provider.rb', line 73

def to_h
    to_hash
end