Skip to content

Commit

Permalink
make load_gcloud_project_id module function (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRoyalTnetennba committed Oct 26, 2018
1 parent f0b0c6f commit 0d2becb
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 6 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
1 change: 1 addition & 0 deletions lib/googleauth/credentials_loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ def load_gcloud_project_id
rescue
warn 'Unable to determine project id.'
end
module_function :load_gcloud_project_id

private

Expand Down
4 changes: 2 additions & 2 deletions lib/googleauth/service_account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def self.make_creds(options = {})
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,
Expand Down Expand Up @@ -157,7 +157,7 @@ def initialize(options = {})
@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

Expand Down
2 changes: 1 addition & 1 deletion lib/googleauth/user_refresh.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def initialize(options = {})
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

Expand Down
2 changes: 1 addition & 1 deletion lib/googleauth/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion spec/googleauth/user_refresh_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def cred_json_text(missing = nil)
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
Expand Down

0 comments on commit 0d2becb

Please sign in to comment.