cloud

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 19, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdcIamUser

func AdcIamUser(ctx context.Context) (string, error)

AdcIamUser returns the Google Cloud IAM user associated with the current ADC (Application Default Credentials). This function is useful for determining the IAM user that is being used to make requests to Google Cloud services.

func CurrentProject

func CurrentProject(ctx context.Context) (string, *google.Credentials, error)

CurrentProject returns the current project ID. If the project is not specified explicitly using environment variables, it will attempt to use the default credentials to determine the project ID. When the credentials are used, the credentials are also returned. If the project is specified explicitly, the credentials returned are nil.

func CurrentUserInfo

func CurrentUserInfo(ctx context.Context) (*googleoauth2.Userinfo, error)

CurrentUserInfo returns the current user's information. This function caches the user info after the first call so that it doesn't need to be retrieved again. Additionally, the expectation is that the user info will not change during the lifetime of the application.

func DefaultCredentials

func DefaultCredentials(ctx context.Context) (*google.Credentials, error)

DefaultCredentials returns the default Google Cloud credentials. It supports ADC (Application Default Credentials) and workload identity for applications running on Google Cloud. This uses default fallback patterns from Google libraries. The default fallback patterns, in order, are: 1. Environment variable GOOGLE_APPLICATION_CREDENTIALS pointing to a service account key file. 2. A JSON file in a well-known location created by the gcloud command-line tool. 3. Credentials from the metadata server on GCE, GKE, App Engine, Cloud Run, and others.

func HttpClient

func HttpClient(creds *google.Credentials) (*http.Client, error)

HttpClient returns an HTTP client that is authenticated to Google Cloud with the given credentials from Google Cloud.

func IamUser

func IamUser(ctx context.Context, creds *google.Credentials) (string, error)

IamUser returns the Google Cloud IAM user associated with the given credentials. This function is useful for determining the IAM user that is being used to make requests to Google Cloud services. The IAM user is determined by querying the OAuth2 token info endpoint.

func ProjectIdFromCredentials

func ProjectIdFromCredentials(creds *google.Credentials) (string, error)

ProjectIdFromCredentials returns the Google Cloud project ID from the given credentials.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL