Documentation
¶
Index ¶
- Constants
- Variables
- func WarpErrors(errs ...error) error
- type Build
- type BuildAction
- type BuildState
- type BuildStatus
- type Config
- type Constraint
- type CronTrigger
- type GeneralBuildingConfig
- type LabelSelectorOperator
- type LabelSelectorRequirement
- type ManualTrigger
- type MatchState
- type MatrixEnv
- type Pipeline
- type Plugin
- type Resource
- type StateDetail
- type StepState
- type StepStatus
- type Task
- type TaskGroup
- type Trigger
- type TriggerConfig
- type TriggerConfigTemplate
- type WebhookTrigger
- type WorkEnv
- type WorkStep
Constants ¶
const ( WorkEnvKey string = "workenv" PluginEnvKey string = "pluginenv" )
Env Key
const ( DefaultNameSpace = "malcolm" // #todo ->param PodTypeJob = "jobpod" PodTypeService = "servicepod" )
consts
const ( TriggerTypeManual = "manual" TriggerTypeCron = "cron" TriggerTypeWeebhook = "webhook" )
Trigger type
Variables ¶
var ( PluginTypeScm = "scm" PluginTypeBuild = "build" PluginTypeArchive = "archive" PluginTypeNotify = "notify" AvailablePluginTypes = sets.NewString(PluginTypeScm, PluginTypeBuild, PluginTypeArchive, PluginTypeNotify) )
Plugin type
var ( TriggerManual = TriggerConfigTemplate{ Type: "manual", Schema: "", } TriggerCron = TriggerConfigTemplate{ Type: "cron", Schema: `{ "description": "webhook setting", "type": "object", "properties": { "schedule": { "type": "string" } } }`, } TriggerWebHook = TriggerConfigTemplate{ Type: "webhook", Schema: `{ "description": "webhook setting", "type": "object", "properties": { "matchevent": { "type": "string" }, "matchbranch": { "type": "string" } } }`, } AvaliablesTriggerTemplate = []TriggerConfigTemplate{TriggerManual, TriggerCron, TriggerWebHook} )
Trigger template type
var DefaultBuildConfig = &GeneralBuildingConfig{ Project: DefaultNameSpace, WorkTimeoutDefault: 60, StepTimeoutDefault: 60, ConstriantStateDefault: MatchStateSuccess, WorkSpace: "/workspace", StorageSize: "1Gi", }
DefaultBuildConfig is default building config
Functions ¶
Types ¶
type Build ¶
type Build struct {
ID bson.ObjectId `bson:"_id"`
PipeID bson.ObjectId `bson:"pipeid" index:"index"`
Trigger Trigger `bson:"trigger,omitempty"`
Title string `bson:"title,omitempty"`
Description string `bson:"description,omitempty"`
Project string `bson:"project,omitempty" index:"index"`
Status BuildStatus `bson:"status,omitempty" index:"index"`
Created time.Time `bson:"created"`
Started time.Time `bson:"started"`
Finished time.Time `bson:"finished"`
Updated time.Time `bson:"updated"`
CurrentStep int `bson:"currentStep,omitempty"`
Steps []*WorkStep `bson:"steps,omitempty"`
Author string `bson:"author,omitempty"`
Dirty bool `bson:"-" json:"-"`
Volumn *v1.PersistentVolumeClaim `bson:"volumn,omitempty" json:"volumn,omitempty"`
}
Build is a running/runned instance of pipeline
type BuildAction ¶
type BuildAction string
BuildAction is trigger input
const ( ActionStart BuildAction = "start" ActionPause BuildAction = "pause" ActionResume BuildAction = "resume" ActionStop BuildAction = "stop" )
BuildAction types
type BuildState ¶
type BuildState string
BuildState is general state info of build
const ( BuildStatePending BuildState = "pending" BuildStateRunning BuildState = "running" BuildStatePaused BuildState = "paused" BuildStatePausing BuildState = "pausing" BuildStateComplete BuildState = "complete" )
BuildState types
type BuildStatus ¶
type BuildStatus struct {
State BuildState
StateDetail StateDetail
Message string
}
BuildStatus represent building status
type Constraint ¶
type Constraint struct {
MatchState `bson:"matchState"` // last step.statedetail match
MatchEnvs map[string]string // step.env match val
MatchExpressions []LabelSelectorRequirement
}
Prerequisites is tells when taskgroup should running
type GeneralBuildingConfig ¶
type GeneralBuildingConfig struct {
Project string
WorkTimeoutDefault int // in minute
StepTimeoutDefault int // in minute
ConstriantStateDefault MatchState
ResourceLimitDefault Resource
ResourceLimitRequest Resource
WorkSpace string
StorageClass string
StorageSize string
}
GeneralBuildingConfig is project based building config
type LabelSelectorOperator ¶
type LabelSelectorOperator string
const ( LabelSelectorOpIn LabelSelectorOperator = "In" LabelSelectorOpNotIn LabelSelectorOperator = "NotIn" LabelSelectorOpExists LabelSelectorOperator = "Exists" LabelSelectorOpDoesNotExist LabelSelectorOperator = "DoesNotExist" )
type LabelSelectorRequirement ¶
type LabelSelectorRequirement struct {
Key string
Operator LabelSelectorOperator
Values []string
}
type ManualTrigger ¶
ManualTrigger ..
type MatchState ¶
type MatchState string
MatchState :last step status
const ( MatchStateFail MatchState = "Fail" MatchStateSuccess MatchState = "Success" MatchStateAlways MatchState = "Always" )
type Pipeline ¶
type Pipeline struct {
ID bson.ObjectId `bson:"_id,omitempty"`
Title string `bson:"title,omitempty"`
Description string `bson:"description,omitempty"`
WorkSpace string `bson:"workspace,omitempty"`
StorageClass string `bson:"storageClass,omitempty"`
StorageSize string `bson:"storageSize,omitempty"`
Trigger TriggerConfig `bson:"trigger,omitempty"` // manual trigger default
TaskGroups []TaskGroup `bson:"taskgroups,omitempty"`
Services []Task `bson:"services,omitempty"`
Matrix MatrixEnv `bson:"matrix,omitempty"`
Created time.Time `bson:"created"`
Updated time.Time `bson:"updated"`
Timeout int `bson:"timeout,omitempty"` // timeout in minutes with default value
}
Pipeline represent pipeline config
func (*Pipeline) ValidAndSetDefault ¶
func (pipe *Pipeline) ValidAndSetDefault(config *GeneralBuildingConfig) (err error)
ValidAndSetDefault check config param valid and set default
type Plugin ¶
type Plugin struct {
ID bson.ObjectId `bson:"_id"`
Type string `bson:"type" index:"+name,unique"`
Name string `bson:"name" index:"unique"`
Description string `bson:"description,omitempty"`
Version string `bson:"version"`
Path string `bson:"url"`
Constraint *Constraint `bson:"constraint"` // default constraint
Schema interface{} `bson:"schema,omitempty"` // for pluginConfig setting
Credentials []string `bson:"credentials,omitempty"` // credential needed
Commands bool `bson:"commands,omitempty"` // allow arbitrary commands
Args bool `bson:"args,omitempty"` // allow arbitrary args
Updated time.Time `bson:"updated,omitempty"`
}
Plugin for build process
type StateDetail ¶
type StateDetail string
StateDetail is status detail of build or step state
const ( StateCompleteDetailFailed StateDetail = "failed" StateCompleteDetailCanceled StateDetail = "canceled" StateCompleteDetailSkipped StateDetail = "skipped" StateCompleteDetailSuccess StateDetail = "success" )
StateDetail types
type StepStatus ¶
type StepStatus struct {
State StepState
StateDetail StateDetail
Message string
}
StepStatus represent building step status
type Task ¶
type Task struct {
Title string `bson:"title,omitempty"`
Plugin string `bson:"plugin,omitempty"`
Environment map[string]interface{} `bson:"environment,omitempty"` // plugin config -> environment
Command []string `bson:"command,omitempty"`
Privileged bool `bson:"privileged,omitempty"`
Args []string `bson:"args,omitempty"`
PullPolicy string `bson:"pullPolicy,omitempty"`
Ports []int `bson:"port,omitempty"` // for service
// Timeout int `bson:"timeout,omitempty"` // timeout in minutes with default value
// key -> path
Credentials map[string]string `bson:"credentials,omitempty"`
}
Task -> single container
func (*Task) ValidAndSetDefault ¶
func (w *Task) ValidAndSetDefault(config *GeneralBuildingConfig) (err error)
ValidAndSetDefault check task param valid and set default
type TaskGroup ¶
type TaskGroup struct {
Title string `bson:"title,omitempty"`
Label string `bson:"label,omitempty"`
PreTasks []Task `bson:"pretasks,omitempty"`
Tasks []Task `bson:"tasks,omitempty"`
Constraint *Constraint `bson:"constraint,omitempty"`
Timeout int `bson:"timeout,omitempty"` // timeout in minutes with default value
}
TaskGroup -> job -> pod -> onestep
func (*TaskGroup) ValidAndSetDefault ¶
func (g *TaskGroup) ValidAndSetDefault(config *GeneralBuildingConfig) (err error)
ValidAndSetDefault check config param valid and set default
type TriggerConfig ¶
type TriggerConfig struct {
Cron *CronTrigger
Mannual *ManualTrigger
WebHook *WebhookTrigger
}
TriggerConfig is trigger config in pipeline
type TriggerConfigTemplate ¶
type TriggerConfigTemplate struct {
Type string `bson:"type,omitempty"`
Schema string `bson:"schema,omitempty"`
}
TriggerConfigTemplate is trigger setting template
type WebhookTrigger ¶
type WebhookTrigger struct {
Repo string
Event string
Branch string
CommitID string
Comment string
Author string
}
WebhookTrigger ..
type WorkEnv ¶
type WorkEnv struct {
Trigger Trigger
PrevStatus StepStatus
}
WorkEnv will be inject to step environment
type WorkStep ¶
type WorkStep struct {
Title string `bson:"title,omitempty"`
StepNo int `bson:"stepno,omitempty"`
Status StepStatus `bson:"status,omitempty"`
Started time.Time `bson:"started"`
Finished time.Time `bson:"finished"`
WorkEnv WorkEnv `bson:"workenv"`
Config *TaskGroup `bson:"-" json:"-"`
K8sjob *batchv1.Job `bson:"job,omitempty" json:"job,omitempty"`
}
WorkStep is a step during a Build