Refactor Google::Auth.determine_creds_class to use case statements
This commit is contained in:
parent
7e522cfe13
commit
13bb435cf8
|
@ -62,11 +62,16 @@ END
|
||||||
json_key = MultiJson.load(json_key_io.read)
|
json_key = MultiJson.load(json_key_io.read)
|
||||||
fail "the json is missing the #{key} field" unless json_key.key?('type')
|
fail "the json is missing the #{key} field" unless json_key.key?('type')
|
||||||
type = json_key['type']
|
type = json_key['type']
|
||||||
return json_key, ServiceAccountCredentials if type == 'service_account'
|
case type
|
||||||
return [json_key, UserRefreshCredentials] if type == 'authorized_user'
|
when 'service_account'
|
||||||
|
[json_key, ServiceAccountCredentials]
|
||||||
|
when 'authorized_user'
|
||||||
|
[json_key, UserRefreshCredentials]
|
||||||
|
else
|
||||||
fail "credentials type '#{type}' is not supported"
|
fail "credentials type '#{type}' is not supported"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Obtains the default credentials implementation to use in this
|
# Obtains the default credentials implementation to use in this
|
||||||
# environment.
|
# environment.
|
||||||
|
|
Loading…
Reference in New Issue