models

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2018 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	HOOKHANDLER_VALIDATION = "pre-build-validation"
	CHECKMARK              = "\u2713"
	FAILED                 = "\u2717"
)
View Source
var SkipMsgs = []string{"[skip ci]", "[ci skip]"}

Functions

func ParseStagesByBuildId

func ParseStagesByBuildId(buildSum *pb.BuildSummary, stageResults []StageResult) *pb.Status

ParseStagesByBuildId will combine the buildsummary + stages to a single object called "Status"

Types

type BranchNotFound

type BranchNotFound struct {
	// contains filtered or unexported fields
}

func Branch404

func Branch404(branch, acctRepo string) *BranchNotFound

func (*BranchNotFound) Error

func (bnf *BranchNotFound) Error() string

type BuildContext

type BuildContext struct {
	Hash       string
	Context    context.Context
	CancelFunc func()
}

type BuildOutput

type BuildOutput struct {
	BuildId  int64  `json:"buildId,omitempty"`
	Output   []byte `json:"output,omitempty"`
	OutputId int64  `json:"outputId,omitempty"` // generated by postgres
}

func (*BuildOutput) Equals

func (o *BuildOutput) Equals(n *BuildOutput) bool

func (*BuildOutput) Validate

func (o *BuildOutput) Validate() error

type CommitNotFound

type CommitNotFound struct {
	// contains filtered or unexported fields
}

func Commit404

func Commit404(hash, acctRepo, branch string) *CommitNotFound

func (*CommitNotFound) Error

func (cnf *CommitNotFound) Error() string

type ErrInvalid

type ErrInvalid struct {
	// contains filtered or unexported fields
}

errors for validation

func NewErrInvalid

func NewErrInvalid(message string) *ErrInvalid

func (*ErrInvalid) Error

func (e *ErrInvalid) Error() string

type Flagger

type Flagger interface {
	IntVar(p *int, name string, value int, usage string)
	BoolVar(p *bool, name string, value bool, usage string)
	StringVar(p *string, name string, value string, usage string)
}

type JsonStringArray

type JsonStringArray []string

JsonStringArray exists because list of messages belonging to stages is stored as json in db. To get it to unparse from DB correctly, we have to implement custom Value() + Scan(). Check postgres.go for usage

func (*JsonStringArray) Scan

func (f *JsonStringArray) Scan(src interface{}) error

func (JsonStringArray) Value

func (f JsonStringArray) Value() (driver.Value, error)

type JsonStringMap

type JsonStringMap map[string]string

func NewMap

func NewMap() JsonStringMap

func (JsonStringMap) Scan

func (f JsonStringMap) Scan(src interface{}) error

func (JsonStringMap) Value

func (f JsonStringMap) Value() (driver.Value, error)

type PollRequest

type PollRequest struct {
	Account  string    `protobuf:"bytes,1,opt,name=account" json:"account,omitempty"`
	Repo     string    `protobuf:"bytes,2,opt,name=repo" json:"repo,omitempty"`
	Cron     string    `protobuf:"bytes,4,opt,name=cron" json:"cron,omitempty"`
	Branches string    `protobuf:"bytes,5,opt,name=branches" json:"branches,omitempty"`
	LastCron time.Time `protobuf:"bytes,6,opt,name=lastCron" json:"lastCron,omitempty"`
}

mirrored from guide ocelot models :/ idk what to do about this

type SSHFacts

type SSHFacts struct {
	User     string
	Host     string
	Port     int
	KeyFP    string
	Password string
	// KeepRepo; if true then the repositories will be left on machine and new commits will be checked out instead of re-cloned? idk. maybe not.
	KeepRepo bool
}

When a werker starts up as an SSH werker, it will also need to be initialized with these fields so it knows

what to connect to

func (*SSHFacts) IsValid

func (sf *SSHFacts) IsValid() bool

func (*SSHFacts) SetFlags

func (sf *SSHFacts) SetFlags(flg Flagger)

type StageResult

type StageResult struct {
	BuildId       int64 //foreign key on build_summary table
	StageResultId int64 //generated by postgres
	Stage         string
	Status        int
	Error         string
	Messages      []string
	StartTime     time.Time
	StageDuration float64
}

