Documentation
¶
Overview ¶
Package naming turns human display names into kcp workspace names.
Workspace names are DNS labels and display names are arbitrary UTF-8, so something has to give. A Strategy decides what: how a display name maps to a workspace name, and what to fall back to when two objects want the same one. Every strategy is a pure function of the object's display name and UID, so reconciling the same object always proposes the same names and never needs to store a decision anywhere.
Index ¶
Constants ¶
const ( // StrategySlug names workspaces after the display name, slugified, // falling back to a UID-derived suffix on collision. The default. StrategySlug = "slug" // StrategyUID names workspaces after the object's UID alone. Opaque // but immune to display-name games; use it when display names are // user-controlled and cosmetic. StrategyUID = "uid" )
Variables ¶
This section is empty.
Functions ¶
func MembershipName ¶
MembershipName derives the object name of a grant from what it grants to whom. It is deterministic so that granting the same access twice is an update in place rather than a second object saying the same thing — which is what lets a role be changed by re-granting it, and what makes seeding safe to repeat.
Subject, tenant and project are slugified because they become part of an object name: a subject is usually an email address, which is not a DNS label. Different subjects can end up with the same slug (alice@x.com, ALICE@X.COM and a group called alice.x.com all become alice-x-com), so a short hash of the kind and subject is added to tell them apart.
Types ¶
type Strategy ¶
type Strategy interface {
// Name returns the strategy's flag value.
Name() string
// Propose returns candidate workspace names, most preferred first.
// Every candidate is a valid DNS label. displayName may be arbitrary
// UTF-8; uid must be stable and unique for the object's lifetime.
Propose(displayName, uid string) []string
}
A Strategy proposes workspace names for an object. Propose returns candidates in preference order; the caller tries each until one is free or already owned by the same object. The last candidate embeds the object's UID and therefore cannot collide with a different object's candidates, so the list never runs out for a well-behaved caller.