builds

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package builds coordinates build lifecycle between DB and builder.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ImageTag

func ImageTag(tenantID, serviceID, buildID string) string

ImageTag generates a deterministic image tag for local registry. Uses full IDs to prevent collisions between tenants.

Types

type Build

type Build struct {
	ID           string `json:"id"`
	ServiceID    string `json:"service_id"`
	ServiceName  string `json:"service_name,omitempty"`
	TenantID     string `json:"tenant_id"`
	Status       string `json:"status"`
	SourceType   string `json:"source_type"`
	SourceURL    string `json:"source_url,omitempty"`
	SourceRef    string `json:"source_ref"`
	Image        string `json:"image,omitempty"`
	NixpacksPlan string `json:"nixpacks_plan,omitempty"`
	Log          string `json:"-"`
	StartedAt    *int64 `json:"started_at,omitempty"`
	FinishedAt   *int64 `json:"finished_at,omitempty"`
	CreatedAt    int64  `json:"created_at"`
}

Build represents a build record.

type DeployFunc

type DeployFunc func(ctx context.Context, tenantID, serviceID, imageTag, buildID string) error

DeployFunc is called when a build succeeds to deploy the resulting image. The buildID parameter links the deployment to the originating build record.

type Manager

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

Manager coordinates build lifecycle.

func NewManager

func NewManager(db *sql.DB, b buildExecutor, deployFn DeployFunc) *Manager

NewManager creates a build manager.

func (*Manager) CancelAllForTenant

func (m *Manager) CancelAllForTenant(ctx context.Context, tenantID string) error

CancelAllForTenant cancels all pending and running builds for a tenant. Used during tenant suspension to free build slots and prevent orphaned builds.

func (*Manager) CancelBuild

func (m *Manager) CancelBuild(ctx context.Context, tenantID, buildID string) error

CancelBuild cancels a running build.

func (*Manager) GetBuild

func (m *Manager) GetBuild(ctx context.Context, tenantID, buildID string) (*Build, error)

GetBuild returns a build by ID, scoped to tenant.

func (*Manager) GetBuildLogs

func (m *Manager) GetBuildLogs(ctx context.Context, tenantID, buildID string) (string, error)

GetBuildLogs returns the full build log.

func (*Manager) ListBuilds

func (m *Manager) ListBuilds(ctx context.Context, tenantID, serviceID string) ([]*Build, error)

ListBuilds returns builds for a service, scoped to tenant.

func (*Manager) ListTenantBuilds

func (m *Manager) ListTenantBuilds(ctx context.Context, tenantID string, limit int) ([]*Build, error)

ListTenantBuilds returns recent builds across all services for a tenant.

func (*Manager) StartBuild

func (m *Manager) StartBuild(ctx context.Context, tenantID, serviceID string, req StartBuildRequest) (*Build, error)

StartBuild creates a build record and starts the build asynchronously.

func (*Manager) StreamBuildLogs

func (m *Manager) StreamBuildLogs(ctx context.Context, tenantID, buildID string, w io.Writer) error

StreamBuildLogs writes the existing log then streams new lines.

type StartBuildRequest

type StartBuildRequest struct {
	SourceType string `json:"source_type"`
	SourceURL  string `json:"source_url"`
	SourceRef  string `json:"source_ref"`
}

StartBuildRequest holds parameters for starting a build.

Jump to

Keyboard shortcuts

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