uidp

package
v0.1.19 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

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

View Source
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

func Ancestry(child string) []string

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 InRoot

func InRoot(child string) bool

InRoot checks whether the UIDP is in the root, as opposed to within a group

func IsAncestor

func IsAncestor(parent, child string) bool

IsAncestor checks whether the "parent" UIDP is an ancestor (non-inclusive) of the given "child" UIDP.

func IsAncestorOrSelf

func IsAncestorOrSelf(parent, child string) bool

IsAncestorOrSelf checks whether the "parent" UIDP is an ancestor (inclusive) of the given "child" UIDP.

func Parent

func Parent(child string) string

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 "/"

func Parents

func Parents(child string) []string

Parents returns all "parent" UIDP for a child UIDP. Returns empty slice if parent is root.

Example:

Parents("a/b/c/d") returns ["a/b/c", "a/b", "a"]

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.

func NewSUID

func NewSUID() SUID

func (SUID) String

func (u SUID) String() string

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.

func NewUID

func NewUID() UID

func (UID) String

func (u UID) String() string

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 NewUIDP

func NewUIDP(path UIDP) UIDP

func (UIDP) NewChild

func (u UIDP) NewChild() UIDP

func (UIDP) String

func (u UIDP) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL