[gcp-auth-extension]: Try resolving GCP_PROJECT with ServiceOptions if not provided #2109
+82
−8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
Enhancement - Try resolving GOOGLE_CLOUD_PROJECT value using google-cloud-sdk.
Having a mandatory
GOOCLE_CLOUD_PROJECT
configuration is unnecessary, given the extension already depends on ADC context existing. It can try to infer the project from it.Still mandatory to have a project id, but this gives more flexibility in the usage of the extension.
Existing Issue(s):
#2102
Testing:
Refactored the project id resolver logic into a separate method, including the more comprehensive
ServiceOptions
resolver. Tested the method for both the current strategy and falling back toServiceOptions
, also added a missing test for not being able to find the option and throwing an exception.Documentation:
GOOGLE_CLOUD_PROJECT
configuration was moved into the optional config section, with a note that even though it's optional, the extension needs it either provided or being able to infer it.Outstanding items:
N/A