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

vault

package
v0.1.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package vault stores secret values in an encrypted file in the workspace (vault.enc), so collections and environment files only ever hold references.

The file is AES-256-GCM encrypted. Its key is a random data key kept in the OS keychain or, where there is no keychain (headless Linux, CI), a key derived with Argon2id from FLOWI_VAULT_KEY or a passphrase. The source is recorded in the file, so a vault is always reopened the way it was created.

FLOWI_SECRET_<ENV>_<NAME> environment variables override vault entries without unlocking it. Masker hides secret values in anything shown or saved.

Index

Constants

View Source
const Mask = "••••••"

Mask replaces secret values wherever they are shown or saved.

View Source
const WorkspaceScope model.ID = "workspace"

WorkspaceScope is the Entry.Collection of secrets that belong to a global environment. Environments are workspace-wide, so their secrets are not tied to any collection. It is not a valid collection id.

Variables

View Source
var ErrKeyNotFound = errors.New("vault key not found")

ErrKeyNotFound is returned by KeyStore.Get when there is no such entry.

Functions

func Overridden

func Overridden(environ []string, envName, name string) (string, bool)

Overridden returns the FLOWI_SECRET_<ENV>_<NAME> value for a secret. An empty value counts as unset, as for every FLOWI_ variable.

func OverrideName

func OverrideName(envName, name string) string

OverrideName is the environment variable that overrides a secret: FLOWI_SECRET_<ENV>_<NAME>, upper-cased, with every character that is not a letter or digit replaced by "_".

Types

type Entry

type Entry struct {
	Collection  model.ID
	Environment model.ID
	Name        string
}

Entry names one secret: a variable of an environment of a collection. Environments are identified by id, so renaming an environment file keeps its secrets.

type KeyStore

type KeyStore interface {
	Get(service, account string) (string, error)
	Set(service, account, secret string) error
}

KeyStore is the OS keychain.

func OSKeyStore

func OSKeyStore() KeyStore

OSKeyStore returns the operating system keychain (macOS Keychain, Secret Service on Linux, Windows Credential Manager).

type LockedError

type LockedError struct{ Reason string }

LockedError means the vault cannot be opened or created: no key source is available, the key is gone, or the passphrase is wrong.

func (*LockedError) Error

func (e *LockedError) Error() string

type Masker

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

Masker replaces known secret values, in the forms they commonly take on the wire, with Mask. It is immutable; the zero value masks nothing.

func NewMasker

func NewMasker(values ...string) Masker

NewMasker returns a masker for values; empty values are ignored.

func (Masker) Bytes

func (m Masker) Bytes(b []byte) []byte

Bytes masks every known secret in b.

func (Masker) String

func (m Masker) String(s string) string

String masks every known secret in s.

func (Masker) With

func (m Masker) With(values ...string) Masker

With returns a masker that also masks values.

type Options

type Options struct {
	File        string // workspaces/<name>/vault.enc
	WorkspaceID model.ID
	Keys        KeyStore               // nil when there is no keychain
	Environ     []string               // for FLOWI_VAULT_KEY and FLOWI_SECRET_*
	Passphrase  func() (string, error) // nil when no prompt is possible
}

Options configures a vault.

type Vault

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

Vault is the encrypted secrets file. It is unlocked on first use and the key kept for the vault's lifetime. Safe for concurrent use.

func New

func New(o Options) *Vault

New returns a vault; nothing is read or unlocked until it is used.

func (*Vault) Get

func (v *Vault) Get(e Entry, envName string) (value string, ok bool, err error)

Get returns a secret's value. FLOWI_SECRET_<ENV>_<NAME> wins over the vault and needs no unlock; envName is the environment's name, as users write it in the variable. ok is false when the secret is not set.

func (*Vault) Names

func (v *Vault) Names(collection model.ID) ([]Entry, error)

Names lists the secrets set for a collection, never their values.

func (*Vault) Set

func (v *Vault) Set(e Entry, value string) error

Set stores a secret, creating the vault on first use.

func (*Vault) Unlock

func (v *Vault) Unlock() error

Unlock opens the vault now (asking for the passphrase if it needs one), so callers can do it before showing live output. Without a vault file there is nothing to unlock.

func (*Vault) Unset

func (v *Vault) Unset(e Entry) error

Unset removes a secret. Removing one that is not set is not an error.

Jump to

Keyboard shortcuts

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