Documentation ¶
Index ¶
- Constants
- type Build
- type BuildFilter
- type BuildStore
- type EnvVariable
- type EnvVariableStore
- type GitHook
- type GitHookParser
- type HostInfo
- type Job
- type JobStore
- type Mount
- type MountsStore
- type Permission
- type PermissionStore
- type Perms
- type Provider
- type ProviderStore
- type Registry
- type Repository
- type RepositoryFilter
- type RepositoryStore
- type Scheduler
- type SchedulerStats
- type StatsService
- type Team
- type TeamStore
- type Timestamp
- type TriggerBuildOpts
- type Usage
- type User
- type UserStore
- type Worker
- type WorkerRegistry
- type WorkerUsage
Constants ¶
const ( BuildStatusUnknown = "unknown" BuildStatusPassing = "passing" BuildStatusFailing = "failing" BuildStatusRunning = "running" )
BuildStatus for badge.
const ( ActionOpen = "open" ActionClose = "close" ActionCreate = "create" ActionDelete = "delete" ActionSync = "sync" )
Hook action constants.
const ( EventPush = "push" EventPullRequest = "pull_request" EventTag = "tag" )
Hook event constants.
const StatsHistoryCount = 120
StatsHistoryCount history units
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Build ¶
type Build struct { ID uint `gorm:"primary_key;auto_increment;not null" json:"id"` Branch string `json:"branch"` Commit string `json:"commit"` CommitMessage string `json:"commitMessage"` Ref string `gorm:"default:'refs/heads/master'" json:"ref"` PR int `json:"pr"` PRTitle string `json:"prTitle"` PRBody string `json:"pr_body"` Config string `sql:"type:text" json:"config"` AuthorLogin string `json:"authorLogin"` AuthorName string `json:"authorName"` AuthorEmail string `json:"authorEmail"` AuthorAvatar string `gorm:"default:'/assets/images/avatars/avatar_1.svg'" json:"authorAvatar"` CommitterLogin string `json:"committerLogin"` CommitterName string `json:"committerName"` CommitterEmail string `json:"committerEmail"` CommitterAvatar string `gorm:"default:'/assets/images/avatars/avatar_1.svg'" json:"committerAvatar"` StartTime *time.Time `json:"startTime"` EndTime *time.Time `json:"endTime"` Jobs []*Job `gorm:"preload:false" json:"jobs,omitempty"` Repository *Repository `gorm:"preload:false" json:"repository,omitempty"` RepositoryID uint `json:"repositoryID"` Timestamp }
Build defines `builds` database table.
type BuildFilter ¶
BuildFilter defines filters used to return list of builds.
type BuildStore ¶
type BuildStore interface { // Find returns build by id from datastore. Find(uint) (*Build, error) // FindUser returns build by id and user id. FindUser(uint, uint) (*Build, error) // FindStatus returns build by repo token and branch. FindStatus(string, string) (string, error) // List returns list of builds from datastore List(BuildFilter) ([]*Build, error) // Create persists build to the datastore. Create(*Build) error // Update persist updated build to the datastore. Update(*Build) error // Delete deletes build from the datastore. Delete(*Build) error // TriggerBuild creates new build and returns associated jobs. TriggerBuild(TriggerBuildOpts) ([]*Job, error) // GenerateBuild generates and triggers build based on post-commit hook. GenerateBuild(repo *Repository, base *GitHook) ([]*Job, uint, error) }
BuildStore defines methods to work with builds
type EnvVariable ¶
type EnvVariable struct { ID uint `gorm:"primary_key;auto_increment;not null" json:"id"` Key string `gorm:"not null" json:"key"` Value string `gorm:"not null" sql:"type:text" json:"value"` Secret bool `gorm:"not null,default:false" json:"secret"` RepositoryID uint `gorm:"not null" json:"repositoryID"` Repository Repository `json:"repository"` Timestamp }
EnvVariable defines `env_variables` db table.
type EnvVariableStore ¶
type EnvVariableStore interface { // Find returns env variable from datastore. Find(uint) (*EnvVariable, error) // List returns list of environment variables from the datastore. List(uint) ([]*EnvVariable, error) // Create persists a new env variable to the datastore. Create(*EnvVariable) error // Update persists updated env variable to the datastore. Update(*EnvVariable) error // Delete deletes env variable from the datastore. Delete(*EnvVariable) error }
EnvVariableStore defines operations on environment variables in datastore.
type GitHook ¶
type GitHook struct { Event string `json:"event"` Action string `json:"action"` Link string `json:"link"` Timestamp time.Time `json:"timestamp"` Title string `json:"title"` Message string `json:"message"` Before string `json:"before"` After string `json:"after"` Ref string `json:"ref"` Fork string `json:"fork"` Source string `json:"source"` Target string `json:"target"` PrNumber int `json:"pr"` PrTitle string `json:"pr_title"` PrBody string `json:"pr_body"` AuthorEmail string `json:"author_email"` AuthorAvatar string `json:"author_avatar"` AuthorName string `json:"author_name"` AuthorLogin string `json:"author_login"` SenderEmail string `json:"sender_email"` SenderName string `json:"sender_name"` SenderAvatar string `json:"sender_avatar"` SenderLogin string `json:"sender_login"` }
GitHook represents the payload of a post-commit scm hook.
type GitHookParser ¶
type GitHookParser interface {
Parse(req *http.Request, secretFunc func(string) *Repository) (*GitHook, *Repository, error)
}
GitHookParser parses a post-commit hook from the SCM and returns mapped data.
type HostInfo ¶
type HostInfo struct { ID string `json:"id"` Addr string `json:"addr"` Hostname string `json:"hostname"` Uptime uint64 `json:"uptime"` BootTime uint64 `json:"bootTime"` Procs uint64 `json:"procs"` Os string `json:"os"` Platform string `json:"platform"` PlatformFamily string `json:"platformFamily"` PlatformVersion string `json:"platformVersion"` KernelVersion string `json:"kernelVersion"` KernelArch string `json:"kernelArch"` VirtualizationSystem string `json:"virtualizationSystem"` VirtualizationRole string `json:"virtualizationRole"` HostID string `json:"hostID"` MaxParallel uint64 `json:"maxParallel"` ConnectedAt time.Time `json:"connectedAt"` }
HostInfo holds host information about remote worker node.
type Job ¶
type Job struct { ID uint `gorm:"primary_key;auto_increment;not null" json:"id"` Commands string `sql:"type:text" json:"commands"` Image string `json:"image"` Env string `json:"env"` Mount string `json:"mount"` StartTime *time.Time `json:"startTime"` EndTime *time.Time `json:"endTime"` Status string `gorm:"not null;size:20;default:'queued'" json:"status"` // queued | running | passing | failing Log string `gorm:"size:16777216" json:"-"` Stage string `json:"stage"` Cache string `json:"cache"` Build *Build `gorm:"preload:false" json:"build,omitempty"` BuildID uint `json:"buildID"` Timestamp }
Job defines `jobs` database table.
type JobStore ¶
type JobStore interface { // Find returns job by id from datastore. Find(uint) (*Job, error) // FindUser returns job by id and user id. FindUser(uint, uint) (*Job, error) // List returns jobs based bu from and to dates. List(time.Time, time.Time) ([]*Job, error) // Create persists job to the datastore. Create(*Job) error // Update persist updated job to the datastore. Update(*Job) error // Delete deletes job from the datastore. Delete(*Job) error }
JobStore defines operations for working with jobs database table.
type Mount ¶
type Mount struct { ID uint `gorm:"primary_key;auto_increment;not null" json:"id"` Host string `gorm:"not null" json:"host"` Container string `gorm:"not null" json:"container"` RepositoryID uint `gorm:"not null" json:"repositoryID"` Repository Repository `json:"repository"` Timestamp }
Mount defines `mounts` db table.
type MountsStore ¶
type MountsStore interface { // Find returns mounts from datastore. Find(uint) (*Mount, error) // List returns list of mounts from the datastore. List(uint) ([]*Mount, error) // Create persists a new mount to the datastore. Create(*Mount) error // Update persists updated mounts to the datastore. Update(*Mount) error // Delete deletes mounts from the datastore. Delete(*Mount) error }
MountsStore defines operations on mounts in datastore
type Permission ¶
type Permission struct { ID uint `gorm:"primary_key;auto_increment;not null" json:"id"` Team *Team `json:"team,omitempty"` TeamID uint `json:"teamID"` Repository *Repository `json:"repository,omitempty"` RepositoryID uint `json:"repositoryID"` Read bool `json:"read"` Write bool `json:"write"` Exec bool `json:"exec"` }
Permission represents team repository permissions
type PermissionStore ¶
type PermissionStore interface { // Find returns permission based by team id and repository id. Find(uint, uint) (*Permission, error) // List returns permissions based by team id. List(uint) ([]*Permission, error) // Create persists new permission to the datastore. Create(*Permission) error // Update persists updated permission to the datastore. Update(*Permission) error // Delete deletes permission from the datastore. Delete(*Permission) error }
PermissionStore defines operations on permissions.
type Provider ¶
type Provider struct { ID uint `gorm:"primary_key;auto_increment;not null" json:"id"` Name string `gorm:"not null" json:"name"` URL string `gorm:"not null" json:"url"` AccessToken string `gorm:"not null" json:"-"` Secret string `gorm:"not null" json:"secret"` Host string `gorm:"not null" json:"host"` LastSync *time.Time `json:"lastSync"` UserID uint `gorm:"not null" json:"userID"` User User `json:"user"` Timestamp }
Provider represents `providers` db table.
type ProviderStore ¶
type ProviderStore interface { // Find returns provider from datastore. Find(uint) (*Provider, error) // List returns providers from datastore. List() ([]*Provider, error) // ListUser returns providers from datastore based // by user ID. ListUser(uint) ([]*Provider, error) // Create persists a new provider to the datastore. Create(*Provider) error // Update persists updated provider to the datastore. Update(*Provider) error // Delete deletes a provider from the datastore. Delete(*Provider) error // Sync synchronizes provider repositories with local repositories. Sync(uint) error }
ProviderStore defines operations on `providers` table.
type Repository ¶
type Repository struct { ID uint `gorm:"primary_key;auto_increment;not null" json:"id"` UID string `gorm:"not null" json:"uid"` ProviderName string `gorm:"not null" json:"providerName"` Namespace string `gorm:"not null" json:"namespace"` Name string `gorm:"not null;size:255" json:"name"` FullName string `gorm:"not null;size:255" json:"fullName"` Private bool `json:"private"` Fork bool `json:"fork"` UseSSH bool `gorm:"default:false" json:"useSSH"` URL string `json:"url"` Clone string `json:"clone"` CloneSSH string `json:"cloneSSH"` DefaultBranch string `json:"defaultBranch"` Active bool `json:"active"` Timeout uint `gorm:"not null,default:3600" json:"timeout"` Token string `gorm:"not null" json:"token"` SSHPrivateKey string `sql:"type:text" json:"-"` UserID uint `json:"userID"` User User `json:"-"` ProviderID uint `gorm:"not null" json:"providerID"` Provider Provider `json:"-"` EnvVariables []EnvVariable `json:"-"` Mounts []*Mount `json:"mounts"` Perms Perms `gorm:"-" json:"perms"` Timestamp }
Repository defines `repositories` db table.
func (*Repository) BeforeCreate ¶
func (r *Repository) BeforeCreate(tx *gorm.DB) (err error)
BeforeCreate hook
func (Repository) TableName ¶
func (Repository) TableName() string
TableName is name that is used in db.
type RepositoryFilter ¶
RepositoryFilter defines filters when listing repositories from the datastore.
type RepositoryStore ¶
type RepositoryStore interface { // Find returns repository from the datastore. Find(uint, uint) (Repository, error) // FindUID returns repository from datastore based by uid. FindUID(string) (Repository, error) // FindClone returns repository by clone URL from the datastore FindClone(string) (Repository, error) // FindToken returns repository by token. FindToken(string) (*Repository, error) // List returns list of repositories from the datastore. List(RepositoryFilter) ([]Repository, int64, error) // Create persists a new repository to the datastore. Create(Repository) error // Update persists updated repository to the datastore. Update(Repository) error // CreateOrUpdate persists new repository to the datastore // if not exists or updates exists one. CreateOrUpdate(Repository) error // Delete deletes repository from the datastore. Delete(Repository) error // GetPermissions returns repo permissions based by user id. GetPermissions(uint, uint) Perms // SetActive persists new active status to the repository in the datastore. SetActive(uint, bool) error // ListHooks returns webhooks for specified repository. ListHooks(uint, uint) ([]*scm.Hook, error) // CreateHook creates webhook for specified repository. CreateHook(uint, uint, gitscm.HookForm) error // DeleteHooks deletes all related webhooks for specified repository DeleteHooks(uint, uint) error // SetMisc persists miscellaneous settings to the repo datastore. SetMisc(id uint, useSSH bool) error // UpdateSSHPrivateKey perstsis ssh privat key to the repo datastore. UpdateSSHPrivateKey(id uint, key string) error }
RepositoryStore defines operations on repositories in datastorage.
type Scheduler ¶
type Scheduler interface { // Next schedules job for execution. Next(*Job) error // Stop cancels scheduled or running job and returns // true if job has been stopped. Stop(uint) (bool, error) // RestartBuild restart the build or associated jobs. RestartBuild(uint) error // StopBuild stops the build or associated jobs. StopBuild(uint) error // Pause pauses the scheduler. Pause() error // Resume starts paused scheduler. Resume() error // IsRunning returns scheduler running status IsRunning() bool // JobLog returns jobs current log output. JobLog(uint) (string, error) // Stats returns scheduler current statistics. Stats() SchedulerStats }
Scheduler represents build jobs scheduler.
type SchedulerStats ¶
type SchedulerStats struct { Queued int `json:"queued"` Pending int `json:"pending"` Workers int `json:"workers"` Max int `json:"max"` Running int `json:"running"` Timestamp time.Time `json:"timestamp"` }
SchedulerStats defines scheduler statistics.
type StatsService ¶
type StatsService interface { GetHistory() ([]Usage, []SchedulerStats) SchedulerStatus() bool }
StatsService defines operations on server statistics.
type Team ¶
type Team struct { ID uint `gorm:"primary_key;auto_increment;not null" json:"id"` Name string `gorm:"not null,unique_index" json:"name"` About string `gorm:"type:text" json:"about"` Color string `gorm:"not null" json:"color"` Users []*User `gorm:"many2many:team_users;" json:"users"` Permissions []Permission `gorm:"constraint:OnUpdate:CASCADE,OnDelete:SET NULL;" json:"perms"` Timestamp }
Team represents `teams` database table.
type TeamStore ¶
type TeamStore interface { // Find returns a team from the datastore. Find(uint) (*Team, error) // List returns a list of teams from the datastore. List() ([]*Team, error) // Create persists a new team to the datastore. Create(*Team) error // Update persists updated team to the datastore. Update(*Team) error // Delete deletes a team from the datastore. Delete(*Team) error // AddUsers appends users to team. AddUsers(uint, []*User) error // DeleteUsers removes users from team. DeleteUsers(uint, []*User) error // UpdateUsers updates users for team. UpdateUsers(uint, []*User) error }
TeamStore defines operations on teams database table.
type Timestamp ¶
type Timestamp struct { CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` DeletedAt *time.Time `json:"deletedAt"` }
Timestamp defines timestamp fields.
type TriggerBuildOpts ¶
TriggerBuildOpts defines options to trigger build.
type Usage ¶
type Usage struct { CPU int32 `json:"cpu"` Mem int32 `json:"mem"` Timestamp time.Time `json:"timestamp"` }
Usage defines server usage stats.
type User ¶
type User struct { ID uint `gorm:"primary_key;auto_increment;not null" json:"id"` Login string `gorm:"size:255;unique_index" json:"login"` Email string `gorm:"not null;size:255;unique_index" json:"email"` Password string `gorm:"not null;size:255;column:password" json:"-"` Name string `gorm:"not null;size:255" json:"name"` Avatar string `gorm:"not null;size:255;default:'/assets/images/avatars/avatar_1.svg'" json:"avatar"` Role string `gorm:"not null;size:20;default:'user'" json:"role"` Active bool `gorm:"not null;default:true" json:"active"` Teams []*Team `gorm:"many2many:team_users;" json:"teams"` Timestamp }
User represents user of the system.
func (User) Claims ¶
func (u User) Claims() auth.UserClaims
Claims returns the token claims to be signed.
type UserStore ¶
type UserStore interface { // Find returns a user from the datastore. Find(uint) (*User, error) // FindEmailOrLogin returns a user from the datastore by email or username. FindEmailOrLogin(string) (*User, error) // List returns a list of users from datastore. List() ([]*User, error) // Create persists a new user to the datastore. Create(*User) error // Update persists updated user to the datastore. Update(*User) error // UpdatePassword persists new user password to the datastore. UpdatePassword(uint, string, string) error // Delete deletes a user from the datastore. Delete(*User) error // Login checks user credentials and returns true if valid. Login(string, string) bool // AdminExists checks and returns if admin user exists in datastore. AdminExists() bool }
UserStore defines operations for working with users.
type Worker ¶
type Worker struct { sync.Mutex ID string Addr string Max int Running int Host HostInfo Usage []WorkerUsage Conn *grpc.ClientConn CLI pb.APIClient Registry WorkerRegistry WS *ws.App }
Worker represents connected worker node.
func NewWorker ¶
func NewWorker(id, addr string, config *config.Config, registry WorkerRegistry, ws *ws.App) (*Worker, error)
NewWorker returns new worker instance.
type WorkerRegistry ¶
type WorkerRegistry interface { // Add adds new worker node to the registry. Add(*Worker) error // Delete removes worker node from the registry. Delete(string) error // List returns list of active worker nodes in registry. List() ([]*Worker, error) }
WorkerRegistry represents registry of operational worker nodes.