Renamed the error vars
This commit is contained in:
parent
a5bb601fe3
commit
7adcf42958
|
@ -34,7 +34,7 @@ module Google
|
||||||
# Module Auth provides classes that provide Google-specific authorization
|
# Module Auth provides classes that provide Google-specific authorization
|
||||||
# used to access Google APIs.
|
# used to access Google APIs.
|
||||||
module Auth
|
module Auth
|
||||||
NOT_FOUND = <<END
|
NOT_FOUND_ERROR = <<END
|
||||||
Could not load the default credentials. Browse to
|
Could not load the default credentials. Browse to
|
||||||
https://developers.google.com/accounts/docs/application-default-credentials
|
https://developers.google.com/accounts/docs/application-default-credentials
|
||||||
for more information
|
for more information
|
||||||
|
@ -53,7 +53,7 @@ END
|
||||||
return creds unless creds.nil?
|
return creds unless creds.nil?
|
||||||
creds = ServiceAccountCredentials.from_well_known_path(scope)
|
creds = ServiceAccountCredentials.from_well_known_path(scope)
|
||||||
return creds unless creds.nil?
|
return creds unless creds.nil?
|
||||||
fail NOT_FOUND unless GCECredentials.on_gce?(options)
|
fail NOT_FOUND_ERROR unless GCECredentials.on_gce?(options)
|
||||||
GCECredentials.new
|
GCECredentials.new
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -54,11 +54,11 @@ module Google
|
||||||
# cf [Application Default Credentials](http://goo.gl/mkAHpZ)
|
# cf [Application Default Credentials](http://goo.gl/mkAHpZ)
|
||||||
class ServiceAccountCredentials < Signet::OAuth2::Client
|
class ServiceAccountCredentials < Signet::OAuth2::Client
|
||||||
ENV_VAR = 'GOOGLE_APPLICATION_CREDENTIALS'
|
ENV_VAR = 'GOOGLE_APPLICATION_CREDENTIALS'
|
||||||
NOT_FOUND_PREFIX =
|
NOT_FOUND_ERROR =
|
||||||
"Unable to read the credential file specified by #{ENV_VAR}"
|
"Unable to read the credential file specified by #{ENV_VAR}"
|
||||||
TOKEN_CRED_URI = 'https://www.googleapis.com/oauth2/v3/token'
|
TOKEN_CRED_URI = 'https://www.googleapis.com/oauth2/v3/token'
|
||||||
WELL_KNOWN_PATH = 'gcloud/application_default_credentials.json'
|
WELL_KNOWN_PATH = 'gcloud/application_default_credentials.json'
|
||||||
WELL_KNOWN_PREFIX = 'Unable to read the default credential file'
|
WELL_KNOWN_ERROR = 'Unable to read the default credential file'
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
extend Memoist
|
extend Memoist
|
||||||
|
@ -79,7 +79,7 @@ module Google
|
||||||
fail 'file #{path} does not exist' unless File.exist?(path)
|
fail 'file #{path} does not exist' unless File.exist?(path)
|
||||||
return new(scope, File.open(path))
|
return new(scope, File.open(path))
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
raise "#{NOT_FOUND_PREFIX}: #{e}"
|
raise "#{NOT_FOUND_ERROR}: #{e}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Creates an instance from a well known path.
|
# Creates an instance from a well known path.
|
||||||
|
@ -94,7 +94,7 @@ module Google
|
||||||
return nil unless File.exist?(path)
|
return nil unless File.exist?(path)
|
||||||
return new(scope, File.open(path))
|
return new(scope, File.open(path))
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
raise "#{WELL_KNOWN_PREFIX}: #{e}"
|
raise "#{WELL_KNOWN_ERROR}: #{e}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue