models

package
v0.0.0-...-079d604 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2016 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AdvisoryBugfix   = "bugfix"
	AdvisorySecurity = "security"
	AdvisoryFeature  = "feature"
)
View Source
const (
	// ListRunning means that the list is running QA tasks
	ListRunning = "running"
	// ListPending means that the list is pending user intervention
	ListPending = "pending"
	// ListSuccess means that all tasks completed successfully
	ListSuccess = "success"
	// ListFailed means that the QA tasks failed to complete
	ListFailed = "failed"

	LinkMain      = "_mainURL"
	LinkChangelog = "_changelogURL"
	LinkSCM       = "_scmlogURL"

	ListStageNotStarted = "_stage_pending"
	ListStageFinished   = "_stage_finished"

	ArtifactBinary = "binary"
	ArtifactSource = "source"
)
View Source
const (
	UserSystem = "[System]"
)

Variables

View Source
var (
	DBPrefix = conf.GetDefault("database.prefix", "kh_").(string)
	DBType   = conf.GetDefault("database.type", "sqlite3").(string)
	DBName   = conf.GetDefault("database.name", "data.sqlite").(string)
	DBHost   = conf.GetDefault("database.host", "localhost:3306").(string)
	DBUser   = conf.GetDefault("database.user", "root").(string)
	DBPass   = conf.GetDefault("database.pass", "toor").(string)
	DBDebug  = conf.GetDefault("database.debug", false).(bool)

	DB *gorm.DB
)

Functions

func CheckAllListStages

func CheckAllListStages()

CheckAllListStages retrieves all stages that are not on the "success" or "failed" state. For each list, it checks the id (to make sure another goroutine is not already checking it), then fires off a goroutine to handle the check.

Types

type Advisory

type Advisory struct {
	// we can't use gorm.Model because of ID
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time

	Dialect    string `gorm:"primary_key"`
	Year       string `gorm:"primary_key"`
	AdvisoryID uint   `gorm:"primary_key" sql:"AUTO_INCREMENT"`

	Type        string
	Summary     string
	Description string

	Lists []List // lists
}

func (*Advisory) TableName

func (a *Advisory) TableName() string

type List

type List struct {
	gorm.Model

	// -- basic information
	Name     string // project name
	Platform string // targeted platform
	Channel  string // targeted sub-platform/repository
	Variants string // variants/architectures (split by ';')

	// -- contained data
	Artifacts  []ListArtifact
	Links      []ListLink
	Changes    string // provide a field which describes changes, whether textual or diff
	BuildDate  time.Time
	AdvisoryID uint // link to advisory

	// -- current stage and activity
	StageCurrent string // either NotStarted, Finished, or the stage defined in between
	StageResult  string // the status of the stage (running, pending, passed, failed)
	// (this will only be set from pending or running when the whole list has finished or a stage has failed)
	Activity []ListActivity

	// -- current stages (populated during StageNotStarted)
	PlatformGitConfig string      // where we read our configuration from
	Stages            []ListStage // the defined stages

	// -- last but not least, integration stuff (five string slots for usage)
	IntegrationName  string
	IntegrationOne   string
	IntegrationTwo   string
	IntegrationThree string
	IntegrationFour  string
	IntegrationFive  string
}

func (*List) AddActivity

func (l *List) AddActivity(u *User, activity string)

func (*List) CheckStage

func (l *List) CheckStage()

CheckStage checks the current stage of the list for completion. If so, it pushes the list to the next stage and fires off tasks. If the present stage is StageNotStarted, it populates the rest of the stages.

func (*List) TableName

func (l *List) TableName() string

type ListActivity

type ListActivity struct {
	gorm.Model

	ListID uint // link to List
	UserID uint // link to User

	Activity string // markdown activity comment
}

func (*ListActivity) MailActivity

func (l *ListActivity) MailActivity()

func (*ListActivity) TableName

func (l *ListActivity) TableName() string

type ListArtifact

type ListArtifact struct {
	gorm.Model

	ListID uint // link to List

	Name    string
	Type    string
	Epoch   int64
	Version string
	Release string
	Variant string

	URL string
}

func (*ListArtifact) TableName

func (l *ListArtifact) TableName() string
type ListLink struct {
	gorm.Model

	ListID uint // link to List

	Name string
	URL  string
}

func (*ListLink) TableName

func (l *ListLink) TableName() string

type ListStage

type ListStage struct {
	gorm.Model

	ListID uint   // link to List
	Name   string // stage name

	// -- processes
	Processes []ListStageProcess
}

func (*ListStage) TableName

func (l *ListStage) TableName() string

type ListStageProcess

type ListStageProcess struct {
	gorm.Model

	ListStageID uint   // link to ListStage
	Name        string // process name
	Optional    bool   // if this stage is okay to fail

	Data []byte // blob data
}

func (*ListStageProcess) ParentList

func (l *ListStageProcess) ParentList() *List

func (*ListStageProcess) TableName

func (l *ListStageProcess) TableName() string

type User

type User struct {
	gorm.Model

	Username    string
	Email       string
	Integration string

	APIKey string `json:"-"`

	Permissions []UserPermission
	Activities  []ListActivity
}

func FindUser

func FindUser(username string) *User

FindUser finds the user with the given username. If a user doesn't exist, it creates one and returns it.

func FindUserByAPI

func FindUserByAPI(apikey string) *User

func FindUserByID

func FindUserByID(id uint) *User

FindUserByID attempts to find the user with the given ID; if it doesn't exist, it returns nil.

func FindUserNoCreate

func FindUserNoCreate(username string) *User

func (*User) Save

func (u *User) Save()

func (*User) String

func (u *User) String() string

func (*User) TableName

func (u *User) TableName() string

type UserPermission

type UserPermission struct {
	gorm.Model

	Permission string
	UserID     uint
}

func (*UserPermission) Save

func (u *UserPermission) Save()

func (*UserPermission) TableName

func (u *UserPermission) TableName() string

Jump to

Keyboard shortcuts

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