vertex

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package vertex implements the inference.Provider interface for Google Cloud Vertex AI. It supports two auth modes:

  • SA key (default): long-lived service account key JSON, with sub-modes for creating, verifying, or using a pre-made key.
  • WIF: Workload Identity Federation with GitHub OIDC — no stored keys.

Index

Constants

View Source
const (
	// SecretCredentials is the repo secret name for the GCP service account key JSON.
	// Uses the FULLSEND_ prefix to avoid confusion with the GCP SDK env var
	// GOOGLE_APPLICATION_CREDENTIALS, which expects a file path, not JSON content.
	SecretCredentials = "FULLSEND_GCP_SA_KEY_JSON"

	// SecretProjectID is the repo secret name for the GCP project ID.
	// Uses the FULLSEND_ prefix for consistency with other secrets.
	SecretProjectID = "FULLSEND_GCP_PROJECT_ID"

	// VariableRegion is the repo variable name for the GCP region.
	VariableRegion = "FULLSEND_GCP_REGION"

	// VariableAuthMode tells workflows which GCP auth method to use.
	// Must be a variable (not a secret) because GitHub's dispatch-time
	// validator does not recognise the secrets context.
	VariableAuthMode = "FULLSEND_GCP_AUTH_MODE"

	// SecretWIFProvider is the repo secret for the full WIF provider resource name.
	// Stored as a secret so the value is masked in GitHub Actions logs.
	SecretWIFProvider = "FULLSEND_GCP_WIF_PROVIDER"

	// SecretWIFServiceAccount is the repo secret for the SA email used with WIF.
	// Stored as a secret so the value is masked in GitHub Actions logs.
	SecretWIFServiceAccount = "FULLSEND_GCP_WIF_SA_EMAIL"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthMode added in v0.2.0

type AuthMode string

AuthMode selects between service-account key and Workload Identity Federation.

const (
	// AuthModeSAKey uses a long-lived service account key JSON file.
	AuthModeSAKey AuthMode = "sa_key"

	// AuthModeWIF uses Workload Identity Federation with GitHub OIDC.
	AuthModeWIF AuthMode = "wif"
)

type Config

type Config struct {
	ProjectID          string   // required
	Region             string   // required: GCP region (e.g. global)
	Mode               AuthMode // "sa_key" (default) or "wif"
	ServiceAccountName string   // optional: existing SA name (sa_key mode 2)
	CredentialJSON     []byte   // optional: pre-made key JSON (sa_key mode 3)
	WIFProvider        string   // WIF mode: full provider resource name
	WIFServiceAccount  string   // WIF mode: service account email
}

Config holds the inputs for Vertex credential provisioning.

type GCPClient

type GCPClient interface {
	// GetServiceAccount checks that a service account exists.
	GetServiceAccount(ctx context.Context, projectID, saName string) error

	// CreateServiceAccount creates a new service account.
	CreateServiceAccount(ctx context.Context, projectID, saName, displayName string) error

	// CreateServiceAccountKey generates a new JSON key for a service account.
	CreateServiceAccountKey(ctx context.Context, projectID, saEmail string) ([]byte, error)
}

GCPClient abstracts GCP IAM operations for testability.

type LiveGCPClient

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

LiveGCPClient implements GCPClient using the GCP IAM REST API. It obtains access tokens via Application Default Credentials.

func NewLiveGCPClient

func NewLiveGCPClient() *LiveGCPClient

NewLiveGCPClient creates a new LiveGCPClient.

func (*LiveGCPClient) CreateServiceAccount

func (c *LiveGCPClient) CreateServiceAccount(ctx context.Context, projectID, saName, displayName string) error

CreateServiceAccount creates a new service account in the project.

func (*LiveGCPClient) CreateServiceAccountKey

func (c *LiveGCPClient) CreateServiceAccountKey(ctx context.Context, projectID, saEmail string) ([]byte, error)

CreateServiceAccountKey generates a new JSON key for the service account.

func (*LiveGCPClient) GetServiceAccount

func (c *LiveGCPClient) GetServiceAccount(ctx context.Context, projectID, saName string) error

GetServiceAccount checks that a service account exists in the project.

type Provider

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

Provider implements inference.Provider for Vertex AI.

func New

func New(cfg Config, gcpAPI GCPClient) *Provider

New creates a Vertex Provider with the given config and GCP client.

func NewAnalyzeOnly

func NewAnalyzeOnly(mode AuthMode) *Provider

NewAnalyzeOnly creates a Provider that only supports SecretNames() and Name(). Calling Provision() on this provider returns an error.

func (*Provider) Name

func (p *Provider) Name() string

Name returns "vertex".

func (*Provider) Provision

func (p *Provider) Provision(ctx context.Context) (map[string]string, error)

Provision acquires GCP credentials and returns them as secrets.

func (*Provider) SecretNames

func (p *Provider) SecretNames() []string

SecretNames returns the secret names this provider manages.

func (*Provider) Variables

func (p *Provider) Variables() map[string]string

Variables returns non-secret name/value pairs to store as repo variables.

Jump to

Keyboard shortcuts

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