envstore

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package envstore is the per-app encrypted environment store (plan §5.5, M5). The whole env blob is AES-256-GCM at rest under the master key; every save is a new immutable version (auditable history + rollback). Secret-flagged values are write-only in the UI and only ever leave via the audited reveal endpoint. Mooring owns the live env: at deploy it renders a fresh 0600 --env-file from this store (plan: env-import "own vs import").

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrBadKey means an env key failed the name grammar.
	ErrBadKey = errors.New("envstore: invalid key (use letters, digits, underscore; not starting with a digit)")
	// ErrBadValue means a value contained NUL or a bare CR/LF.
	ErrBadValue = errors.New("envstore: value must not contain NUL or newlines")
)

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Key    string
	Value  secret.Redacted
	Secret bool
	// Enc marks how Value is encoded for storage. "" means a plain value; "b64"
	// means Value is std-base64 and must be decoded before use (this is how
	// multi-line secrets — generated PEM keypairs — survive the no-newline rule).
	Enc string
}

Entry is one environment variable. Value is wrapped so it never logs in clear.

func (Entry) DecodedValue

func (e Entry) DecodedValue() ([]byte, error)

DecodedValue returns the entry's value with any storage encoding undone: a "b64" entry (a generated PEM keypair) decodes back to the raw PEM bytes.

type Store

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

Store persists encrypted, versioned env blobs.

func New

func New(db *store.DB, cipher *secret.Cipher) *Store

New builds a Store.

func (*Store) Current

func (s *Store) Current(project string) ([]Entry, int, error)

Current returns the latest version's entries (sorted by key) and its version number (0 if none yet).

func (*Store) DeleteApp

func (s *Store) DeleteApp(ctx context.Context, project string) error

DeleteApp removes ALL env versions (literals + encrypted secrets) for an app — the entire history, so no secret material survives. Used by the app-delete teardown.

func (*Store) Get

func (s *Store) Get(project, key string) (Entry, bool, error)

Get returns one key's full entry, including its Enc marker (so a caller that writes the value to a file can decode it). Prefer this over Reveal for secret_files materialization.

func (*Store) Render

func (s *Store) Render(project string) (map[string]string, error)

Render returns the current env as a key→value map for deploy and validation.

func (*Store) Reveal

func (s *Store) Reveal(project, key string) (string, bool, error)

Reveal returns one key's plaintext value (for the audited reveal endpoint).

func (*Store) Rollback

func (s *Store) Rollback(ctx context.Context, project string, version int, actor string) (int, error)

Rollback re-saves a prior version's content as a NEW version (never a pointer flip — the history stays linear and auditable, plan philosophy).

func (*Store) Save

func (s *Store) Save(ctx context.Context, project string, entries []Entry, actor string) (int, error)

Save validates and writes a new version. Duplicate keys are rejected.

func (*Store) Versions

func (s *Store) Versions(project string) ([]Version, error)

Versions lists the version history (newest first).

type Version

type Version struct {
	Version   int
	CreatedAt int64
	Actor     string
}

Version describes one saved blob version.

Jump to

Keyboard shortcuts

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