executor

package
v0.44.1 Latest Latest
Warning

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

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

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

func (c *CloudBuild) Probe(ctx context.Context, ref Ref) (Phase, error)

Probe reports the build's phase.

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.

type TokenFunc

type TokenFunc func(ctx context.Context) (string, error)

TokenFunc returns a currently-valid OAuth2 access token (cloud-platform scope). Injected — same pattern as the gcp-pam approval backend — so the package has no GCP credential dependency and tests fake the endpoint.

Jump to

Keyboard shortcuts

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