api

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2017 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GitLab CodeSourceType = "gitlab"
	GitHub                = "github"
	SVN                   = "svn"
)
View Source
const (
	// Limit represents the name of the query parameter for pagination limit.
	Limit string = "limit"

	// Start represents the name of the query parameter for pagination start.
	Start string = "start"

	// Filter represents the name of the query parameter for filtering.
	Filter string = "filter"

	// RecentPipelineRecordCount represents the count of recent pipeline records.
	RecentPipelineRecordCount string = "recentCount"

	// RecentSuccessPipelineRecordCount represents the count of recent success pipeline records.
	RecentSuccessPipelineRecordCount string = "recentSuccessCount"

	// RecentFailedPipelineRecordCount represents the count of recent failed pipeline records.
	RecentFailedPipelineRecordCount string = "recentFailedCount"
)
View Source
const (
	// GITHUB is the name of github.
	GITHUB string = "github"
	// GITLAB is the name of gitlab.
	GITLAB string = "gitlab"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AutoTrigger

type AutoTrigger struct {
	SCMTrigger   *SCMTrigger   `bson:"scmTrigger,omitempty" json:"scmTrigger,omitempty" description:"SCM trigger strategy"`
	TimerTrigger *TimerTrigger `bson:"timerTrigger,omitempty" json:"timerTrigger,omitempty" description:"timer trigger strategy"`
}

AutoTrigger represents the auto trigger strategy of the pipeline.

type Build

type Build struct {
	BuilderImage *BuilderImage `bson:"builderImage,omitempty" json:"builderImage,omitempty" description:"image information of the builder"`
	Stages       *BuildStages  `bson:"stages,omitempty" json:"stages,omitempty" description:"stages of CI"`
}

Build represents the build config and stages of CI.

type BuildStages

type BuildStages struct {
	CodeCheckout    *CodeCheckoutStage    `bson:"codeCheckout,omitempty" json:"codeCheckout,omitempty" description:"code checkout stage"`
	UnitTest        *UnitTestStage        `bson:"unitTest,omitempty" json:"unitTest,omitempty" description:"unit test stage"`
	CodeScan        *CodeScanStage        `bson:"codeScan,omitempty" json:"codeScan,omitempty" description:"code scan stage"`
	Package         *PackageStage         `bson:"package,omitempty" json:"package,omitempty" description:"package stage"`
	ImageBuild      *ImageBuildStage      `bson:"imageBuild,omitempty" json:"imageBuild,omitempty" description:"image build stage"`
	IntegrationTest *IntegrationTestStage `bson:"integrationTest,omitempty" json:"integrationTest,omitempty" description:"integration test stage"`
	ImageRelease    *ImageReleaseStage    `bson:"imageRelease,omitempty" json:"imageRelease,omitempty" description:"image release stage"`
}

BuildStages represents the build stages of CI.

type BuilderImage

type BuilderImage struct {
	Image   string   `bson:"image,omitempty" json:"image,omitempty" description:"image name of the builder"`
	EnvVars []EnvVar `bson:"envVars,omitempty" json:"envVars,omitempty" description:"environment variables of the builder"`
}

BuilderImage represents the image information of the builder.

type CodeCheckoutStage

type CodeCheckoutStage struct {
	CodeSources []*CodeSource `bson:"codeSources,omitempty" json:"codeSources,omitempty" description:"list of code sources to be checked out"`
}

CodeCheckoutStage represents the config of code checkout stage.

type CodeScanStage

type CodeScanStage struct {
	GeneralStage
	Outputs []string `bson:"outputs,omitempty" json:"outputs,omitempty" description:"list of output path of this stage"`
}

CodeScanStage represents the config of code scan stage.

type CodeSource

type CodeSource struct {
	Type CodeSourceType `bson:"type,omitempty" json:"type,omitempty" description:"type of code source, support gitlab, github and svn"`
	// Whether is the main repo. Only support webhook and tag for main repo.
	Main   bool       `bson:"main,omitempty" json:"main,omitempty" description:"whether is the main repo"`
	GitLab *GitSource `bson:"gitLab,omitempty" json:"gitLab,omitempty" description:"code from gitlab"`
	GitHub *GitSource `bson:"gitHub,omitempty" json:"gitHub,omitempty" description:"code from github"`
}

CodeSource represents the config of code source, only one type is supported.

type CodeSourceType

type CodeSourceType string

CodeSourceType represents the type of code source, supports gitlab, github and svn.

type CommitTrigger

type CommitTrigger struct {
	GeneralTrigger
}

CommitTrigger represents the trigger from SCM commit.

type CommitWithCommentsTrigger

type CommitWithCommentsTrigger struct {
	GeneralTrigger
	Comment []string `bson:"comment,omitempty" json:"comment,omitempty" description:"list of comments in commit"`
}

CommitWithCommentsTrigger represents the trigger from SCM commit with specified comments.

type CronTrigger

type CronTrigger struct {
	GeneralTrigger
	Expression string `bson:"expression,omitempty" json:"expression,omitempty" description:"expression of cron job"`
}

CronTrigger represents the trigger from cron job.

type EnvVar

type EnvVar struct {
	Name  string `bson:"name,omitempty" json:"name,omitempty" description:"name of the environment variable"`
	Value string `bson:"value,omitempty" json:"value,omitempty" description:"value of the environment variable"`
}

EnvVar represents the environment variables with name and value.

type ErrorResponse

type ErrorResponse struct {
	Message string `json:"message,omitempty"`
	Reason  string `json:"reason,omitempty"`
	Details string `json:"details,omitempty"`
}

ErrorResponse represents response of error.

type GeneralStage

type GeneralStage struct {
	Command []string `bson:"command,omitempty" json:"command,omitempty" description:"list of commands to run for this stage"`
}

GeneralStage represents the basic config shared by all stages.

type GeneralStageStatus

type GeneralStageStatus struct {
	Status    Status    `bson:"status,omitempty" json:"status,omitempty" description:"status of the stage"`
	StartTime time.Time `bson:"startTime,omitempty" json:"startTime,omitempty" description:"start time of the stage"`
	EndTime   time.Time `bson:"endTime,omitempty" json:"endTime,omitempty" description:"end time of the stage"`
}

GeneralStageStatus represents the information of stage.

type GeneralTrigger

type GeneralTrigger struct {
	Stages string `bson:"stages,omitempty" json:"stages,omitempty" description:"stages of the auto triggered running"`
}

GeneralTrigger represents the general config for all auto trigger strategies.

type GitSource

type GitSource struct {
	Url      string `bson:"url,omitempty" json:"url,omitempty" description:"url of git repo"`
	Ref      string `bson:"ref,omitempty" json:"ref,omitempty" description:"reference of git repo, support branch, tag"`
	Username string `bson:"username,omitempty" json:"username,omitempty" description:"username of git"`
	Password string `bson:"password,omitempty" json:"password,omitempty" description:"password of git"`
}

GitSource represents the config to get code from git.

type ImageBuildInfo

type ImageBuildInfo struct {
	ContextDir     string `bson:"contextDir,omitempty" json:"contextDir,omitempty" description:"context directory for image build"`
	Dockerfile     string `bson:"dockerfile,omitempty" json:"dockerfile,omitempty" description:"dockerfile content for image build"`
	DockerfilePath string `bson:"dockerfilePath,omitempty" json:"dockerfilePath,omitempty" description:"dockerfile path for image build"`
	ImageName      string `bson:"imageName,omitempty" json:"imageName,omitempty" description:"name of the built image"`
}

ImageBuildInfo represents the config to build the image. Only one of Dockerfile and DockerfilePath needs to be set. If both of them are set, Dockerfile will be used with high priority.

type ImageBuildStage

type ImageBuildStage struct {
	BuildInfos []*ImageBuildInfo `bson:"buildInfos,omitempty" json:"buildInfos,omitempty" description:"list of output path of this stage"`
}

ImageBuildStage represents the config of image build stage.

type ImageReleasePolicy

type ImageReleasePolicy struct {
	ImageName string                 `bson:"imageName,omitempty" json:"imageName,omitempty" description:"image to be released"`
	Type      ImageReleasePolicyType `bson:"type,omitempty" json:"type,omitempty" description:"type of image release policy"`
}

ImageReleasePolicy represents the policy to release image.

type ImageReleasePolicyType

type ImageReleasePolicyType string

ImageReleasePolicyType represents the type of image release policy.

const (
	// AlwaysRelease always releases the images.
	AlwaysRelease ImageReleasePolicyType = "Always"

	// IntegrationTestSuccessRelease releases the images only when the integration test success.
	IntegrationTestSuccessRelease ImageReleasePolicyType = "IntegrationTestSuccess"
)

type ImageReleaseStage

type ImageReleaseStage struct {
	ReleasePolicy []ImageReleasePolicy `bson:"releasePolicy,omitempty" json:"releasePolicy,omitempty" description:"list of policies for image release"`
}

ImageReleaseStage represents the config of image release stage.

type IntegrationTestConfig

type IntegrationTestConfig struct {
	ImageName string   `bson:"imageName,omitempty" json:"imageName,omitempty" description:"built image name to run the integration test"`
	Command   []string `bson:"command,omitempty" json:"command,omitempty" description:"list of commands to run for integration test"`
	EnvVars   []EnvVar `bson:"envVars,omitempty" json:"envVars,omitempty" description:"environment variables for integration test"`
}

IntegrationTestConfig represents the config for integration test.

type IntegrationTestStage

type IntegrationTestStage struct {
	Config   *IntegrationTestConfig `bson:"Config,omitempty" json:"Config,omitempty" description:"integration test config"`
	Services []Service              `bson:"services,omitempty" json:"services,omitempty" description:"list of dependent services for integration test"`
}

IntegrationTestStage represents the config of integration test stage.

type ListMeta

type ListMeta struct {
	Total int `json:"total" description:"total items count"`
}

ListMeta represents metadata that list resources must have.

type ListReposResponse

type ListReposResponse struct {
	Username  string       `json:"username,omitempty"`
	Repos     []Repository `json:"repos,omitempty"`
	AvatarURL string       `json:"avatarUrl,omitempty"`
}

ListReposResponse represents a collection of repositories.

type ListResponse

type ListResponse struct {
	Meta  ListMeta    `json:"metadata" description:"pagination object"`
	Items interface{} `json:"items" description:"list resources"`
}

ListResponse represents a collection of some resources.

type PackageStage

type PackageStage struct {
	GeneralStage
	Outputs []string `bson:"outputs,omitempty" json:"outputs,omitempty" description:"list of output path of this stage"`
}

PackageStage represents the config of package stage.

type Pipeline

type Pipeline struct {
	ID          string `bson:"_id,omitempty" json:"id,omitempty" description:"id of the pipeline"`
	Name        string `bson:"name,omitempty" json:"name,omitempty" description:"name of the pipeline,unique in one project"`
	Alias       string `bson:"alias,omitempty" json:"alias,omitempty" description:"alias of the pipeline"`
	Description string `bson:"description,omitempty" json:"description,omitempty" description:"description of the pipeline"`
	Owner       string `bson:"owner,omitempty" json:"owner,omitempty" description:"owner of the pipeline"`
	ProjectID   string `bson:"projectID,omitempty" json:"projectID,omitempty" description:"id of the project which the pipeline belongs to"`
	// TODO (robin)Remove the association between the pipeline and the service after pipeline replaces service.
	ServiceID            string           `bson:"serviceID,omitempty" json:"serviceID,omitempty" description:"id of the service which the pipeline is related to"`
	Build                *Build           `bson:"build,omitempty" json:"build,omitempty" description:"build spec of the pipeline"`
	AutoTrigger          *AutoTrigger     `bson:"autoTrigger,omitempty" json:"autoTrigger,omitempty" description:"auto trigger strategy of the pipeline"`
	CreationTime         time.Time        `bson:"creationTime,omitempty" json:"creationTime,omitempty" description:"creation time of the pipeline"`
	LastUpdateTime       time.Time        `bson:"lastUpdateTime,omitempty" json:"lastUpdateTime,omitempty" description:"last update time of the pipeline"`
	RecentRecords        []PipelineRecord `bson:"recentRecords,omitempty" json:"recentRecords,omitempty" description:"recent records of the pipeline"`
	RecentSuccessRecords []PipelineRecord `` /* 128-byte string literal not displayed */
	RecentFailedRecords  []PipelineRecord `bson:"recentFailedRecords,omitempty" json:"recentFailedRecords,omitempty" description:"recent failed records of the pipeline"`
}

Pipeline represents a set of configs to describe the workflow of CI/CD.

type PipelinePerformParams

type PipelinePerformParams struct {
	Ref          string   `bson:"ref,omitempty" json:"ref,omitempty" description:"reference of git repo, support branch, tag"`
	Name         string   `bson:"name,omitempty" json:"name,omitempty" description:"name of this running of pipeline"`
	Description  string   `bson:"description,omitempty" json:"description,omitempty" description:"description of this running of pipeline"`
	CreateSCMTag bool     `bson:"createScmTag,omitempty" json:"createScmTag,omitempty" description:"whether create tag in SCM"`
	Stages       []string `bson:"stages,omitempty" json:"stages,omitempty" description:"stages to be executed"`
}

PipelinePerformParams the params to perform the pipeline.

type PipelineRecord

type PipelineRecord struct {
	ID          string       `bson:"_id,omitempty" json:"id,omitempty" description:"id of the pipeline record"`
	Name        string       `bson:"name,omitempty" json:"name,omitempty" description:"name of the pipeline record"`
	PipelineID  string       `` /* 133-byte string literal not displayed */
	VersionID   string       `bson:"versionID,omitempty" json:"versionID,omitempty" description:"id of the version which the pipeline record is related to"`
	Trigger     string       `bson:"trigger,omitempty" json:"trigger,omitempty" description:"trigger of the pipeline record"`
	StageStatus *StageStatus `bson:"stageStatus,omitempty" json:"stageStatus,omitempty" description:"status of each pipeline stage"`
	Status      Status       `bson:"status,omitempty" json:"status,omitempty" description:"status of the pipeline record"`
	StartTime   time.Time    `bson:"startTime,omitempty" json:"startTime,omitempty" description:"start time of the pipeline record"`
	EndTime     time.Time    `bson:"endTime,omitempty" json:"endTime,omitempty" description:"end time of the pipeline record"`
}

PipelineRecord represents the running record of pipeline.

type Project

type Project struct {
	ID             string    `bson:"_id,omitempty" json:"id,omitempty" description:"id of the project"`
	Name           string    `bson:"name,omitempty" json:"name,omitempty" description:"name of the project, should be unique"`
	Description    string    `bson:"description,omitempty" json:"description,omitempty" description:"description of the project"`
	Owner          string    `bson:"owner,omitempty" json:"owner,omitempty" description:"owner of the project"`
	CreationTime   time.Time `bson:"creationTime,omitempty" json:"creationTime,omitempty" description:"creation time of the project"`
	LastUpdateTime time.Time `bson:"lastUpdateTime,omitempty" json:"lastUpdateTime,omitempty" description:"last update time of the project"`
}

Project represents a group to manage a set of related applications. It maybe a real project, which contains several or many applications.

type QueryParams

type QueryParams struct {
	Start  int                    `json:"start,omitempty" description:"query start index, default is 0"`
	Limit  int                    `json:"limit,omitempty" description:"specify the number of records, default is +Inf to not limit"`
	Filter map[string]interface{} `json:"filter,omitempty" description:"pattern to filter the records, default is nil to not filter"`
}

QueryParams represents a collection of query param.

type Repository

type Repository struct {
	Name  string `json:"name,omitempty"`
	Owner string `json:"owner,omitempty"`
	URL   string `json:"url,omitempty"`
}

Repository represents the informations of a repository.

type SCMTrigger

type SCMTrigger struct {
	CommitTrigger *CommitTrigger `bson:"commitTrigger,omitempty" json:"commitTrigger,omitempty" description:"commit trigger strategy"`
}

SCMTrigger represents the auto trigger strategy from SCM.

type ScmToken

type ScmToken struct {
	ProjectID string       `bson:"projectId,omitempty" json:"projectId,omitempty" description:"id of the project which the token belongs to"`
	ScmType   string       `bson:"scmType,omitempty" json:"scmType,omitempty" description:"the type of scm, it can be github or gitlab"`
	Token     oauth2.Token `bson:"token,omitempty" json:"token,omitempty"`
}

ScmToken represents a set of token informations of the projcet.

type Service

type Service struct {
	Name    string   `bson:"name,omitempty" json:"name,omitempty" description:"name of the service"`
	Image   string   `bson:"image,omitempty" json:"image,omitempty" description:"image name of the service"`
	Command []string `bson:"command,omitempty" json:"command,omitempty" description:"list of commands to start the service"`
	EnvVars []EnvVar `bson:"envVars,omitempty" json:"envVars,omitempty" description:"environment variables of the service"`
}

Service represents the dependent service needed for integration test.

type StageStatus

type StageStatus struct {
	CodeCheckout    *GeneralStageStatus `bson:"codeCheckout,omitempty" json:"codeCheckout,omitempty" description:"status of code checkout stage"`
	UnitTest        *GeneralStageStatus `bson:"unitTest,omitempty" json:"unitTest,omitempty" description:"status of unit test stage"`
	CodeScan        *GeneralStageStatus `bson:"codeScan,omitempty" json:"codeScan,omitempty" description:"status of code scan stage"`
	Package         *GeneralStageStatus `bson:"package,omitempty" json:"package,omitempty" description:"status of package stage"`
	ImageBuild      *GeneralStageStatus `bson:"imageBuild,omitempty" json:"imageBuild,omitempty" description:"status of image build stage"`
	IntegrationTest *GeneralStageStatus `bson:"integrationTest,omitempty" json:"integrationTest,omitempty" description:"status of integration test stage"`
	ImageRelease    *GeneralStageStatus `bson:"imageRelease,omitempty" json:"imageRelease,omitempty" description:"status of image release stage"`
}

TODO The status of every stage may be different. StageStatus represents the collections of status for all stages.

type Status

type Status string

Status can be the status of some pipeline record or some stage

const (
	// Pending represents the status that is triggered but still not running.
	Pending Status = "Pending"
	// Running represents the status that is running.
	Running Status = "Running"
	// Success represents the status that finished and succeeded.
	Success Status = "Success"
	// Failed represents the status that finished but failed.
	Failed Status = "Failed"
	// Aborted represents the status that the stage was aborted by some reason, and we can get the reason from the log.
	Aborted Status = "Aborted"
)

type TimerTrigger

type TimerTrigger struct {
	CronTrigger []*CronTrigger `bson:"cronTrigger,omitempty" json:"cronTrigger,omitempty" description:"list of cron trigger strategies"`
}

TimerTrigger represents the auto trigger strategy from timer.

type UnitTestStage

type UnitTestStage struct {
	GeneralStage
	Outputs []string `bson:"outputs,omitempty" json:"outputs,omitempty" description:"list of output path of this stage"`
}

UnitTestStage represents the config of unit test stage.

Jump to

Keyboard shortcuts

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