48 lines
1.1 KiB
Go
48 lines
1.1 KiB
Go
package store
|
|
|
|
import (
|
|
"crypto/ecdsa"
|
|
"crypto/x509"
|
|
"fmt"
|
|
|
|
"git.t-juice.club/torjus/ezshare/pb"
|
|
)
|
|
|
|
var ErrNoSuchItem = fmt.Errorf("no such item")
|
|
|
|
type FileStore interface {
|
|
GetFile(id string) (*pb.File, error)
|
|
StoreFile(file *pb.File) (string, error)
|
|
DeleteFile(id string) error
|
|
ListFiles() ([]*pb.ListFilesResponse_ListFileInfo, error)
|
|
}
|
|
|
|
type DataStore interface {
|
|
BinaryStore
|
|
CertificateStore
|
|
UserStore
|
|
}
|
|
|
|
type CertificateStore interface {
|
|
GetCertificate(serial string) (*x509.Certificate, error)
|
|
StoreCertificate(cert *x509.Certificate) error
|
|
GetKey(id string) (*ecdsa.PrivateKey, error)
|
|
StoreKey(id string, key *ecdsa.PrivateKey) error
|
|
ListCertificates() ([]string, error)
|
|
Revoke(serial string) error
|
|
IsRevoked(serial string) (bool, error)
|
|
}
|
|
|
|
type UserStore interface {
|
|
StoreUser(user *pb.User) error
|
|
GetUser(id string) (*pb.User, error)
|
|
GetUserByUsername(username string) (*pb.User, error)
|
|
ListUsers() ([]string, error)
|
|
}
|
|
|
|
type BinaryStore interface {
|
|
StoreBinary(release *pb.Binary) error
|
|
GetBinary(version, os, arch string) (*pb.Binary, error)
|
|
List() ([]string, error)
|
|
}
|