448 lines
15 KiB
Go
448 lines
15 KiB
Go
// Code generated by seatgen from the seat definitions; DO NOT EDIT.
|
|
|
|
// Package nodebuildimage is the contract of the seat "node-build-image", defined whole (seats/node-build-image/seat.json): The image build module on a node: it takes the asks of the builder and the checker, runs them as steps and answers.
|
|
package nodebuildimage
|
|
|
|
import (
|
|
"bytes"
|
|
"encoding/json"
|
|
"errors"
|
|
"strings"
|
|
)
|
|
|
|
// Seat is the seat's name.
|
|
const Seat = "node-build-image"
|
|
|
|
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-image.accept.delivery"
|
|
|
|
// AcceptSubjectCheck is where check is sent.
|
|
const AcceptSubjectCheck = "mesh.seat.node-build-image.accept.check"
|
|
|
|
// AcceptSubjectRecheck is where recheck is sent.
|
|
const AcceptSubjectRecheck = "mesh.seat.node-build-image.accept.recheck"
|
|
|
|
const (
|
|
StateSteps = "steps"
|
|
StatePauses = "pauses"
|
|
StateToolchains = "toolchains"
|
|
)
|
|
|
|
// StepsByNodeIDKey is the key of one value of the state steps under the form "<node>.<id>".
|
|
func StepsByNodeIDKey(node, id string) string { return node + "." + id }
|
|
|
|
// ParseStepsByNodeIDKey reads the parts of a key of the form "<node>.<id>", 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 "<node>.<id>", 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.<node>".
|
|
func PausesByPausedNodeKey(node string) string { return "paused." + node }
|
|
|
|
// ParsePausesByPausedNodeKey reads the parts of a key of the form "paused.<node>", 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.<node>", 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.<node>".
|
|
func PausesByCapacityNodeKey(node string) string { return "capacity." + node }
|
|
|
|
// ParsePausesByCapacityNodeKey reads the parts of a key of the form "capacity.<node>", 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.<node>", 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 "<node>.<language>".
|
|
func ToolchainsByNodeLanguageKey(node, language string) string { return node + "." + language }
|
|
|
|
// ParseToolchainsByNodeLanguageKey reads the parts of a key of the form "<node>.<language>", 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 "<node>.<language>", 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
|
|
}
|
|
|
|
// BuildAnswerArtifactsItem is a type of the contract.
|
|
type BuildAnswerArtifactsItem struct {
|
|
Artifact string `json:"artifact"`
|
|
Digest string `json:"digest"`
|
|
Reference string `json:"reference,omitempty"`
|
|
}
|
|
|
|
// BuildAnswerToolchain is a type of the contract.
|
|
type BuildAnswerToolchain struct {
|
|
Language string `json:"language"`
|
|
Recipe string `json:"recipe"`
|
|
Version string `json:"version"`
|
|
}
|
|
|
|
// BuildAnswer is a type of the contract.
|
|
type BuildAnswer struct {
|
|
Artifacts []BuildAnswerArtifactsItem `json:"artifacts"`
|
|
Imports []string `json:"imports,omitempty"`
|
|
OutOfStep []string `json:"out-of-step,omitempty"`
|
|
Toolchain *BuildAnswerToolchain `json:"toolchain,omitempty"`
|
|
}
|
|
|
|
// Capacity is how many steps the node runs at once.
|
|
type Capacity struct {
|
|
// when (RFC 3339 time)
|
|
At string `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"`
|
|
}
|
|
|
|
// CheckAnswerLevelsItemDigestNeedsItem is a type of the contract.
|
|
type CheckAnswerLevelsItemDigestNeedsItem struct {
|
|
Needs []string `json:"needs,omitempty"`
|
|
Package string `json:"package,omitempty"`
|
|
}
|
|
|
|
// CheckAnswerLevelsItemDigestPackagesItem is a type of the contract.
|
|
type CheckAnswerLevelsItemDigestPackagesItem struct {
|
|
Digest string `json:"digest"`
|
|
Package string `json:"package"`
|
|
}
|
|
|
|
// CheckAnswerLevelsItemDigest is a type of the contract.
|
|
type CheckAnswerLevelsItemDigest struct {
|
|
Beside []string `json:"beside,omitempty"`
|
|
JudgedBy string `json:"judged_by,omitempty"`
|
|
Level string `json:"level,omitempty"`
|
|
Needs []CheckAnswerLevelsItemDigestNeedsItem `json:"needs,omitempty"`
|
|
Packages []CheckAnswerLevelsItemDigestPackagesItem `json:"packages,omitempty"`
|
|
WithoutTests []string `json:"without_tests,omitempty"`
|
|
}
|
|
|
|
// CheckAnswerLevelsItemKeptItem is a type of the contract.
|
|
type CheckAnswerLevelsItemKeptItem struct {
|
|
Digest string `json:"digest,omitempty"`
|
|
Package string `json:"package,omitempty"`
|
|
Tests int64 `json:"tests,omitempty"`
|
|
}
|
|
|
|
// CheckAnswerLevelsItemUnmetItem is a type of the contract.
|
|
type CheckAnswerLevelsItemUnmetItem struct {
|
|
Needs []string `json:"needs,omitempty"`
|
|
Package string `json:"package,omitempty"`
|
|
}
|
|
|
|
// CheckAnswerLevelsItem is a type of the contract.
|
|
type CheckAnswerLevelsItem struct {
|
|
Digest *CheckAnswerLevelsItemDigest `json:"digest,omitempty"`
|
|
Judged string `json:"judged,omitempty"`
|
|
Kept []CheckAnswerLevelsItemKeptItem `json:"kept,omitempty"`
|
|
Level string `json:"level"`
|
|
Tests []any `json:"tests,omitempty"`
|
|
Unmet []CheckAnswerLevelsItemUnmetItem `json:"unmet,omitempty"`
|
|
}
|
|
|
|
// CheckAnswer is a type of the contract.
|
|
type CheckAnswer struct {
|
|
// what the build module fetches: the repository, commit and directory, as the indexer states it
|
|
Fetch any `json:"fetch"`
|
|
Levels []CheckAnswerLevelsItem `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"`
|
|
}
|
|
|
|
// Pause is whether the node takes no new ask.
|
|
type Pause struct {
|
|
// when (RFC 3339 time)
|
|
At string `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 string `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 string `json:"phase-at,omitempty"`
|
|
Reason string `json:"reason,omitempty"`
|
|
// what the step answered
|
|
Result any `json:"result,omitempty"`
|
|
// when (RFC 3339 time)
|
|
Started string `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"`
|
|
}
|
|
|
|
// StepAskBuildArtifactsItem is a type of the contract.
|
|
type StepAskBuildArtifactsItem struct {
|
|
Artifact string `json:"artifact"`
|
|
From string `json:"from,omitempty"`
|
|
Seat string `json:"seat,omitempty"`
|
|
Version string `json:"version,omitempty"`
|
|
}
|
|
|
|
// StepAskBuildToolchain is a type of the contract.
|
|
type StepAskBuildToolchain struct {
|
|
Language string `json:"language"`
|
|
Recipe string `json:"recipe"`
|
|
Version string `json:"version"`
|
|
}
|
|
|
|
// StepAskBuild is a type of the contract.
|
|
type StepAskBuild struct {
|
|
Artifacts []StepAskBuildArtifactsItem `json:"artifacts"`
|
|
// what the build module fetches: the repository, commit and directory, as the indexer states it
|
|
Fetch any `json:"fetch,omitempty"`
|
|
Fp string `json:"fp,omitempty"`
|
|
Module string `json:"module"`
|
|
Path string `json:"path,omitempty"`
|
|
Publish bool `json:"publish,omitempty"`
|
|
Toolchain *StepAskBuildToolchain `json:"toolchain,omitempty"`
|
|
}
|
|
|
|
// StepAskCheck is a type of the contract.
|
|
type StepAskCheck struct {
|
|
// what the build module fetches: the repository, commit and directory, as the indexer states it
|
|
Fetch any `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"`
|
|
// what the build module fetches: the repository, commit and directory, as the indexer states it
|
|
Fetch any `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 string `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"`
|
|
}
|
|
|
|
// Toolchain is the toolchain a node reports.
|
|
type Toolchain struct {
|
|
// when (RFC 3339 time)
|
|
At string `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"`
|
|
}
|
|
|
|
// 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 <node>.<id>.
|
|
type StepsByNodeIDValue = Step
|
|
|
|
// PausesByPausedNodeValue is one value of the state pauses under the key paused.<node>.
|
|
type PausesByPausedNodeValue = Pause
|
|
|
|
// PausesByCapacityNodeValue is one value of the state pauses under the key capacity.<node>.
|
|
type PausesByCapacityNodeValue = Capacity
|
|
|
|
// ToolchainsByNodeLanguageValue is one value of the state toolchains under the key <node>.<language>.
|
|
type ToolchainsByNodeLanguageValue = Toolchain
|