deploy

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 24 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// SettingDeployBinary names the installed binary, whose commit is "what is deployed". Unset means this hub's own
	// executable, which is the installed binary on every hub that has not been moved.
	SettingDeployBinary = "deploy_binary"
	// SettingDeployScript names the script a click runs. Unset means scripts/live/deploy-ready.ps1 in the
	// integration checkout.
	SettingDeployScript = "deploy_script"

	// ReadyEvent is the stream event a board re-fetches on. A delta, like `deps` and `audit`.
	ReadyEvent = "deploy-ready"
)
View Source
const SettingDeployOwner = "deploy_owner"

SettingDeployOwner is the hub setting naming the deploy owner, a handle or `name@room`. Resolved at each call, the way report_to is, because the owner's card id changes when it is relaunched. Unset means no owner: a request is refused rather than guessed at.

Variables

This section is empty.

Functions

func DeployEnv

func DeployEnv(env []string) []string

DeployEnv drops every ATRIUM_* variable from env. The hub runs inside a session's environment more often than not, and ATRIUM_NEW_BUILD or ATRIUM_LOCATION there would point the deploy at a binary or a hub nobody checked. The script reads what it needs (ATRIUM_HOSTS) from the User environment itself.

func DescribeDeploy

func DescribeDeploy(req *mcp.CallToolRequest, in DeployInput, out DeployOutput) (string, string, bool)

func ParseVersionCommit

func ParseVersionCommit(out string) string

Types

type Calls

type Calls struct {
	// Settings is the hub's own settings. Nil on a hub with no store.
	Settings    func() Settings
	RepoFor     func(name string) (gitsync.Repo, error)
	Runner      func() *gitsync.Runner
	Watchers    func() int
	Broadcast   func(ev wire.Event)
	Rooms       func() []wire.Attached
	Attached    func() []wire.Attached
	RoomGet     func(ctx context.Context, room, path string, out any) bool
	RecordAudit func(room, kind, detail string)
}

Calls is every call out of the deploy into the rest of the hub.

type DeployInput

type DeployInput struct {
	Action     string   `json:"action" jsonschema:"request, start, wait, cancel or status"`
	Room       string   `json:"room,omitempty" jsonschema:"the room to deploy. default: your own"`
	Why        string   `json:"why,omitempty" jsonschema:"request: what the deploy is for. cancel: why it is called off"`
	SHA        string   `json:"sha,omitempty" jsonschema:"request: the commit you need live, if there is one"`
	Exempt     []string `json:"exempt,omitempty" jsonschema:"start: up to three cards the deploy itself needs, never held"`
	MaxSeconds int      `json:"max_seconds,omitempty" jsonschema:"wait: how long to wait for the room to go quiet, at most 600"`
}

type DeployOutput

type DeployOutput struct {
	Room    string          `json:"room"`
	State   string          `json:"state"`
	Owner   string          `json:"owner,omitempty"`
	Note    string          `json:"note,omitempty"`
	Pending []deployAsk     `json:"pending,omitempty"`
	Running []deployAsk     `json:"running,omitempty"`
	Hold    json.RawMessage `json:"hold,omitempty"`
	Busy    []deployBusy    `json:"busy,omitempty"`
	Ungated []string        `json:"ungated,omitempty"`
}

type DeployProc

type DeployProc struct {
	Pid  int
	Wait func() (int, error)
}

DeployProc is a started script. Wait blocks until it exits and returns the exit code.

type MCP

type MCP struct {
	ctl.Caller
	// Settings is the hub's settings, where requests and the owner are kept. Nil on a hub with no store.
	Settings func() Settings
	// Mu serialises a room's requests. It is the control server's, so every MCP made from it shares one.
	Mu *sync.Mutex
	// Say sends a message to a card as the caller.
	Say func(ctx context.Context, req *mcp.CallToolRequest, to, text string) error
}

MCP is the deploy tool. The Caller is the hub's control server.

func (*MCP) DeployHandler

func (c *MCP) DeployHandler(ctx context.Context, req *mcp.CallToolRequest, in DeployInput) (
	*mcp.CallToolResult, DeployOutput, error)

func (*MCP) RegisterDeploy