this is store inside of build_stage_details

func (*StageResult) Validate

func (r *StageResult) Validate() error

type Translator

type Translator interface {
	//TranslatePush should take a reader body, unmarshal it to vcs-specific model, then translate it to the global Push object
	TranslatePush(reader io.Reader) (*pb.Push, error)

	//TranslatePush should take a reader body, unmarshal it to vcs-specific model, then translate it to the global PullRequest object
	TranslatePR(reader io.Reader) (*pb.PullRequest, error)
}

type Transport

type Transport struct {
	Hash     string
	InfoChan chan []byte
	DbId     int64
}

Transport struct is for the Transport channel that will interact with the streaming side of the service to stream results back to the admin. It sends just enough to be unique, the hash that triggered the build and the InfoChan which the builder will write to.

type VCSHandler

type VCSHandler interface {
	//Walk will iterate over all repositories for specified vcs account, and create webhooks at specified webhook url
	//if one does not yet exist
	Walk() error

	//GetFile retrieves file based on file path, full repo name, and commit hash
	GetFile(filePath string, fullRepoName string, commitHash string) (bytez []byte, err error)

	//CreateWebhook will create a webhook using the webhook creation endpoint associated with codebase
	CreateWebhook(webhookURL string) error

	//GetCallbackURL retrieves the current callback URL
	GetCallbackURL() string

	//SetCallbackURL sets the callback URL for webhooks
	SetCallbackURL(callbackURL string)

	//SetBaseURL set the base URL for this handler
	SetBaseURL(baseURL string)

	//GetBaseURL returns the base URL for this handler
	GetBaseURL() string

	//FindWebhooks iterates over existing webhooks and returns true (matches our callback urls) if one already exists
	FindWebhooks(getWebhookURL string) bool

	//Get Repository details by account name + repo name
	GetRepoDetail(acctRepo string) (pbb.PaginatedRepository_RepositoryValues, error)

	//todo: make this return []*pb.Commit to remove dependency on bitbucket models
	//GetAllCommits returns a paginated list of commits corresponding with branch
	GetAllCommits(acctRepo string, branch string) (*pbb.Commits, error)

	//GetAllBranchesLastCommitData returns a list of all active branches, their last hash, and the last commit datetime
	GetAllBranchesLastCommitData(acctRepo string) ([]*pb.BranchHistory, error)

	//GetBranchLastCommitData should return the last hash and commit datetime of a specific branch
	GetBranchLastCommitData(acctRepo, branch string) (*pb.BranchHistory, error)

	//GetCommitLog will return a list of Commits, starting with the most recent and ending at the lastHash value.
	// If the lastHash commit value is never found, will return an error.
	GetCommitLog(acctRepo string, branch string, lastHash string) ([]*pb.Commit, error)

	// GetPRCommits will return a list of commits for the given url for commits. It'll call the url from (e.g. bb or github),
	//   unmarshal into its vcs-specific model, then translate to the global model to return a list of generic commits
	GetPRCommits(url string) ([]*pb.Commit, error)

	// PostPRComment will add a comment to a pr belonging to acct/repo acctRepo and id prId with a comment that is along the lines of
	// Ocelot build has <status>.
	PostPRComment(acctRepo, prId, hash string, failed bool, buildId int64) error

	GetClient() ocenet.HttpClient
}

type WerkType

type WerkType int
const (
	Kubernetes WerkType = iota
	Docker
	SSH
	Exec
)

func (WerkType) String

func (w WerkType) String() string

type WerkerFacts

type WerkerFacts struct {
	Uuid        uuid.UUID
	WerkerType  WerkType
	LoopbackIp  string
	RegisterIP  string
	ServicePort string
	GrpcPort    string
	// set dev mode
	Dev bool
	// this is only for SSH type werkers
	Ssh *SSHFacts
}

WerkerFacts is a struct for the configurations in werker that affect actual builds. Think of it like gather facts w/ ansible.

func NewFacts

func NewFacts() *WerkerFacts

Directories

Path Synopsis
Package pb is a generated GoMock package.
Package pb is a generated GoMock package.
slack
pb

Jump to

Keyboard shortcuts

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