gcp_project

package
v1.224.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

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

View Source
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

func (i *Identity) CredentialsExist() (bool, error)

CredentialsExist returns true (no credentials needed).

func (*Identity) Environment

func (i *Identity) Environment() (map[string]string, error)

Environment returns environment variables for this identity.

func (*Identity) GetProviderName

func (i *Identity) GetProviderName() (string, error)

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) Kind

func (i *Identity) Kind() string

Kind returns the identity kind.

func (*Identity) LoadCredentials

func (i *Identity) LoadCredentials(ctx context.Context) (types.ICredentials, error)

LoadCredentials returns minimal credentials with project info (no stored credentials).

func (*Identity) Logout

func (i *Identity) Logout(ctx context.Context) error

Logout is a no-op (no credentials to clean up).

func (*Identity) Name

func (i *Identity) Name() string

Name returns the identity name.

func (*Identity) Paths

func (i *Identity) Paths() ([]types.Path, error)

Paths returns empty (no credential files).

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

func (i *Identity) SetConfig(config *schema.Identity)

SetConfig sets the identity configuration (for Via.Provider resolution).

func (*Identity) SetName

func (i *Identity) SetName(name string)

SetName sets the identity name.

func (*Identity) SetRealm

func (i *Identity) SetRealm(realm string)

SetRealm satisfies the Identity interface. The project identity is realm-independent because it only sets GCP project/region/zone context via environment variables — it performs no credential file I/O. The value is stored but not used in behavior.

func (*Identity) Validate

func (i *Identity) Validate() error

Validate validates the identity configuration.

Jump to

Keyboard shortcuts

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