ezshare/store/store.go

48 lines
1.1 KiB
Go
Raw Permalink Normal View History

2021-12-03 22:04:09 +00:00
package store
import (
2021-12-05 00:00:32 +00:00
"crypto/ecdsa"
"crypto/x509"
2021-12-03 22:04:09 +00:00
"fmt"
2022-01-13 17:40:15 +00:00
"git.t-juice.club/torjus/ezshare/pb"
2021-12-03 22:04:09 +00:00
)
2021-12-05 11:42:22 +00:00
var ErrNoSuchItem = fmt.Errorf("no such item")
2021-12-03 22:04:09 +00:00
type FileStore interface {
GetFile(id string) (*pb.File, error)
StoreFile(file *pb.File) (string, error)
DeleteFile(id string) error
2021-12-04 10:30:42 +00:00
ListFiles() ([]*pb.ListFilesResponse_ListFileInfo, error)
2021-12-03 22:04:09 +00:00
}
2021-12-05 00:00:32 +00:00
2021-12-08 08:42:12 +00:00
type DataStore interface {
BinaryStore
CertificateStore
UserStore
}
2021-12-05 00:00:32 +00:00
type CertificateStore interface {
2021-12-06 18:14:39 +00:00
GetCertificate(serial string) (*x509.Certificate, error)
StoreCertificate(cert *x509.Certificate) error
2021-12-05 00:00:32 +00:00
GetKey(id string) (*ecdsa.PrivateKey, error)
StoreKey(id string, key *ecdsa.PrivateKey) error
ListCertificates() ([]string, error)
2021-12-06 16:28:48 +00:00
Revoke(serial string) error
IsRevoked(serial string) (bool, error)
2021-12-05 00:00:32 +00:00
}
2021-12-05 10:08:09 +00:00
type UserStore interface {
StoreUser(user *pb.User) error
GetUser(id string) (*pb.User, error)
2021-12-05 11:39:28 +00:00
GetUserByUsername(username string) (*pb.User, error)
2021-12-05 10:08:09 +00:00
ListUsers() ([]string, error)
}
2021-12-08 04:42:25 +00:00
type BinaryStore interface {
StoreBinary(release *pb.Binary) error
GetBinary(version, os, arch string) (*pb.Binary, error)
2021-12-08 05:17:11 +00:00
List() ([]string, error)
2021-12-08 04:42:25 +00:00
}