store

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

Store manages encrypted .env version history.

func New

func New(maxVersions int) (*Store, error)

New creates a new Store with the given maximum version count.

func (*Store) Append

func (s *Store) Append(projectID string, content []byte, encryptionKey [32]byte) (*VersionInfo, error)

Append encrypts and saves a .env file as the next version in one atomic, locked operation.

func (*Store) CheckWritable

func (s *Store) CheckWritable(projectID string) error

CheckWritable verifies that the project namespace can be locked and created without mutating version history.

func (*Store) Latest

func (s *Store) Latest(projectID string) (*VersionInfo, error)

Latest returns the most recent version, or nil if none exist.

func (*Store) List

func (s *Store) List(projectID string) ([]VersionInfo, error)

List returns all stored versions for a project, newest first.

func (*Store) MigrateNamespace

func (s *Store) MigrateNamespace(fromProjectID, toProjectID string) error

MigrateNamespace copies legacy encrypted backup files into the canonical project namespace without deleting the source namespace.

func (*Store) NextSequence

func (s *Store) NextSequence(projectID string) (int, error)

NextSequence returns the next monotonically increasing version sequence number for a project.

func (*Store) Reencrypt

func (s *Store) Reencrypt(projectID string, oldKey, newKey [32]byte) error

Reencrypt rewrites all stored versions for a project with a new at-rest key.

func (*Store) Restore

func (s *Store) Restore(projectID string, sequence int, encryptionKey [32]byte) ([]byte, error)

Restore decrypts and returns a specific version.

func (*Store) Save

func (s *Store) Save(projectID string, content []byte, sequence int, encryptionKey [32]byte) error

Save encrypts and saves a .env file as a new version.

type VersionInfo

type VersionInfo struct {
	Sequence  int
	Timestamp time.Time
	FilePath  string
	SizeBytes int64
}

VersionInfo describes a stored version.

Jump to

Keyboard shortcuts

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