local

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package local implements an owner-only, descriptor-relative local secret store. The root is always supplied explicitly by the caller.

Index

Constants

This section is empty.

Variables

View Source
var ErrCommitVisibleDurabilityUnknown = ErrDurabilityUnknown

ErrCommitVisibleDurabilityUnknown is a descriptive alias retained for callers that name the visible commit state explicitly.

View Source
var ErrDurabilityUnknown = errors.New("local: visible commit durability unknown")

ErrDurabilityUnknown identifies a mutation whose visible state changed but whose directory durability could not be confirmed.

View Source
var ErrListTooLarge = errors.New("local: listing exceeds bounded record limit")

ErrListTooLarge reports a directory whose bounded scan would exceed the local store's work and memory budget.

View Source
var ErrPageTokenExpired = errors.New("local: page token expired")

ErrPageTokenExpired identifies a continuation token that was evicted, consumed, or belongs to another store instance.

View Source
var ErrUnsupportedPlatform = errors.New("local: unsupported platform")

ErrUnsupportedPlatform identifies a platform where this package cannot prove the required handle-relative and owner-only invariants.

Functions

This section is empty.

Types

type CommitVisibleDurabilityUnknownError

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

CommitVisibleDurabilityUnknownError reports a successful rename/unlink followed by failed durability bookkeeping. Visible is always true; callers must reread/adopt state and must not assume the old value survived.

func (*CommitVisibleDurabilityUnknownError) Error

func (*CommitVisibleDurabilityUnknownError) Is

func (*CommitVisibleDurabilityUnknownError) Reference

Reference returns the safe reference associated with the visible mutation.

func (*CommitVisibleDurabilityUnknownError) Unwrap

func (*CommitVisibleDurabilityUnknownError) Visible

Visible reports that the rename or unlink already occurred.

type DurabilityUnknownError

type DurabilityUnknownError = CommitVisibleDurabilityUnknownError

DurabilityUnknownError is an alias for the typed visible-commit failure.

type Hooks

type Hooks struct {
	BeforeRead         func() error
	BeforeExistingRead func() error
	BeforeVersion      func() error
	BeforeTempWrite    func() error
	BeforeWrite        func() error
	BeforeRename       func() error
	AfterRename        func() error
	BeforeUnlink       func() error
	AfterUnlink        func() error
	SyncDir            func() error
	NewVersion         func() (secrets.Version, error)
}

Hooks are optional test seams for exercising cancellation, mutation linearization, and durability rules. Production callers should leave all fields nil. Mutation hooks run while the store's cross-process lock is held; read hooks run immediately before their unresolved filesystem read.

type Options

type Options struct {
	Hooks Hooks
}

Options configures NewWithOptions. The zero value is the normal production configuration.

type PageTokenExpiredError

type PageTokenExpiredError struct {
	Reason string
}

PageTokenExpiredError reports stateful cursor expiry without exposing the token itself. A continuation token is one-time use and is never replayable.

func (*PageTokenExpiredError) Error

func (e *PageTokenExpiredError) Error() string

func (*PageTokenExpiredError) Unwrap

func (e *PageTokenExpiredError) Unwrap() error

type Store

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

Store is a concurrent-safe local secret store. A Store owns an open handle to its root directory for its entire lifetime.

func New

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

New opens or creates an owner-only store rooted at root. root must be an absolute, clean path; no environment variable or process home is consulted.

func NewStore

func NewStore(root string) (*Store, error)

NewStore is an explicit alias for New for callers that prefer a noun-style constructor.

func NewWithOptions

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

NewWithOptions opens a store with optional failure-injection hooks.

func Open

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

Open is an alias for New.

func (*Store) Close

func (s *Store) Close() error

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

func (*Store) Delete

Delete removes exactly ref. Unlink is the deletion linearization point and absent references are idempotent.

func (*Store) Filename

func (s *Store) Filename(ref secrets.Reference) string

Filename returns the single path component used for ref. It is useful for diagnostics and tests; callers must not use it to bypass Store methods.

func (*Store) List

func (s *Store) List(ctx context.Context, namespace secrets.Namespace, token secrets.PageToken, limit int) (secrets.Page[secrets.Metadata], error)

List returns metadata only, constrained to namespace and a bounded page. The first call captures a bounded in-memory snapshot; continuation tokens identify that snapshot and cannot cross stores or namespaces.

func (*Store) Put

func (s *Store) Put(ctx context.Context, ref secrets.Reference, value secrets.Secret, options secrets.PutOptions) (secrets.Record, error)

Put stores value under ref according to options. Rename is the mutation linearization point; after it succeeds the old value is never reported as surviving.

func (*Store) Resolve

func (s *Store) Resolve(ctx context.Context, ref secrets.Reference) (secrets.Record, error)

Resolve loads one record and validates its envelope before returning it.

func (*Store) Root

func (s *Store) Root() string

Root returns the clean root path supplied to the constructor.

func (*Store) SupportsCompareAndSwap

func (s *Store) SupportsCompareAndSwap() bool

SupportsCompareAndSwap reports affirmative CAS support.

func (*Store) SupportsCreateOnly

func (s *Store) SupportsCreateOnly() bool

SupportsCreateOnly reports affirmative create-only support.

type UnsupportedPlatformError

type UnsupportedPlatformError struct{}

UnsupportedPlatformError is returned at construction time on platforms without the required filesystem primitives.

func (UnsupportedPlatformError) Error

func (UnsupportedPlatformError) Unwrap

Jump to

Keyboard shortcuts

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