secretprovider

package
v0.17.3 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultCacheTTL = 5 * time.Minute

Variables

This section is empty.

Functions

func RegisterConfigs

func RegisterConfigs(registry *Registry, configs []Config) error

RegisterConfigs creates and registers providers from config blocks.

Types

type Config

type Config struct {
	Provider string `toml:"provider"`
	Alias    string `toml:"alias"`

	Address      string `toml:"address"`
	Token        string `toml:"token"`
	CacheTTL     string `toml:"cache_ttl"`
	DefaultField string `toml:"default_field"`

	AppRoleID     string `toml:"app_role_id"`
	AppRoleSecret string `toml:"app_role_secret"`
	Namespace     string `toml:"namespace"`
	KVVersion     int    `toml:"kv_version"`

	InsecureSkipTLS bool `toml:"insecure_skip_tls"`
}

Config describes one secret provider registration.

type Provider

type Provider interface {
	ID() string
	Resolve(ctx context.Context, path string, field string) (string, error)
	List(ctx context.Context, path string) ([]string, error)
}

Provider resolves secrets from an external source.

func NewOnePasswordProvider

func NewOnePasswordProvider(cfg Config) (Provider, error)

NewOnePasswordProvider creates a 1Password Connect-backed secret provider.

func NewProvider

func NewProvider(cfg Config) (Provider, error)

NewProvider creates a concrete provider from config.

func NewVaultProvider

func NewVaultProvider(cfg Config) (Provider, error)

NewVaultProvider creates a Vault-backed secret provider.

type Registry

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

Registry stores secret providers by alias and caches resolved values.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates an empty secret provider registry.

func (*Registry) Aliases

func (r *Registry) Aliases() []string

Aliases returns the registered aliases in unspecified order.

func (*Registry) HasProviders

func (r *Registry) HasProviders() bool

HasProviders reports whether any aliases are registered.

func (*Registry) List

func (r *Registry) List(ctx context.Context, alias, path string) ([]string, error)

List returns the keys at a path using the provider registered for alias.

func (*Registry) Register

func (r *Registry) Register(p Provider, alias string, cacheTTL time.Duration) error

Register adds a provider under an alias.

func (*Registry) ResetForTests

func (r *Registry) ResetForTests()

ResetForTests clears registrations and cache. Intended for tests only.

func (*Registry) Resolve

func (r *Registry) Resolve(ctx context.Context, alias, path, field string) (string, error)

Resolve fetches a secret using the provider registered for alias.

Jump to

Keyboard shortcuts

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