Add Google Cloud Platform (gcloud) shell plugin#579
Open
mlsimon734 wants to merge 5 commits into1Password:mainfrom
Open
Add Google Cloud Platform (gcloud) shell plugin#579mlsimon734 wants to merge 5 commits into1Password:mainfrom
mlsimon734 wants to merge 5 commits into1Password:mainfrom
Conversation
Add a new gcloud plugin that supports importing and provisioning GCP service account keys and application default credentials. The plugin writes credential JSON to a temp file and sets GOOGLE_APPLICATION_CREDENTIALS for compatibility with all GCP tools.
Update the GCPProvisioner to automatically parse 'client_email' and 'project_id' from the credential JSON, setting CLOUDSDK_CORE_ACCOUNT and CLOUDSDK_CORE_PROJECT environment variables. This ensures seamless multi-account and profile support out of the box, while still allowing explicit command-line flags to override these settings. Additionally: - Add an optional 'Account' field to the ServiceAccountKey credential type to allow explicit overrides. - Update importers to set a NameHint based on the account email for easier selection during initialization. - Add tests to verify explicit account overrides and accurate environment variable provisioning.
The SDK's SanitizeNameHint truncates hints to 24 characters, so the expected NameHint in the importer test needed to use the truncated form.
10b4430 to
92a2db0
Compare
Add detailed doc comment to TryGCloudApplicationDefaultCredentialsFile explaining that authorized_user refresh tokens have different lifetimes depending on account type (personal vs managed org), helping users understand when service account keys are the better choice.
GOOGLE_APPLICATION_CREDENTIALS is only respected by client libraries, not by gcloud CLI commands. Set CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE so the gcloud CLI uses the provisioned credential file directly, bypassing its own auth store.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
gcloud,gsutil, andbqCLI toolsGOOGLE_APPLICATION_CREDENTIALS, plus automaticCLOUDSDK_CORE_PROJECTandCLOUDSDK_CORE_ACCOUNTresolution from the credential~/.config/gcloud/application_default_credentials.jsonand theGOOGLE_APPLICATION_CREDENTIALSenv varservice_accountandauthorized_usercredential typesTest plan
make gcloud/validate— all checks passmake test— gcloud tests pass (17 scenarios covering provisioner, importer, and NeedsAuth)make gcloud/build— builds and installs locallyop plugin init gcloud— end-to-end verification (requires 1Password CLI)