Help us shape the future of Go! Take the 2026 Go Developer Survey

deploys

package
v0.4.0-beta.12 Latest Latest
Warning

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

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

Documentation

Overview

Package deploys keeps the per-deployment history of deploys: which revision was deployed, what triggered it, how it went and its output. Rollback picks a past record and redeploys its revision.

Index

Constants

View Source
const (

	// MaxLogBytes caps one deploy's stored output.
	MaxLogBytes = 1 << 20
)

Variables

View Source
var ErrNotFound = errors.New("deploy record not found")

Functions

This section is empty.

Types

type LogWriter

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

LogWriter appends a deploy's output lines to its log file and stops at MaxLogBytes.

func (*LogWriter) Close

func (w *LogWriter) Close() error

func (*LogWriter) Line

func (w *LogWriter) Line(line string)

func (*LogWriter) Phase

func (w *LogWriter) Phase(phase Phase)

Phase records that the deploy entered a phase at this point of its output.

type Phase

type Phase string

Phase is where a deploy is in its life. Queued, building and deploying are set while it runs. Active marks the newest successful deploy, which is the one serving; older successful ones read as removed.

const (
	PhaseQueued    Phase = "queued"
	PhaseBuilding  Phase = "building"
	PhaseDeploying Phase = "deploying"
	PhaseActive    Phase = "active"
	PhaseFailed    Phase = "failed"
	PhaseRemoved   Phase = "removed"
)

type PhaseStart

type PhaseStart struct {
	Phase Phase `json:"phase"`
	From  int   `json:"from"`
}

PhaseStart marks the output line at which a deploy entered a phase, so a log can be split into its build and deploy parts.

type Record

type Record struct {
	ID         string     `json:"id"`
	Action     string     `json:"action,omitempty"`
	Revision   string     `json:"revision,omitempty"`
	Branch     string     `json:"branch,omitempty"`
	Message    string     `json:"message,omitempty"`
	Trigger    Trigger    `json:"trigger"`
	Status     Status     `json:"status"`
	Phase      Phase      `json:"phase"`
	Error      string     `json:"error,omitempty"`
	StartedAt  time.Time  `json:"started_at"`
	FinishedAt *time.Time `json:"finished_at,omitempty"`
}

type Status

type Status string
const (
	StatusRunning   Status = "running"
	StatusSucceeded Status = "succeeded"
	StatusFailed    Status = "failed"
)

type Store

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

func NewStore

func NewStore(deploymentsPath string) *Store

func (*Store) Delete

func (s *Store) Delete(deployment string) error

func (*Store) Finish

func (s *Store) Finish(deployment, id, revision, message string, deployErr error) error

Finish closes a running record. A non-empty revision replaces the requested one with the commit that was actually fetched, and message is that commit's subject.

func (*Store) Get

func (s *Store) Get(deployment, id string) (Record, error)

func (*Store) List

func (s *Store) List(deployment string) ([]Record, error)

List returns the records newest first. Only the newest successful deploy is active; earlier successful ones are reported as removed.

func (*Store) OpenLog

func (s *Store) OpenLog(deployment, id string) (*LogWriter, error)

func (*Store) ReadLog

func (s *Store) ReadLog(deployment, id string) (string, []PhaseStart, error)

ReadLog returns a deploy's stored output and where each phase began in it.

func (*Store) SetPhase

func (s *Store) SetPhase(deployment, id string, phase Phase) error

SetPhase moves a running record to another phase.

func (*Store) Start

func (s *Store) Start(deployment string, rec Record) (Record, error)

Start records a new running deploy, newest first, and returns it.

type Trigger

type Trigger string
const (
	TriggerManual   Trigger = "manual"
	TriggerPush     Trigger = "push"
	TriggerPR       Trigger = "pull_request"
	TriggerRollback Trigger = "rollback"
)

Jump to

Keyboard shortcuts

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