Documentation
¶
Overview ¶
Package gcp_project implements the gcp/project identity.
This identity sets GCP project context without performing authentication. It configures environment variables for project and region, allowing tools like gcloud, terraform, and the GCP SDKs to target a specific project.
Use this identity when:
- You have ambient credentials (ADC, metadata server, etc.)
- You need to target a specific project without switching credentials
- You want consistent project/region settings across tools
Configuration example in atmos.yaml:
auth:
identities:
prod-context:
kind: gcp/project
principal:
project_id: my-prod-project
region: us-central1
zone: us-central1-a # optional
This identity does NOT:
- Authenticate or obtain credentials
- Call any GCP APIs
- Require a provider
Environment variables set:
- GOOGLE_CLOUD_PROJECT / GCLOUD_PROJECT / CLOUDSDK_CORE_PROJECT
- GOOGLE_CLOUD_REGION / CLOUDSDK_COMPUTE_REGION (if region specified)
- GOOGLE_CLOUD_ZONE / CLOUDSDK_COMPUTE_ZONE (if zone specified)
Index ¶
- Constants
- type Identity
- func (i *Identity) Authenticate(ctx context.Context, baseCreds types.ICredentials) (types.ICredentials, error)
- func (i *Identity) CredentialsExist() (bool, error)
- func (i *Identity) Environment() (map[string]string, error)
- func (i *Identity) GetProviderName() (string, error)
- func (i *Identity) Kind() string
- func (i *Identity) LoadCredentials(ctx context.Context) (types.ICredentials, error)
- func (i *Identity) Logout(ctx context.Context) error
- func (i *Identity) Name() string
- func (i *Identity) Paths() ([]types.Path, error)
- func (i *Identity) PostAuthenticate(ctx context.Context, params *types.PostAuthenticateParams) error
- func (i *Identity) PrepareEnvironment(ctx context.Context, environ map[string]string) (map[string]string, error)
- func (i *Identity) SetConfig(config *schema.Identity)
- func (i *Identity) SetName(name string)
- func (i *Identity) SetRealm(realm string)
- func (i *Identity) Validate() error
Constants ¶
const ( // IdentityKind is the kind identifier for this identity. IdentityKind = types.IdentityKindGCPProject // "gcp/project" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Identity ¶
type Identity struct {
// contains filtered or unexported fields
}
Identity implements the gcp/project identity. This identity sets project context without authentication.
func New ¶
func New(principal *types.GCPProjectIdentityPrincipal) (*Identity, error)
New creates a new project identity.
func (*Identity) Authenticate ¶
func (i *Identity) Authenticate(ctx context.Context, baseCreds types.ICredentials) (types.ICredentials, error)
Authenticate returns credentials with project context (no authentication performed). The project identity only sets context; it passes through base credentials if provided.
func (*Identity) CredentialsExist ¶
CredentialsExist returns true (no credentials needed).
func (*Identity) Environment ¶
Environment returns environment variables for this identity.
func (*Identity) GetProviderName ¶
GetProviderName returns the provider name from config, or empty string. GCP project identities may or may not have a provider (via.provider is optional).
func (*Identity) LoadCredentials ¶
LoadCredentials returns minimal credentials with project info (no stored credentials).
func (*Identity) PostAuthenticate ¶
func (i *Identity) PostAuthenticate(ctx context.Context, params *types.PostAuthenticateParams) error
PostAuthenticate sets up environment variables and populates auth context.
func (*Identity) PrepareEnvironment ¶
func (i *Identity) PrepareEnvironment(ctx context.Context, environ map[string]string) (map[string]string, error)
PrepareEnvironment merges identity environment into the given map.
func (*Identity) SetConfig ¶
SetConfig sets the identity configuration (for Via.Provider resolution).