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



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

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



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

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



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

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



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

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



75
76
77
# File 'lib/aws_assume_role/credentials/factories/default_chain_provider.rb', line 75

def to_h
    to_hash
end