// Code generated by seatgen from the seat definitions; DO NOT EDIT. // Package nodebuildnode is the contract of the seat "node-build-node", defined whole (seats/node-build-node/seat.json): The Node build module on a node: it takes the asks of the builder and the checker, runs them as steps and answers. package nodebuildnode import ( "bytes" "encoding/json" "errors" "strings" "time" ) // Seat is the seat's name. const Seat = "node-build-node" const ( VerbCurrent = "current" VerbPause = "pause" VerbResume = "resume" ) const ( AcceptDelivery = "delivery" AcceptCheck = "check" AcceptRecheck = "recheck" ) // Verbs is every verb the seat serves, in its definition's order: a new copy each call. func Verbs() []string { return []string{VerbCurrent, VerbPause, VerbResume} } // AcceptSubjectDelivery is where delivery is sent. const AcceptSubjectDelivery = "mesh.seat.node-build-node.accept.delivery" // AcceptSubjectCheck is where check is sent. const AcceptSubjectCheck = "mesh.seat.node-build-node.accept.check" // AcceptSubjectRecheck is where recheck is sent. const AcceptSubjectRecheck = "mesh.seat.node-build-node.accept.recheck" const ( StateSteps = "steps" StatePauses = "pauses" StateToolchains = "toolchains" ) // StepsByNodeIDKey is the key of one value of the state steps under the form ".". func StepsByNodeIDKey(node, id string) string { return node + "." + id } // ParseStepsByNodeIDKey reads the parts of a key of the form ".", in the order of the form; the last result is false for a key of another form. func ParseStepsByNodeIDKey(key string) (string, string, bool) { rest := key v0, after0, found0 := strings.Cut(rest, ".") if !found0 || v0 == "" { return "", "", false } rest = after0 if rest == "" { return "", "", false } v2 := rest rest = "" if rest != "" { return "", "", false } return v0, v2, true } // DecodeStepsByNodeIDValue reads one value of the state steps under the form ".", refusing a field StepsByNodeIDValue does not know and any text after the value. func DecodeStepsByNodeIDValue(raw []byte) (StepsByNodeIDValue, error) { var v StepsByNodeIDValue dec := json.NewDecoder(bytes.NewReader(raw)) dec.DisallowUnknownFields() if err := dec.Decode(&v); err != nil { return v, err } if dec.More() { return v, errors.New("text after the value") } return v, nil } // PausesByPausedNodeKey is the key of one value of the state pauses under the form "paused.". func PausesByPausedNodeKey(node string) string { return "paused." + node } // ParsePausesByPausedNodeKey reads the parts of a key of the form "paused.", in the order of the form; the last result is false for a key of another form. func ParsePausesByPausedNodeKey(key string) (string, bool) { rest := key if !strings.HasPrefix(rest, "paused.") { return "", false } rest = rest[7:] if rest == "" { return "", false } v1 := rest rest = "" if rest != "" { return "", false } return v1, true } // DecodePausesByPausedNodeValue reads one value of the state pauses under the form "paused.", refusing a field PausesByPausedNodeValue does not know and any text after the value. func DecodePausesByPausedNodeValue(raw []byte) (PausesByPausedNodeValue, error) { var v PausesByPausedNodeValue dec := json.NewDecoder(bytes.NewReader(raw)) dec.DisallowUnknownFields() if err := dec.Decode(&v); err != nil { return v, err } if dec.More() { return v, errors.New("text after the value") } return v, nil } // PausesByCapacityNodeKey is the key of one value of the state pauses under the form "capacity.". func PausesByCapacityNodeKey(node string) string { return "capacity." + node } // ParsePausesByCapacityNodeKey reads the parts of a key of the form "capacity.", in the order of the form; the last result is false for a key of another form. func ParsePausesByCapacityNodeKey(key string) (string, bool) { rest := key if !strings.HasPrefix(rest, "capacity.") { return "", false } rest = rest[9:] if rest == "" { return "", false } v1 := rest rest = "" if rest != "" { return "", false } return v1, true } // DecodePausesByCapacityNodeValue reads one value of the state pauses under the form "capacity.", refusing a field PausesByCapacityNodeValue does not know and any text after the value. func DecodePausesByCapacityNodeValue(raw []byte) (PausesByCapacityNodeValue, error) { var v PausesByCapacityNodeValue dec := json.NewDecoder(bytes.NewReader(raw)) dec.DisallowUnknownFields() if err := dec.Decode(&v); err != nil { return v, err } if dec.More() { return v, errors.New("text after the value") } return v, nil } // ToolchainsByNodeLanguageKey is the key of one value of the state toolchains under the form ".". func ToolchainsByNodeLanguageKey(node, language string) string { return node + "." + language } // ParseToolchainsByNodeLanguageKey reads the parts of a key of the form ".", in the order of the form; the last result is false for a key of another form. func ParseToolchainsByNodeLanguageKey(key string) (string, string, bool) { rest := key v0, after0, found0 := strings.Cut(rest, ".") if !found0 || v0 == "" { return "", "", false } rest = after0 if rest == "" { return "", "", false } v2 := rest rest = "" if rest != "" { return "", "", false } return v0, v2, true } // DecodeToolchainsByNodeLanguageValue reads one value of the state toolchains under the form ".", refusing a field ToolchainsByNodeLanguageValue does not know and any text after the value. func DecodeToolchainsByNodeLanguageValue(raw []byte) (ToolchainsByNodeLanguageValue, error) { var v ToolchainsByNodeLanguageValue dec := json.NewDecoder(bytes.NewReader(raw)) dec.DisallowUnknownFields() if err := dec.Decode(&v); err != nil { return v, err } if dec.More() { return v, errors.New("text after the value") } return v, nil } // AskArtifact is one artifact of a build ask: built from the fetched tree, or copied from an upstream pin. type AskArtifact struct { Artifact string `json:"artifact"` From string `json:"from,omitempty"` Seat string `json:"seat,omitempty"` Version string `json:"version,omitempty"` } // BuildAnswer is a type of the contract. type BuildAnswer struct { Artifacts []BuiltArtifact `json:"artifacts"` Imports []string `json:"imports,omitempty"` OutOfStep []string `json:"out-of-step,omitempty"` Toolchain *ToolchainUsed `json:"toolchain,omitempty"` } // BuiltArtifact is one artifact a build made: its digest and the reference it was published under. type BuiltArtifact struct { Artifact string `json:"artifact"` Digest string `json:"digest"` Reference string `json:"reference,omitempty"` } // Capacity is how many steps the node runs at once. type Capacity struct { // when (RFC 3339 time) At *time.Time `json:"at,omitempty"` BuildHours string `json:"build-hours,omitempty"` BuildHoursFault string `json:"build-hours-fault,omitempty"` ByCpu int64 `json:"by-cpu,omitempty"` Configured int64 `json:"configured"` ConfiguredFrom string `json:"configured-from,omitempty"` CoresPerStep float64 `json:"cores-per-step,omitempty"` Effective int64 `json:"effective"` Ineligible string `json:"ineligible,omitempty"` OutsideHours bool `json:"outside-hours,omitempty"` QuotaCores float64 `json:"quota-cores,omitempty"` QuotaFrom string `json:"quota-from,omitempty"` // the layout version V int64 `json:"v,omitempty"` Why string `json:"why"` } // CheckAnswer is a type of the contract. type CheckAnswer struct { Fetch Fetch `json:"fetch"` Levels []LevelAnswer `json:"levels,omitempty"` } // ComposeAnswer is a type of the contract. type ComposeAnswer struct { Built bool `json:"built"` Key string `json:"key,omitempty"` // the compose-candidate verdict Verdict any `json:"verdict,omitempty"` } // FetchBesideItem is a type of the contract. type FetchBesideItem struct { Commit string `json:"commit"` Repository string `json:"repository"` } // Fetch is what a build module's fetch tool is asked: the repository and the full commit, the pull request's ref when only its head carries the commit, the trunk commit to merge onto for a merge preview, the module's directory and named paths, the mesh packages to build against, and the sibling repositories placed beside. type Fetch struct { // the trunk commit a merge preview merges onto Base string `json:"base,omitempty"` // the sibling repositories placed beside the fetched tree Beside []FetchBesideItem `json:"beside,omitempty"` // the full commit Commit string `json:"commit"` // the module's directory in the repository ("." for its root), with paths Dir string `json:"dir,omitempty"` // the version (a full commit) of each mesh package to build against, by its module path Packages map[string]string `json:"packages,omitempty"` // the paths the module names, relative to dir Paths []string `json:"paths,omitempty"` // the pull request's ref, when only its head carries the commit Ref string `json:"ref,omitempty"` // / Repository string `json:"repository"` } // LevelAnswerDigestNeedsItem is a type of the contract. type LevelAnswerDigestNeedsItem struct { Needs []string `json:"needs,omitempty"` Package string `json:"package,omitempty"` } // LevelAnswerDigestPackagesItem is a type of the contract. type LevelAnswerDigestPackagesItem struct { Digest string `json:"digest"` Package string `json:"package"` } // LevelAnswerDigest is a type of the contract. type LevelAnswerDigest struct { Beside []string `json:"beside,omitempty"` JudgedBy string `json:"judged_by,omitempty"` Level string `json:"level,omitempty"` Needs []LevelAnswerDigestNeedsItem `json:"needs,omitempty"` Packages []LevelAnswerDigestPackagesItem `json:"packages,omitempty"` WithoutTests []string `json:"without_tests,omitempty"` } // LevelAnswerKeptItem is a type of the contract. type LevelAnswerKeptItem struct { Digest string `json:"digest,omitempty"` Package string `json:"package,omitempty"` Tests int64 `json:"tests,omitempty"` } // LevelAnswerUnmetItem is a type of the contract. type LevelAnswerUnmetItem struct { Needs []string `json:"needs,omitempty"` Package string `json:"package,omitempty"` } // LevelAnswer is one level of a check ask: the digest's answer, the kept verdicts taken, one test result per test step run, and the packages the node could not test. type LevelAnswer struct { Digest *LevelAnswerDigest `json:"digest,omitempty"` Judged string `json:"judged,omitempty"` Kept []LevelAnswerKeptItem `json:"kept,omitempty"` Level string `json:"level"` Tests []any `json:"tests,omitempty"` Unmet []LevelAnswerUnmetItem `json:"unmet,omitempty"` } // Pause is whether the node takes no new ask. type Pause struct { // when (RFC 3339 time) At *time.Time `json:"at,omitempty"` By string `json:"by,omitempty"` Paused bool `json:"paused"` // the layout version V int64 `json:"v,omitempty"` } // Step is one step a build module runs on a node. type Step struct { // when (RFC 3339 time) Ended *time.Time `json:"ended,omitempty"` ID string `json:"id"` Node string `json:"node"` Owner string `json:"owner,omitempty"` Phase string `json:"phase,omitempty"` // when (RFC 3339 time) PhaseAt *time.Time `json:"phase-at,omitempty"` Reason string `json:"reason,omitempty"` Result *StepResult `json:"result,omitempty"` // when (RFC 3339 time) Started time.Time `json:"started"` // running, passed, failed or refused State string `json:"state"` Tool string `json:"tool"` // the layout version V int64 `json:"v,omitempty"` What string `json:"what,omitempty"` } // StepAskBuild is a type of the contract. type StepAskBuild struct { Artifacts []AskArtifact `json:"artifacts"` Fetch *Fetch `json:"fetch,omitempty"` Fp string `json:"fp,omitempty"` Module string `json:"module"` Path string `json:"path,omitempty"` Publish bool `json:"publish,omitempty"` Toolchain *ToolchainUsed `json:"toolchain,omitempty"` } // StepAskCheck is a type of the contract. type StepAskCheck struct { Fetch Fetch `json:"fetch"` Kept bool `json:"kept,omitempty"` Levels []string `json:"levels"` Packages []string `json:"packages,omitempty"` Run string `json:"run,omitempty"` Runner string `json:"runner,omitempty"` RunnerWhen string `json:"runner_when,omitempty"` } // StepAskCompose is a type of the contract. type StepAskCompose struct { Dir string `json:"dir"` Fetch Fetch `json:"fetch"` Package string `json:"package"` Reader string `json:"reader,omitempty"` // the compose-candidate request Request any `json:"request"` } // StepAsk is one ask of a build module. type StepAsk struct { Asker string `json:"asker"` // when (RFC 3339 time) At *time.Time `json:"at,omitempty"` Build *StepAskBuild `json:"build,omitempty"` Check *StepAskCheck `json:"check,omitempty"` Compose *StepAskCompose `json:"compose,omitempty"` ID string `json:"id"` // build, check or compose Kind string `json:"kind"` // go, typescript or image Language string `json:"language"` Needs []string `json:"needs,omitempty"` // package to the tagged version a build pins Packages map[string]string `json:"packages,omitempty"` // the layout version V int64 `json:"v,omitempty"` } // StepResult is what a step answered, by the kind of ask: a build's artifacts, toolchain, imports and out-of-step modules; a check's fetch and levels; a compose's built, key and verdict; a declined ask's declined, needs and lacks. The fields of the kinds do not meet, so one layout holds the four. type StepResult struct { Artifacts []BuiltArtifact `json:"artifacts,omitempty"` Built bool `json:"built,omitempty"` // the holder declined the ask: its node lacks what the ask needs Declined bool `json:"declined,omitempty"` Fetch *Fetch `json:"fetch,omitempty"` Imports []string `json:"imports,omitempty"` Key string `json:"key,omitempty"` // what the holder's node lacks of it Lacks []string `json:"lacks,omitempty"` Levels []LevelAnswer `json:"levels,omitempty"` // what the declined ask needs Needs []string `json:"needs,omitempty"` OutOfStep []string `json:"out-of-step,omitempty"` Toolchain *ToolchainUsed `json:"toolchain,omitempty"` // the compose-candidate verdict (the composer's own layout) Verdict any `json:"verdict,omitempty"` } // Toolchain is the toolchain a node reports. type Toolchain struct { // when (RFC 3339 time) At *time.Time `json:"at,omitempty"` // go or typescript Language string `json:"language"` Recipe string `json:"recipe"` // the layout version V int64 `json:"v,omitempty"` Version string `json:"version"` } // ToolchainUsed is the toolchain a build was made with: the language, the installed version and the build module's recipe. type ToolchainUsed struct { Language string `json:"language"` Recipe string `json:"recipe"` Version string `json:"version"` } // CurrentInput is what current takes. type CurrentInput struct { } // CurrentAnswer is what current answers. type CurrentAnswer = map[string]any // PauseInput is what pause takes. type PauseInput struct { } // PauseAnswer is what pause answers. type PauseAnswer = map[string]any // ResumeInput is what resume takes. type ResumeInput struct { } // ResumeAnswer is what resume answers. type ResumeAnswer = map[string]any // DeliveryAccept is the body of delivery. type DeliveryAccept = StepAsk // CheckAccept is the body of check. type CheckAccept = StepAsk // RecheckAccept is the body of recheck. type RecheckAccept = StepAsk // StepsByNodeIDValue is one value of the state steps under the key .. type StepsByNodeIDValue = Step // PausesByPausedNodeValue is one value of the state pauses under the key paused.. type PausesByPausedNodeValue = Pause // PausesByCapacityNodeValue is one value of the state pauses under the key capacity.. type PausesByCapacityNodeValue = Capacity // ToolchainsByNodeLanguageValue is one value of the state toolchains under the key .. type ToolchainsByNodeLanguageValue = Toolchain