func (c *MCP) RegisterDeploy(s *mcp.Server, class ctl.Class)

type NewContextRun

type NewContextRun struct {
	Room  string `json:"room"`
	Card  string `json:"card"`
	Name  string `json:"name"`
	Step  string `json:"step"`
	N     int    `json:"n"`
	Since string `json:"since,omitempty"`
}

NewContextRun is one card with a run in flight, as the board lists it.

type ReadyState

type ReadyState struct {
	Mu sync.Mutex

	// Seams for a test. In production both are the real thing.
	Installed func(ctx context.Context, p *Service) (string, error)
	// Bound is how long one pass may run, deployReadyBound unless a test shortens it.
	Bound time.Duration
	Spawn func(script, tip string) (*DeployProc, error)
	// clearing is the new contexts under way. Nil means ask the attached rooms.
	Clearing func(ctx context.Context) []NewContextRun

	Checker *deployready.Checker

	HaveRep bool
	// inflight is true while one pass reads git. The lock is not held for it.
	Inflight bool
	// contains filtered or unexported fields
}

type ReadyView

type ReadyView struct {
	deployready.Report
	Deploy deployRun `json:"deploy"`
	// Building is true while a pass is reading git, or none has finished yet. Computed and AgeSeconds say how old
	// the answer is, and are absent until the first pass has finished. See readyCached.
	Building   bool   `json:"building"`
	Computed   string `json:"computed,omitempty"`
	AgeSeconds int    `json:"age_seconds"`
	// Script is what a click would run, so the board can say so. Empty when there is no way to run one.
	Script string `json:"script,omitempty"`
}

ReadyView is what GET answers: the report, flat, and where a deploy stands.

type Service

type Service struct {
	Calls
	// contains filtered or unexported fields
}

Service is the deploy readiness, the deploy queue, the new contexts under way and the deploy owner. See mcp.go for the tool.

func New

func New(c Calls) *Service

New is a Service with deploy-ready off.

func (*Service) DeployReady

func (p *Service) DeployReady() *ReadyState

func (*Service) DeployReadyTick

func (p *Service) DeployReadyTick(ctx context.Context)

DeployReadyTick re-reads the answer once a minute and tells watching boards when it moved. It deploys nothing. Skipped while nobody is watching, because the next GET pays for the same pass.

func (*Service) NewContextsUnderWay

func (p *Service) NewContextsUnderWay(ctx context.Context) []NewContextRun

NewContextsUnderWay asks each attached room for its cards and keeps the ones with a run that has not failed. A failed chip is not under way: nothing is typing and a restart loses nothing.

func (*Service) ServeDeployOwner

func (p *Service) ServeDeployOwner(w http.ResponseWriter, r *http.Request)

ServeDeployOwner answers GET and PUT /_hub/deploy-owner, `{"owner": "merge"}`. Set from the hub's machine only, like the launch caps: who may take a room down is not something a board reached over an overlay decides. Empty clears it.

func (*Service) ServeDeployQueue

func (p *Service) ServeDeployQueue(w http.ResponseWriter, r *http.Request)

func (*Service) ServeDeployReady

func (p *Service) ServeDeployReady(w http.ResponseWriter, r *http.Request, sub string)

ServeDeployReady answers /_hub/deploy-ready and /_hub/deploy-ready/deploy.

func (*Service) ServeNewContexts

func (p *Service) ServeNewContexts(w http.ResponseWriter, r *http.Request)

ServeNewContexts answers GET /_hub/new-contexts with the runs under way, so a deploy script can wait on them.

func (*Service) SetDeployReady

func (p *Service) SetDeployReady()

SetDeployReady turns the state on. A hub that never calls it answers /_hub/deploy-ready with 404.

func (*Service) SetRunningCommit

func (p *Service) SetRunningCommit(commit string)

SetRunningCommit says which commit this hub's own binary was built from. Empty means the hub cannot say, and the queue then falls back to the installed binary's commit.

type Settings

type Settings interface {
	HubSetting(name string) (string, error)
	SetHubSetting(name, value string) error
}

Settings is the part of the hub's store the deploy reads and writes.

Jump to

Keyboard shortcuts

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