Documentation
¶
Index ¶
- Constants
- func DeployEnv(env []string) []string
- func DescribeDeploy(req *mcp.CallToolRequest, in DeployInput, out DeployOutput) (string, string, bool)
- func ParseVersionCommit(out string) string
- type Calls
- type DeployInput
- type DeployOutput
- type DeployProc
- type MCP
- type NewContextRun
- type ReadyState
- type ReadyView
- type Service
- func (p *Service) DeployReady() *ReadyState
- func (p *Service) DeployReadyTick(ctx context.Context)
- func (p *Service) NewContextsUnderWay(ctx context.Context) []NewContextRun
- func (p *Service) ServeDeployOwner(w http.ResponseWriter, r *http.Request)
- func (p *Service) ServeDeployQueue(w http.ResponseWriter, r *http.Request)
- func (p *Service) ServeDeployReady(w http.ResponseWriter, r *http.Request, sub string)
- func (p *Service) ServeNewContexts(w http.ResponseWriter, r *http.Request)
- func (p *Service) SetDeployReady()
- func (p *Service) SetRunningCommit(commit string)
- type Settings
Constants ¶
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" )
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 ¶
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 ¶
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 ¶
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)
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 (*Service) DeployReady ¶
func (p *Service) DeployReady() *ReadyState
func (*Service) DeployReadyTick ¶
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 ¶
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 ¶
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.