Documentation
¶
Index ¶
- func AdcIamUser(ctx context.Context) (string, error)
- func CurrentProject(ctx context.Context) (string, *google.Credentials, error)
- func DefaultCredentials(ctx context.Context) (*google.Credentials, error)
- func IamUser(ctx context.Context, creds *google.Credentials) (string, error)
- func NewCloudMetadata() blackstart.Module
- func ProjectIdFromCredentials(creds *google.Credentials) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AdcIamUser ¶
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 ¶
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 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 IamUser ¶
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 NewCloudMetadata ¶ added in v0.1.4
func NewCloudMetadata() blackstart.Module
NewCloudMetadata creates a module that emits runtime metadata from the Google metadata service.
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.