Skip to content

Commit 07c5d5c

Browse files
committed
Style, formatting and comment changes
1 parent 077f657 commit 07c5d5c

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/aws/google.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module Aws
2020
#
2121
# ec2 = Aws::EC2::Client.new(credentials: role_credentials)
2222
#
23-
# If you omit `:client` option, a new {STS::Client} object will be
23+
# If you omit `:client` option, a new {Aws::STS::Client} object will be
2424
# constructed.
2525
class Google
2626
include ::Aws::CredentialProvider
@@ -101,7 +101,8 @@ def refresh
101101
rescue JWT::DecodeError, JWT::ExpiredSignature
102102
# Refresh and retry once if token is expired or invalid.
103103
client.refresh!
104-
(tries -= 1).zero? ? raise : retry
104+
raise if (tries -= 1).zero?
105+
retry
105106
end
106107

107108
@client.assume_role_with_web_identity(
@@ -111,14 +112,16 @@ def refresh
111112
)
112113
)
113114
rescue Signet::AuthorizationError => e
114-
(@google_client = google_oauth) && retry || raise
115+
retry if (@google_client = google_oauth)
116+
raise
115117
rescue Aws::STS::Errors::AccessDenied => e
116118
retry if (@google_client = google_oauth)
117119
raise e, "\nYour Google ID does not have access to the requested AWS Role. Ask your administrator to provide access.
118120
Role: #{@assume_role_params[:role_arn]}
119121
Email: #{token_params['email']}
120122
Google ID: #{token_params['sub']}", e.backtrace
121123
end
124+
122125
c = assume_role.credentials
123126
@credentials = Aws::Credentials.new(
124127
c.access_key_id,
@@ -129,8 +132,7 @@ def refresh
129132
write_credentials
130133
end
131134

132-
# Use `aws configure set` to write credentials and expiration to AWS credentials file.
133-
# AWS CLI is needed because writing AWS credentials is not supported by the AWS Ruby SDK.
135+
# Write credentials and expiration to AWS credentials file.
134136
def write_credentials
135137
%w[
136138
access_key_id
@@ -150,8 +152,6 @@ def get(key, opts = {})
150152
profile = opts.delete(:profile) || @profile_name
151153
if @parsed_config && (prof_config = @parsed_config[profile])
152154
prof_config[key]
153-
else
154-
nil
155155
end
156156
end
157157
end

0 commit comments

Comments
 (0)