models

package
v0.0.0-...-e364ea7 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2017 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StatusUnknown indicates a unknown build status
	StatusUnknown = "unknown"
	// StatusNew indicates a new unbuilt build
	StatusNew = "new"
	// StatusBusy indicates a currently in progress build
	StatusBusy = "busy"
	// StatusFailed indicates a failed build status
	StatusFailed = "failed"
	// StatusPassed indicates a succesful build
	StatusPassed = "passed"
	// StatusError indicates an error occurred during build
	StatusError = "error"
)

Variables

This section is empty.

Functions

func Handle

func Handle() *gorm.DB

Handle returns the database interface handle, it is a singleton

func Init

func Init() error

Init initializes the database and auto-migrates the database tables

func ScheduleJob

func ScheduleJob(buildID, branchID uint, ref string) error

func UpdateBranchStatus

func UpdateBranchStatus(branchID uint, s string, t time.Time)

func ValidAPIKey

func ValidAPIKey(key string) bool

Types

type Artifact

type Artifact struct {
	gorm.Model

	Job      Job
	JobID    uint
	FilePath string
}

Artifact repesents a build artifact

it belongs to a Job

type Branch

type Branch struct {
	gorm.Model

	Name          string
	LastReference string
	Enabled       bool

	Build   Build
	BuildID uint `gorm:"index"`
	Jobs    []Job

	Status     string
	StatusTime time.Time
}

func GetBranchByID

func GetBranchByID(branchID int, err error) (*Branch, error)

func (*Branch) Disable

func (b *Branch) Disable()

func (*Branch) Enable

func (b *Branch) Enable()

func (*Branch) UpdateStatus

func (b *Branch) UpdateStatus(s string, t time.Time)

type Build

type Build struct {
	gorm.Model

	URI        string `form:"uri"`
	Personal   bool   `form:"personal"`
	UserID     uint   `gorm:"index" form:"userID"`
	User       User
	Jobs       []Job
	Branches   []Branch
	Status     string
	StatusTime time.Time
}

func BuildList

func BuildList(userID uint, err error) ([]Build, error)

func BuildWithBranches

func BuildWithBranches(buildID int, userID uint) (*Build, error)

func (*Build) IsValid

func (b *Build) IsValid() error

func (*Build) UpdateStatus

func (b *Build) UpdateStatus()

type Job

type Job struct {
	gorm.Model

	Reference     string
	CommitMessage string
	Status        string
	Container     string
	Message       string
	Start         time.Time
	End           time.Time
	Tag           string
	BuildDir      string
	Branch        Branch
	BranchID      uint `gorm:"index"`
	Build         Build
	BuildID       uint   `gorm:"index"`
	StatusTime    string `gorm:"-"`
	Duration      string `gorm:"-"`
	Artifacts     []Artifact
}

func GetJobByID

func GetJobByID(jobID int, err error) (*Job, error)

func (*Job) SetStatus

func (j *Job) SetStatus(status string, message ...string) error

func (*Job) SetStatusTime

func (j *Job) SetStatusTime()

func (*Job) StoreMeta

func (j *Job) StoreMeta(tag, commitMsg string)

type User

type User struct {
	gorm.Model

	Username      string
	Password      string
	PasswordPlain string `gorm:"-"`
	APIKey        string
}

func (*User) BeforeSave

func (u *User) BeforeSave(scope *gorm.Scope) error

func (User) IsValid

func (u User) IsValid() bool

IsValid validates the user

func (*User) ValidPassword

func (u *User) ValidPassword() bool

Jump to

Keyboard shortcuts

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