Files
mesh-delivery/modules/mesh-grants/internal/buscompose/names.go
T

83 lines
3.8 KiB
Go

package buscompose
import (
"fmt"
"regexp"
)
// **The states and holders of other parts that the grants part names** (novox/hq ADR 0634 §1: no contract names a holder; ADR 0635
// §4): each is the holder's own manifest's, as its `reads` and states say it, and the part reads or grants them by these names.
// TestTheNamesAreTheManifests checks those its own manifest lists in `reads`.
const (
AssignerModule = "mesh-delivery-assigner"
IndexerModule = "mesh-delivery-indexer"
VaultModule = "mesh-vault"
// EnrolmentModule is the module holding the seat mesh-node-enroller.
EnrolmentModule = "mesh-enrolment"
// PlacementBucket and SeatHoldersBucket are the assigner's states placement and seat-holders (reads:
// mesh-delivery-assigner.placement; the seat-holders state is read as a named reader), PlacementRead the address of the first.
PlacementBucket = AssignerModule + "_placement"
PlacementRead = AssignerModule + ".placement"
SeatHoldersRead = AssignerModule + ".seat-holders"
SeatHoldersBucket = AssignerModule + "_seat-holders"
AssignerWantsBucket = AssignerModule + "_wants"
PlacementCandidatesBucket = AssignerModule + "_candidates"
PlacementProposalsBucket = AssignerModule + "_placement-proposals"
CandidatesBucket = IndexerModule + "_candidates"
ModulesBucket = IndexerModule + "_modules"
ManifestsBucket = IndexerModule + "_manifests"
VerdictsBucket = IndexerModule + "_verdicts"
EnrolmentsState = "enrolments"
EnrolmentsBucket = EnrolmentModule + "_" + EnrolmentsState
EnrolmentsRead = EnrolmentModule + "." + EnrolmentsState
// EnrolmentLive and EnrolmentRedeeming are the stages of an enrolment the grants part reads (the seat's Stage).
EnrolmentLive = "live"
EnrolmentRedeeming = "redeeming"
NodeLoginsState = "node-logins"
NodeLoginsBucket = VaultModule + "_" + NodeLoginsState
NodeLoginsRead = VaultModule + "." + NodeLoginsState
SignersBucket = VaultModule + "_signers"
// RotateNodeVerb and NodeAccountConfirmVerb are the seat mesh-vault's verbs the grants part grants.
RotateNodeVerb = "rotate-node"
NodeAccountConfirmVerb = "node-account-confirm"
// The node-engine's states (its module is EngineModule).
EngineDataState = "data"
EngineDataBucket = EngineModule + "_" + EngineDataState
EngineDataRead = EngineModule + "." + EngineDataState
// EnginePackagesState is the engine's state of its node's declared packages.
EnginePackagesState = "packages"
NodeHealthBucket = EngineModule + "_health"
NodeHealthRead = EngineModule + ".health"
HaveBucket = "node-engine_have"
// HaveNodeWord is the word a node's own key in `have` carries after its name.
HaveNodeWord = "node"
// ComposedState is the engine's per-node state of compositions, kept one bucket per node, `composed-<node>`.
ComposedState = "composed"
ComposedRead = EngineModule + "." + ComposedState
ComposedBucketPrefix = "composed-"
ComposedHistory = 5
)
// ComposedReaders are the modules the engine's compositions are read by (the engine's `composed` state is named-reader).
var ComposedReaders = []string{AssignerModule, "mesh-delivery-view", "mesh-provisioner"}
var composedNode = regexp.MustCompile(`^[A-Za-z0-9_-]+$`)
// ComposedBucketFor is the name of a node's bucket of compositions: `composed-<node>`, the node's name one a bucket and a
// subject token accept (letters, digits, '_' and '-').
func ComposedBucketFor(node string) (string, error) {
if node == "" {
return "", fmt.Errorf("buscompose: the node name is empty; a node's composition bucket is named for its node")
}
if !composedNode.MatchString(node) {
return "", fmt.Errorf("buscompose: the node name %q is not one a bucket accepts: letters, digits, '_' and '-' only", node)
}
return ComposedBucketPrefix + node, nil
}