A tools program that serves a seat's verbs as tools reads a verb's description from the generated contract, one copy taken from seat.json, instead of writing it again. Generated again in all five folders by mesh-delivery's seatgen (feat/47-H2 b65b6173), which now writes VerbDescription; seatgen -check clean, every package's vet and tests green. Builds: design 47 H2 H-A-449
355 lines
16 KiB
Go
355 lines
16 KiB
Go
// Code generated by seatgen from the seat definitions; DO NOT EDIT.
|
|
|
|
// Package meshprovisioner is the contract of the seat "mesh-provisioner", defined whole (seats/mesh-provisioner/seat.json): The provisioner (ADR 0349): which domain answers which kind of placeholder, what each module needs, what is applied where.
|
|
package meshprovisioner
|
|
|
|
import (
|
|
"encoding/json"
|
|
"strings"
|
|
"time"
|
|
)
|
|
|
|
// Seat is the seat's name.
|
|
const Seat = "mesh-provisioner"
|
|
|
|
// Form is the form of the seat's values, events and answers this contract was generated at (design 47 H2 §780):
|
|
// a reader of a value of another form says "form N, this reader knows M".
|
|
const Form = 1
|
|
|
|
// The forms and the digest of the fields this contract was generated from: the generator's compare fails a definition
|
|
// whose fields changed while its forms did not (design 47 H2 §780).
|
|
const (
|
|
generatedForms = "1"
|
|
generatedFieldsDigest = "PlansByNodeModuleValue=e3b5d8ddd5a1 ProvisioningAnswer=7538f2f5e68e ProvisionsByNodeConsumerProvisionLocalValue=32b55a872069 ProvisionsByNodeConsumerProvisionLocalValueConsumer=920ee010c907 ProvisionsByNodeConsumerProvisionLocalValuePlan=71e13248b267 ProvisionsByNodeConsumerProvisionLocalValueProvider=920ee010c907 ProvisionsByNodeConsumerProvisionLocalValueReference=ce6c167e9bea ProvisionsByNodeConsumerProvisionLocalValueWarrant=245d42c27175 ProvisionsByNodeConsumerProvisionValue=1b9faba7e8e2 ProvisionsByNodeConsumerProvisionValueConsumer=920ee010c907 ProvisionsByNodeConsumerProvisionValuePlan=71e13248b267 ProvisionsByNodeConsumerProvisionValueProvider=920ee010c907 ProvisionsByNodeConsumerProvisionValueReference=ce6c167e9bea ProvisionsByNodeConsumerProvisionValueWarrant=245d42c27175"
|
|
)
|
|
|
|
const (
|
|
VerbProvisioning = "provisioning"
|
|
)
|
|
|
|
// Verbs is every verb the seat serves, in its definition's order: a new copy each call.
|
|
func Verbs() []string {
|
|
return []string{VerbProvisioning}
|
|
}
|
|
|
|
// VerbDescription is a verb's description as the seat's definition says it, "" for a verb the seat does not serve or
|
|
// does not describe (design 47 H2 H-A-449).
|
|
func VerbDescription(verb string) string {
|
|
switch verb {
|
|
case VerbProvisioning:
|
|
return "Read what the provisioner keeps: the registry (which domain answers which kind of placeholder), the needs each module on each node recorded, what is applied where, or the items of every collection, narrowed by node and module. Reads only."
|
|
}
|
|
return ""
|
|
}
|
|
|
|
const (
|
|
StatePlans = "plans"
|
|
StateProvisions = "provisions"
|
|
)
|
|
|
|
// PlansByNodeModuleKey is the key of one value of the state plans under the form "<node>.<module>".
|
|
func PlansByNodeModuleKey(node, module string) string { return node + "." + module }
|
|
|
|
// ParsePlansByNodeModuleKey reads the parts of a key of the form "<node>.<module>", in the order of the form; the last result is false for a key of another form.
|
|
func ParsePlansByNodeModuleKey(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
|
|
}
|
|
|
|
// DecodePlansByNodeModuleValue reads one value of the state plans under the form "<node>.<module>" as another part wrote it: a field PlansByNodeModuleValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
|
|
func DecodePlansByNodeModuleValue(raw []byte) (PlansByNodeModuleValue, int, error) {
|
|
var v PlansByNodeModuleValue
|
|
if err := json.Unmarshal(raw, &v); err != nil {
|
|
return v, 0, err
|
|
}
|
|
return v, formRead(raw), nil
|
|
}
|
|
|
|
// ProvisionsByNodeConsumerProvisionKey is the key of one value of the state provisions under the form "<node>.<consumer>.<provision>".
|
|
func ProvisionsByNodeConsumerProvisionKey(node, consumer, provision string) string {
|
|
return node + "." + consumer + "." + provision
|
|
}
|
|
|
|
// ParseProvisionsByNodeConsumerProvisionKey reads the parts of a key of the form "<node>.<consumer>.<provision>", in the order of the form; the last result is false for a key of another form.
|
|
func ParseProvisionsByNodeConsumerProvisionKey(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
|
|
}
|
|
|
|
// DecodeProvisionsByNodeConsumerProvisionValue reads one value of the state provisions under the form "<node>.<consumer>.<provision>" as another part wrote it: a field ProvisionsByNodeConsumerProvisionValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
|
|
func DecodeProvisionsByNodeConsumerProvisionValue(raw []byte) (ProvisionsByNodeConsumerProvisionValue, int, error) {
|
|
var v ProvisionsByNodeConsumerProvisionValue
|
|
if err := json.Unmarshal(raw, &v); err != nil {
|
|
return v, 0, err
|
|
}
|
|
return v, formRead(raw), nil
|
|
}
|
|
|
|
// ProvisionsByNodeConsumerProvisionLocalKey is the key of one value of the state provisions under the form "<node>.<consumer>.<provision>.<local>".
|
|
func ProvisionsByNodeConsumerProvisionLocalKey(node, consumer, provision, local string) string {
|
|
return node + "." + consumer + "." + provision + "." + local
|
|
}
|
|
|
|
// ParseProvisionsByNodeConsumerProvisionLocalKey reads the parts of a key of the form "<node>.<consumer>.<provision>.<local>", in the order of the form; the last result is false for a key of another form.
|
|
func ParseProvisionsByNodeConsumerProvisionLocalKey(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
|
|
}
|
|
|
|
// DecodeProvisionsByNodeConsumerProvisionLocalValue reads one value of the state provisions under the form "<node>.<consumer>.<provision>.<local>" as another part wrote it: a field ProvisionsByNodeConsumerProvisionLocalValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
|
|
func DecodeProvisionsByNodeConsumerProvisionLocalValue(raw []byte) (ProvisionsByNodeConsumerProvisionLocalValue, int, error) {
|
|
var v ProvisionsByNodeConsumerProvisionLocalValue
|
|
if err := json.Unmarshal(raw, &v); err != nil {
|
|
return v, 0, err
|
|
}
|
|
return v, formRead(raw), nil
|
|
}
|
|
|
|
// ProvisioningInput is what provisioning takes.
|
|
type ProvisioningInput struct {
|
|
// for collect: a collection
|
|
Collection string `json:"collection,omitempty"`
|
|
// a module: for collect, a contributor
|
|
Module string `json:"module,omitempty"`
|
|
// a node
|
|
Node string `json:"node,omitempty"`
|
|
// registry (when not given), needs, applied or collect
|
|
What string `json:"what,omitempty"`
|
|
}
|
|
|
|
// ProvisioningAnswer is what provisioning answers.
|
|
type ProvisioningAnswer = map[string]any
|
|
|
|
// PlansByNodeModuleValue is one value of the state plans under the key <node>.<module>.
|
|
type PlansByNodeModuleValue struct {
|
|
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
|
|
Form int64 `json:"form,omitempty"`
|
|
Module string `json:"module"`
|
|
Node string `json:"node"`
|
|
// the module's plan
|
|
Plan map[string]any `json:"plan"`
|
|
V int64 `json:"v,omitempty"`
|
|
}
|
|
|
|
// ProvisionsByNodeConsumerProvisionValueConsumer is a type of the contract.
|
|
type ProvisionsByNodeConsumerProvisionValueConsumer struct {
|
|
Module string `json:"module,omitempty"`
|
|
Node string `json:"node,omitempty"`
|
|
}
|
|
|
|
// ProvisionsByNodeConsumerProvisionValuePlan is the plan's provision: the entry the key was composed from, at the consumer's wanted build or its newest (issue 1126).
|
|
type ProvisionsByNodeConsumerProvisionValuePlan struct {
|
|
As string `json:"as,omitempty"`
|
|
At string `json:"at,omitempty"`
|
|
// the provider's own contract's bytes, carried unread
|
|
Contributed map[string]any `json:"contributed,omitempty"`
|
|
Contributes map[string]any `json:"contributes,omitempty"`
|
|
CredentialForm any `json:"credential-form,omitempty"`
|
|
CredentialTool string `json:"credential-tool,omitempty"`
|
|
From string `json:"from,omitempty"`
|
|
Local string `json:"local,omitempty"`
|
|
Name string `json:"name,omitempty"`
|
|
Names map[string]string `json:"names,omitempty"`
|
|
Path string `json:"path,omitempty"`
|
|
Provider string `json:"provider"`
|
|
ProviderModule string `json:"provider-module"`
|
|
Provision string `json:"provision"`
|
|
}
|
|
|
|
// ProvisionsByNodeConsumerProvisionValueProvider is a type of the contract.
|
|
type ProvisionsByNodeConsumerProvisionValueProvider struct {
|
|
Module string `json:"module,omitempty"`
|
|
Node string `json:"node,omitempty"`
|
|
}
|
|
|
|
// ProvisionsByNodeConsumerProvisionValueReference is a type of the contract.
|
|
type ProvisionsByNodeConsumerProvisionValueReference struct {
|
|
Generation int64 `json:"generation,omitempty"`
|
|
ID string `json:"id,omitempty"`
|
|
}
|
|
|
|
// ProvisionsByNodeConsumerProvisionValueWarrant is a type of the contract.
|
|
type ProvisionsByNodeConsumerProvisionValueWarrant struct {
|
|
Ask string `json:"ask,omitempty"`
|
|
At *time.Time `json:"at,omitempty"`
|
|
By string `json:"by,omitempty"`
|
|
Option string `json:"option,omitempty"`
|
|
}
|
|
|
|
// ProvisionsByNodeConsumerProvisionValue is one value of the state provisions under the key <node>.<consumer>.<provision>.
|
|
type ProvisionsByNodeConsumerProvisionValue struct {
|
|
Ask string `json:"ask,omitempty"`
|
|
At time.Time `json:"at"`
|
|
Consumer ProvisionsByNodeConsumerProvisionValueConsumer `json:"consumer"`
|
|
DependsOn []string `json:"depends-on,omitempty"`
|
|
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
|
|
Form int64 `json:"form,omitempty"`
|
|
Local string `json:"local,omitempty"`
|
|
// the plan's provision: the entry the key was composed from, at the consumer's wanted build or its newest (issue 1126)
|
|
Plan *ProvisionsByNodeConsumerProvisionValuePlan `json:"plan,omitempty"`
|
|
Provider ProvisionsByNodeConsumerProvisionValueProvider `json:"provider"`
|
|
Provision string `json:"provision"`
|
|
Reference *ProvisionsByNodeConsumerProvisionValueReference `json:"reference,omitempty"`
|
|
State string `json:"state"`
|
|
V int64 `json:"v,omitempty"`
|
|
Warrant *ProvisionsByNodeConsumerProvisionValueWarrant `json:"warrant,omitempty"`
|
|
Why string `json:"why,omitempty"`
|
|
}
|
|
|
|
// The values of ProvisionsByNodeConsumerProvisionValue's state.
|
|
const (
|
|
ProvisionsByNodeConsumerProvisionValueStateAsked = "asked"
|
|
ProvisionsByNodeConsumerProvisionValueStateProvided = "provided"
|
|
ProvisionsByNodeConsumerProvisionValueStateWaits = "waits"
|
|
ProvisionsByNodeConsumerProvisionValueStateFailed = "failed"
|
|
ProvisionsByNodeConsumerProvisionValueStateRetiring = "retiring"
|
|
)
|
|
|
|
// ProvisionsByNodeConsumerProvisionLocalValueConsumer is a type of the contract.
|
|
type ProvisionsByNodeConsumerProvisionLocalValueConsumer struct {
|
|
Module string `json:"module,omitempty"`
|
|
Node string `json:"node,omitempty"`
|
|
}
|
|
|
|
// ProvisionsByNodeConsumerProvisionLocalValuePlan is the plan's provision: the entry the key was composed from, at the consumer's wanted build or its newest (issue 1126).
|
|
type ProvisionsByNodeConsumerProvisionLocalValuePlan struct {
|
|
As string `json:"as,omitempty"`
|
|
At string `json:"at,omitempty"`
|
|
// the provider's own contract's bytes, carried unread
|
|
Contributed map[string]any `json:"contributed,omitempty"`
|
|
Contributes map[string]any `json:"contributes,omitempty"`
|
|
CredentialForm any `json:"credential-form,omitempty"`
|
|
CredentialTool string `json:"credential-tool,omitempty"`
|
|
From string `json:"from,omitempty"`
|
|
Local string `json:"local,omitempty"`
|
|
Name string `json:"name,omitempty"`
|
|
Names map[string]string `json:"names,omitempty"`
|
|
Path string `json:"path,omitempty"`
|
|
Provider string `json:"provider"`
|
|
ProviderModule string `json:"provider-module"`
|
|
Provision string `json:"provision"`
|
|
}
|
|
|
|
// ProvisionsByNodeConsumerProvisionLocalValueProvider is a type of the contract.
|
|
type ProvisionsByNodeConsumerProvisionLocalValueProvider struct {
|
|
Module string `json:"module,omitempty"`
|
|
Node string `json:"node,omitempty"`
|
|
}
|
|
|
|
// ProvisionsByNodeConsumerProvisionLocalValueReference is a type of the contract.
|
|
type ProvisionsByNodeConsumerProvisionLocalValueReference struct {
|
|
Generation int64 `json:"generation,omitempty"`
|
|
ID string `json:"id,omitempty"`
|
|
}
|
|
|
|
// ProvisionsByNodeConsumerProvisionLocalValueWarrant is a type of the contract.
|
|
type ProvisionsByNodeConsumerProvisionLocalValueWarrant struct {
|
|
Ask string `json:"ask,omitempty"`
|
|
At *time.Time `json:"at,omitempty"`
|
|
By string `json:"by,omitempty"`
|
|
Option string `json:"option,omitempty"`
|
|
}
|
|
|
|
// ProvisionsByNodeConsumerProvisionLocalValue is one value of the state provisions under the key <node>.<consumer>.<provision>.<local>.
|
|
type ProvisionsByNodeConsumerProvisionLocalValue struct {
|
|
Ask string `json:"ask,omitempty"`
|
|
At time.Time `json:"at"`
|
|
Consumer ProvisionsByNodeConsumerProvisionLocalValueConsumer `json:"consumer"`
|
|
DependsOn []string `json:"depends-on,omitempty"`
|
|
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
|
|
Form int64 `json:"form,omitempty"`
|
|
Local string `json:"local,omitempty"`
|
|
// the plan's provision: the entry the key was composed from, at the consumer's wanted build or its newest (issue 1126)
|
|
Plan *ProvisionsByNodeConsumerProvisionLocalValuePlan `json:"plan,omitempty"`
|
|
Provider ProvisionsByNodeConsumerProvisionLocalValueProvider `json:"provider"`
|
|
Provision string `json:"provision"`
|
|
Reference *ProvisionsByNodeConsumerProvisionLocalValueReference `json:"reference,omitempty"`
|
|
State string `json:"state"`
|
|
V int64 `json:"v,omitempty"`
|
|
Warrant *ProvisionsByNodeConsumerProvisionLocalValueWarrant `json:"warrant,omitempty"`
|
|
Why string `json:"why,omitempty"`
|
|
}
|
|
|
|
// The values of ProvisionsByNodeConsumerProvisionLocalValue's state.
|
|
const (
|
|
ProvisionsByNodeConsumerProvisionLocalValueStateAsked = "asked"
|
|
ProvisionsByNodeConsumerProvisionLocalValueStateProvided = "provided"
|
|
ProvisionsByNodeConsumerProvisionLocalValueStateWaits = "waits"
|
|
ProvisionsByNodeConsumerProvisionLocalValueStateFailed = "failed"
|
|
ProvisionsByNodeConsumerProvisionLocalValueStateRetiring = "retiring"
|
|
)
|
|
|
|
// DecodeProvisioningAnswer reads a ProvisioningAnswer as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
|
|
func DecodeProvisioningAnswer(raw []byte) (ProvisioningAnswer, int, error) {
|
|
var v ProvisioningAnswer
|
|
if err := json.Unmarshal(raw, &v); err != nil {
|
|
return v, 0, err
|
|
}
|
|
return v, formRead(raw), nil
|
|
}
|
|
|
|
// formRead is the form a value says on the wire: 1 when it says none, or is no object.
|
|
func formRead(raw []byte) int {
|
|
var f struct {
|
|
Form int `json:"form"`
|
|
}
|
|
if json.Unmarshal(raw, &f) != nil || f.Form < 1 {
|
|
return 1
|
|
}
|
|
return f.Form
|
|
}
|