Documentation
¶
Overview ¶
Package gcf implements the dispatch.Dispatcher interface using a GCP Cloud Function as the token mint. The mint validates GitHub OIDC tokens via Workload Identity Federation and issues scoped installation tokens for each agent role.
Index ¶
- Constants
- Variables
- func DefaultFunctionSourceDir() string
- func LastWIFProviderCondition(client GCFClient) string
- func ValidateProjectID(id string) bool
- func ValidateRegion(region string) bool
- func ValidateRepoSlug(slug string) bool
- type Config
- type DeployMode
- type FakeGCFOption
- func WithFakeErrors(errs map[string]error) FakeGCFOption
- func WithFakeFunctionInfo(info *FunctionInfo) FakeGCFOption
- func WithFakeRevisionInfo(info *ServiceRevisionInfo) FakeGCFOption
- func WithFakeSecrets(secrets map[string]bool) FakeGCFOption
- func WithFakeTrafficEnvVars(env map[string]string) FakeGCFOption
- func WithFakeWIFProvider(p *WIFProviderInfo) FakeGCFOption
- type FunctionConfig
- type FunctionInfo
- type GCFClient
- type LiveGCFClient
- func (c *LiveGCFClient) AccessSecretVersion(ctx context.Context, projectID, secretID string) ([]byte, error)
- func (c *LiveGCFClient) AddSecretVersion(ctx context.Context, projectID, secretID string, data []byte) error
- func (c *LiveGCFClient) CreateFunction(ctx context.Context, projectID, region, functionName string, ...) (string, error)
- func (c *LiveGCFClient) CreateSecret(ctx context.Context, projectID, secretID string) error
- func (c *LiveGCFClient) CreateServiceAccount(ctx context.Context, projectID, saName, displayName string) error
- func (c *LiveGCFClient) CreateWIFPool(ctx context.Context, projectNumber, poolID, displayName string) error
- func (c *LiveGCFClient) CreateWIFProvider(ctx context.Context, projectNumber, poolID, providerID string, ...) error
- func (c *LiveGCFClient) DeleteSecret(ctx context.Context, projectID, secretID string) error
- func (c *LiveGCFClient) DeleteWIFProvider(ctx context.Context, projectNumber, poolID, providerID string) error
- func (c *LiveGCFClient) DisableSecretVersion(ctx context.Context, projectID, secretID string) error
- func (c *LiveGCFClient) DisableWIFProvider(ctx context.Context, projectNumber, poolID, providerID string) error
- func (c *LiveGCFClient) EnableSecretVersion(ctx context.Context, projectID, secretID string) error
- func (c *LiveGCFClient) GetCloudRunServiceURI(ctx context.Context, projectID, region, serviceName string) (string, error)
- func (c *LiveGCFClient) GetFunction(ctx context.Context, projectID, region, functionName string) (*FunctionInfo, error)
- func (c *LiveGCFClient) GetProjectNumber(ctx context.Context, projectID string) (string, error)
- func (c *LiveGCFClient) GetSecret(ctx context.Context, projectID, secretID string) error
- func (c *LiveGCFClient) GetServiceRevisionInfo(ctx context.Context, projectID, region, serviceName string) (*ServiceRevisionInfo, error)
- func (c *LiveGCFClient) GetServiceTrafficEnvVars(ctx context.Context, projectID, region, serviceName string) (map[string]string, error)
- func (c *LiveGCFClient) GetWIFProvider(ctx context.Context, projectNumber, poolID, providerID string) (*WIFProviderInfo, error)
- func (c *LiveGCFClient) SetCloudRunInvoker(ctx context.Context, projectID, region, serviceName string) error
- func (c *LiveGCFClient) SetProjectIAMBinding(ctx context.Context, projectID, member, role string) error
- func (c *LiveGCFClient) SetSecretIAMBinding(ctx context.Context, resource, member, role string) error
- func (c *LiveGCFClient) UpdateFunction(ctx context.Context, projectID, region, functionName string, ...) (string, error)
- func (c *LiveGCFClient) UpdateFunctionEnvVars(ctx context.Context, projectID, region, functionName string, ...) (string, error)
- func (c *LiveGCFClient) UpdateServiceEnvVars(ctx context.Context, projectID, region, serviceName string, ...) (string, error)
- func (c *LiveGCFClient) UpdateWIFProvider(ctx context.Context, projectNumber, poolID, providerID string, ...) error
- func (c *LiveGCFClient) UploadFunctionSource(ctx context.Context, projectID, region string, sourceZip []byte) (json.RawMessage, error)
- func (c *LiveGCFClient) WaitForOperation(ctx context.Context, operationName string) error
- type MintDiscovery
- type OIDCProviderConfig
- type Provisioner
- func (p *Provisioner) AddRoleToMint(ctx context.Context, role, appID string) error
- func (p *Provisioner) DeleteAgentPEM(ctx context.Context, role string) error
- func (p *Provisioner) DeleteWIFProvider(ctx context.Context, providerID string) error
- func (p *Provisioner) DisableWIFProvider(ctx context.Context, providerID string) error
- func (p *Provisioner) DiscoverMint(ctx context.Context) (*MintDiscovery, error)
- func (p *Provisioner) EnsureMintServiceAccount(ctx context.Context) error
- func (p *Provisioner) EnsureOrgInMint(ctx context.Context, expectedURL string, org string) error
- func (p *Provisioner) EnsureOrgInWIFCondition(ctx context.Context, org string) error
- func (p *Provisioner) GetExistingRoleAppIDs(ctx context.Context) (map[string]string, error)
- func (p *Provisioner) GetFunctionURL(ctx context.Context) (string, error)
- func (p *Provisioner) GetServiceRevisionInfo(ctx context.Context) (*ServiceRevisionInfo, error)
- func (p *Provisioner) GetServiceTrafficEnvVars(ctx context.Context) (map[string]string, error)
- func (p *Provisioner) GrantOrgVertexAIAccess(ctx context.Context, org string) error
- func (p *Provisioner) Name() string
- func (p *Provisioner) OrgSecretNames() []string
- func (p *Provisioner) OrgVariableNames() []string
- func (p *Provisioner) Provision(ctx context.Context) (map[string]string, error)
- func (p *Provisioner) ProvisionWIF(ctx context.Context) (wifProvider string, err error)
- func (p *Provisioner) RegisterPerRepoWIF(ctx context.Context, repo string) error
- func (p *Provisioner) RemoveOrgFromMint(ctx context.Context, org string) error
- func (p *Provisioner) RemoveOrgFromWIFCondition(ctx context.Context, org string) error
- func (p *Provisioner) RemoveRepoFromMint(ctx context.Context, repo string) error
- func (p *Provisioner) RemoveRoleFromMint(ctx context.Context, role string) error
- func (p *Provisioner) SecretExists(ctx context.Context, role string) (bool, error)
- func (p *Provisioner) StoreAgentPEM(ctx context.Context, role string, pemData []byte) error
- type RevisionSummary
- type ServiceRevisionInfo
- type WIFProviderInfo
Constants ¶
const ( // DefaultInferencePool is the WIF pool used by inference commands. // Separate from the mint pool (defaultPool) so that mint and inference // lifecycle operations don't interfere with each other. DefaultInferencePool = "fullsend-inference" )
const PlaceholderOrg = "x0fullsend0placeholder"
PlaceholderOrg is the deploy-time placeholder used in the WIF condition and env vars before any real orgs are enrolled. Must pass mintcore.GitHubOrgPattern validation (used by Provision), but should not collide with any real GitHub org. The CLI rejects this value at enrollment time.
Variables ¶
var ErrFunctionNotFound = errors.New("mint function not found")
ErrFunctionNotFound is returned when the mint function does not exist.
var ErrSecretNotFound = errors.New("secret not found")
ErrSecretNotFound is returned when a Secret Manager secret does not exist.
Functions ¶
func DefaultFunctionSourceDir ¶
func DefaultFunctionSourceDir() string
DefaultFunctionSourceDir returns the default path to the Cloud Function source directory. This assumes the CLI is run from the repository root.
func LastWIFProviderCondition ¶ added in v0.31.0
LastWIFProviderCondition returns the AttributeCondition passed to the most recent CreateWIFProvider or UpdateWIFProvider call on a fake client, for cross-package test assertions. Returns "" if client isn't a fake or no call was made yet.
func ValidateProjectID ¶ added in v0.12.0
ValidateProjectID checks if a string is a valid GCP project ID.
func ValidateRegion ¶ added in v0.12.0
ValidateRegion checks if a string is a valid GCP region.
func ValidateRepoSlug ¶ added in v0.12.0
ValidateRepoSlug checks if a string is a valid GitHub repository name.
Types ¶
type Config ¶
type Config struct {
ProjectID string
Region string // default: "us-central1"
WIFPoolName string // default: "fullsend-pool"
WIFProvider string // default: "github-oidc"
GitHubOrgs []string
Repo string // per-repo mode: "owner/repo"; empty = per-org
FunctionSourceDir string // path to Cloud Function source directory
// AgentPEMs maps role → PEM private key data for all agent Apps.
AgentPEMs map[string][]byte
// AgentAppIDs maps role → GitHub App ID for all agent Apps.
AgentAppIDs map[string]string
// MintURL, if set, skips infrastructure deployment and uses the
// existing mint at this URL for PEM storage, org registration,
// per-repo WIF, and PEM auto-copy.
MintURL string
// DeployMode controls function deployment: auto (default) or skip.
DeployMode DeployMode
// Version is the fullsend semver (e.g. "0.27.0") to stamp on the
// deployed mint. Embedded directly into the source code at bundle time.
Version string
// Commit is the git commit SHA to stamp on the deployed mint.
// Embedded directly into the source code at bundle time.
Commit string
// PublicMint bootstraps ALLOWED_ORGS=* and a permissive WIF provider CEL.
PublicMint bool
}
Config holds the inputs for GCF mint provisioning.
type DeployMode ¶
type DeployMode int
DeployMode controls Cloud Function deployment behavior.
const ( // DeployAuto compares source hash; skips deploy if unchanged. DeployAuto DeployMode = iota // DeploySkip never redeploys; reuses the existing function URL. DeploySkip )
type FakeGCFOption ¶ added in v0.19.0
type FakeGCFOption func(*fakeGCFClient)
FakeGCFOption configures a client from NewFakeGCFClient.
func WithFakeErrors ¶ added in v0.19.0
func WithFakeErrors(errs map[string]error) FakeGCFOption
func WithFakeFunctionInfo ¶ added in v0.19.0
func WithFakeFunctionInfo(info *FunctionInfo) FakeGCFOption
func WithFakeRevisionInfo ¶ added in v0.19.0
func WithFakeRevisionInfo(info *ServiceRevisionInfo) FakeGCFOption
func WithFakeSecrets ¶ added in v0.19.0
func WithFakeSecrets(secrets map[string]bool) FakeGCFOption
func WithFakeTrafficEnvVars ¶ added in v0.19.0
func WithFakeTrafficEnvVars(env map[string]string) FakeGCFOption
func WithFakeWIFProvider ¶ added in v0.19.0
func WithFakeWIFProvider(p *WIFProviderInfo) FakeGCFOption
type FunctionConfig ¶
type FunctionConfig struct {
ServiceAccount string
EnvVars map[string]string
StorageSource json.RawMessage // structured object from generateUploadUrl response
EntryPoint string
Runtime string
}
FunctionConfig holds parameters for creating a Cloud Function.
type FunctionInfo ¶
type FunctionInfo struct {
Name string
State string
URI string
Region string
EnvVars map[string]string
}
FunctionInfo holds metadata about a deployed Cloud Function.
type GCFClient ¶
type GCFClient interface {
// Service account operations
CreateServiceAccount(ctx context.Context, projectID, saName, displayName string) error
// WIF operations
CreateWIFPool(ctx context.Context, projectNumber, poolID, displayName string) error
CreateWIFProvider(ctx context.Context, projectNumber, poolID, providerID string, cfg OIDCProviderConfig) error
GetWIFProvider(ctx context.Context, projectNumber, poolID, providerID string) (*WIFProviderInfo, error)
UpdateWIFProvider(ctx context.Context, projectNumber, poolID, providerID string, cfg OIDCProviderConfig) error
DisableWIFProvider(ctx context.Context, projectNumber, poolID, providerID string) error
DeleteWIFProvider(ctx context.Context, projectNumber, poolID, providerID string) error
// Secret Manager
GetSecret(ctx context.Context, projectID, secretID string) error
CreateSecret(ctx context.Context, projectID, secretID string) error
AddSecretVersion(ctx context.Context, projectID, secretID string, data []byte) error
AccessSecretVersion(ctx context.Context, projectID, secretID string) ([]byte, error)
DisableSecretVersion(ctx context.Context, projectID, secretID string) error
EnableSecretVersion(ctx context.Context, projectID, secretID string) error
DeleteSecret(ctx context.Context, projectID, secretID string) error
// IAM bindings
SetSecretIAMBinding(ctx context.Context, resource, member, role string) error
SetProjectIAMBinding(ctx context.Context, projectID, member, role string) error
// Cloud Run IAM (for function invoker policy)
SetCloudRunInvoker(ctx context.Context, projectID, region, serviceName string) error
// Cloud Functions v2
GetFunction(ctx context.Context, projectID, region, functionName string) (*FunctionInfo, error)
// GetCloudRunServiceURI returns the public URI of the Cloud Run service
// backing a Gen2 Cloud Function (same name as the function).
GetCloudRunServiceURI(ctx context.Context, projectID, region, serviceName string) (string, error)
UploadFunctionSource(ctx context.Context, projectID, region string, sourceZip []byte) (storageSource json.RawMessage, err error)
CreateFunction(ctx context.Context, projectID, region, functionName string, cfg FunctionConfig) (string, error)
UpdateFunction(ctx context.Context, projectID, region, functionName string, cfg FunctionConfig) (string, error)
UpdateFunctionEnvVars(ctx context.Context, projectID, region, functionName string, envVars map[string]string) (string, error)
// UpdateServiceEnvVars updates environment variables on the underlying
// Cloud Run service directly, bypassing the Cloud Functions API. This
// avoids triggering a source rebuild — only a new revision is created
// reusing the existing container image. Uses a multi-step approach:
// GETs the current service, PATCHes the template to create a new
// revision, GETs the service again to discover the revision name,
// then PATCHes traffic to pin 100% to that revision (REVISION-pinned,
// matching Cloud Functions deploy behavior). Returns the new revision
// name.
UpdateServiceEnvVars(ctx context.Context, projectID, region, serviceName string, envVars map[string]string) (string, error)
// GetServiceRevisionInfo returns Cloud Run service details including the
// traffic-serving revision, template revision, allocation type, and recent
// revision history. Used by mint status for revision awareness.
GetServiceRevisionInfo(ctx context.Context, projectID, region, serviceName string) (*ServiceRevisionInfo, error)
// GetServiceTrafficEnvVars reads environment variables from the Cloud Run
// revision currently serving traffic, rather than from the service template.
// This avoids reading stale data when the template and traffic-serving
// revision have diverged.
GetServiceTrafficEnvVars(ctx context.Context, projectID, region, serviceName string) (map[string]string, error)
WaitForOperation(ctx context.Context, operationName string) error
// Project number lookup
GetProjectNumber(ctx context.Context, projectID string) (string, error)
}
GCFClient abstracts GCP API operations needed by the provisioner.
func NewFakeGCFClient ¶ added in v0.19.0
func NewFakeGCFClient(opts ...FakeGCFOption) GCFClient
NewFakeGCFClient returns an in-memory GCFClient for tests.
type LiveGCFClient ¶
LiveGCFClient implements GCFClient using GCP REST APIs. It embeds *gcp.Client for shared ADC auth.
func NewLiveGCFClient ¶
func NewLiveGCFClient(quotaProject string) *LiveGCFClient
NewLiveGCFClient creates a new LiveGCFClient. The quotaProject is set as x-goog-user-project on every request so API quota is billed to the target project, not the shared ADC OAuth client project.
func (*LiveGCFClient) AccessSecretVersion ¶
func (c *LiveGCFClient) AccessSecretVersion(ctx context.Context, projectID, secretID string) ([]byte, error)
AccessSecretVersion reads the latest version of a Secret Manager secret.
func (*LiveGCFClient) AddSecretVersion ¶
func (c *LiveGCFClient) AddSecretVersion(ctx context.Context, projectID, secretID string, data []byte) error
AddSecretVersion adds a new version with the given data to an existing secret.
func (*LiveGCFClient) CreateFunction ¶
func (c *LiveGCFClient) CreateFunction(ctx context.Context, projectID, region, functionName string, cfg FunctionConfig) (string, error)
CreateFunction creates a Cloud Function v2.
func (*LiveGCFClient) CreateSecret ¶
func (c *LiveGCFClient) CreateSecret(ctx context.Context, projectID, secretID string) error
CreateSecret creates a Secret Manager secret.
func (*LiveGCFClient) CreateServiceAccount ¶
func (c *LiveGCFClient) CreateServiceAccount(ctx context.Context, projectID, saName, displayName string) error
CreateServiceAccount creates a new service account.
func (*LiveGCFClient) CreateWIFPool ¶
func (c *LiveGCFClient) CreateWIFPool(ctx context.Context, projectNumber, poolID, displayName string) error
CreateWIFPool creates a new WIF pool.
func (*LiveGCFClient) CreateWIFProvider ¶
func (c *LiveGCFClient) CreateWIFProvider(ctx context.Context, projectNumber, poolID, providerID string, cfg OIDCProviderConfig) error
CreateWIFProvider creates a WIF OIDC provider.
func (*LiveGCFClient) DeleteSecret ¶ added in v0.12.0
func (c *LiveGCFClient) DeleteSecret(ctx context.Context, projectID, secretID string) error
DeleteSecret permanently deletes a Secret Manager secret and all its versions.
func (*LiveGCFClient) DeleteWIFProvider ¶ added in v0.12.0
func (c *LiveGCFClient) DeleteWIFProvider(ctx context.Context, projectNumber, poolID, providerID string) error
DeleteWIFProvider permanently deletes a WIF provider.
func (*LiveGCFClient) DisableSecretVersion ¶ added in v0.12.0
func (c *LiveGCFClient) DisableSecretVersion(ctx context.Context, projectID, secretID string) error
DisableSecretVersion disables the latest version of a Secret Manager secret. The disable API rejects the "latest" alias, so we first resolve it to a numeric version via GET, then disable that version.
func (*LiveGCFClient) DisableWIFProvider ¶ added in v0.12.0
func (c *LiveGCFClient) DisableWIFProvider(ctx context.Context, projectNumber, poolID, providerID string) error
DisableWIFProvider sets a WIF provider's disabled state to true.
func (*LiveGCFClient) EnableSecretVersion ¶ added in v0.12.0
func (c *LiveGCFClient) EnableSecretVersion(ctx context.Context, projectID, secretID string) error
EnableSecretVersion enables the latest version of a Secret Manager secret. Mirrors DisableSecretVersion: resolves "latest" to a numeric version, then enables it. No-op if the version is already enabled or does not exist.
func (*LiveGCFClient) GetCloudRunServiceURI ¶ added in v0.30.0
func (c *LiveGCFClient) GetCloudRunServiceURI(ctx context.Context, projectID, region, serviceName string) (string, error)
GetCloudRunServiceURI returns the public URI of a Cloud Run service.
func (*LiveGCFClient) GetFunction ¶
func (c *LiveGCFClient) GetFunction(ctx context.Context, projectID, region, functionName string) (*FunctionInfo, error)
GetFunction checks if a Cloud Function exists and returns its info.
func (*LiveGCFClient) GetProjectNumber ¶
GetProjectNumber looks up the project number for a project ID.
func (*LiveGCFClient) GetSecret ¶
func (c *LiveGCFClient) GetSecret(ctx context.Context, projectID, secretID string) error
GetSecret checks that a Secret Manager secret exists.
func (*LiveGCFClient) GetServiceRevisionInfo ¶ added in v0.14.0
func (c *LiveGCFClient) GetServiceRevisionInfo(ctx context.Context, projectID, region, serviceName string) (*ServiceRevisionInfo, error)
GetServiceRevisionInfo returns Cloud Run service details including the traffic-serving revision, template revision, allocation type, and recent revision history.
func (*LiveGCFClient) GetServiceTrafficEnvVars ¶ added in v0.14.0
func (c *LiveGCFClient) GetServiceTrafficEnvVars(ctx context.Context, projectID, region, serviceName string) (map[string]string, error)
GetServiceTrafficEnvVars reads environment variables from the Cloud Run revision that is currently serving traffic, rather than from the service template. Although UpdateServiceEnvVars now pins traffic to the new revision, divergence can still occur if the traffic PATCH fails (partial failure) or from historical deployments before traffic pinning was added. This method resolves that by finding the revision that has traffic allocated and reading its container env vars directly.
Uses the trafficStatuses field (observed state) rather than the traffic field (desired config) so that revision names are always resolved — even for TRAFFIC_TARGET_ALLOCATION_TYPE_LATEST entries — and the data reflects actual serving state rather than desired configuration.
func (*LiveGCFClient) GetWIFProvider ¶
func (c *LiveGCFClient) GetWIFProvider(ctx context.Context, projectNumber, poolID, providerID string) (*WIFProviderInfo, error)
GetWIFProvider reads an existing WIF OIDC provider's configuration.
func (*LiveGCFClient) SetCloudRunInvoker ¶
func (c *LiveGCFClient) SetCloudRunInvoker(ctx context.Context, projectID, region, serviceName string) error
SetCloudRunInvoker ensures allUsers has roles/run.invoker on the Cloud Run service backing a Cloud Function. Uses read-modify-write with retry on 409 (etag conflict) to preserve existing bindings. The function's own OIDC validation is the security boundary.
func (*LiveGCFClient) SetProjectIAMBinding ¶
func (c *LiveGCFClient) SetProjectIAMBinding(ctx context.Context, projectID, member, role string) error
SetProjectIAMBinding sets an IAM binding on a GCP project. Uses read-modify-write with retry on 409 Conflict (etag mismatch).
func (*LiveGCFClient) SetSecretIAMBinding ¶
func (c *LiveGCFClient) SetSecretIAMBinding(ctx context.Context, resource, member, role string) error
SetSecretIAMBinding sets an IAM binding on a Secret Manager resource. Uses read-modify-write with retry on 409 Conflict (etag mismatch).
func (*LiveGCFClient) UpdateFunction ¶
func (c *LiveGCFClient) UpdateFunction(ctx context.Context, projectID, region, functionName string, cfg FunctionConfig) (string, error)
UpdateFunction updates an existing Cloud Function v2 using the PATCH API. It returns a long-running operation name that can be polled with WaitForOperation.
func (*LiveGCFClient) UpdateFunctionEnvVars ¶
func (c *LiveGCFClient) UpdateFunctionEnvVars(ctx context.Context, projectID, region, functionName string, envVars map[string]string) (string, error)
UpdateFunctionEnvVars updates only the environment variables of a Cloud Function v2, leaving build config and other service config untouched.
func (*LiveGCFClient) UpdateServiceEnvVars ¶ added in v0.12.0
func (c *LiveGCFClient) UpdateServiceEnvVars(ctx context.Context, projectID, region, serviceName string, envVars map[string]string) (string, error)
UpdateServiceEnvVars updates environment variables on the underlying Cloud Run service directly via the Cloud Run Admin API v2, bypassing the Cloud Functions API entirely. This avoids triggering a source rebuild — only a new Cloud Run revision is created reusing the existing container image.
Uses a multi-step approach to match Cloud Functions deploy behavior:
- GET current service to preserve container config
- PATCH template to create a new revision with updated env vars
- GET service to discover the new revision name
- PATCH traffic to pin 100% to the new revision (REVISION-pinned)
This ensures explicit revision-pinned traffic routing. If the traffic PATCH fails, the old revision continues serving — no traffic is lost. Returns the new revision name for CLI reporting and rollback reference.
func (*LiveGCFClient) UpdateWIFProvider ¶
func (c *LiveGCFClient) UpdateWIFProvider(ctx context.Context, projectNumber, poolID, providerID string, cfg OIDCProviderConfig) error
UpdateWIFProvider patches an existing WIF OIDC provider's attribute condition and allowed audiences.
func (*LiveGCFClient) UploadFunctionSource ¶
func (c *LiveGCFClient) UploadFunctionSource(ctx context.Context, projectID, region string, sourceZip []byte) (json.RawMessage, error)
UploadFunctionSource generates a signed upload URL and uploads the source zip. Returns the storage source URI for use in CreateFunction.
func (*LiveGCFClient) WaitForOperation ¶
func (c *LiveGCFClient) WaitForOperation(ctx context.Context, operationName string) error
WaitForOperation polls a long-running operation until it completes or the context is canceled. Polls every 5 seconds for up to 10 minutes.
type MintDiscovery ¶
MintDiscovery holds the results of a single GetFunction call, providing the URL, existing role-to-app-ID mappings, and per-repo WIF repos.
type OIDCProviderConfig ¶
type OIDCProviderConfig struct {
IssuerURI string
AttributeCondition string
AllowedAudiences []string
}
OIDCProviderConfig holds configuration for a WIF OIDC provider.
type Provisioner ¶
type Provisioner struct {
// contains filtered or unexported fields
}
Provisioner creates GCP infrastructure for OIDC-based token minting.
func NewProvisioner ¶
func NewProvisioner(cfg Config, gcpAPI GCFClient) *Provisioner
NewProvisioner creates a new Provisioner with defaults applied.
func (*Provisioner) AddRoleToMint ¶ added in v0.19.0
func (p *Provisioner) AddRoleToMint(ctx context.Context, role, appID string) error
AddRoleToMint registers a role's app ID in ROLE_APP_IDS and updates ALLOWED_ROLES on the traffic-serving Cloud Run revision.
func (*Provisioner) DeleteAgentPEM ¶ added in v0.19.0
func (p *Provisioner) DeleteAgentPEM(ctx context.Context, role string) error
DeleteAgentPEM permanently deletes the Secret Manager secret for the given role.
func (*Provisioner) DeleteWIFProvider ¶ added in v0.12.0
func (p *Provisioner) DeleteWIFProvider(ctx context.Context, providerID string) error
DeleteWIFProvider permanently deletes a WIF provider.
func (*Provisioner) DisableWIFProvider ¶ added in v0.12.0
func (p *Provisioner) DisableWIFProvider(ctx context.Context, providerID string) error
DisableWIFProvider sets a WIF provider's disabled field to true.
func (*Provisioner) DiscoverMint ¶
func (p *Provisioner) DiscoverMint(ctx context.Context) (*MintDiscovery, error)
DiscoverMint fetches the mint service once and returns its URL and ROLE_APP_IDS. Gen2 mint is backed by Cloud Run; when the Cloud Functions API is unavailable (common for WIF principals with run.admin only), discovery falls back to the Cloud Run API.
func (*Provisioner) EnsureMintServiceAccount ¶ added in v0.14.0
func (p *Provisioner) EnsureMintServiceAccount(ctx context.Context) error
EnsureMintServiceAccount creates the mint service account if it does not already exist. Call this before StoreAgentPEM so the IAM binding on secrets can reference the service account.
func (*Provisioner) EnsureOrgInMint ¶
EnsureOrgInMint validates that a mint function exists at expectedURL and that the given org is registered in ALLOWED_ORGS. If the org is missing, it updates the function's env vars to include it.
WARNING: read-modify-write without locking — concurrent calls from parallel per-repo installs sharing the same mint can race, causing one update to overwrite the other. Run installs sequentially when sharing a mint, or accept that a lost update will be corrected on the next run.
func (*Provisioner) EnsureOrgInWIFCondition ¶ added in v0.12.0
func (p *Provisioner) EnsureOrgInWIFCondition(ctx context.Context, org string) error
EnsureOrgInWIFCondition adds an org to the org-level WIF provider's attribute condition. Reads the existing condition, merges, and updates. Strips the deploy-time placeholder (PlaceholderOrg) if present. WARNING: read-modify-write without locking — concurrent calls may race.
func (*Provisioner) GetExistingRoleAppIDs ¶
GetExistingRoleAppIDs reads ROLE_APP_IDS from the deployed mint function. Returns (nil, nil) if the function doesn't exist or has no ROLE_APP_IDS.
func (*Provisioner) GetFunctionURL ¶
func (p *Provisioner) GetFunctionURL(ctx context.Context) (string, error)
GetFunctionURL returns the URL of the deployed mint function.
func (*Provisioner) GetServiceRevisionInfo ¶ added in v0.14.0
func (p *Provisioner) GetServiceRevisionInfo(ctx context.Context) (*ServiceRevisionInfo, error)
GetServiceRevisionInfo queries the Cloud Run service for revision details including traffic routing, template divergence, and recent revision history.
func (*Provisioner) GetServiceTrafficEnvVars ¶ added in v0.14.0
GetServiceTrafficEnvVars reads env vars from the traffic-serving Cloud Run revision. This is a convenience wrapper around the GCFClient method.
func (*Provisioner) GrantOrgVertexAIAccess ¶ added in v0.12.0
func (p *Provisioner) GrantOrgVertexAIAccess(ctx context.Context, org string) error
GrantOrgVertexAIAccess grants roles/aiplatform.user to an org's .fullsend repo principal so that enrolled org workflows can call Agent Platform.
func (*Provisioner) Name ¶
func (p *Provisioner) Name() string
Name returns the dispatcher identifier.
func (*Provisioner) OrgSecretNames ¶
func (p *Provisioner) OrgSecretNames() []string
OrgSecretNames returns nil — the mint uses Secret Manager, not org secrets.
func (*Provisioner) OrgVariableNames ¶
func (p *Provisioner) OrgVariableNames() []string
OrgVariableNames returns the org variables this dispatcher manages.
func (*Provisioner) Provision ¶
Provision creates the GCP infrastructure for the token mint.
When MintURL is empty, deploys the full mint infrastructure:
- Look up project number
- Create/verify service account
- Create/verify WIF pool + provider
- Grant Agent Platform access to each org's WIF principalSet (direct WIF)
- Store all agent PEMs in Secret Manager
- Grant SA access to all role secrets
- Deploy Cloud Function
- Return FULLSEND_MINT_URL
When MintURL is set, reuses an existing mint:
- Store all agent PEMs in Secret Manager
- Return the provided MintURL
func (*Provisioner) ProvisionWIF ¶
func (p *Provisioner) ProvisionWIF(ctx context.Context) (wifProvider string, err error)
ProvisionWIF creates the WIF infrastructure (service account, pool, provider, principal binding) needed for GitHub Actions to authenticate via OIDC. All operations are idempotent. Returns the full WIF provider resource path and service account email.
func (*Provisioner) RegisterPerRepoWIF ¶
func (p *Provisioner) RegisterPerRepoWIF(ctx context.Context, repo string) error
RegisterPerRepoWIF adds a repo to the mint's PER_REPO_WIF_REPOS env var so the mint routes OIDC tokens from that repo to a dedicated WIF provider instead of the org-level default. Idempotent — skips repos already listed. Not safe for concurrent calls — run per-repo installs sequentially when sharing a mint.
func (*Provisioner) RemoveOrgFromMint ¶ added in v0.12.0
func (p *Provisioner) RemoveOrgFromMint(ctx context.Context, org string) error
RemoveOrgFromMint removes an org from ALLOWED_ORGS. Role app IDs are shared across orgs and are not modified. Uses read-modify-write via UpdateServiceEnvVars (Cloud Run API, no rebuild).
func (*Provisioner) RemoveOrgFromWIFCondition ¶ added in v0.12.0
func (p *Provisioner) RemoveOrgFromWIFCondition(ctx context.Context, org string) error
RemoveOrgFromWIFCondition removes an org from the org-level WIF provider's attribute condition. WARNING: read-modify-write without locking — concurrent calls may race.
func (*Provisioner) RemoveRepoFromMint ¶ added in v0.12.0
func (p *Provisioner) RemoveRepoFromMint(ctx context.Context, repo string) error
RemoveRepoFromMint removes a repo from PER_REPO_WIF_REPOS. Uses read-modify-write via UpdateServiceEnvVars.
func (*Provisioner) RemoveRoleFromMint ¶ added in v0.19.0
func (p *Provisioner) RemoveRoleFromMint(ctx context.Context, role string) error
RemoveRoleFromMint removes a role-only entry from ROLE_APP_IDS and updates ALLOWED_ROLES on the traffic-serving Cloud Run revision.
func (*Provisioner) SecretExists ¶
SecretExists checks whether the Secret Manager secret for the given role exists.
func (*Provisioner) StoreAgentPEM ¶
StoreAgentPEM persists a role's PEM in Secret Manager. Called during App setup so each PEM is stored immediately after creation.
type RevisionSummary ¶ added in v0.14.0
type RevisionSummary struct {
Name string // short name, e.g. "fullsend-mint-00114-fm9"
CreateTime string // RFC3339 timestamp
Active bool // true if the revision has conditions indicating it is active/ready
}
RevisionSummary is a brief snapshot of a Cloud Run revision.
type ServiceRevisionInfo ¶ added in v0.14.0
type ServiceRevisionInfo struct {
// TrafficRevision is the full resource name of the revision currently serving traffic.
TrafficRevision string
// TrafficRevisionShort is the short revision name (e.g., "fullsend-mint-00114-fm9").
TrafficRevisionShort string
// TrafficAllocType is the traffic allocation type (e.g., "TRAFFIC_TARGET_ALLOCATION_TYPE_LATEST").
TrafficAllocType string
// TrafficPercent is the percentage of traffic the serving revision receives.
TrafficPercent int
// TemplateRevision is the revision name from the service template (latest created).
TemplateRevision string
// TemplateMatchesTraffic is true when the template's latest revision matches
// the traffic-serving revision.
TemplateMatchesTraffic bool
// RecentRevisions lists the most recent revisions (up to 5), newest first.
RecentRevisions []RevisionSummary
// TrafficEnvVars holds the env vars from the traffic-serving revision.
TrafficEnvVars map[string]string
}
ServiceRevisionInfo holds Cloud Run service details including which revision is serving traffic, recent revision history, and whether the service template diverges from the traffic-serving revision.
type WIFProviderInfo ¶
WIFProviderInfo holds metadata about a WIF OIDC provider.