class AWS::Core::CredentialProviders::SharedCredentialFileProvider
Constants
- KEY_MAP
@api private
Attributes
path[R]
@return [String]
profile_name[R]
@return [String]
Public Class Methods
new(options = {})
click to toggle source
@option [String] :path @option [String] :profile_name
# File lib/aws/core/credential_providers.rb, line 291 def initialize(options = {}) @path = options[:path] || shared_credential_file_path @profile_name = options[:profile_name] @profile_name ||= ENV['AWS_PROFILE'] @profile_name ||= 'default' end
Public Instance Methods
get_credentials()
click to toggle source
(see AWS::Core::CredentialProviders::Provider#get_credentials)
# File lib/aws/core/credential_providers.rb, line 305 def get_credentials if File.exist?(path) && File.readable?(path) load_from_path else {} end end
Private Instance Methods
load_from_path()
click to toggle source
# File lib/aws/core/credential_providers.rb, line 315 def load_from_path profile = load_profile KEY_MAP.inject({}) do |credentials, (source, target)| credentials[target] = profile[source] if profile.key?(source) credentials end end
load_profile()
click to toggle source
# File lib/aws/core/credential_providers.rb, line 323 def load_profile ini = IniParser.parse(File.read(path)) ini[profile_name] || {} end