secretref

package
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend interface {
	Resolve(ctx context.Context, ref Ref) (string, error)
}

Backend resolves a parsed secret reference into a plaintext value.

type BlobBackend

type BlobBackend interface {
	Backend
	Scheme() string
	LoadBlob(ctx context.Context, ref Ref) ([]byte, error)
}

BlobBackend extends a backend to support binary data retrieval.

type Error

type Error struct {
	Kind   ErrorKind
	Ref    string
	Detail string
	Err    error
}

Error is a typed secret reference error.

func NewError

func NewError(kind ErrorKind, ref, detail string, err error) *Error

NewError builds a typed secret-reference error. Backend implementations outside this package use it to report failures in the same shape the built-in backends do, so callers can branch on Kind regardless of which backend produced the error.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type ErrorKind

type ErrorKind string
const (
	KindInvalidRef         ErrorKind = "invalid_ref"
	KindNotFound           ErrorKind = "not_found"
	KindBackendUnavailable ErrorKind = "backend_unavailable"
)

type Ref

type Ref struct {
	Raw    string
	Scheme string
	Path   string
}

Ref represents a parsed secret reference in the form <scheme>://<path>.

func Parse

func Parse(raw string) (Ref, error)

Parse parses a secret reference.

type Resolver

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

Resolver routes secret references by scheme.

Resolutions from interactive native stores (macOS Keychain, Windows Credential Manager, Linux Secret Service) are cached in-process and deduplicated with singleflight. This matters for unsigned/dev builds, where the OS cannot persist an "always allow" ACL keyed to the binary's code signature and so re-prompts on every keychain access: without the cache, the concurrent store probes and per-action re-probes would each pop a separate password dialog. With it, a given reference prompts at most once per process.

func NewResolver

func NewResolver(backends map[string]Backend) *Resolver

NewResolver creates a resolver from scheme backends.

func (*Resolver) DeleteBlob

func (r *Resolver) DeleteBlob(ctx context.Context, raw string) error

DeleteBlob parses and removes a binary blob from a secret reference.

func (*Resolver) Exists

func (r *Resolver) Exists(ctx context.Context, raw string) (bool, error)

Exists reports whether a writable secret reference already exists.

func (*Resolver) LoadBlob

func (r *Resolver) LoadBlob(ctx context.Context, raw string) ([]byte, error)

LoadBlob parses and retrieves a binary blob from a secret reference.

func (*Resolver) Resolve

func (r *Resolver) Resolve(ctx context.Context, raw string) (string, error)

Resolve parses and resolves a secret reference.

func (*Resolver) SaveBlob

func (r *Resolver) SaveBlob(ctx context.Context, raw string, data []byte) error

SaveBlob parses and atomically stores a binary blob to a secret reference.

func (*Resolver) Store

func (r *Resolver) Store(ctx context.Context, raw, value string) error

Store writes a secret value through a writable backend.

func (*Resolver) WritableBackends

func (r *Resolver) WritableBackends() []WritableBackend

WritableBackends returns registered backends that support interactive writes.

type WritableBackend

type WritableBackend interface {
	Backend
	Scheme() string
	DisplayName() string
	WriteSupported() bool
	DefaultRef(storeName, account string) string
	Exists(ctx context.Context, ref Ref) (bool, error)
	Store(ctx context.Context, ref Ref, value string) error
}

WritableBackend extends a backend with native-store write and existence checks for interactive CLI flows.

type WritableBlobBackend

type WritableBlobBackend interface {
	BlobBackend
	SaveBlob(ctx context.Context, ref Ref, data []byte) error
	DeleteBlob(ctx context.Context, ref Ref) error
}

WritableBlobBackend extends a backend to support atomic binary data storage.

Directories

Path Synopsis
Package backends holds the secret backends Cloudstic ships with, split out from the pkg/secretref contract so that implementing a custom backend does not drag in the platform-native ones (macOS Keychain, libsecret, Windows Credential Manager) and their build constraints.
Package backends holds the secret backends Cloudstic ships with, split out from the pkg/secretref contract so that implementing a custom backend does not drag in the platform-native ones (macOS Keychain, libsecret, Windows Credential Manager) and their build constraints.

Jump to

Keyboard shortcuts

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