Files
mesh-delivery/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reservedverb.go
T
jschoubben e84e2adff0 builder: answer reserved for a bundle's or an archive's name, and log a name no entry carries
distribution's tag of mesh-delivery-pipeline 0.1.6 was refused: reserved answered 'no entry carries the name
mesh-delivery-pipeline/program', since the lookup matched only an artifact's package name and a bundle's entry
names none. A bundle's or an archive's name is <module>/<artifact>, read from its reference through NameOf; a
name no entry carries is said in the builder's log with the entries looked at.

Builds: design 47 G A-418, §478, §572
2026-11-15 03:00:14 +01:00

66 lines
2.8 KiB
Go

package main
import (
"context"
"encoding/json"
"fmt"
"strings"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
"git.novox.be/novox/mesh-sdk/go/process"
"mesh-delivery-builder/internal/versions"
)
// The seat mesh-builds' verb reserved is answered by the builder's own process (design 47 G A-115, A-127; A-87: builder_build stays
// its tools bundle's): a module's reserved version with each artifact's digest once built, for a registry holder deciding whether to
// publish. Given a name it finds the module from the catalog half the process follows (carriers) and, for a version no reservation
// holds, asks the seat mesh-catalog's verb versions. The process's manifest declares the verb in `serves` beside its process.
// reservedReader is the state reserved read through its store, as the verb's answers read it.
func reservedReader(ctx context.Context, store versions.Store) versions.Reader {
return versions.Reader{
Keys: func() ([]string, error) { return store.KeysOf(ctx, versions.AllFilter) },
Get: func(key string) (json.RawMessage, bool, error) {
v, _, found, err := store.Get(ctx, key)
return v, found, err
}}
}
// reservedVerb is the handler of the verb reserved; missed is told each name no entry carries, for the builder's log (design 47 G
// A-418).
func reservedVerb(ctx context.Context, rr versions.Reader, carriers func(context.Context, string) ([]versions.Built, error), released versions.CatalogVersions, missed func(name string)) process.SeatHandler {
return func(_ string, body json.RawMessage) (any, error) {
var in meshbuilds.ReservedInput
if len(body) > 0 {
if err := json.Unmarshal(body, &in); err != nil {
return nil, fmt.Errorf("the arguments do not fit the verb reserved: %w", err)
}
}
if name := strings.TrimSpace(in.Name); name != "" {
a, err := versions.AnswerReservedByName(ctx, rr, carriers, released, name, in.Version)
if err == nil && missed != nil && strings.HasPrefix(a.Error, versions.NoEntryCarries) {
missed(name)
}
return a, err
}
return versions.AnswerReservedVerb(rr, in.Module, in.Version)
}
}
// catalogReleased are a module's released versions, asked of the seat mesh-catalog's verb versions through call.
func catalogReleased(call toolCaller) versions.CatalogVersions {
return func(_ context.Context, module string) ([]meshcatalog.VersionEntry, error) {
raw, err := call("seat:"+meshcatalog.Seat+".versions", meshcatalog.VersionsInput{Module: module})
if err != nil {
return nil, err
}
var a meshcatalog.VersionsAnswer
if err := json.Unmarshal(raw, &a); err != nil {
return nil, fmt.Errorf("the seat mesh-catalog's versions answered what does not read: %w", err)
}
return a.Versions, nil
}
}