Files
mesh-delivery/sdk/kept/kept.go
T
jschoubben 541eaa20fe
mesh/delivery merged: source.main moved to novox/mesh-delivery@21eaa55b277a
mesh/delivery-group group fix/47-G-bridge merged: every member is merged
mesh/check checking 541eaa20fec4 on 21eaa55b277a
Bridge for G's take-in: the pre-G package directories contracts/go and sdk again, unused
The running pre-G indexer publishes a repository's packages only when every package directory it published last is
still in the tree; G moved contracts/go and sdk to modules/, so mesh-delivery's packages, G's renamed paths among them,
are never published and nothing importing them builds (2026-11-13, indexer journal 'its packages are not published').
These are the trees of e70754ef, unchanged, without sdk/module.json (no second module). Nothing imports them; they go
once G's indexer runs and publishes without them.

Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
2026-11-13 14:34:40 +01:00

35 lines
1.1 KiB
Go

// Package kept holds what the layouts of the Delivery domain's kept values share: the reading of one at its version and the form
// of a digest. It names no seat and no module (ADR 0634 §2). The version (keys.Version, keys.CheckVersion), the rule a name
// must keep to be a key part (keys.CheckName), keys.IsHex64 and the escaping of a name (keys.EscapeName) are mesh-sdk's,
// since more than one domain uses them.
package kept
import (
"encoding/json"
"fmt"
"regexp"
"git.novox.be/novox/mesh-sdk/go/keys"
)
// Decode reads data into into after CheckVersion.
func Decode(data []byte, into any) error {
if err := keys.CheckVersion(data); err != nil {
return err
}
if err := json.Unmarshal(data, into); err != nil {
return fmt.Errorf("kept: value does not fit its shape: %w", err)
}
return nil
}
var digestForm = regexp.MustCompile(`^sha256:[0-9a-f]{64}$`)
// CheckDigest refuses a digest that is not sha256:<64 lowercase hex digits>, saying what it is of.
func CheckDigest(digest, of string) error {
if !digestForm.MatchString(digest) {
return fmt.Errorf("kept: %s %q is not sha256:<64 lowercase hex digits>", of, digest)
}
return nil
}