providers

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BWProvider

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

BWProvider wraps BWClient to implement the Provider interface. URI parsing is handled here so that callers only see the generic Resolve(uri) method.

func NewBWProvider

func NewBWProvider(client *bw.BWClient) *BWProvider

NewBWProvider creates a BWProvider backed by the given BWClient.

func (*BWProvider) Client

func (p *BWProvider) Client() *bw.BWClient

Client returns the underlying BWClient. Use this only when you need access to BW-specific operations (e.g. FolderItems) that are not part of the Provider interface.

func (*BWProvider) Close

func (p *BWProvider) Close() error

Close zeros the in-process BW session token.

func (*BWProvider) Resolve

func (p *BWProvider) Resolve(uri string) (string, error)

Resolve parses the bw:// URI and delegates to the underlying BWClient.

func (*BWProvider) Schemes

func (p *BWProvider) Schemes() []string

Schemes returns ["bw"] — the URI scheme handled by this provider.

type Provider

type Provider interface {
	// Schemes returns the URI schemes this provider handles, e.g. ["bw"].
	Schemes() []string

	// Resolve fetches the secret identified by the full URI string (e.g. "bw://folder/item")
	// and returns its plaintext value.
	// URI parsing and validation are the responsibility of the provider.
	Resolve(uri string) (string, error)

	// Close releases any in-process resources (sessions, tokens).
	// It must be safe to call multiple times.
	Close() error
}

Provider is the extension point for secret backends. Each backend implements this interface and registers itself with a Registry so callers never need to import concrete client types.

type Registry

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

Registry routes secret URIs to the correct Provider by URI scheme. Build one registry at startup and pass it to all callers instead of threading concrete provider types throughout the codebase.

Usage:

reg := providers.NewRegistry()
reg.Register(providers.NewBWProvider(bwClient))
value, err := reg.Resolve("bw://folder/item")

func NewRegistry

func NewRegistry() *Registry

NewRegistry returns an empty registry.

func (*Registry) Close

func (r *Registry) Close() error

Close calls Close on every registered provider exactly once. If a provider is registered for multiple schemes it is still closed only once. A non-nil error from one provider does not stop the others from being closed. The last non-nil error is returned.

func (*Registry) IsSecretRef

func (r *Registry) IsSecretRef(uri string) bool

IsSecretRef returns true if uri uses a scheme registered with this registry.

func (*Registry) ProviderFor

func (r *Registry) ProviderFor(scheme string) (Provider, bool)

ProviderFor returns the provider registered for the given scheme. The second return value is false if no provider is registered.

func (*Registry) Register

func (r *Registry) Register(p Provider)

Register adds a provider for all of its declared schemes. Panics if a scheme is already registered — this is a programming error caught at startup, not a runtime condition.

func (*Registry) Resolve

func (r *Registry) Resolve(uri string) (string, error)

Resolve dispatches a secret URI to the appropriate provider. Returns an error if no provider is registered for the URI scheme.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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