make load_gcloud_project_id module function (#170)

This commit is contained in:
Graham Paye 2018-10-26 12:17:12 -07:00 committed by GitHub
parent f0b0c6f8e8
commit 0d2becbdcd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 11 additions and 6 deletions

View File

@ -1,4 +1,8 @@
## 0.7.0 (2018/10/23)
## 0.7.1 (2018/10/25)
* Make load_gcloud_project_id module function.
## 0.7.0 (2018/10/24)
* Add project_id instance variable to UserRefreshCredentials, ServiceAccountCredentials, and Credentials.

View File

@ -147,6 +147,7 @@ module Google
rescue
warn 'Unable to determine project id.'
end
module_function :load_gcloud_project_id
private

View File

@ -65,7 +65,7 @@ module Google
client_email = ENV[CredentialsLoader::CLIENT_EMAIL_VAR]
project_id = ENV[CredentialsLoader::PROJECT_ID_VAR]
end
project_id ||= self.class.load_gcloud_project_id
project_id ||= CredentialsLoader.load_gcloud_project_id
new(token_credential_uri: TOKEN_CRED_URI,
audience: TOKEN_CRED_URI,
@ -157,7 +157,7 @@ module Google
@issuer = ENV[CredentialsLoader::CLIENT_EMAIL_VAR]
@project_id = ENV[CredentialsLoader::PROJECT_ID_VAR]
end
@project_id ||= self.class.load_gcloud_project_id
@project_id ||= CredentialsLoader.load_gcloud_project_id
@signing_key = OpenSSL::PKey::RSA.new(@private_key)
end

View File

@ -90,7 +90,7 @@ module Google
options[:token_credential_uri] ||= TOKEN_CRED_URI
options[:authorization_uri] ||= AUTHORIZATION_URI
@project_id = options[:project_id]
@project_id ||= self.class.load_gcloud_project_id
@project_id ||= CredentialsLoader.load_gcloud_project_id
super(options)
end

View File

@ -31,6 +31,6 @@ module Google
# Module Auth provides classes that provide Google-specific authorization
# used to access Google APIs.
module Auth
VERSION = '0.7.0'.freeze
VERSION = '0.7.1'.freeze
end
end

View File

@ -221,7 +221,7 @@ describe Google::Auth::UserRefreshCredentials do
ENV['HOME'] = dir
ENV['APPDATA'] = dir
ENV[PROJECT_ID_VAR] = nil
expect(@clz).to receive(:load_gcloud_project_id).with(no_args)
expect(Google::Auth::CredentialsLoader).to receive(:load_gcloud_project_id).with(no_args)
@clz.from_well_known_path(@scope)
end
end