286 lines
9.3 KiB
Go
286 lines
9.3 KiB
Go
// Code generated by seatgen from the seat definitions; DO NOT EDIT.
|
|
|
|
// Package meshconfig is the contract of the seat "mesh-config", defined whole (seats/mesh-config/seat.json): The mesh's config values: read and set one, and the renames still open. mesh-config's own events stay under its own subjects (ADR 0620 §2).
|
|
package meshconfig
|
|
|
|
import (
|
|
"bytes"
|
|
"encoding/json"
|
|
"errors"
|
|
"strings"
|
|
"time"
|
|
)
|
|
|
|
// Seat is the seat's name.
|
|
const Seat = "mesh-config"
|
|
|
|
const (
|
|
VerbConfig = "config"
|
|
VerbRenames = "renames"
|
|
)
|
|
|
|
// Verbs is every verb the seat serves, in its definition's order: a new copy each call.
|
|
func Verbs() []string {
|
|
return []string{VerbConfig, VerbRenames}
|
|
}
|
|
|
|
// The holder's own events, listed beside the seat and published under the holder's subjects (ADR 0620 §2).
|
|
const (
|
|
HolderEventConfigChanged = "config-changed"
|
|
HolderEventRenamed = "renamed"
|
|
HolderEventRetiring = "retiring"
|
|
HolderEventRetired = "retired"
|
|
)
|
|
|
|
// HolderSubjectConfigChanged is where the holder publishes config-changed.
|
|
func HolderSubjectConfigChanged(holder string) string {
|
|
return "mesh.mod." + holder + ".event.config-changed"
|
|
}
|
|
|
|
// HolderSubjectRenamed is where the holder publishes renamed, kept in config.events.
|
|
func HolderSubjectRenamed(holder string) string { return "mesh.stream." + holder + ".event.renamed" }
|
|
|
|
// HolderSubjectRetiring is where the holder publishes retiring, kept in config.events.
|
|
func HolderSubjectRetiring(holder string) string { return "mesh.stream." + holder + ".event.retiring" }
|
|
|
|
// HolderSubjectRetired is where the holder publishes retired, kept in config.events.
|
|
func HolderSubjectRetired(holder string) string { return "mesh.stream." + holder + ".event.retired" }
|
|
|
|
const (
|
|
StateResolved = "resolved"
|
|
StateKept = "kept"
|
|
)
|
|
|
|
// ResolvedByNodeModuleKeyKey is the key of one value of the state resolved under the form "<node>.<module>.<key>".
|
|
func ResolvedByNodeModuleKeyKey(node, module, key string) string {
|
|
return node + "." + module + "." + key
|
|
}
|
|
|
|
// ParseResolvedByNodeModuleKeyKey reads the parts of a key of the form "<node>.<module>.<key>", in the order of the form; the last result is false for a key of another form.
|
|
func ParseResolvedByNodeModuleKeyKey(key 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
|
|
if rest == "" {
|
|
return "", "", "", false
|
|
}
|
|
v4 := rest
|
|
rest = ""
|
|
if rest != "" {
|
|
return "", "", "", false
|
|
}
|
|
return v0, v2, v4, true
|
|
}
|
|
|
|
// DecodeResolvedByNodeModuleKeyValue reads one value of the state resolved under the form "<node>.<module>.<key>", refusing a field ResolvedByNodeModuleKeyValue does not know and any text after the value.
|
|
func DecodeResolvedByNodeModuleKeyValue(raw []byte) (ResolvedByNodeModuleKeyValue, error) {
|
|
var v ResolvedByNodeModuleKeyValue
|
|
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
|
|
}
|
|
|
|
// KeptByOwnerRepositoryNumberNodeModuleKeyKey is the key of one value of the state kept under the form "<owner>.<repository>.<number>.<node>.<module>.<key>".
|
|
func KeptByOwnerRepositoryNumberNodeModuleKeyKey(owner, repository, number, node, module, key string) string {
|
|
return owner + "." + repository + "." + number + "." + node + "." + module + "." + key
|
|
}
|
|
|
|
// ParseKeptByOwnerRepositoryNumberNodeModuleKeyKey reads the parts of a key of the form "<owner>.<repository>.<number>.<node>.<module>.<key>", in the order of the form; the last result is false for a key of another form.
|
|
func ParseKeptByOwnerRepositoryNumberNodeModuleKeyKey(key string) (string, 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
|
|
v6, after6, found6 := strings.Cut(rest, ".")
|
|
if !found6 || v6 == "" {
|
|
return "", "", "", "", "", "", false
|
|
}
|
|
rest = after6
|
|
v8, after8, found8 := strings.Cut(rest, ".")
|
|
if !found8 || v8 == "" {
|
|
return "", "", "", "", "", "", false
|
|
}
|
|
rest = after8
|
|
if rest == "" {
|
|
return "", "", "", "", "", "", false
|
|
}
|
|
v10 := rest
|
|
rest = ""
|
|
if rest != "" {
|
|
return "", "", "", "", "", "", false
|
|
}
|
|
return v0, v2, v4, v6, v8, v10, true
|
|
}
|
|
|
|
// DecodeKeptByOwnerRepositoryNumberNodeModuleKeyValue reads one value of the state kept under the form "<owner>.<repository>.<number>.<node>.<module>.<key>", refusing a field KeptByOwnerRepositoryNumberNodeModuleKeyValue does not know and any text after the value.
|
|
func DecodeKeptByOwnerRepositoryNumberNodeModuleKeyValue(raw []byte) (KeptByOwnerRepositoryNumberNodeModuleKeyValue, error) {
|
|
var v KeptByOwnerRepositoryNumberNodeModuleKeyValue
|
|
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
|
|
}
|
|
|
|
// ConfigInput is what config takes.
|
|
type ConfigInput struct {
|
|
// list (when not given), set, clear or history
|
|
Action string `json:"action,omitempty"`
|
|
// who gave the value at the controller's terminal
|
|
By string `json:"by,omitempty"`
|
|
// the config key
|
|
Key string `json:"key,omitempty"`
|
|
// for history: at most this many, newest
|
|
Limit float64 `json:"limit,omitempty"`
|
|
// a module: its own value, with node
|
|
Module string `json:"module,omitempty"`
|
|
// a node
|
|
Node string `json:"node,omitempty"`
|
|
// for set: the value, of the key's type: a number, a string, a boolean, or for a trusted key an object or a list
|
|
Value any `json:"value,omitempty"`
|
|
// for set and clear: why
|
|
Why string `json:"why,omitempty"`
|
|
}
|
|
|
|
// ConfigAnswer is what config answers.
|
|
type ConfigAnswer = map[string]any
|
|
|
|
// RenamesInput is what renames takes.
|
|
type RenamesInput struct {
|
|
// one module (optional)
|
|
Module string `json:"module,omitempty"`
|
|
}
|
|
|
|
// RenamesAnswerRenamesItem is a type of the contract.
|
|
type RenamesAnswerRenamesItem struct {
|
|
// when it moved, RFC 3339
|
|
At string `json:"at,omitempty"`
|
|
// the old name
|
|
From string `json:"from"`
|
|
// the module
|
|
Module string `json:"module"`
|
|
// the nodes still holding the old name open
|
|
Open []string `json:"open,omitempty"`
|
|
// the new name
|
|
To string `json:"to"`
|
|
}
|
|
|
|
// RenamesAnswer is what renames answers.
|
|
type RenamesAnswer struct {
|
|
// every open rename
|
|
Renames []RenamesAnswerRenamesItem `json:"renames"`
|
|
}
|
|
|
|
// RenamedHolderEvent is the body of the holder's event renamed.
|
|
type RenamedHolderEvent struct {
|
|
// when, RFC 3339
|
|
At string `json:"at"`
|
|
// the old name
|
|
From string `json:"from"`
|
|
// the module
|
|
Module string `json:"module"`
|
|
// the new name
|
|
To string `json:"to"`
|
|
}
|
|
|
|
// RetiringHolderEvent is the body of the holder's event retiring.
|
|
type RetiringHolderEvent struct {
|
|
// the ask's id
|
|
Ask string `json:"ask,omitempty"`
|
|
// the value's or secret's name
|
|
Key string `json:"key"`
|
|
Kind string `json:"kind"`
|
|
// the module
|
|
Module string `json:"module"`
|
|
// since when, RFC 3339
|
|
Since string `json:"since"`
|
|
}
|
|
|
|
// The values of RetiringHolderEvent's kind.
|
|
const (
|
|
RetiringHolderEventKindValue = "value"
|
|
RetiringHolderEventKindSecret = "secret"
|
|
)
|
|
|
|
// RetiredHolderEvent is the body of the holder's event retired.
|
|
type RetiredHolderEvent struct {
|
|
// the ask's id
|
|
Ask string `json:"ask,omitempty"`
|
|
// the module
|
|
Module string `json:"module"`
|
|
// the name
|
|
Name string `json:"name"`
|
|
// the node
|
|
Node string `json:"node,omitempty"`
|
|
}
|
|
|
|
// ResolvedByNodeModuleKeyValue is one value of the state resolved under the key <node>.<module>.<key>.
|
|
type ResolvedByNodeModuleKeyValue struct {
|
|
Key string `json:"key"`
|
|
Module string `json:"module"`
|
|
Node string `json:"node"`
|
|
// the predefined key the value falls back to
|
|
Predefined string `json:"predefined,omitempty"`
|
|
// an unset value is the operator's own to set
|
|
Required bool `json:"required,omitempty"`
|
|
Source string `json:"source"`
|
|
Trusted bool `json:"trusted,omitempty"`
|
|
Value any `json:"value,omitempty"`
|
|
}
|
|
|
|
// KeptByOwnerRepositoryNumberNodeModuleKeyValue is one value of the state kept under the key <owner>.<repository>.<number>.<node>.<module>.<key>.
|
|
type KeptByOwnerRepositoryNumberNodeModuleKeyValue struct {
|
|
// who approved it, as the proposal kept it
|
|
Approved string `json:"approved,omitempty"`
|
|
// when it was kept
|
|
At *time.Time `json:"at,omitempty"`
|
|
By string `json:"by,omitempty"`
|
|
// the digest of what the declaration holds the value to; the value stays only while it is the same
|
|
Declaration string `json:"declaration"`
|
|
// the head the declaration was read at
|
|
Head string `json:"head"`
|
|
// the config key
|
|
Key string `json:"key"`
|
|
Module string `json:"module"`
|
|
Node string `json:"node"`
|
|
// the proposal's id
|
|
Proposal string `json:"proposal,omitempty"`
|
|
// the pull request, owner/repository#number
|
|
Pull string `json:"pull"`
|
|
// the value held, as the operator approved it
|
|
Value any `json:"value"`
|
|
// where the value was proposed from
|
|
Via string `json:"via,omitempty"`
|
|
Why string `json:"why,omitempty"`
|
|
}
|