domain

package
v0.0.0-...-a2be96e Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2020 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultBranchName = "master"
View Source
const MaxBranches = 100

Variables

View Source
var (
	ErrApplicationNotFound      = errors.New("application not found")
	ErrBranchNotFound           = errors.New("branch not found")
	ErrBranchExist              = errors.New("branch already exist")
	ErrTooManyBranches          = errors.New("too many branches")
	ErrCantRemoveDefaultBranch  = errors.New("can't remove default branch")
	ErrBuildNotFound            = errors.New("build not found")
	ErrBuildAlreadyUploaded     = errors.New("build already uploaded")
	ErrWrongManifestApplication = errors.New("wrong application in manifest")
	ErrTokenNotFound            = errors.New("auth token not found")
)

Functions

func MarshalManifest

func MarshalManifest(m *ApplicationManifest) ([]byte, error)

Types

type AppRepository

type AppRepository interface {
	FindByID(ctx context.Context, id ID) (*Application, error)
	FindByUserIdent(ctx context.Context, id UserID, ident string) (*Application, error)
	FindByUser(ctx context.Context, id UserID) ([]*Application, error)

	Create(ctx context.Context, app *Application) error
	Update(ctx context.Context, app *Application) error
}

type Application

type Application struct {
	ID            ID
	Owner         UserID
	Name          string
	Title         string
	DefaultBranch string
	Branches      []*Branch
}

func NewApplication

func NewApplication(owner UserID, name, title string) *Application

func (*Application) AddBuild

func (a *Application) AddBuild(branchName string, buildID ID) (*BuildInfo, error)

func (*Application) FindBranch

func (a *Application) FindBranch(name string) (*Branch, error)

func (*Application) NewBranch

func (a *Application) NewBranch(name string) (*Branch, error)

func (*Application) PromoteBranch

func (a *Application) PromoteBranch(from, to string) error

func (*Application) PublishBuild

func (a *Application) PublishBuild(branchName string, build string) (*Branch, error)

func (*Application) RemoveBranch

func (a *Application) RemoveBranch(name string) error

type ApplicationManifest

type ApplicationManifest struct {
	// Application ID
	AppID ID `json:"app_id"`

	Bundles []Bundle `json:"bundles"`
}

func UnmarshalManifest

func UnmarshalManifest(data []byte) (*ApplicationManifest, error)

func (*ApplicationManifest) RequiredSpace

func (m *ApplicationManifest) RequiredSpace(platform Platform, locale Locale) int64

func (*ApplicationManifest) Validate

func (m *ApplicationManifest) Validate() error

type Applications

type Applications []*Application

type Branch

type Branch struct {
	AppID       ID
	Name        string
	LiveBuildID ID
	PublishedAt time.Time
	Builds      []*BuildInfo
}

func NewBranch

func NewBranch(app *Application, name string) *Branch

func (*Branch) BuildsCount

func (b *Branch) BuildsCount() int

func (*Branch) FindBuild

func (b *Branch) FindBuild(ident string) (*BuildInfo, error)

func (*Branch) HasLiveBuild

func (b *Branch) HasLiveBuild() bool

func (*Branch) LatestBuild

func (b *Branch) LatestBuild() (*BuildInfo, error)

func (*Branch) LiveBuild

func (b *Branch) LiveBuild() (*BuildInfo, error)

func (*Branch) PublishBuild

func (b *Branch) PublishBuild(ident string) error

type Build

type Build struct {
	ID        ID
	AppID     ID
	Manifest  *ApplicationManifest
	Uploaded  bool
	CreatedAt time.Time
}

func NewBuild

func NewBuild(app *Application, m *ApplicationManifest) (*Build, error)

func (*Build) MarkUploaded

func (b *Build) MarkUploaded() error

type BuildDownloader

type BuildDownloader interface {
	Download(manifest *ApplicationManifest, path string) error
}

type BuildInfo

type BuildInfo struct {
	ID        ID
	AppID     ID
	CreatedAt time.Time
}

type BuildRepository

type BuildRepository interface {
	FindByID(ctx context.Context, id ID) (*Build, error)

	Create(ctx context.Context, build *Build) error
	Update(ctx context.Context, build *Build) error
	Delete(ctx context.Context, id ID) error
}

type BuildUploader

type BuildUploader interface {
	Upload(manifest *ApplicationManifest, path string) error
}

type Bundle

type Bundle struct {
	Label         string         `json:"label"`
	Platforms     []Platform     `json:"platforms"`
	Locales       []Locale       `json:"locales"`
	LocalRoot     string         `json:"local_root"`
	Exclude       []Exclude      `json:"exclude"`
	InstallPath   string         `json:"install_path"`
	LaunchOptions []LaunchOption `json:"launch_options"`

	Files []FileInfo `json:"files"`
}

func (*Bundle) GetInstallPath

func (b *Bundle) GetInstallPath() string

func (*Bundle) Match

func (b *Bundle) Match(platform Platform, locale Locale) bool

func (*Bundle) MatchLocale

func (b *Bundle) MatchLocale(locale Locale) bool

func (*Bundle) MatchPlatform

func (b *Bundle) MatchPlatform(platform Platform) bool

type Exclude

type Exclude struct {
	Pattern string `json:"pattern"`
}

type FileInfo

type FileInfo struct {
	Name string `json:"name"`
	Size int64  `json:"size"`
	Hash uint64 `json:"hash"`
}

type ID

type ID struct {
	uuid.UUID
}

func NewID

func NewID() ID

func ParseID

func ParseID(v string) (ID, error)

func (ID) IsNil

func (id ID) IsNil() bool

func (ID) Match

func (id ID) Match(ident string) bool

func (ID) Short

func (id ID) Short() string

type LaunchOption

type LaunchOption struct {
	Executable string `json:"executable"`
}

type Locale

type Locale string
var DefaultLocale Locale = "en-US"

func (Locale) IsValid

func (l Locale) IsValid() bool

type Platform

type Platform string
const (
	Linux Platform = "linux"
	Win32 Platform = "win32"
	Win64 Platform = "win64"
	MacOS Platform = "macos"
)

func DetectPlatform

func DetectPlatform() Platform

func (Platform) IsValid

func (p Platform) IsValid() bool

func (Platform) String

func (p Platform) String() string

type Token

type Token struct {
	ID        string
	UserID    UserID
	Personal  bool
	CreatedAt time.Time
}

type TokenRepository

type TokenRepository interface {
	FindByID(ctx context.Context, id string) (*Token, error)

	Create(ctx context.Context, token *Token) error
	Delete(ctx context.Context, id string) error
	DeleteByUser(ctx context.Context, userID UserID, onlyPersonal bool) error
}

type TokenService

type TokenService interface {
	NewToken(ctx context.Context, userID UserID) (string, error)
	NewPersonalToken(ctx context.Context, userID UserID) (string, error)

	RevokeToken(ctx context.Context, token string) error
	RevokeUserTokens(ctx context.Context, userID UserID) error
	RevokePersonalToken(ctx context.Context, userID UserID) error

	AuthenticateUser(ctx context.Context, token string) (UserID, error)
}

type UserID

type UserID string

Jump to

Keyboard shortcuts

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