Help us shape the future of Go! Take the 2026 Go Developer Survey

secrets

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package secrets resolves secret references in configuration through an omnivault vault.

A Resolver expands ${NAME} and $NAME references the way os.ExpandEnv does, except that each NAME is read from a vault instead of the process environment. The default resolver (Env) is backed by omnivault's environment provider and behaves exactly like os.ExpandEnv: a reference to a missing secret expands to the empty string.

Any other vault plugs in through New (an omnivault.Vault the deployment built itself) or FromURI (an omnivault URI such as env://, file:///dir, or a scheme a cloud provider package registered with omnivault.RegisterProvider). SystemForge itself imports no cloud SDK: a deployment that keeps its secrets in, say, AWS Secrets Manager imports that provider's registration package in its own main package.

Errors other than "secret not found" (an unreachable vault, a permission error) are returned, never treated as an empty value.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WholeReference

func WholeReference(s string) (string, bool)

WholeReference reports whether s is entirely one ${NAME} reference and returns NAME.

Types

type Resolver

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

Resolver reads secret values from an omnivault vault.

func Env

func Env() *Resolver

Env returns a resolver backed by the process environment, the default: Expand then behaves exactly like os.ExpandEnv.

func FromURI

func FromURI(uri string) (*Resolver, error)

FromURI returns a resolver backed by the vault omnivault.VaultFromURI opens for uri (env://, file:///dir, memory://, or a scheme registered with omnivault.RegisterProvider). Close closes the vault.

func New

func New(v omnivault.Vault) (*Resolver, error)

New returns a resolver backed by v. Close closes v.

func (*Resolver) Close

func (r *Resolver) Close() error

Close releases the backing vault.

func (*Resolver) Expand

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

Expand replaces ${NAME} and $NAME references in s with the secrets they name, with os.Expand's syntax; a missing secret expands to the empty string. It returns the first vault error.

func (*Resolver) ExpandWhole

func (r *Resolver) ExpandWhole(ctx context.Context, s string) (string, error)

ExpandWhole is Expand for values that may hold arbitrary data, such as PEM keys: a value that is entirely one ${NAME} reference (surrounding space ignored) is replaced by the secret without re-scanning it, so a "$" inside the secret is kept. Anything else goes through Expand.

func (*Resolver) Lookup

func (r *Resolver) Lookup(ctx context.Context, name string) (string, bool, error)

Lookup returns the secret stored under name and whether it exists. A missing secret is not an error; any other vault error is returned.

func (*Resolver) Name

func (r *Resolver) Name() string

Name returns the backing vault's provider name.

Jump to

Keyboard shortcuts

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