secret

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package secret resolves secret references of the form <scheme>://<ref> against pluggable sources — the seam that lets mcpcli pull credentials from Bitwarden Secrets Manager (bws://) today and other secret managers later. A Resolver is built per run with its sources handed in explicitly (no init, no global registry): adding a manager means one new package implementing Source plus one registration line at the cli wiring site.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Resolver

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

Resolver dispatches secret references to registered sources. Build one per run with New; a Resolver is immutable after construction and holds nothing but its source map.

func New

func New(sources ...Source) (*Resolver, error)

New returns a Resolver dispatching to the given sources. Schemes are lowercased at insert and deduped on the lowered form, so two sources claiming the same scheme in any case spelling fail construction. An empty Scheme is not special-cased and simply dedupes like any other value.

func (*Resolver) Expand

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

Expand resolves value when its scheme matches a registered source — the scheme is lowercased before lookup (RFC 3986: schemes are case-insensitive, so "BWS://name" reaches the "bws" source) and the source receives whatever follows the first "://". Anything else passes through unchanged. Expansion is single-pass: a resolved value is never re-scanned, so a decrypted secret whose VALUE is itself a registered ref comes back as-is instead of looping (self or mutual refs).

func (*Resolver) Recognizes

func (r *Resolver) Recognizes(value string) bool

Recognizes reports whether value looks like a reference this Resolver would expand: its scheme — lowercased, same rule as Expand — matches a registered source. It performs no resolution (no network, no side effects), so callers can classify values without paying for a fetch.

type Source

type Source interface {
	Scheme() string
	Resolve(ctx context.Context, ref string) (string, error)
}

Source resolves references for one URL scheme. Scheme returns the scheme it claims (compared case-insensitively: "BWS" and "bws" are the same registration). Resolve receives ref — whatever follows the "<scheme>://" prefix — and owns its grammar entirely (uuid, name, path, ...).

Jump to

Keyboard shortcuts

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