fs

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2020 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package fs implements a secret key store that stores secret keys as files on the file system.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyStore

type KeyStore struct {
	// Dir is the directory where secret key files
	// are located. The key store will read / write
	// secrets from / to files in this directory.
	Dir string

	// CacheExpireAfter is the duration after which
	// cache entries expire such that they have to
	// be loaded from the backend storage again.
	CacheExpireAfter time.Duration

	// CacheExpireUnusedAfter is the duration after
	// which not recently used cache entries expire
	// such that they have to be loaded from the
	// backend storage again.
	// Not recently is defined as: CacheExpireUnusedAfter / 2
	CacheExpireUnusedAfter time.Duration

	// ErrorLog specifies an optional logger for errors
	// when files cannot be opened, deleted or contain
	// invalid content.
	// If nil, logging is done via the log package's
	// standard logger.
	ErrorLog *log.Logger
	// contains filtered or unexported fields
}

KeyStore is a file system secret key store that stores secret keys as files in a directory.

func (*KeyStore) Create

func (store *KeyStore) Create(name string, secret secret.Secret) error

Create adds the given secret key to the store if and only if no entry for name exists. If an entry already exists it returns kes.ErrKeyExists.

In particular, Create creates a new file in KeyStore.Dir and writes the secret key to it.

func (*KeyStore) Delete

func (store *KeyStore) Delete(name string) error

Delete removes a the secret key with the given name from the key store and deletes the associated file, if it exists.

func (*KeyStore) Get

func (store *KeyStore) Get(name string) (secret.Secret, error)

Get returns the secret key associated with the given name. If no entry for name exists, Get returns kes.ErrKeyNotFound.

In particular, Get reads the secret key from the associated file in KeyStore.Dir.

Jump to

Keyboard shortcuts

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