456 lines
14 KiB
Go
456 lines
14 KiB
Go
// Code generated by seatgen from the seat definitions; DO NOT EDIT.
|
|
|
|
// Package meshdelivery is the contract of the seat "mesh-delivery", defined whole (seats/mesh-delivery/seat.json): The delivery gate: reads and steers deliveries, merges and the checks that decide them; the merge is made on the operator's Approve once both checks passed.
|
|
package meshdelivery
|
|
|
|
import (
|
|
"bytes"
|
|
"encoding/json"
|
|
"errors"
|
|
"strings"
|
|
"time"
|
|
)
|
|
|
|
// Seat is the seat's name.
|
|
const Seat = "mesh-delivery"
|
|
|
|
const (
|
|
VerbDeliveries = "deliveries"
|
|
VerbTimes = "times"
|
|
VerbShow = "show"
|
|
VerbGroups = "groups"
|
|
VerbWhatIf = "what-if"
|
|
VerbChecks = "checks"
|
|
VerbTable = "table"
|
|
VerbStalled = "stalled"
|
|
VerbRecheck = "recheck"
|
|
VerbRelease = "release"
|
|
VerbStop = "stop"
|
|
VerbClose = "close"
|
|
VerbRetireHistory = "retire-history"
|
|
VerbSettle = "settle"
|
|
)
|
|
|
|
// Verbs is every verb the seat serves, in its definition's order: a new copy each call.
|
|
func Verbs() []string {
|
|
return []string{VerbDeliveries, VerbTimes, VerbShow, VerbGroups, VerbWhatIf, VerbChecks, VerbTable, VerbStalled, VerbRecheck, VerbRelease, VerbStop, VerbClose, VerbRetireHistory, VerbSettle}
|
|
}
|
|
|
|
const (
|
|
StateSource = "source"
|
|
StateMerges = "merges"
|
|
StateAsks = "asks"
|
|
StateOwed = "owed"
|
|
StateTurns = "turns"
|
|
)
|
|
|
|
// SourceByMainKey is the key of one value of the state source under the form "main".
|
|
func SourceByMainKey() string { return "main" }
|
|
|
|
// ParseSourceByMainKey reads the parts of a key of the form "main", in the order of the form; the last result is false for a key of another form.
|
|
func ParseSourceByMainKey(key string) bool {
|
|
rest := key
|
|
if !strings.HasPrefix(rest, "main") {
|
|
return false
|
|
}
|
|
rest = rest[4:]
|
|
if rest != "" {
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
|
|
// DecodeSourceByMainValue reads one value of the state source under the form "main", refusing a field SourceByMainValue does not know and any text after the value.
|
|
func DecodeSourceByMainValue(raw []byte) (SourceByMainValue, error) {
|
|
var v SourceByMainValue
|
|
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
|
|
}
|
|
|
|
// MergesByGroupKey is the key of one value of the state merges under the form "<group>".
|
|
func MergesByGroupKey(group string) string { return group }
|
|
|
|
// ParseMergesByGroupKey reads the parts of a key of the form "<group>", in the order of the form; the last result is false for a key of another form.
|
|
func ParseMergesByGroupKey(key string) (string, bool) {
|
|
rest := key
|
|
if rest == "" {
|
|
return "", false
|
|
}
|
|
v0 := rest
|
|
rest = ""
|
|
if rest != "" {
|
|
return "", false
|
|
}
|
|
return v0, true
|
|
}
|
|
|
|
// DecodeMergesByGroupValue reads one value of the state merges under the form "<group>", refusing a field MergesByGroupValue does not know and any text after the value.
|
|
func DecodeMergesByGroupValue(raw []byte) (MergesByGroupValue, error) {
|
|
var v MergesByGroupValue
|
|
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
|
|
}
|
|
|
|
// AsksByMergeGroupHeadsKey is the key of one value of the state asks under the form "merge.<group>.<heads>".
|
|
func AsksByMergeGroupHeadsKey(group, heads string) string { return "merge." + group + "." + heads }
|
|
|
|
// ParseAsksByMergeGroupHeadsKey reads the parts of a key of the form "merge.<group>.<heads>", in the order of the form; the last result is false for a key of another form.
|
|
func ParseAsksByMergeGroupHeadsKey(key string) (string, string, bool) {
|
|
rest := key
|
|
if !strings.HasPrefix(rest, "merge.") {
|
|
return "", "", false
|
|
}
|
|
rest = rest[6:]
|
|
v1, after1, found1 := strings.Cut(rest, ".")
|
|
if !found1 || v1 == "" {
|
|
return "", "", false
|
|
}
|
|
rest = after1
|
|
if rest == "" {
|
|
return "", "", false
|
|
}
|
|
v3 := rest
|
|
rest = ""
|
|
if rest != "" {
|
|
return "", "", false
|
|
}
|
|
return v1, v3, true
|
|
}
|
|
|
|
// DecodeAsksByMergeGroupHeadsValue reads one value of the state asks under the form "merge.<group>.<heads>", refusing a field AsksByMergeGroupHeadsValue does not know and any text after the value.
|
|
func DecodeAsksByMergeGroupHeadsValue(raw []byte) (AsksByMergeGroupHeadsValue, error) {
|
|
var v AsksByMergeGroupHeadsValue
|
|
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
|
|
}
|
|
|
|
// OwedByRepositoryNumberHeadActKey is the key of one value of the state owed under the form "<repository>.<number>.<head>.<act>".
|
|
func OwedByRepositoryNumberHeadActKey(repository, number, head, act string) string {
|
|
return repository + "." + number + "." + head + "." + act
|
|
}
|
|
|
|
// ParseOwedByRepositoryNumberHeadActKey reads the parts of a key of the form "<repository>.<number>.<head>.<act>", in the order of the form; the last result is false for a key of another form.
|
|
func ParseOwedByRepositoryNumberHeadActKey(key string) (string, string, string, string, bool) {
|
|
rest := key
|
|
v0, after0, found0 := strings.Cut(rest, ".")
|
|
if !found0 || v0 == "" {
|
|
return "", "", "", "", false
|
|
}
|
|
rest = after0
|
|
v2, after2, found2 := strings.Cut(rest, ".")
|
|
if !found2 || v2 == "" {
|
|
return "", "", "", "", false
|
|
}
|
|
rest = after2
|
|
v4, after4, found4 := strings.Cut(rest, ".")
|
|
if !found4 || v4 == "" {
|
|
return "", "", "", "", false
|
|
}
|
|
rest = after4
|
|
if rest == "" {
|
|
return "", "", "", "", false
|
|
}
|
|
v6 := rest
|
|
rest = ""
|
|
if rest != "" {
|
|
return "", "", "", "", false
|
|
}
|
|
return v0, v2, v4, v6, true
|
|
}
|
|
|
|
// DecodeOwedByRepositoryNumberHeadActValue reads one value of the state owed under the form "<repository>.<number>.<head>.<act>", refusing a field OwedByRepositoryNumberHeadActValue does not know and any text after the value.
|
|
func DecodeOwedByRepositoryNumberHeadActValue(raw []byte) (OwedByRepositoryNumberHeadActValue, error) {
|
|
var v OwedByRepositoryNumberHeadActValue
|
|
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
|
|
}
|
|
|
|
// TurnsByRepositoryKey is the key of one value of the state turns under the form "<repository>".
|
|
func TurnsByRepositoryKey(repository string) string { return repository }
|
|
|
|
// ParseTurnsByRepositoryKey reads the parts of a key of the form "<repository>", in the order of the form; the last result is false for a key of another form.
|
|
func ParseTurnsByRepositoryKey(key string) (string, bool) {
|
|
rest := key
|
|
if rest == "" {
|
|
return "", false
|
|
}
|
|
v0 := rest
|
|
rest = ""
|
|
if rest != "" {
|
|
return "", false
|
|
}
|
|
return v0, true
|
|
}
|
|
|
|
// DecodeTurnsByRepositoryValue reads one value of the state turns under the form "<repository>", refusing a field TurnsByRepositoryValue does not know and any text after the value.
|
|
func DecodeTurnsByRepositoryValue(raw []byte) (TurnsByRepositoryValue, error) {
|
|
var v TurnsByRepositoryValue
|
|
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
|
|
}
|
|
|
|
// DeliveriesInput is what deliveries takes.
|
|
type DeliveriesInput struct {
|
|
// "true": the final ones of the last thirty days too
|
|
All string `json:"all,omitempty"`
|
|
// a group's id (its branch name)
|
|
Group string `json:"group,omitempty"`
|
|
// owner/repository
|
|
Repository string `json:"repository,omitempty"`
|
|
// one state, e.g. delivering or held
|
|
State string `json:"state,omitempty"`
|
|
}
|
|
|
|
// The values of DeliveriesInput's all.
|
|
const (
|
|
DeliveriesInputAllTrue = "true"
|
|
DeliveriesInputAllFalse = "false"
|
|
)
|
|
|
|
// DeliveriesAnswer is what deliveries answers.
|
|
type DeliveriesAnswer = map[string]any
|
|
|
|
// TimesInput is what times takes.
|
|
type TimesInput struct {
|
|
}
|
|
|
|
// TimesAnswer is what times answers.
|
|
type TimesAnswer = map[string]any
|
|
|
|
// ShowInput is what show takes.
|
|
type ShowInput struct {
|
|
// a delivery's id, or a group's
|
|
ID string `json:"id"`
|
|
}
|
|
|
|
// ShowAnswer is what show answers.
|
|
type ShowAnswer = map[string]any
|
|
|
|
// GroupsInput is what groups takes.
|
|
type GroupsInput struct {
|
|
// "true": the groups that ended too
|
|
All string `json:"all,omitempty"`
|
|
}
|
|
|
|
// The values of GroupsInput's all.
|
|
const (
|
|
GroupsInputAllTrue = "true"
|
|
GroupsInputAllFalse = "false"
|
|
)
|
|
|
|
// GroupsAnswer is what groups answers.
|
|
type GroupsAnswer = map[string]any
|
|
|
|
// WhatIfInput is what what-if takes.
|
|
type WhatIfInput struct {
|
|
}
|
|
|
|
// WhatIfAnswer is what what-if answers.
|
|
type WhatIfAnswer = map[string]any
|
|
|
|
// ChecksInput is what checks takes.
|
|
type ChecksInput struct {
|
|
// a commit's sha, or the start of one, instead of a pull request
|
|
Commit string `json:"commit,omitempty"`
|
|
// a pull request's number: its head is read
|
|
Number string `json:"number,omitempty"`
|
|
// owner/repository
|
|
Repository string `json:"repository"`
|
|
}
|
|
|
|
// ChecksAnswer is what checks answers.
|
|
type ChecksAnswer = map[string]any
|
|
|
|
// TableInput is what table takes.
|
|
type TableInput struct {
|
|
}
|
|
|
|
// TableAnswer is what table answers.
|
|
type TableAnswer = map[string]any
|
|
|
|
// StalledInput is what stalled takes.
|
|
type StalledInput struct {
|
|
}
|
|
|
|
// StalledAnswer is what stalled answers.
|
|
type StalledAnswer = map[string]any
|
|
|
|
// RecheckInput is what recheck takes.
|
|
type RecheckInput struct {
|
|
// the delivery's id
|
|
ID string `json:"id"`
|
|
// why, kept with the transition
|
|
Why string `json:"why"`
|
|
}
|
|
|
|
// RecheckAnswer is what recheck answers.
|
|
type RecheckAnswer = map[string]any
|
|
|
|
// ReleaseInput is what release takes.
|
|
type ReleaseInput struct {
|
|
}
|
|
|
|
// ReleaseAnswer is what release answers.
|
|
type ReleaseAnswer = map[string]any
|
|
|
|
// StopInput is what stop takes.
|
|
type StopInput struct {
|
|
}
|
|
|
|
// StopAnswer is what stop answers.
|
|
type StopAnswer = map[string]any
|
|
|
|
// CloseInput is what close takes.
|
|
type CloseInput struct {
|
|
// the delivery's id
|
|
ID string `json:"id"`
|
|
// the condition it answers
|
|
Why string `json:"why"`
|
|
}
|
|
|
|
// CloseAnswer is what close answers.
|
|
type CloseAnswer = map[string]any
|
|
|
|
// RetireHistoryInput is what retire-history takes.
|
|
type RetireHistoryInput struct {
|
|
}
|
|
|
|
// RetireHistoryAnswer is what retire-history answers.
|
|
type RetireHistoryAnswer = map[string]any
|
|
|
|
// SettleInput is what settle takes.
|
|
type SettleInput struct {
|
|
// the held deliveries' ids (owner/repository@commit)
|
|
Ids []string `json:"ids"`
|
|
// why they may be settled, shown to the operator
|
|
Why string `json:"why"`
|
|
}
|
|
|
|
// SettleAnswer is what settle answers.
|
|
type SettleAnswer = map[string]any
|
|
|
|
// SourceByMainValue is one value of the state source under the key main.
|
|
type SourceByMainValue struct {
|
|
// the group that moved it
|
|
Group string `json:"group"`
|
|
// repository to the merged head, a full commit
|
|
Heads map[string]string `json:"heads"`
|
|
// the layout version
|
|
V int64 `json:"v,omitempty"`
|
|
}
|
|
|
|
// MergesByGroupValuePullsItem is a type of the contract.
|
|
type MergesByGroupValuePullsItem struct {
|
|
Commit string `json:"commit,omitempty"`
|
|
Head string `json:"head"`
|
|
Number int64 `json:"number"`
|
|
Repository string `json:"repository"`
|
|
// merging, merged or refused
|
|
State string `json:"state"`
|
|
Words string `json:"words,omitempty"`
|
|
}
|
|
|
|
// MergesByGroupValue is one value of the state merges under the key <group>.
|
|
type MergesByGroupValue struct {
|
|
// <repository>@<number> to the approved head
|
|
Approved map[string]string `json:"approved,omitempty"`
|
|
// the ask key
|
|
Ask string `json:"ask"`
|
|
Group string `json:"group"`
|
|
Pulls []MergesByGroupValuePullsItem `json:"pulls"`
|
|
// the layout version
|
|
V int64 `json:"v,omitempty"`
|
|
}
|
|
|
|
// AsksByMergeGroupHeadsValueHeadsItem is a type of the contract.
|
|
type AsksByMergeGroupHeadsValueHeadsItem struct {
|
|
// the full commit
|
|
Head string `json:"head"`
|
|
Number int64 `json:"number"`
|
|
// <owner>/<name>
|
|
Repository string `json:"repository"`
|
|
}
|
|
|
|
// AsksByMergeGroupHeadsValue is one value of the state asks under the key merge.<group>.<heads>.
|
|
type AsksByMergeGroupHeadsValue struct {
|
|
// the operator-channel ask as raised
|
|
Ask any `json:"ask"`
|
|
// the number of times it was asked
|
|
Asking int64 `json:"asking,omitempty"`
|
|
Group string `json:"group"`
|
|
Heads []AsksByMergeGroupHeadsValueHeadsItem `json:"heads"`
|
|
// the layout version
|
|
V int64 `json:"v,omitempty"`
|
|
}
|
|
|
|
// OwedByRepositoryNumberHeadActValue is one value of the state owed under the key <repository>.<number>.<head>.<act>.
|
|
type OwedByRepositoryNumberHeadActValue struct {
|
|
// status=<context>, view, note or comment.<seq>
|
|
Act string `json:"act"`
|
|
Context string `json:"context,omitempty"`
|
|
Ref string `json:"ref,omitempty"`
|
|
State string `json:"state,omitempty"`
|
|
Target string `json:"target,omitempty"`
|
|
Text string `json:"text,omitempty"`
|
|
// the layout version
|
|
V int64 `json:"v,omitempty"`
|
|
}
|
|
|
|
// TurnsByRepositoryValueWaitingItem is a type of the contract.
|
|
type TurnsByRepositoryValueWaitingItem struct {
|
|
// when (RFC 3339 time)
|
|
Approved time.Time `json:"approved"`
|
|
Ask string `json:"ask,omitempty"`
|
|
Group string `json:"group"`
|
|
Heads string `json:"heads"`
|
|
// when (RFC 3339 time)
|
|
Since time.Time `json:"since"`
|
|
Step string `json:"step,omitempty"`
|
|
WaitsFor string `json:"waits-for,omitempty"`
|
|
// when (RFC 3339 time)
|
|
WaitsSince *time.Time `json:"waits-since,omitempty"`
|
|
}
|
|
|
|
// TurnsByRepositoryValue is one value of the state turns under the key <repository>.
|
|
type TurnsByRepositoryValue struct {
|
|
Repository string `json:"repository"`
|
|
// the layout version
|
|
V int64 `json:"v,omitempty"`
|
|
Waiting []TurnsByRepositoryValueWaitingItem `json:"waiting"`
|
|
}
|