Documentation
¶
Overview ¶
Package executor abstracts the CI muscle the control plane drives: serve receives the webhooks and asks a Backend to start/cancel/probe builds. Only cloudbuild is implemented; other shapes (github-actions workflow_dispatch, gitlab, generic webhook) are documented futures behind the same seam.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend interface {
// Start begins a run and returns its backend reference.
Start(ctx context.Context, req RunRequest) (Ref, error)
// Cancel stops an in-flight run. Idempotent; cancelling a finished run is
// not an error.
Cancel(ctx context.Context, ref Ref) error
// Probe reports the run's current phase — used by the start watchdog to
// distinguish "still provisioning" from "never started".
Probe(ctx context.Context, ref Ref) (Phase, error)
}
Backend starts and manages CI runs.
type CloudBuild ¶
type CloudBuild struct {
// contains filtered or unexported fields
}
CloudBuild drives Google Cloud Build triggers via the REST API (projects.locations.triggers.run / builds.cancel / builds.get). The trigger definitions stay terraform-managed; serve only runs them by name.
func NewCloudBuild ¶
func NewCloudBuild(project, region string, triggers map[string]string, token TokenFunc) *CloudBuild
NewCloudBuild builds the backend. triggers maps run kinds ("plan"/"apply") to Cloud Build trigger names in project/region.
func (*CloudBuild) Cancel ¶
func (c *CloudBuild) Cancel(ctx context.Context, ref Ref) error
Cancel stops an in-flight build. A build already finished (or being torn down) is treated as success — cancel is best-effort supersede cleanup.
func (*CloudBuild) Start ¶
func (c *CloudBuild) Start(ctx context.Context, req RunRequest) (Ref, error)
Start invokes triggers.run for the request's kind. The exact commit rides as commitSha; _EXECUTION_ID / _PR_NUMBER substitutions let the build report under the serve-minted execution id.
type Phase ¶
type Phase string
Phase is the backend's view of a run, for the start watchdog.
const ( PhaseQueued Phase = "queued" // accepted, not yet provisioned PhaseWorking Phase = "working" // machine running PhaseDone Phase = "done" // finished successfully PhaseFailed Phase = "failed" // finished unsuccessfully (incl. cancelled) PhaseNotFound Phase = "notfound" // backend has no such run )
type Ref ¶
type Ref struct {
ID string
}
Ref identifies a started run at the backend (e.g. a Cloud Build build id).
type RunRequest ¶
type RunRequest struct {
Kind string // "plan" | "apply" (selects the backend trigger)
Environment string
SHA string // exact commit to build
Branch string // branch ref for backends that need one
ExecutionID string // serve-minted execution id the runner must report under
PR int
}
RunRequest describes one CI run to start.