@@ -11,7 +11,7 @@ def initialize(config = nil)
1111 def resolve
1212 providers . each do |method_name , options |
1313 provider = send ( method_name , options . merge ( config : @config ) )
14- return provider if provider && provider . set?
14+ return provider if provider & .set?
1515 end
1616 nil
1717 end
@@ -54,59 +54,65 @@ def static_credentials(options)
5454 end
5555
5656 def static_profile_assume_role_web_identity_credentials ( options )
57- if Aws . shared_config . config_enabled? && options [ :config ] && options [ :config ] . profile
58- with_metrics ( 'CREDENTIALS_CODE' ) do
59- creds = Aws . shared_config . assume_role_web_identity_credentials_from_config (
60- profile : options [ :config ] . profile ,
61- region : options [ :config ] . region
62- )
63- creds . metrics << 'CREDENTIALS_CODE' if creds
64- creds
65- end
57+ return unless Aws . shared_config . config_enabled? && options [ :config ] &.profile
58+
59+ with_metrics ( 'CREDENTIALS_CODE' ) do
60+ creds = Aws . shared_config . assume_role_web_identity_credentials_from_config (
61+ profile : options [ :config ] . profile ,
62+ region : options [ :config ] . region
63+ )
64+ return unless creds
65+
66+ creds . metrics << 'CREDENTIALS_CODE'
67+ creds
6668 end
6769 end
6870
6971 def static_profile_sso_credentials ( options )
70- if Aws . shared_config . config_enabled? && options [ :config ] && options [ :config ] . profile
71- with_metrics ( 'CREDENTIALS_CODE' ) do
72- creds = Aws . shared_config . sso_credentials_from_config (
73- profile : options [ :config ] . profile
74- )
75- creds . metrics << 'CREDENTIALS_CODE' if creds
76- creds
77- end
72+ return unless Aws . shared_config . config_enabled? && options [ :config ] &.profile
73+
74+ with_metrics ( 'CREDENTIALS_CODE' ) do
75+ creds = Aws . shared_config . sso_credentials_from_config (
76+ profile : options [ :config ] . profile
77+ )
78+ return unless creds
79+
80+ creds . metrics << 'CREDENTIALS_CODE'
81+ creds
7882 end
7983 end
8084
8185 def static_profile_assume_role_credentials ( options )
82- if Aws . shared_config . config_enabled? && options [ :config ] && options [ :config ] . profile
83- with_metrics ( 'CREDENTIALS_CODE' ) do
84- creds = assume_role_with_profile ( options , options [ :config ] . profile )
85- creds . metrics << 'CREDENTIALS_CODE' if creds
86- creds
87- end
86+ return unless Aws . shared_config . config_enabled? && options [ :config ] &.profile
87+
88+ with_metrics ( 'CREDENTIALS_CODE' ) do
89+ creds = assume_role_with_profile ( options , options [ :config ] . profile )
90+ return unless creds
91+
92+ creds . metrics << 'CREDENTIALS_CODE'
93+ creds
8894 end
8995 end
9096
9197 def static_profile_credentials ( options )
92- if options [ :config ] && options [ :config ] . profile
93- creds = SharedCredentials . new ( profile_name : options [ :config ] . profile )
94- creds . metrics << 'CREDENTIALS_PROFILE'
95- creds
96- end
98+ return unless options [ :config ] & .profile
99+
100+ creds = SharedCredentials . new ( profile_name : options [ :config ] . profile )
101+ creds . metrics << 'CREDENTIALS_PROFILE'
102+ creds
97103 rescue Errors ::NoSuchProfileError
98104 nil
99105 end
100106
101107 def static_profile_process_credentials ( options )
102- if Aws . shared_config . config_enabled? && options [ :config ] && options [ :config ] . profile
103- process_provider = Aws . shared_config . credential_process ( profile : options [ :config ] . profile )
104- if process_provider
105- creds = ProcessCredentials . new ( [ process_provider ] )
106- creds . metrics << 'CREDENTIALS_PROFILE_PROCESS' << 'CREDENTIALS_CODE'
107- creds
108- end
109- end
108+ return unless Aws . shared_config . config_enabled? && options [ :config ] & .profile
109+
110+ process_provider = Aws . shared_config . credential_process ( profile : options [ :config ] . profile )
111+ return unless process_provider
112+
113+ creds = ProcessCredentials . new ( [ process_provider ] )
114+ creds . metrics . concat ( %w[ CREDENTIALS_PROFILE_PROCESS CREDENTIALS_CODE ] )
115+ creds
110116 rescue Errors ::NoSuchProfileError
111117 nil
112118 end
@@ -134,7 +140,7 @@ def envar(keys)
134140 end
135141
136142 def determine_profile_name ( options )
137- ( options [ :config ] && options [ :config ] . profile ) || ENV [ 'AWS_PROFILE' ] || ENV [ 'AWS_DEFAULT_PROFILE' ] || 'default'
143+ ( options [ :config ] & .profile ) || ENV [ 'AWS_PROFILE' ] || ENV [ 'AWS_DEFAULT_PROFILE' ] || 'default'
138144 end
139145
140146 def shared_credentials ( options )
@@ -213,7 +219,7 @@ def assume_role_with_profile(options, profile_name)
213219 profile : profile_name ,
214220 chain_config : @config
215221 }
216- if options [ :config ] && options [ :config ] . region
222+ if options [ :config ] & .region
217223 assume_opts [ :region ] = options [ :config ] . region
218224 end
219225 Aws . shared_config . assume_role_credentials_from_config ( assume_opts )
0 commit comments