Documentation
¶
Overview ¶
Package adc handles Google Application Default Credentials.
Index ¶
Constants ¶
const ( // TypeAuthorizedUser represents user credentials from gcloud auth. TypeAuthorizedUser = "authorized_user" // TypeServiceAccount represents service account credentials. TypeServiceAccount = "service_account" )
Variables ¶
This section is empty.
Functions ¶
func FindFile ¶
func FindFile() string
FindFile locates the ADC file using Google's standard search order. Returns empty string if not found.
Search order:
- GOOGLE_APPLICATION_CREDENTIALS environment variable
- Default location: ~/.config/gcloud/application_default_credentials.json
func FormatBrief ¶
FormatBrief creates a one-line summary of Google Cloud auth status. This is used in the provider table view.
Format: "{Type}, {Project status}, Location: {location}" Example: "User Credentials, Project: my-project, Location: us-central1".
func ReadConfig ¶
ReadConfig reads a value from gcloud configuration files. Supports "project" from [core] section and "region" from [compute] section. Returns empty string if config not found or key doesn't exist.
Types ¶
type Details ¶
type Details struct {
State State
Type string // "User Credentials" | "Service Account"
Account string // Email address or client ID
Project string // Project ID
ProjectSource string // "ADC (quota_project_id)" | "env (GOOGLE_VERTEX_PROJECT)" | "gcloud config" | "not set"
Location string // Region
LocationSource string // "env (GOOGLE_VERTEX_LOCATION)" | "gcloud config" | "default"
UniverseDomain string // Usually "googleapis.com"
ADCPath string // Path to ADC file
LastAuth time.Time // File modification time
ErrorMessage string // Error message (only for invalid/missing states)
}
Details contains Google Cloud authentication details.
This type is used in auth.Status.GoogleCloud field (stored as interface{} to avoid import cycles).
func BuildDetails ¶
func BuildDetails() *Details
BuildDetails creates comprehensive Google Cloud authentication status. Performs local inspection only - no network calls are made.
This function:
- Finds the ADC file
- Parses and validates it
- Extracts project/location from multiple sources
- Returns complete authentication details
type File ¶
type File struct {
Type string `json:"type"`
QuotaProjectID string `json:"quota_project_id"`
ProjectID string `json:"project_id"`
Account string `json:"account"`
ClientID string `json:"client_id"`
UniverseDomain string `json:"universe_domain"`
}
File represents an Application Default Credentials JSON file.