model

package
v0.0.0-...-9a8ef1a Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2018 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// status of the whole build
	BUILD_WAITING = "waiting"
	BUILD_RUNNING = "running"
	BUILD_PASSED  = "passed"
	BUILD_FAILED  = "failed"

	// status of a single stage
	STAGE_IGNORED = "ignored"
	STAGE_RUNNING = "running"
	STAGE_FAILED  = "failed"
	STAGE_PASSED  = "passed"
)
View Source
const (
	TRIGGER_MANUAL = "manual"
	TRIGGER_POLL   = "poll"
	KEY_PREFIX     = "-----BEGIN"
)
View Source
const (
	LUA_TAG = "lua"
)

Variables

View Source
var (
	ErrBuildRunning = errors.New("build already running")
	ErrUnknownHash  = errors.New("unknown hash")
)
View Source
var (
	// regular expressions
	ReFnAlias = regexp.MustCompile("^\\s*\\${(.*?)}\\s*$")
)

Functions

func Close

func Close() error

Closes the bolt database.

func Get

func Get() *storm.DB

Returns the database handle.

func Open

func Open(path string) error

Opens the bolt database.

func ParseLuaScript

func ParseLuaScript(fn string, args string, src string) string

Parses the lua script in an configuration property. Applies all custom syntax.

func PurgeProjects

func PurgeProjects(projects []*Project)

Types

type Build

type Build struct {
	Id       uint64        `json:"-" storm:"id,increment" groups:"queryall,one"`
	Project  uint64        `json:"-" strom:"index"`
	Num      int           `json:"num" strom:"index" groups:"queryall,one"`
	Status   string        `json:"status" groups:"queryall,one"`
	Commit   Commit        `json:"commit" groups:"queryall,one"`
	Time     time.Time     `json:"time" groups:"queryall,one"`
	Duration time.Duration `json:"duration" groups:"queryall,one"`
	Node     string        `json:"node" groups:"queryall,one"`
	Stages   []Stage       `json:"stages" groups:"one"`
}

func (*Build) GetArtifactName

func (b *Build) GetArtifactName(basepath string) string

Get the local artifact name for this build in respect to the given basepath.

func (*Build) Publish

func (b *Build) Publish(event interface{})

Consume all events which are feed from the channel src. The database is automatically updated with each event.

func (*Build) Save

func (b *Build) Save() error

Inserts or Updates the Build in the database.

type Commit

type Commit struct {
	Message string `json:"message" groups:"queryall,one"`
	Author  string `json:"author" groups:"queryall,one"`
	Ref     string `json:"ref" groups:"queryall,one"`
}

type EventBase

type EventBase struct {
	Project   int   `json:"project_id"`
	Build     int   `json:"build_num"`
	Timestamp int64 `json:"timestamp"`
}

type EvtCommitFound

type EvtCommitFound struct {
	*EventBase
	Commit Commit `json:"commit"`
}

type EvtPipelineBegin

type EvtPipelineBegin struct {
	*EventBase
	Time   time.Time `json:"time"`
	Status string    `json:"status"`
	Agent  string    `json:"agent"`
}

type EvtPipelineFinished

type EvtPipelineFinished struct {
	*EventBase
	Status   string        `json:"status"`
	Duration time.Duration `json:"duration"`
}

type EvtPipelineFound

type EvtPipelineFound struct {
	*EventBase
	Stages []string `json:"stages"`
}

type EvtStageBegin

type EvtStageBegin struct {
	*EventBase
	Stage  int    `json:"stage"`
	Status string `json:"status"`
}

type EvtStageFinish

type EvtStageFinish struct {
	*EventBase
	Stage    int           `json:"stage"`
	Status   string        `json:"status"`
	Duration time.Duration `json:"duration"`
}

type EvtStageLog

type EvtStageLog struct {
	*EventBase
	Stage   int    `json:"stage"`
	Message string `json:"message"`
}

type Project

type Project struct {
	Id            int               `yaml:"-" json:"id"`
	Name          string            `yaml:"name,omitempty" json:"name"`
	Scm           string            `yaml:"scm,omitempty" json:"scm"`
	Repository    string            `yaml:"repo,omitempty" json:"repository"`
	Branch        string            `yaml:"branch,omitempty" json:"branch"`
	Trigger       string            `yaml:"trigger,omitempty" json:"trigger"`
	Interval      int               `yaml:"interval,omitempty" json:"interval"`
	TriggerTokens []string          `yaml:"trigger_tokens,omitempty"`
	TriggerFilter string            `yaml:"trigger_filter,omitempty" lua:"trigger_filter"`
	Env           map[string]string `yaml:"env,omitempty" json:"env"`
	EnvSecret     map[string]string `yaml:"env_secret,omitempty" json:"env_secret"`
	CommitUrl     string            `yaml:"commit_url,omitempty" json:"commit_url"`
	BadgeEnable   bool              `yaml:"badge" json:"badge"`
	KeepHistory   int               `yaml:"keep_history,omitempty"`
	Hash          string            `yaml:"hash,omitempty" json:"-"`
	PrivateKey    string            `yaml:"key,omitempty" json:"key"`
	// contains filtered or unexported fields
}

func (*Project) AssignId

func (p *Project) AssignId() error

Assigns a proper ID to this project.

func (*Project) CheckIntegrity

func (p *Project) CheckIntegrity()

Checks the integrty of a project and corrects if necessary.

func (*Project) CreateLuaVm

func (p *Project) CreateLuaVm() error

Creates a lua vm for this project.

func (*Project) EvalTriggerFilter

func (p *Project) EvalTriggerFilter(body string) (bool, error)

Executes the trigger filter script.

func (*Project) GetLastBuild

func (p *Project) GetLastBuild() (*Build, error)

Gets the latest build of this project.

func (*Project) GetPrivateKey

func (p *Project) GetPrivateKey() ([]byte, error)

Returns the private key which is configured for the project. It is ether read from the given file or from the property itself.

func (*Project) GetRepository

func (p *Project) GetRepository() string

Returns the repository url for this project. A dummy username and password is inserted if no one is provided in the configuration file.

func (*Project) IsMissconfigured

func (p *Project) IsMissconfigured() error

Returns an error if the project is missconfigured.

func (*Project) IsTriggerTokenValid

func (p *Project) IsTriggerTokenValid(token string) bool

Returns true if token is a valid token for this project.

func (*Project) IsValid

func (p *Project) IsValid() bool

Returns true if the project is valid and should be made available to the public.

func (*Project) Lock

func (p *Project) Lock() error

Marks the project as running.

func (*Project) NewBuild

func (p *Project) NewBuild() *Build

Creates a new Build from this project.

func (*Project) RunGc

func (p *Project) RunGc(artifacts string) error

Executes the garbage collection process for this project.

func (*Project) Unlock

func (p *Project) Unlock()

Marks the project as finished.

type ProjectMapping

type ProjectMapping struct {
	Id   int    `storm:"id,increment"`
	Hash string `storm:"unique"`
}

type Stage

type Stage struct {
	Name     string        `json:"name" groups:"one"`
	Status   string        `json:"status" groups:"one"`
	Duration time.Duration `json:"duration" groups:"one"`
	Log      []string      `json:"-"`
}

func (*Stage) RawLog

func (s *Stage) RawLog() string

Gets the raw log of the stage

Jump to

Keyboard shortcuts

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