storage

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backup added in v0.4.0

type Backup struct {
	Date  time.Time `json:"date"`
	Items []Item    `json:"items"`
}

Backup structure

type ByName added in v0.2.0

type ByName []Item

For sorting items

func (ByName) Len added in v0.2.0

func (a ByName) Len() int

func (ByName) Less added in v0.2.0

func (a ByName) Less(i, j int) bool

func (ByName) Swap added in v0.2.0

func (a ByName) Swap(i, j int)

type Credential

type Credential struct {
	Username      string   `json:"username"`
	Password      string   `json:"password"`
	RecoveryCodes []string `json:"recoveryCodes"`
}

type Data

type Data struct {
	Items []Item `json:"items"`
}

Data structure

type FireStore

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

func NewFirestore added in v0.2.0

func NewFirestore(ctx context.Context) (*FireStore, error)

func (*FireStore) AddCredential

func (fs *FireStore) AddCredential(ctx context.Context, name string, credential Credential) error

func (*FireStore) CreateItem added in v0.2.0

func (fs *FireStore) CreateItem(ctx context.Context, item Item) error

func (*FireStore) DeleteCredential

func (fs *FireStore) DeleteCredential(ctx context.Context, item Item, credential Credential) error

func (*FireStore) GetAllItems added in v0.2.0

func (fs *FireStore) GetAllItems(ctx context.Context) ([]Item, error)

func (*FireStore) GetItemByIndex added in v0.2.0

func (fs *FireStore) GetItemByIndex(ctx context.Context, index int) (Item, error)

func (*FireStore) GetItemByName added in v0.2.0

func (fs *FireStore) GetItemByName(ctx context.Context, name string) (Item, error)

func (*FireStore) SetData added in v0.2.0

func (fs *FireStore) SetData(ctx context.Context, data Data) error

func (*FireStore) UpdateItem

func (fs *FireStore) UpdateItem(ctx context.Context, item Item) error

type Item

type Item struct {
	Name        string       `json:"name"`
	Credentials []Credential `json:"credentials"`
}

Item structure

func (*Item) GetCredentialByUsername

func (item *Item) GetCredentialByUsername(username string) (Credential, error)

func (*Item) GetCredentialsName

func (item *Item) GetCredentialsName() ([]string, error)

func (*Item) GetUsernameArray

func (item *Item) GetUsernameArray() []string

type LocalStorage

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

func NewLocalStorage added in v0.2.0

func NewLocalStorage() (*LocalStorage, error)

func (*LocalStorage) AddCredential

func (ls *LocalStorage) AddCredential(ctx context.Context, name string, credential Credential) error

func (*LocalStorage) CreateItem added in v0.2.0

func (ls *LocalStorage) CreateItem(ctx context.Context, website Item) error

Add data

func (*LocalStorage) DeleteCredential

func (ls *LocalStorage) DeleteCredential(ctx context.Context, item Item, credential Credential) error

func (*LocalStorage) GetAllItems added in v0.2.0

func (ls *LocalStorage) GetAllItems(ctx context.Context) ([]Item, error)

func (*LocalStorage) GetItemByIndex added in v0.2.0

func (ls *LocalStorage) GetItemByIndex(ctx context.Context, index int) (Item, error)

func (*LocalStorage) GetItemByName added in v0.2.0

func (ls *LocalStorage) GetItemByName(ctx context.Context, name string) (Item, error)

Get item by name

func (*LocalStorage) SetData added in v0.2.0

func (ls *LocalStorage) SetData(ctx context.Context, data Data) error

func (*LocalStorage) UpdateItem

func (ls *LocalStorage) UpdateItem(ctx context.Context, item Item) error

type Storage

type Storage interface {
	GetItemByName(context.Context, string) (Item, error)
	GetItemByIndex(context.Context, int) (Item, error)
	GetAllItems(context.Context) ([]Item, error)
	CreateItem(context.Context, Item) error
	AddCredential(context.Context, string, Credential) error
	DeleteCredential(context.Context, Item, Credential) error
	UpdateItem(context.Context, Item) error
	SetData(context.Context, Data) error
}

Storage interface

Jump to

Keyboard shortcuts

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