Help us shape the future of Go! Take the 2026 Go Developer Survey

catalog

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package catalog contains explicit credential catalog backends.

Index

Constants

View Source
const (
	// Filename is the only catalog data file in a local catalog root.
	Filename     = "catalog.json"
	LockFilename = ".catalog.lock"

	SchemaV1        = credentials.RecordSchemaV1
	CatalogSchemaV1 = SchemaV1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Hooks

type Hooks struct {
	BeforeRead  func() error
	BeforeReady func() error
	BeforeClose func() error
	// BeforeInitialize runs only for a newly O_EXCL-created catalog file,
	// while the constructor holds the cross-process lock.
	BeforeInitialize func() error
	BeforeTempWrite  func() error
	BeforeRename     func() error
	AfterRename      func() error
	BeforeUnlink     func() error
	AfterUnlink      func() error
	SyncDir          func() error
}

Hooks are failure-injection seams used by tests. Production callers should leave them nil. Mutation hooks execute while the cross-process lock is held; lifetime hooks run at the corresponding lock boundary.

type Local

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

Local is a strict owner-only catalog backed by one bounded JSON file. The platform implementation retains an open root descriptor and lock handle so path replacement cannot redirect operations to a different directory.

func New

func New(root string) (*Local, error)

New opens a local catalog rooted at an explicit absolute directory.

func NewCatalog

func NewCatalog(root string) (*Local, error)

NewCatalog is a descriptive alias for New.

func NewLocal

func NewLocal(root string) (*Local, error)

NewLocal is a descriptive alias for New.

func NewLocalCatalog

func NewLocalCatalog(root string) (*Local, error)

func NewWithOptions

func NewWithOptions(root string, options Options) (*Local, error)

NewWithOptions opens a local catalog with test-only failure hooks.

func Open

func Open(root string) (*Local, error)

Open is an alias for New.

func (*Local) Close

func (l *Local) Close() error

Close releases the held root and lock descriptors. It is idempotent.

func (*Local) Create

func (l *Local) Create(ctx context.Context, record credentials.Record) error

Create publishes one record only when its reference is absent. The file rename is the mutation linearization point; after a successful rename a canceled context does not turn the committed mutation into a failure.

func (*Local) Delete

func (l *Local) Delete(ctx context.Context, ref credentials.Reference) error

Delete removes one catalog record. It is deliberately a catalog-only operation; state deletion is the caller's separate exact-version action.

func (*Local) Get

Get resolves exactly one safe record. The complete file is validated before the requested record is returned.

func (*Local) List

func (l *Local) List(ctx context.Context) ([]credentials.Record, error)

List validates and returns all records in stable canonical-reference order.

func (*Local) Path

func (l *Local) Path() string

Path returns the path at which the data file is presented. It is for diagnostics and tests; callers must use Catalog methods for access.

func (*Local) Root

func (l *Local) Root() string

Root returns the explicit clean path supplied to New.

func (*Local) Update

func (l *Local) Update(ctx context.Context, expected, next credentials.Record) error

Update performs an optional compare-and-swap replacement. Both records are validated and the expected record must match byte-for-byte at the mutation point. Create and Delete never weaken their own semantics.

type LocalCatalog

type LocalCatalog = Local

type Options

type Options struct{ Hooks Hooks }

Options configures NewWithOptions.

Jump to

Keyboard shortcuts

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