Documentation ¶
Index ¶
- Constants
- func CreateJob(definition *Definition, jobInfo *JobBuildInfo, scmClient scm.Client) (j *kube.Job, err error)
- func CreatePipeline(p *Pipeline, c scm.Client, k kv.KVClient) (err error)
- type Build
- func (b *Build) CreateStages(kvClient kv.KVClient) (err error)
- func (b *Build) Delete(pipelinesID string, kvClient kv.KVClient, mcClient *mc.MinioClient) (err error)
- func (b *Build) GetStage(idx int, kvClient kv.KVClient) (*Stage, bool)
- func (b *Build) GetStages(kvClient kv.KVClient) ([]*Stage, error)
- func (b *Build) Notify(kvClient kv.KVClient) error
- func (b *Build) Save(kvClient kv.KVClient) (err error)
- type BuildSummary
- type Definition
- type DefinitionFile
- type JobBuildInfo
- type Key
- type NextJobInfo
- type Notifier
- type Pipeline
- func (p *Pipeline) CreateBuild(b *Build, stages []*Stage, kvClient kv.KVClient, scmClient scm.Client) error
- func (p *Pipeline) Definition(ref string, c scm.Client) (*Definition, error)
- func (p *Pipeline) DeletePipeline(kvClient kv.KVClient, mcClient *mc.MinioClient) (err error)
- func (p *Pipeline) GenerateHookSecret(secret string) (string, error)
- func (p *Pipeline) GetAllBuildsSummary(kvClient kv.KVClient) ([]*BuildSummary, error)
- func (p *Pipeline) GetBuild(num int, kvClient kv.KVClient) (*Build, bool)
- func (p *Pipeline) GetBuildSummary(num int, kvClient kv.KVClient) (*BuildSummary, bool)
- func (p *Pipeline) GetBuilds(kvClient kv.KVClient) ([]*Build, error)
- func (p *Pipeline) GetDefinitionFile(c scm.Client, ref string) (*DefinitionFile, bool)
- func (p *Pipeline) PrepareBuildStage(n *NextJobInfo, scmClient scm.Client) (*Definition, *JobBuildInfo, error)
- func (p *Pipeline) Save(kvClient kv.KVClient) (err error)
- func (p *Pipeline) UpdateDefinitionFile(c scm.Client, file *DefinitionFile, commit map[string]string) (*DefinitionFile, error)
- func (p *Pipeline) UpdatePipeline(definition *Definition, kvClient kv.KVClient)
- func (p *Pipeline) Validate() error
- type SpecDetails
- type Stage
- type StatusUpdate
- type TemplateDetails
- type User
Constants ¶
const ( // PipelineYAML is the YAML file that holds the pipeline specifications PipelineYAML = ".pipeline.yml" // BuildFailure indicates that the build has failed BuildFailure = "FAIL" // BuildPending indicates that the build is pending BuildPending = "PENDING" // BuildRunning indicates that the build is running BuildRunning = "RUNNING" // BuildSuccess indicates that the build was successful BuildSuccess = "SUCCESS" // BuildWaiting indicates that the build is waiting for user input BuildWaiting = "WAITING" )
Variables ¶
This section is empty.
Functions ¶
func CreateJob ¶
func CreateJob(definition *Definition, jobInfo *JobBuildInfo, scmClient scm.Client) (j *kube.Job, err error)
CreateJob creates a kubernetes Job for the given build information
Types ¶
type Build ¶
type Build struct { ID string `json:"id"` Number int `json:"number"` Status string `json:"status"` Created int64 `json:"created"` Started int64 `json:"started"` Finished int64 `json:"finished"` CurrentStage int `json:"current_stage"` Branch string `json:"branch"` Commit string `json:"commit"` Author string `json:"author"` Event string `json:"event"` CloneURL string `json:"clone_url"` Pipeline string `json:"-"` Stages []*Stage `json:"stages,omitempty"` }
Build contains the details needed to run a build
func (*Build) CreateStages ¶
CreateStages perists the build's stage details
type BuildSummary ¶
type BuildSummary struct { ID string `json:"id"` Number int `json:"number"` Status string `json:"status"` Created int64 `json:"created"` Started int64 `json:"started"` Finished int64 `json:"finished"` Branch string `json:"branch"` Commit string `json:"commit"` Author string `json:"author"` }
BuildSummary contains the summarized details of a build
type Definition ¶
type Definition struct { APIVersion string `json:"apiVersion"` Kind string `json:"kind"` Metadata map[string]interface{} `json:"metadata"` Spec SpecDetails `json:"spec"` }
func GetDefinition ¶
func GetDefinition(definition []byte) (payload *Definition, err error)
func (*Definition) GetStages ¶
func (d *Definition) GetStages() []*Stage
type DefinitionFile ¶
DefinitionFile holds repository metadata of the definition file (PipelineYAML)
func (*DefinitionFile) SaveToRepo ¶
func (d *DefinitionFile) SaveToRepo(c scm.Client, owner, repo string, commit map[string]string) (*DefinitionFile, error)
type JobBuildInfo ¶
type JobBuildInfo struct { PipelineUUID string `json:"pipeline_uuid"` Build string `json:"build"` Stage string `json:"stage"` Commit string `json:"commit"` Branch string `json:"branch"` User string `json:"user,omitempty"` Repo string `json:"repo,omitempty"` Owner string `json:"owner,omitempty"` }
JobBuildInfo contains the required details for creating a job
func GetJobBuildInfo ¶
func GetJobBuildInfo(jobInfo []byte) (payload *JobBuildInfo, err error)
type NextJobInfo ¶
NextJobInfo contains the data needed to get the details for creating a job
type Pipeline ¶
type Pipeline struct { ID string `json:"id"` Name string `json:"-"` Owner string `json:"owner"` Repo string `json:"repo"` Events []string `json:"events,omitempty"` Builds []*Build `json:"builds,omitempty"` LatestBuildNumber int `json:"-"` LatestBuild *BuildSummary `json:"latest_build,omitempty"` Keys Key `json:"-"` Login string `json:"login"` Source string `json:"-"` Notifiers []*Notifier `json:"notif,omitempty"` Secrets []string `json:"secrets,omitempty"` Vars map[string]interface{} `json:"vars, omitempty"` }
Pipeline contains the details of a repo required for a build
func FindAllPipelines ¶
FindAllPipelines returns all the pipelines
func FindPipeline ¶
FindPipeline returns a pipeline based on the given owner & repo details
func (*Pipeline) CreateBuild ¶
func (p *Pipeline) CreateBuild(b *Build, stages []*Stage, kvClient kv.KVClient, scmClient scm.Client) error
CreateBuild persists build & stage details based on the given definition
func (*Pipeline) Definition ¶
Definition retrieves the pipeline definition from a given reference
func (*Pipeline) DeletePipeline ¶
func (*Pipeline) GenerateHookSecret ¶
GenerateHookSecret generates the secret for web hooks used for hook authentication
func (*Pipeline) GetAllBuildsSummary ¶
func (p *Pipeline) GetAllBuildsSummary(kvClient kv.KVClient) ([]*BuildSummary, error)
GetAllBuildsSummary fetches all summarized builds from the store
func (*Pipeline) GetBuildSummary ¶
GetBuildSummary fetches a specific build by its number and returns a summarized details
func (*Pipeline) GetDefinitionFile ¶
GetDefinitionFile fetches the definition file (PipelineYAML) from the pipeline's repository returns the content (possibly encoded in base64, see scm API) and the SHA of the file (blob)
func (*Pipeline) PrepareBuildStage ¶
func (p *Pipeline) PrepareBuildStage(n *NextJobInfo, scmClient scm.Client) (*Definition, *JobBuildInfo, error)
PrepareBuildStage gets the details needed to run a job
func (*Pipeline) UpdateDefinitionFile ¶
func (p *Pipeline) UpdateDefinitionFile(c scm.Client, file *DefinitionFile, commit map[string]string) (*DefinitionFile, error)
UpdateDefinitionFile commits the changes of the definition file (PipelineYAML) or creates the file if it does not exist either directly to the default branch or through a pull request
func (*Pipeline) UpdatePipeline ¶
func (p *Pipeline) UpdatePipeline(definition *Definition, kvClient kv.KVClient)
type SpecDetails ¶
type SpecDetails struct { Selector struct { MatchLabels map[string]interface{} `json:"matchLabels"` } `json:"selector"` Template TemplateDetails `json:"template"` }
type Stage ¶
type Stage struct { ID string `json:"id"` Name string `json:"name"` Type string `json:"type"` Index int `json:"index"` Params map[string]interface{} `json:"params"` Labels map[string]interface{} `json:"labels"` Started int64 `json:"started,omitempty"` Finished int64 `json:"finished,omitempty"` Message string `json:"message,omitempty"` Status string `json:"status"` Namespace string `json:"pod_namespace"` JobName string `json:"job_name,omitempty"` PodName string `json:"pod_name,omitempty"` DockerImage string `json:"docker_image,omitempty"` Artifacts []string `json:"artifacts,omitempty"` Secrets []string `json:"secrets"` Vars map[string]interface{} `json:"vars"` }
Stage contains the current state of a job
type StatusUpdate ¶
type StatusUpdate struct { Status string `json:"status"` JobName string `json:"job_name"` PodName string `json:"pod_name"` Timestamp int64 `json:"timestamp"` DockerImage string `json:"docker_image"` Message string `json:"message"` }
StatusUpdate contains details for stage patch updates