store

package
v0.0.0-...-cf84262 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ManifestPath = ".gostore.json"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AddParams

type AddParams struct {
	CommonParams

	Path string
	Key  maybe.Maybe[string]

	Data []byte
}

type CloneParams

type CloneParams struct {
	CommonParams

	ID string

	StorageType storage.Type
	Remote      string
}

type CommonParams

type CommonParams struct {
	StorePath maybe.Maybe[string]
	StoreID   maybe.Maybe[string]
}

type CopyParams

type CopyParams struct {
	CommonParams

	Src string
	Dst string
}

type GetParams

type GetParams struct {
	CommonParams

	Path string
	Key  maybe.Maybe[string]
}

type IdentityProvider

type IdentityProvider interface {
	IdentityByRecipient(ctx context.Context, recipient encryption.Recipient) (maybe.Maybe[encryption.Identity], error)
}

type InitParams

type InitParams struct {
	CommonParams

	// if there is no key passed new one will be created
	Recipients []encryption.Recipient

	StorageType maybe.Maybe[storage.Type]
	Remote      maybe.Maybe[string]
}

type InitRes

type InitRes struct {
	StorePath         string
	GeneratedIdentity maybe.Maybe[encryption.Identity]
}

type ListParams

type ListParams struct {
	CommonParams

	Path string
}

type Manifest

type Manifest struct {
	StorageType storage.Type
	Encryption  encryption.Encryption
	Recipients  []encryption.Recipient
	Unpacked    bool
}

type ManifestSerializer

type ManifestSerializer interface {
	Serialize(m Manifest) ([]byte, error)
	Deserialize(data []byte) (Manifest, error)
}

type MoveParams

type MoveParams struct {
	CommonParams

	Src string
	Dst string
}

type RawSecret

type RawSecret struct {
	Data    maybe.Maybe[[]byte]
	Payload maybe.Maybe[map[string][]byte]
}

RawSecret - raw secret one of

type RemoveParams

type RemoveParams struct {
	CommonParams

	Path string
	Key  maybe.Maybe[string]
}

type Secret

type Secret struct {
	// Payload is json object with encrypted values
	Payload map[string][]byte
}

type SecretData

type SecretData struct {
	Name    string
	Payload []byte

	Default bool // means that secret data stored in default field
}

type SecretSerializer

type SecretSerializer interface {
	Serialize(secret Secret) ([]byte, error)
	Deserialize([]byte) (Secret, error)

	RawSerialize(secret RawSecret) ([]byte, error)
	RawDeserialize(data []byte) (RawSecret, error)
}

type Service

type Service interface {
	// Init creates new store
	Init(ctx context.Context, params InitParams) (InitRes, error)
	// Clone store from remote
	Clone(ctx context.Context, params CloneParams) error

	Add(ctx context.Context, params AddParams) error

	Copy(ctx context.Context, params CopyParams) error
	Move(ctx context.Context, params MoveParams) error

	Get(ctx context.Context, params GetParams) ([]SecretData, error)
	List(ctx context.Context, params ListParams) (storage.Tree, error)

	Remove(ctx context.Context, params RemoveParams) error

	Unpack(ctx context.Context, params CommonParams) error
	Pack(ctx context.Context, params CommonParams) error

	Sync(ctx context.Context, params SyncParams) error
	Rollback(ctx context.Context, params CommonParams) error
}

func NewStoreService

func NewStoreService(
	storageManager storage.Manager,
	encryptionManager encryption.Manager,
	manifestSerializer ManifestSerializer,
	secretSerializer SecretSerializer,
	identityProvider IdentityProvider,
) Service

type SyncParams

type SyncParams struct {
	CommonParams
}

Jump to

Keyboard shortcuts

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