storage

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: May 24, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package storage is used to handle persistence.

Index

Constants

View Source
const (
	// ConfKeyFilePath represents the password db path key in the conf map.
	ConfKeyFilePath = "CONF_KEY_FILE_PATH"
	// ConfKeyFilePermission represents the password db file permission key in the conf map.
	ConfKeyFilePermission = "CONF_KEY_FILE_PERMISSION"
	// FilePermissionPattern represents the password db file permission regex.
	FilePermissionPattern = "[0,2,4,6][0-7][0-7][0-7]"
	// FileStorageID is the File storage type ID.
	FileStorageID = "File"
)
View Source
const (
	// GoogleDriveStorageID is the File storage type ID.
	GoogleDriveStorageID = "GoogleDrive"
	// ConfKeyTokenFilePath represents the token file path in the conf map.
	ConfKeyTokenFilePath = "CONF_KEY_TOKEN_FILE_PATH"
	// ConfKeyDirectory represents the password file directory in the conf map.
	ConfKeyDirectory = "CONF_KEY_DIRECTORY"
	// ConfKeyPasswordDBFile represents the password Database file name in the conf map.
	ConfKeyPasswordDBFile = "CONF_KEY_PASSWORD_DB_FILE"
)

Variables

View Source
var (
	// ErrInvalidPermission represents an invalid permission error.
	ErrInvalidPermission = func(p string) error { return errors.New(fmt.Sprintf("invalid permission: %s", p)) }
	// ErrUnableToConfigure represents unable to configure file storage error.
	ErrUnableToConfigure = func(e error) error { return errors.Wrap(e, "unable to configure storage") }
)

Functions

This section is empty.

Types

type Factory

type Factory struct {
	ID string
}

Factory struct holds Storage.

func (*Factory) Storage

func (f *Factory) Storage() Storage

Storage method returns Storage.

type File

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

File represent a file as a storage.

func (*File) Backup added in v0.9.1

func (f *File) Backup() error

Backup backups file in the file storage.

func (*File) Init

func (f *File) Init(conf map[string]string) error

Init initialises the file storage.

func (*File) InitForFirstTime

func (f *File) InitForFirstTime(data []byte, conf map[string]string) error

InitForFirstTime initialises the file storage for the first time.

func (*File) Load

func (f *File) Load() ([]byte, error)

Load loads the file storage as a byte array.

func (*File) Store

func (f *File) Store(data []byte) error

Store store data in the file storage.

type GoogleDrive added in v0.9.0

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

GoogleDrive represent a GoogleDrive as a storage.

func (*GoogleDrive) Backup added in v0.9.1

func (g *GoogleDrive) Backup() error

Backup backups the given password database data in the GoogleDrive storage.

func (*GoogleDrive) Init added in v0.9.0

func (g *GoogleDrive) Init(conf map[string]string) error

Init initialises the storage. After "InitForFirstTime" method, this function can be called to initialize the GoogleDrive storage in the consequent uses.

func (*GoogleDrive) InitForFirstTime added in v0.9.0

func (g *GoogleDrive) InitForFirstTime(data []byte, conf map[string]string) error

InitForFirstTime initialises the GoogleDrive storage for the first time.

func (*GoogleDrive) Load added in v0.9.0

func (g *GoogleDrive) Load() ([]byte, error)

Load loads the GoogleDrive storage as a byte array.

func (*GoogleDrive) Store added in v0.9.0

func (g *GoogleDrive) Store(data []byte) error

Store store data in the GoogleDrive storage.

type Storage

type Storage interface {
	// InitForFirstTime initialises the storage for the first time.
	InitForFirstTime(data []byte, conf map[string]string) error

	// Init initialises the storage.
	// After "InitForFirstTime" method, this function can be called to initialize the storage in the consequent uses.
	Init(conf map[string]string) error

	// Load loads the storage as a byte array.
	Load() ([]byte, error)

	// Store store data in the storage.
	Store(data []byte) error

	// Backup backups the file in the storage.
	Backup() error
}

Storage interface is used to store data.

Directories

Path Synopsis
Package googledrive holds the implementation related to Drive interactions.
Package googledrive holds the implementation related to Drive interactions.

Jump to

Keyboard shortcuts

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