id

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package id defines TypeID-based identity types for all Vault entities.

Every entity in Vault uses a single ID struct with a prefix that identifies the entity type. IDs are K-sortable (UUIDv7-based), globally unique, and URL-safe in the format "prefix_suffix".

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnyID

type AnyID = ID

AnyID is a type alias that accepts any valid prefix.

type AuditID

type AuditID = ID

AuditID is a type-safe identifier for audit entries (prefix: "vaudit").

type ConfigID

type ConfigID = ID

ConfigID is a type-safe identifier for configs (prefix: "cfg").

type FlagID

type FlagID = ID

FlagID is a type-safe identifier for flags (prefix: "flag").

type ID

type ID struct {
	// contains filtered or unexported fields
}

ID is the primary identifier type for all Vault entities. It wraps a TypeID providing a prefix-qualified, globally unique, sortable, URL-safe identifier in the format "prefix_suffix".

var Nil ID

Nil is the zero-value ID.

func MustParse

func MustParse(s string) ID

MustParse is like Parse but panics on error. Use for hardcoded ID values.

func MustParseWithPrefix

func MustParseWithPrefix(s string, expected Prefix) ID

MustParseWithPrefix is like ParseWithPrefix but panics on error.

func New

func New(prefix Prefix) ID

New generates a new globally unique ID with the given prefix. It panics if prefix is not a valid TypeID prefix (programming error).

func NewAuditID

func NewAuditID() ID

NewAuditID generates a new unique audit ID.

func NewConfigID

func NewConfigID() ID

NewConfigID generates a new unique config ID.

func NewFlagID

func NewFlagID() ID

NewFlagID generates a new unique flag ID.

func NewOverrideID

func NewOverrideID() ID

NewOverrideID generates a new unique override ID.

func NewRotationID

func NewRotationID() ID

NewRotationID generates a new unique rotation ID.

func NewRuleID

func NewRuleID() ID

NewRuleID generates a new unique rule ID.

func NewSecretID

func NewSecretID() ID

NewSecretID generates a new unique secret ID.

func NewVersionID

func NewVersionID() ID

NewVersionID generates a new unique version ID.

func Parse

func Parse(s string) (ID, error)

Parse parses a TypeID string (e.g., "sec_01h2xcejqtf2nbrexx3vqjhp41") into an ID. Returns an error if the string is not valid.

func ParseAny

func ParseAny(s string) (ID, error)

ParseAny parses a string into an ID without type checking the prefix.

func ParseAuditID

func ParseAuditID(s string) (ID, error)

ParseAuditID parses a string and validates the "vaudit" prefix.

func ParseConfigID

func ParseConfigID(s string) (ID, error)

ParseConfigID parses a string and validates the "cfg" prefix.

func ParseFlagID

func ParseFlagID(s string) (ID, error)

ParseFlagID parses a string and validates the "flag" prefix.

func ParseOverrideID

func ParseOverrideID(s string) (ID, error)

ParseOverrideID parses a string and validates the "ovr" prefix.

func ParseRotationID

func ParseRotationID(s string) (ID, error)

ParseRotationID parses a string and validates the "rot" prefix.

func ParseRuleID

func ParseRuleID(s string) (ID, error)

ParseRuleID parses a string and validates the "rule" prefix.

func ParseSecretID

func ParseSecretID(s string) (ID, error)

ParseSecretID parses a string and validates the "sec" prefix.

func ParseVersionID

func ParseVersionID(s string) (ID, error)

ParseVersionID parses a string and validates the "ver" prefix.

func ParseWithPrefix

func ParseWithPrefix(s string, expected Prefix) (ID, error)

ParseWithPrefix parses a TypeID string and validates that its prefix matches the expected value.

func (ID) IsNil

func (i ID) IsNil() bool

IsNil reports whether this ID is the zero value.

func (ID) MarshalBSONValue

func (i ID) MarshalBSONValue() (bsonType byte, data []byte, err error)

MarshalBSONValue satisfies bson.ValueMarshaler (mongo-driver v2) so the ID is stored as a BSON string instead of an opaque struct. No bson import needed because Go uses structural typing for interface satisfaction.

func (ID) MarshalText

func (i ID) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (ID) Prefix

func (i ID) Prefix() Prefix

Prefix returns the prefix component of this ID.

func (*ID) Scan

func (i *ID) Scan(src any) error

Scan implements sql.Scanner for database retrieval.

func (ID) String

func (i ID) String() string

String returns the full TypeID string representation (prefix_suffix). Returns an empty string for the Nil ID.

func (*ID) UnmarshalBSONValue

func (i *ID) UnmarshalBSONValue(t byte, data []byte) error

UnmarshalBSONValue satisfies bson.ValueUnmarshaler (mongo-driver v2).

func (*ID) UnmarshalText

func (i *ID) UnmarshalText(data []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

func (ID) Value

func (i ID) Value() (driver.Value, error)

Value implements driver.Valuer for database storage. Returns nil for the Nil ID so that optional foreign key columns store NULL.

type OverrideID

type OverrideID = ID

OverrideID is a type-safe identifier for overrides (prefix: "ovr").

type Prefix

type Prefix string

Prefix identifies the entity type encoded in a TypeID.

const (
	PrefixSecret   Prefix = "sec"
	PrefixFlag     Prefix = "flag"
	PrefixRule     Prefix = "rule"
	PrefixConfig   Prefix = "cfg"
	PrefixOverride Prefix = "ovr"
	PrefixRotation Prefix = "rot"
	PrefixVersion  Prefix = "ver"
	PrefixAudit    Prefix = "vaudit"
)

Prefix constants for all Vault entity types.

type RotationID

type RotationID = ID

RotationID is a type-safe identifier for rotations (prefix: "rot").

type RuleID

type RuleID = ID

RuleID is a type-safe identifier for rules (prefix: "rule").

type SecretID

type SecretID = ID

SecretID is a type-safe identifier for secrets (prefix: "sec").

type VersionID

type VersionID = ID

VersionID is a type-safe identifier for versions (prefix: "ver").

Jump to

Keyboard shortcuts

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