Documentation
¶
Index ¶
- Constants
- Variables
- func AddStorage(storageType string, storage Storage) error
- func ApplicationsToProtos(list []Application) []*pb.Application
- func DownloadsToProtos(list []Download) []*pb.Download
- func ErrApplicationIdInvalidCharacter(char string) error
- func NewLocalStorage(storagePath ...string) (*localStorage, error)
- func Parse(ver string) (string, string, string)
- func Sha1ToString(in []byte) string
- func Sha256ToString(in []byte) string
- func VersionsToProtos(list []Version) []*pb.Version
- type Application
- type Download
- type Storage
- type Store
- type Version
Constants ¶
View Source
const ( StorageTypeLocal = "local" StorageTypeGithub = "github" StorageTypeS3 = "s3" )
Variables ¶
View Source
var ( ErrVersionNotFound = errors.New("versions.not_found") ErrVersionExists = errors.New("versions.exists") ErrVersionIsNil = errors.New("versions.version.is_nil") ErrVersionMissingOS = errors.New("versions.missing.os") ErrVersionMissingArch = errors.New("versions.missing.arch") ErrVersionInvalidId = errors.New("versions.invalid.id") ErrVersionMissingId = errors.New("versions.missing.id") ErrVersionIdNotEmpty = errors.New("versions.invalid.id_not_empty") ErrVersionMissingApplication = errors.New("versions.missing.application") ErrVersionMissingApplicationId = errors.New("versions.missing.application_id") ErrVersionMissingComponents = errors.New("versions.missing.major_minor_and_revision") ErrApplicationExists = errors.New("versions.application.exists") ErrApplicationMissingId = errors.New("versions.application.missing.id") ErrApplicationMissingName = errors.New("versions.application.missing.name") ErrApplicationNotFound = errors.New("versions.application.not_found") ErrStorageInvalidType = errors.New("versions.storage.invalid_type") ErrDownloadExists = errors.New("versions.download.exists") ErrDownloadNotFound = errors.New("versions.download.not_found") ErrDownloadStorageTypeMissing = errors.New("versions.download.storage_type.missing") ErrDownloadDataIsNil = errors.New("versions.download.data.is_nil") ErrDownloadFilenameMissing = errors.New("versions.download.filename.missing") ErrDownloadIdMissing = errors.New("versions.download.id.missing") ErrDownloadVersionIdMissing = errors.New("versions.download.verision_id.missing") ErrDownloadFileNotFound = errors.New("versions.download.file.not_found") )
Functions ¶
func AddStorage ¶
func ApplicationsToProtos ¶
func ApplicationsToProtos(list []Application) []*pb.Application
func DownloadsToProtos ¶
func NewLocalStorage ¶
func Sha1ToString ¶
func Sha256ToString ¶
func VersionsToProtos ¶
Types ¶
type Application ¶
type Application struct {
Id string `json:"id"`
Name string `json:"name"`
UpdatedAt time.Time `json:"updated_at"`
CreatedAt time.Time `json:"created_at"`
}
func ApplicationFromProto ¶
func ApplicationFromProto(proto *pb.Application) Application
func (*Application) ToProto ¶
func (a *Application) ToProto() *pb.Application
func (*Application) Validate ¶
func (a *Application) Validate() (bool, error)
type Download ¶
type Download struct {
Id int `json:"id"`
VersionId int `json:"version_id"`
StorageType string `json:"storage_type"`
ContentType string `json:"content_type"`
Filename string `json:"filename"`
Ext string `json:"ext"`
Format string `json:"format"`
Protocol string `json:"protocol"`
OS string `json:"os"`
Arch string `json:"arch"`
SHA1 string `json:"sha1"`
SHA256 string `json:"sha256"`
Downloads int `json:"total_downloads"`
UpdatedAt time.Time `json:"updated_at"`
CreatedAt time.Time `json:"created_at"`
Data []byte `json:"-"`
}
func DownloadFromProto ¶
type Storage ¶
func GetStorage ¶
type Store ¶
type Store interface {
Type() string
Migrations() error
Create(*Version) error
Update(*Version) error
Delete(id int) error
GetById(id int) (Version, error)
// Get returns the version(s) for an application ID.
// options:
// opts[0] > 0 = limit
// opts[1] > 0 = offset
GetByApplication(appId string, opts ...int) ([]Version, error)
Exists(*Version) bool
// GetLatest returns the latest version for an application ID.
// options:
// opts[0] > 0 = stable only
GetLatest(appId string, opts ...int) (Version, error)
ApplicationExists(*Application) bool
CreateApplication(*Application) error
UpdateApplication(*Application) error
DeleteApplication(id string) error
GetApplicationById(id string) (Application, error)
GetApplications(opts ...int) ([]Application, error)
DownloadExists(*Download) bool
CreateDownload(*Download) error
UpdateDownload(*Download) error
DeleteDownload(id int) error
GetDownloadById(id int) (Download, error)
GetDownloads(opts ...int) ([]Download, error)
}
type Version ¶
type Version struct {
Id int `json:"id"`
Major string `json:"major"`
Minor string `json:"minor"`
Revision string `json:"revision"`
ApplicationId string `json:"application_id"`
Name string `json:"name"`
Stable bool `json:"stable"`
Downloads []Download `json:"downloads"`
UpdatedAt time.Time `json:"updated_at"`
CreatedAt time.Time `json:"created_at"`
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.