Documentation
¶
Overview ¶
Package uidp contains utilities for reasoning about and manipulating the Chainguard IAM "UIDP" (UID Path) concept.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Valid = regexp.MustCompile(`^[0-9a-f]{40}(?:/[0-9a-f]{16})*$`).MatchString
Valid returns true for valid UIDP values. The base segment of a UIDP is 20 hex-encoded bytes (40 characters). This may be followed by zero or more parts with 8 hex-encoded bytes (16 characters).
Functions ¶
func Ancestry ¶
Ancestry returns all parent UIDPs and the child. Returns only the child if it is root.
Example:
Ancestry("a/b/c/d") returns ["a/b/c/d", "a/b/c", "a/b", "a"]
func IsAncestor ¶
IsAncestor checks whether the "parent" UIDP is an ancestor (non-inclusive) of the given "child" UIDP.
func IsAncestorOrSelf ¶
IsAncestorOrSelf checks whether the "parent" UIDP is an ancestor (inclusive) of the given "child" UIDP.
func Parent ¶
Parent returns the "parent" UIDP for a child UIDP. Returns / if parent is root.
Example:
Parent("a/b/c") returns "a/b"
Parent("a") returns "/"
Types ¶
type SUID ¶
type SUID string
SUID is be used to form the primary key for items that must be unique within some scoping (non-global).
- A SUID is 8 random bytes, URL safe hex encoded.
type UID ¶
type UID string
UID will is used for the primary key for items that must be globally unique.
- A UID is 20 bytes of random bytes, URL safe hex encoded.
type UIDP ¶
type UIDP string
UIDP is be used to denote the fully-qualified path for scoped keys.
- A UIDP will consist of '/' delimited SUID segments with a UID root, following POSIX directory semantics.
- The "basename" SUID is our key within the scoping of the "dirname" UIDP.
func (UIDP) Reparent ¶ added in v0.1.55
Reparent creates a new UIDP under parent using the SUID of u. This produces a deterministic child UIDP, useful when moving a record from one parent to another while preserving its identity within the new parent.
u must not be a root-level UIDP (i.e. it must contain a '/'). Returns an error if u has no SUID component to preserve.