secrets

package
v1.30.3 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2026 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Registry

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

Registry manages all secret resolvers. It is thread-safe and can be used concurrently.

func NewRegistry

func NewRegistry(baseDirs ...string) *Registry

NewRegistry creates a new registry with all registered providers. baseDirs is used by the file provider to resolve relative paths. The file provider tries each base directory in order until a file is found.

func (*Registry) CheckAccessibility

func (r *Registry) CheckAccessibility(ctx context.Context, refs []core.SecretRef) error

CheckAccessibility validates that all secrets are accessible without fetching values. Used during dry-run and validate modes. Returns an error if any secret is inaccessible.

func (*Registry) Get

func (r *Registry) Get(provider string) Resolver

Get retrieves a resolver by provider name. Returns nil if the provider is not registered.

func (*Registry) Providers

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

Providers returns the names of all registered providers.

func (*Registry) Register

func (r *Registry) Register(name string, res Resolver)

Register adds a custom resolver to the registry. If a resolver with the same name already exists, it will be replaced. This is useful for adding custom providers or testing.

func (*Registry) Resolve

func (r *Registry) Resolve(ctx context.Context, ref core.SecretRef) (string, error)

Resolve fetches a single secret value. Returns an error if the provider is unknown or resolution fails.

func (*Registry) ResolveAll

func (r *Registry) ResolveAll(ctx context.Context, refs []core.SecretRef) ([]string, error)

ResolveAll fetches all secrets and returns them as environment variable strings. Format: "NAME=value" Returns an error if any secret fails to resolve.

type Resolver

type Resolver interface {
	// Name returns the provider identifier (e.g., "env", "file", "gcp-secrets").
	Name() string

	// Resolve fetches the secret value for the given reference.
	// Returns an error if the secret cannot be retrieved.
	Resolve(ctx context.Context, ref core.SecretRef) (string, error)

	// Validate checks if the secret reference is structurally valid for this provider.
	// This is called at parse time and should not make network calls.
	Validate(ref core.SecretRef) error

	// CheckAccessibility verifies the secret is accessible without fetching its value.
	// Used during dry-run and validate modes.
	// Should verify:
	//   - Provider is reachable
	//   - Credentials are valid
	//   - Secret exists
	//   - Caller has permission
	CheckAccessibility(ctx context.Context, ref core.SecretRef) error
}

Resolver fetches secret values from a specific backend. Implementations must be thread-safe as they may be called concurrently.

Jump to

Keyboard shortcuts

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