Skip to content

Add Google Cloud Platform (gcloud) shell plugin#579

Open
mlsimon734 wants to merge 5 commits into1Password:mainfrom
mlsimon734:michael/gcloud-plugin
Open

Add Google Cloud Platform (gcloud) shell plugin#579
mlsimon734 wants to merge 5 commits into1Password:mainfrom
mlsimon734:michael/gcloud-plugin

Conversation

@mlsimon734
Copy link

@mlsimon734 mlsimon734 commented Feb 27, 2026

Summary

  • Adds a new shell plugin for Google Cloud Platform with support for gcloud, gsutil, and bq CLI tools
  • Credentials are provisioned via a temporary JSON file with GOOGLE_APPLICATION_CREDENTIALS, plus automatic CLOUDSDK_CORE_PROJECT and CLOUDSDK_CORE_ACCOUNT resolution from the credential
  • Imports from ~/.config/gcloud/application_default_credentials.json and the GOOGLE_APPLICATION_CREDENTIALS env var
  • Supports both service_account and authorized_user credential types

Test plan

  • make gcloud/validate — all checks pass
  • make test — gcloud tests pass (17 scenarios covering provisioner, importer, and NeedsAuth)
  • make gcloud/build — builds and installs locally
  • op plugin init gcloud — end-to-end verification (requires 1Password CLI)

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.
@mlsimon734 mlsimon734 force-pushed the michael/gcloud-plugin branch from 10b4430 to 92a2db0 Compare February 27, 2026 10:29
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.
@mlsimon734 mlsimon734 marked this pull request as ready for review February 28, 2026 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant