gcp

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTokenUrl = "https://oauth2.googleapis.com/token" //nolint:gosec // G101: public OAuth token endpoint URL, not a credential
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(options ...gcp_config.Option) *Client

func NewClientWithUrls

func NewClientWithUrls(metadataBaseUrl *url.URL, tokenUrl string, options ...gcp_config.Option) *Client

func (*Client) FindDefaultCredentials

func (c *Client) FindDefaultCredentials(ctx context.Context, scopes []string, options ...fetch_config.Option) (token_source.TokenSource, error)

FindDefaultCredentials discovers Google credentials using the Application Default Credentials chain:

  1. GOOGLE_APPLICATION_CREDENTIALS env var — reads the JSON file it points to.
  2. Well-known file — user credentials from gcloud auth application-default login.
  3. Metadata server — if running on GCP (Compute Engine, Cloud Run, etc.).

func (*Client) GetIdToken

func (c *Client) GetIdToken(ctx context.Context, audience string, options ...fetch_config.Option) (string, error)

func (*Client) GetProjectId

func (c *Client) GetProjectId(ctx context.Context, options ...fetch_config.Option) (string, error)

func (*Client) GetServiceAccountEmail

func (c *Client) GetServiceAccountEmail(ctx context.Context, options ...fetch_config.Option) (string, error)

GetServiceAccountEmail returns the email address of the runtime's default service account by querying the GCP metadata server. Only works when running inside a GCP environment that exposes the metadata server (Compute Engine, Cloud Run, GKE, etc.).

Jump to

Keyboard shortcuts

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