Files
mesh-contracts/provisioning/go/seats/meshprovisioner/contract.go
T
jschoubben 2172a8732d H2 K1: every seat package read tolerantly, saying its form
A reader of another part's value refused a field it did not know, so a holder
that added one broke every reader until each was rebuilt. Every package is
generated again by mesh-delivery's seatgen (feat/47-H2 ff7db337): each
generated decoder keeps unknown fields, returns the form read (1 when absent)
and each package states its Form (1 everywhere, left out on the wire). The
hand-written clients take the three values, and the node-engine client's
ask, answer, composition and have decoders keep unknown fields too; their tests
now hold that tolerance. seatgen -check clean in all five folders.

Builds: design 47 H2 §780; H-A-350 DMC-4
2026-11-21 23:15:25 +01:00

345 lines
15 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 = "878e1ffd0497bd99a1544b43596e8317c72417540badaef82999fe69e55202b6"
)
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}
}
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
}