fsvault

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package fsvault provides a simple crud abstraction over the filesystem as a datastore.

Data keys should use '/' as a separator, which keeps the implementation simple by mirroring the underlying filesystem.

Data is any []byte slice.

Encryption of the data, at rest, is enabled by providing a list of encryption key strings to the NewFSVault() method.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete added in v0.3.0

func Delete(vaultRoot string, vaultKey string) error

Delete removes the file or directory (if empty) at key.

func DeleteMapValue added in v0.3.0

func DeleteMapValue[V any](vaultRoot string, vaultKey string, mapKey string)

func Get added in v0.3.0

func Get(vaultRoot string, vaultKey string) ([]byte, error)

Get returns the data at key, or an error.

If encryption keys are present, and a non-primary encryption key successfully decrypted the data, then the data is re-stored using the primary encryption key. See the main documentation for more on encryption key rollover.

func GetMap added in v0.3.0

func GetMap[V any](vaultRoot string, vaultKey string) map[string]V

GetMap returns the map at key, or an empty map if it doesn't exist.

func GetMapValue added in v0.3.0

func GetMapValue[V any](vaultRoot string, vaultKey string, mapKey string) V

func KeyExists added in v0.3.0

func KeyExists(vaultRoot string, vaultKey string) (bool, error)

KeyExists returns true if data exists at key, and is read/writeable.

func List added in v0.3.0

func List(vaultRoot string, vaultKey string) []string

List returns an alphabetically sorted list of the object names found a key.

func Put added in v0.3.0

func Put(vaultRoot string, vaultKey string, data []byte) error

Put writes data to a file at key, overwriting if the file exists.

If encryption keys are present then the primary (first) key is used to encrypt the data.

func PutMapValue added in v0.3.0

func PutMapValue[V any](vaultRoot string, vaultKey string, mapKey string, value V)

PutMapValue adds value at mapKey, or overwrites value if it exists

Types

type Unlocker added in v0.3.0

type Unlocker interface {
	Unlock()
}

Unlocker provides an Unlock method to release the lock.

func GetMapValueWithLock added in v0.3.0

func GetMapValueWithLock[V any](vaultRoot string, vaultKey string, mapKey string) (Unlocker, V)

GetMapValueWithLock returns the value and a lock on the map, the caller must release the lock.

func GetMapWithLock added in v0.3.0

func GetMapWithLock[V any](vaultRoot string, vaultKey string) (Unlocker, map[string]V)

GetMapWithLock returns the map with a lock the caller must unlock. If the map doesn't exist, the key lock is still returned.

func GetWithLock added in v0.3.0

func GetWithLock(vaultRoot string, vaultKey string) (Unlocker, []byte, error)

GetWithLock returns a locked mutex with the data, enabling synchronised key updates. The caller must Unlock() the lock.

Jump to

Keyboard shortcuts

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