pipeline

package
v0.0.0-...-0b82c43 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2016 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
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

func CreatePipeline

func CreatePipeline(p *Pipeline, c scm.Client, k kv.KVClient) (err error)

CreatePipeline persists the pipeline details and setups the webhook and deploy keys(used for builds) to the remote SCM

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

func (b *Build) CreateStages(kvClient kv.KVClient) (err error)

CreateStages perists the build's stage details

func (*Build) Delete

func (b *Build) Delete(pipelinesID string, kvClient kv.KVClient, mcClient *mc.MinioClient) (err error)

func (*Build) GetStage

func (b *Build) GetStage(idx int, kvClient kv.KVClient) (*Stage, bool)

GetStage fetches a specific stage by its index

func (*Build) GetStages

func (b *Build) GetStages(kvClient kv.KVClient) ([]*Stage, error)

GetStages fetches all stages of the build from the store

func (*Build) Notify

func (b *Build) Notify(kvClient kv.KVClient) error

func (*Build) Save

func (b *Build) Save(kvClient kv.KVClient) (err error)

Save persists the build details to `etcd`

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

type DefinitionFile struct {
	Content *string `json:"content,omitempty"`
	SHA     *string `json:"sha"`
}

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 Key

type Key struct {
	Private string
	Public  string
}

Key contains the public/private keypair used for deployments

type NextJobInfo

type NextJobInfo struct {
	Commit      string
	BuildNumber int
	StageIndex  int
}

NextJobInfo contains the data needed to get the details for creating a job

type Notifier

type Notifier struct {
	Type      string                 `json:"type"`
	Metadata  map[string]interface{} `json:"metadata, omitempty"`
	Namespace string                 `json:"-"`
}

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

func FindAllPipelines(kvClient kv.KVClient) ([]*Pipeline, error)

FindAllPipelines returns all the pipelines

func FindPipeline

func FindPipeline(owner, repo string, kvClient kv.KVClient) (*Pipeline, bool)

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

func (p *Pipeline) Definition(ref string, c scm.Client) (*Definition, error)

Definition retrieves the pipeline definition from a given reference

func (*Pipeline) DeletePipeline

func (p *Pipeline) DeletePipeline(kvClient kv.KVClient, mcClient *mc.MinioClient) (err error)

func (*Pipeline) GenerateHookSecret

func (p *Pipeline) GenerateHookSecret(secret string) (string, error)

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) GetBuild

func (p *Pipeline) GetBuild(num int, kvClient kv.KVClient) (*Build, bool)

GetBuild fetches a specific build by its number

func (*Pipeline) GetBuildSummary

func (p *Pipeline) GetBuildSummary(num int, kvClient kv.KVClient) (*BuildSummary, bool)

GetBuildSummary fetches a specific build by its number and returns a summarized details

func (*Pipeline) GetBuilds

func (p *Pipeline) GetBuilds(kvClient kv.KVClient) ([]*Build, error)

GetBuilds fetches all builds from the store

func (*Pipeline) GetDefinitionFile

func (p *Pipeline) GetDefinitionFile(c scm.Client, ref string) (*DefinitionFile, bool)

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) Save

func (p *Pipeline) Save(kvClient kv.KVClient) (err error)

Save persists the pipeline details to `etcd`

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)

func (*Pipeline) Validate

func (p *Pipeline) Validate() error

Validate checks if the required values for a pipeline are present

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

func (*Stage) Save

func (s *Stage) Save(namespace string, kvClient kv.KVClient) (err error)

Save persists the stage details to `etcd`

func (*Stage) UpdateStatus

func (s *Stage) UpdateStatus(u *StatusUpdate, p *Pipeline, b *Build, kvClient kv.KVClient, c scm.Client) (*Stage, error)

UpdateStatus updates the status of a build stage

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

type TemplateDetails

type TemplateDetails struct {
	Metadata  map[string]interface{} `json:"metadata"`
	Stages    []Stage                `json:"stages"`
	Notifiers []*Notifier            `json:"notif,omitempty"`
	Secrets   []string               `json:"secrets,omitempty"`
	Vars      map[string]interface{} `json:"vars,omitempty"`
}

type User

type User struct {
	Name     string `json:"name"`
	RemoteID string `json:"id"`
	Token    string `json:"access_token"`
}

User contains user details from the remote SCM

func FindUser

func FindUser(remoteID string, kvClient kv.KVClient) (*User, bool)

FindUser finds a User given a remote ID

func (*User) Save

func (u *User) Save(kvClient kv.KVClient) (err error)

Save persists User details to the store

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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