task

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IToi

func IToi(before interface{}, after interface{}) error

Types

type Artifact

type Artifact struct {
	TaskType   config.TaskType `bson:"type"                          json:"type"`
	Enabled    bool            `bson:"enabled"                       json:"enabled"`
	TaskStatus config.Status   `bson:"status"                        json:"status"`
	Name       string          `bson:"name"                          json:"name"`
	Image      string          `bson:"image"                         json:"image"`
	RegistryID string          `bson:"registry_id"                   json:"registry_id"`
	Timeout    int             `bson:"timeout,omitempty"             json:"timeout,omitempty"`
	Error      string          `bson:"error,omitempty"               json:"error,omitempty"`
	StartTime  int64           `bson:"start_time,omitempty"          json:"start_time,omitempty"`
	EndTime    int64           `bson:"end_time,omitempty"            json:"end_time,omitempty"`
	LogFile    string          `bson:"log_file"                      json:"log_file"`
	IsRestart  bool            `bson:"is_restart"                    json:"is_restart"`
}

func (*Artifact) ToSubTask

func (d *Artifact) ToSubTask() (map[string]interface{}, error)

type ArtifactArgs

type ArtifactArgs struct {
	Name        string      `bson:"name"                      json:"name"`
	ServiceName string      `bson:"service_name"              json:"service_name"`
	Image       string      `bson:"image"                     json:"image"`
	Deploy      []DeployEnv `bson:"deloy"                     json:"deploy"`
}

type Build

type Build struct {
	TaskType   config.TaskType `bson:"type"                       json:"type"`
	Enabled    bool            `bson:"enabled"                    json:"enabled"`
	TaskStatus config.Status   `bson:"status"                     json:"status"`
	// 新增一个service表示服务名称
	Service string `bson:"service"                    json:"service"`
	// 该名称实际为服务组件名称
	ServiceName       string               `bson:"service_name"               json:"service_name"`
	ServiceType       string               `bson:"service_type"               json:"service_type"`
	EnvName           string               `bson:"env_name"                   json:"env_name"`
	Namespace         string               `bson:"namespace"                  json:"namespace"`
	Timeout           int                  `bson:"timeout"                    json:"timeout,omitempty"`
	Error             string               `bson:"error,omitempty"            json:"error,omitempty"`
	StartTime         int64                `bson:"start_time"                 json:"start_time,omitempty"`
	EndTime           int64                `bson:"end_time"                   json:"end_time,omitempty"`
	JobCtx            JobCtx               `bson:"job_ctx"                    json:"job_ctx"`
	DockerBuild       *DockerBuild         `bson:"docker_build,omitempty"     json:"docker_build,omitempty"`
	InstallItems      []*Item              `bson:"install_items"              json:"install_items"`
	BuildOS           string               `bson:"build_os"                   json:"build_os,omitempty"`
	ImageFrom         string               `bson:"image_from"                 json:"image_from,omitempty"`
	ImageID           string               `bson:"image_id"                   json:"image_id"`
	ResReq            setting.Request      `bson:"res_req"                    json:"res_req"`
	LogFile           string               `bson:"log_file"                   json:"log_file"`
	InstallCtx        []*Install           `bson:"-"                          json:"install_ctx,omitempty"`
	Registries        []*RegistryNamespace `bson:"-"                   json:"registries"`
	StaticCheckStatus *StaticCheckStatus   `bson:"static_check_status,omitempty" json:"static_check_status,omitempty"`
	UTStatus          *UTStatus            `bson:"ut_status,omitempty" json:"ut_status,omitempty"`
	DockerBuildStatus *DockerBuildStatus   `bson:"docker_build_status,omitempty" json:"docker_build_status,omitempty"`
	BuildStatus       *BuildStatus         `bson:"build_status,omitempty" json:"build_status,omitempty"`
	IsRestart         bool                 `bson:"is_restart"                      json:"is_restart"`
}

func (*Build) ToSubTask

func (b *Build) ToSubTask() (map[string]interface{}, error)

ToSubTask ...

type BuildArgs

type BuildArgs struct {
	Repos []*Repository `bson:"repos"               json:"repos"`
}

type BuildConfig

type BuildConfig struct {
	KubeNamespace string
}

type BuildStatus

type BuildStatus struct {
	StepStatus
}

type BuildStep

type BuildStep struct {
	BuildType  string `bson:"type"                         json:"type"`
	Scripts    string `bson:"scripts"                      json:"scripts"`
	MainGoFile string `bson:"main,omitempty"               json:"main,omitempty"`
}

type ConfigPayload

type ConfigPayload struct {
	Proxy              Proxy              `json:"proxy"`
	S3Storage          S3Config           `json:"s3_storage"`
	Github             GithubConfig       `json:"github"`
	Gitlab             GitlabConfig       `json:"gitlab"`
	Build              BuildConfig        `json:"build"`
	Test               TestConfig         `json:"test"`
	Registry           RegistryConfig     `json:"registry"`
	Release            ReleaseConfig      `json:"release"`
	JenkinsBuildConfig JenkinsBuildConfig `json:"jenkins_build_config"`
	// 推送线上镜像需要的用户名密码, 根据pipeline镜像发布模块动态配置
	ImageRelease ImageReleaseConfig `json:"image_release"`
	Docker       DockerConfig       `json:"docker"`

	ClassicBuild bool `json:"classic_build"`

	CustomDNSSupported bool `json:"custom_dns_supported"`
	HubServerAddr      string
	DeployClusterID    string

	RepoConfigs map[string]*RegistryNamespace

	// IgnoreCache means ignore docker build cache
	IgnoreCache bool `json:"ignore_cache"`

	// ResetCache means ignore workspace cache
	ResetCache  bool          `json:"reset_cache"`
	PrivateKeys []*PrivateKey `json:"private_keys"`
}

func (*ConfigPayload) GetGitKnownHost

func (cp *ConfigPayload) GetGitKnownHost() string

type Container

type Container struct {
	Name  string `bson:"name"           json:"name"`
	Image string `bson:"image"          json:"image"`
}

type Deploy

type Deploy struct {
	TaskType        config.TaskType `bson:"type"                          json:"type"`
	Enabled         bool            `bson:"enabled"                       json:"enabled"`
	TaskStatus      config.Status   `bson:"status"                        json:"status"`
	Namespace       string          `bson:"namespace"                     json:"namespace"`
	EnvName         string          `bson:"env_name"                      json:"env_name"`
	ProductName     string          `bson:"product_name"                  json:"product_name"`
	ServiceName     string          `bson:"service_name"                  json:"service_name"`
	ServiceType     string          `bson:"service_type"                  json:"service_type"`
	ServiceRevision int64           `bson:"service_revision,omitempty"    json:"service_revision,omitempty"`
	ContainerName   string          `bson:"container_name"                json:"container_name"`
	Image           string          `bson:"image"                         json:"image"`
	Timeout         int             `bson:"timeout,omitempty"             json:"timeout,omitempty"`
	Error           string          `bson:"error,omitempty"               json:"error,omitempty"`
	StartTime       int64           `bson:"start_time,omitempty"          json:"start_time,omitempty"`
	EndTime         int64           `bson:"end_time,omitempty"            json:"end_time,omitempty"`

	ReplaceResources []Resource `bson:"replace_resources"       json:"replace_resources"`
	SkipWaiting      bool       `bson:"skipWaiting"             json:"skipWaiting"`
	IsRestart        bool       `bson:"is_restart"              json:"is_restart"`
	ResetImage       bool       `bson:"reset_image"             json:"reset_image"`
}

Deploy 容器部署任务

func (*Deploy) SetImage

func (d *Deploy) SetImage(image string)

SetImage ...

func (*Deploy) SetNamespace

func (d *Deploy) SetNamespace(namespace string)

SetNamespace ...

func (*Deploy) ToSubTask

func (d *Deploy) ToSubTask() (*map[string]interface{}, error)

ToSubTask ...

type DeployArgs

type DeployArgs struct {
	// 目标部署环境
	Namespace string `json:"namespace"`
	// 镜像或者二进制名称后缀, 一般为branch或者PR
	Tag string `json:"suffix"`
	// 部署镜像名称
	// 格式: xxx.com/{namespace}/{service name}:{timestamp}-{suffix}}
	// timestamp format: 20060102150405
	Image string `json:"image"`
	// 部署二进制包名称
	// 格式: {service name}-{timestamp}-{suffix}}.tar.gz
	// timestamp format: 20060102150405
	PackageFile string `json:"package_file"`
}

type DeployEnv

type DeployEnv struct {
	Env         string `json:"env"`
	Type        string `json:"type"`
	ProductName string `json:"product_name,omitempty"`
}

type DistributeToS3

type DistributeToS3 struct {
	TaskType       config.TaskType `bson:"type"                           json:"type"`
	Enabled        bool            `bson:"enabled"                        json:"enabled"`
	TaskStatus     config.Status   `bson:"status"                         json:"status"`
	PackageFile    string          `bson:"package_file"                   json:"package_file"`
	ProductName    string          `bson:"product_name"                   json:"product_name"`
	ServiceName    string          `bson:"service_name"                   json:"service_name"`
	RemoteFileKey  string          `bson:"remote_file_key"                json:"remote_file_key,omitempty"`
	Timeout        int             `bson:"timeout,omitempty"              json:"timeout,omitempty"`
	Error          string          `bson:"error,omitempty"                json:"error,omitempty"`
	StartTime      int64           `bson:"start_time,omitempty"           json:"start_time,omitempty"`
	EndTime        int64           `bson:"end_time,omitempty"             json:"end_time,omitempty"`
	DestStorageURL string          `bson:"dest_storage_url"               json:"dest_storage_url"`
	//SrcStorageUrl  string `bson:"src_storage_url"                json:"src_storage_url"`
	S3StorageID string `bson:"s3_storage_id"                  json:"s3_storage_id"`
}

func (*DistributeToS3) SetPackageFile

func (d *DistributeToS3) SetPackageFile(packageFile string)

SetPackageFile ...

func (*DistributeToS3) ToSubTask

func (d *DistributeToS3) ToSubTask() (*map[string]interface{}, error)

ToSubTask ...

type DockerBuild

type DockerBuild struct {
	TaskType   config.TaskType `bson:"type"                    json:"type"`
	Enabled    bool            `bson:"enabled"                 json:"enabled"`
	TaskStatus config.Status   `bson:"status"                  json:"status"`
	WorkDir    string          `bson:"work_dir"                json:"work_dir"`             // Dockerfile 路径
	DockerFile string          `bson:"docker_file"             json:"docker_file"`          // Dockerfile 名称, 默认为Dockerfile
	BuildArgs  string          `bson:"build_args,omitempty"    json:"build_args,omitempty"` // Docker build可变参数
	Image      string          `bson:"image"                   json:"image"`
	OnSetup    string          `bson:"setup,omitempty"         json:"setup,omitempty"`
	Timeout    int             `bson:"timeout"                 json:"timeout,omitempty"`
	Error      string          `bson:"error"                   json:"error,omitempty"`
	StartTime  int64           `bson:"start_time"              json:"start_time,omitempty"`
	EndTime    int64           `bson:"end_time"                json:"end_time,omitempty"`
	JobName    string          `bson:"job_name"                json:"job_name"`
	LogFile    string          `bson:"log_file"                json:"log_file"`
}

func (*DockerBuild) ToSubTask

func (db *DockerBuild) ToSubTask() (map[string]interface{}, error)

type DockerBuildCtx

type DockerBuildCtx struct {
	WorkDir         string `yaml:"work_dir" bson:"work_dir" json:"work_dir"`
	DockerFile      string `yaml:"docker_file" bson:"docker_file" json:"docker_file"`
	ImageName       string `yaml:"image_name" bson:"image_name" json:"image_name"`
	BuildArgs       string `yaml:"build_args" bson:"build_args" json:"build_args"`
	ImageReleaseTag string `yaml:"image_release_tag,omitempty" bson:"image_release_tag,omitempty" json:"image_release_tag"`
}

DockerBuildCtx ... Docker build参数 WorkDir: docker build执行路径 DockerFile: dockerfile名称, 默认为Dockerfile ImageBuild: build image镜像全称, e.g. xxx.com/release-candidates/image:tag

func (*DockerBuildCtx) GetDockerFile

func (buildCtx *DockerBuildCtx) GetDockerFile() string

GetDockerFile ...

type DockerBuildStatus

type DockerBuildStatus struct {
	StepStatus
	ImageName    string `bson:"image_name" json:"image_name"`
	RegistryRepo string `bson:"registry_repo" json:"registry_repo"`
}

type DockerConfig

type DockerConfig struct {
	HostList []string
}

type EnvConfig

type EnvConfig struct {
	EnvName string   `bson:"env_name,omitempty" json:"env_name"`
	HostIDs []string `bson:"host_ids,omitempty" json:"host_ids"`
}

type FileArchiveCtx

type FileArchiveCtx struct {
	FileLocation string `yaml:"file_location" bson:"file_location" json:"file_location"`
	FileName     string `yaml:"file_name" bson:"file_name" json:"file_name"`
}

type GithubConfig

type GithubConfig struct {
	// github API access token
	AccessToken string
	// github ssh key with base64 encoded
	SSHKey string
	// github knownhost
	KnownHost string
	// github app private key
	AppKey string
	// gihhub app id
	AppID int
}

type GitlabConfig

type GitlabConfig struct {
	APIServer string
	// Github API access token
	AccessToken string
	// gitlab ssh key with base64 encoded
	SSHKey string
	// gitlab knownhost
	KnownHost string
}

type HookPayload

type HookPayload struct {
	Owner      string `bson:"owner"          json:"owner,omitempty"`
	Repo       string `bson:"repo"           json:"repo,omitempty"`
	Branch     string `bson:"branch"         json:"branch,omitempty"`
	Ref        string `bson:"ref"            json:"ref,omitempty"`
	IsPr       bool   `bson:"is_pr"          json:"is_pr,omitempty"`
	CheckRunID int64  `bson:"check_run_id"   json:"check_run_id,omitempty"`
	DeliveryID string `bson:"delivery_id"    json:"delivery_id,omitempty"`
}

type ImageReleaseConfig

type ImageReleaseConfig struct {
	Addr      string
	AccessKey string
	SecretKey string
}

type Install

type Install struct {
	ObjectIDHex  string   `bson:"-"                      json:"-"`
	Name         string   `bson:"name"                   json:"name"`
	Version      string   `bson:"version"                json:"version"`
	Scripts      string   `bson:"scripts"                json:"scripts"`
	UpdateTime   int64    `bson:"update_time"            json:"update_time"`
	UpdateBy     string   `bson:"update_by"              json:"update_by"`
	Envs         []string `bson:"env"                    json:"env"`
	BinPath      string   `bson:"bin_path"               json:"bin_path"`
	Enabled      bool     `bson:"enabled"                json:"enabled"`
	DownloadPath string   `bson:"download_path"          json:"download_path"`
}

type Item

type Item struct {
	Name    string `bson:"name"                   json:"name"`
	Version string `bson:"version"                json:"version"`
}

type JenkinsBuild

type JenkinsBuild struct {
	TaskType           config.TaskType     `bson:"type"                    json:"type"`
	Enabled            bool                `bson:"enabled"                 json:"enabled"`
	TaskStatus         config.Status       `bson:"status"                  json:"status"`
	ServiceName        string              `bson:"service_name"            json:"service_name"`
	Service            string              `bson:"service"                 json:"service"`
	OnSetup            string              `bson:"setup,omitempty"         json:"setup,omitempty"`
	Timeout            int                 `bson:"timeout"                 json:"timeout,omitempty"`
	Error              string              `bson:"error"                   json:"error,omitempty"`
	ResReq             setting.Request     `bson:"res_req"                 json:"res_req"`
	JenkinsIntegration *JenkinsIntegration `bson:"jenkins_integration"     json:"jenkins_integration"`
	JenkinsBuildArgs   *JenkinsBuildArgs   `bson:"jenkins_build_args"      json:"jenkins_build_args"`
	StartTime          int64               `bson:"start_time"              json:"start_time,omitempty"`
	EndTime            int64               `bson:"end_time"                json:"end_time,omitempty"`
	LogFile            string              `bson:"log_file"                json:"log_file"`
	Image              string              `bson:"image,omitempty"         json:"image,omitempty"`
	IsRestart          bool                `bson:"is_restart"              json:"is_restart"`
}

JenkinsBuild ...

func (*JenkinsBuild) SetIntegration

func (j *JenkinsBuild) SetIntegration(jenkinsIntegration *JenkinsIntegration)

SetIntegration ...

func (*JenkinsBuild) SetJenkinsBuildArgs

func (j *JenkinsBuild) SetJenkinsBuildArgs(jenkinsBuildArgs *JenkinsBuildArgs)

SetIntegration ...

func (*JenkinsBuild) ToSubTask

func (j *JenkinsBuild) ToSubTask() (map[string]interface{}, error)

type JenkinsBuildArgs

type JenkinsBuildArgs struct {
	JobName            string               `bson:"job_name"            json:"job_name"`
	JenkinsBuildParams []*JenkinsBuildParam `bson:"jenkins_build_param" json:"jenkins_build_params"`
}

type JenkinsBuildConfig

type JenkinsBuildConfig struct {
	JenkinsBuildImage string
}

type JenkinsBuildParam

type JenkinsBuildParam struct {
	Name  string      `json:"name"`
	Value interface{} `json:"value"`
}

type JenkinsIntegration

type JenkinsIntegration struct {
	URL      string `bson:"url"                   json:"url"`
	Username string `bson:"username"              json:"username"`
	Password string `bson:"password"              json:"password"`
}

type Jira

type Jira struct {
	TaskType   config.TaskType `bson:"type"                     json:"type"`
	Enabled    bool            `bson:"enabled"                  json:"enabled"`
	TaskStatus config.Status   `bson:"status"                   json:"status"`
	Builds     []*Repository   `bson:"builds,omitempty"         json:"builds,omitempty"`
	// TODO: (min) move JiraIssue back to this file
	Issues    []*JiraIssue `bson:"issues,omitempty"         json:"issues,omitempty"`
	Timeout   int          `bson:"timeout,omitempty"        json:"timeout,omitempty"`
	Error     string       `bson:"error,omitempty"          json:"error,omitempty"`
	StartTime int64        `bson:"start_time,omitempty"     json:"start_time,omitempty"`
	EndTime   int64        `bson:"end_time,omitempty"       json:"end_time,omitempty"`
}

func (*Jira) ToSubTask

func (j *Jira) ToSubTask() (map[string]interface{}, error)

type JiraIssue

type JiraIssue struct {
	ID          string `bson:"id,omitempty"                    json:"id,omitempty"`
	Key         string `bson:"key,omitempty"                   json:"key,omitempty"`
	URL         string `bson:"url,omitempty"                   json:"url,omitempty"`
	Summary     string `bson:"summary"                         json:"summary"`
	Description string `bson:"description,omitempty"           json:"description,omitempty"`
	Priority    string `bson:"priority,omitempty"              json:"priority,omitempty"`
	Creator     string `bson:"creator,omitempty"               json:"creator,omitempty"`
	Assignee    string `bson:"assignee,omitempty"              json:"assignee,omitempty"`
	Reporter    string `bson:"reporter,omitempty"              json:"reporter,omitempty"`
}

type JobCtx

type JobCtx struct {
	EnableProxy    bool   `bson:"enable_proxy"                   json:"enable_proxy"`
	Proxy          *Proxy `bson:"proxy"                          json:"proxy"`
	CleanWorkspace bool   `bson:"clean_workspace"                json:"clean_workspace"`

	// BuildJobCtx
	Builds     []*Repository `bson:"builds"                         json:"builds"`
	BuildSteps []*BuildStep  `bson:"build_steps,omitempty"          json:"build_steps"`
	SSHs       []*SSH        `bson:"sshs,omitempty"                 json:"sshs"`
	// Envs stores user defined env key val for build
	// TODO: 之后可以不用keystore, 将用户敏感信息保存在此字段
	EnvVars     []*KeyVal `bson:"envs,omitempty"                 json:"envs"`
	UploadPkg   bool      `bson:"upload_pkg"                     json:"upload_pkg"`
	PackageFile string    `bson:"package_file,omitempty"         json:"package_file,omitempty"`
	Image       string    `bson:"image,omitempty"                json:"image,omitempty"`

	// TestJobCtx
	TestThreshold  int    `bson:"test_threshold"                 json:"test_threshold"`
	TestResultPath string `bson:"test_result_path,omitempty"     json:"test_result_path,omitempty"`
	TestReportPath string `bson:"test_report_path,omitempty"     json:"test_report_path,omitempty"`
	TestJobName    string `bson:"test_job_name,omitempty"        json:"test_job_name,omitempty"`
	// DockerBuildCtx
	DockerBuildCtx *DockerBuildCtx `bson:"docker_build_ctx,omitempty" json:"docker_build_ctx,omitempty"`
	FileArchiveCtx *FileArchiveCtx `bson:"file_archive_ctx,omitempty" json:"file_archive_ctx,omitempty"`
	// TestType
	TestType string `bson:"test_type"                       json:"test_type"`
	// Caches
	Caches        []string `bson:"caches" json:"caches"`
	ArtifactPaths []string `bson:"artifact_paths,omitempty" json:"artifact_paths,omitempty"`
	IsHasArtifact bool     `bson:"is_has_artifact" json:"is_has_artifact"`

	// ClassicBuild used by qbox build
	ClassicBuild    bool   `bson:"classic_build"                  json:"classic_build"`
	PostScripts     string `bson:"post_scripts,omitempty"         json:"post_scripts"`
	PMDeployScripts string `bson:"pm_deploy_scripts,omitempty"    json:"pm_deploy_scripts"`
}

type JobCtxBuilder

type JobCtxBuilder struct {
	JobName       string
	ArchiveBucket string
	ArchiveFile   string
	PipelineCtx   *PipelineCtx
	JobCtx        JobCtx
	Installs      []*Install
}

type KeyVal

type KeyVal struct {
	Key          string `bson:"key"                 json:"key"`
	Value        string `bson:"value"               json:"value"`
	IsCredential bool   `bson:"is_credential"       json:"is_credential"`
}

type PipelineCtx

type PipelineCtx struct {
	DockerHost        string
	Workspace         string
	DistDir           string
	DockerMountDir    string
	ConfigMapMountDir string
	MultiRun          bool
}

type PrivateKey added in v1.2.0

type PrivateKey struct {
	Name string `json:"name"`
}

type ProductService

type ProductService struct {
	ServiceName string           `bson:"service_name"               json:"service_name"`
	ProductName string           `bson:"product_name"               json:"product_name"`
	Type        string           `bson:"type"                       json:"type"`
	Revision    int64            `bson:"revision"                   json:"revision"`
	Containers  []*Container     `bson:"containers"                 json:"containers,omitempty"`
	Configs     []*ServiceConfig `bson:"configs,omitempty"          json:"configs,omitempty"`
	Render      *RenderInfo      `bson:"render,omitempty"           json:"render,omitempty"` // 记录每个服务render信息 便于更新单个服务
	EnvConfigs  []*EnvConfig     `bson:"-"                          json:"env_configs,omitempty"`
}

type Proxy

type Proxy struct {
	//ID primitive.ObjectID `bson:"_id,omitempty"           json:"id,omitempty"`
	// http或socks5 暂时只支持http代理
	Type         string `bson:"type"                         json:"type"`
	Address      string `bson:"address"                      json:"address"`
	Port         int    `bson:"port"                         json:"port"`
	NeedPassword bool   `bson:"need_password"                json:"need_password"`
	Username     string `bson:"username"                     json:"username"`
	Password     string `bson:"password"                     json:"password"`
	// 代理用途,app表示应用代理,repo表示代码库代理。保留字段,暂时默认设置为default,以后可能用到。
	Usage                  string `bson:"usage"                        json:"usage"`
	EnableRepoProxy        bool   `bson:"enable_repo_proxy"            json:"enable_repo_proxy"`
	EnableApplicationProxy bool   `bson:"enable_application_proxy"     json:"enable_application_proxy"`
	CreateTime             int64  `bson:"create_time"                  json:"create_time"`
	UpdateTime             int64  `bson:"update_time"                  json:"update_time"`
	UpdateBy               string `bson:"update_by"                    json:"update_by"`
}

func (*Proxy) GetProxyURL

func (p *Proxy) GetProxyURL() string

func (Proxy) TableName

func (Proxy) TableName() string

type ProxyConfig

type ProxyConfig struct {
	HTTPAddr   string
	HTTPSAddr  string
	Socks5Addr string
	NoProxy    string
}

type RegistryConfig

type RegistryConfig struct {
	Addr        string
	AccessKey   string
	SecretKey   string
	Namespace   string
	RepoAddress string
}

type RegistryNamespace

type RegistryNamespace struct {
	OrgID       int    `bson:"org_id"                      json:"org_id"`
	RegAddr     string `bson:"reg_addr"                    json:"reg_addr"`
	RegType     string `bson:"reg_type"                    json:"reg_type"`
	RegProvider string `bson:"reg_provider"                json:"reg_provider"`
	IsDefault   bool   `bson:"is_default"                  json:"is_default"`
	Namespace   string `bson:"namespace"                   json:"namespace"`
	AccessKey   string `bson:"access_key"                  json:"access_key"`
	SecretKey   string `bson:"secret_key"                  json:"secret_key"`
	Region      string `bson:"region,omitempty"            json:"region,omitempty"`
	UpdateTime  int64  `bson:"update_time"                 json:"update_time"`
	UpdateBy    string `bson:"update_by"                   json:"update_by"`
}

type ReleaseConfig

type ReleaseConfig struct {
	// ReaperImage sets build job image
	// e.g. xxx.com/poetry-resources/reaper-plugin:1.0.0
	ReaperImage string
	// ReaperBinaryFile sets download url of reaper binary file in build job
	// e.g. http://resource.koderover.com/reaper-20201014203000
	ReaperBinaryFile string
	// PredatorImage sets docker build image
	// e.g. xxx.com/poetry-resources/predator-plugin:v0.1.0
	PredatorImage string
}

type ReleaseImage

type ReleaseImage struct {
	TaskType     config.TaskType `bson:"type"                           json:"type"`
	Enabled      bool            `bson:"enabled"                        json:"enabled"`
	TaskStatus   config.Status   `bson:"status"                         json:"status"`
	ImageTest    string          `bson:"image_test"                     json:"image_test"`
	ImageRelease string          `bson:"image_release"                  json:"image_release"`
	ImageRepo    string          `bson:"image_repo"                     json:"image_repo"`
	Timeout      int             `bson:"timeout,omitempty"              json:"timeout,omitempty"`
	Error        string          `bson:"error,omitempty"                json:"error,omitempty"`
	StartTime    int64           `bson:"start_time,omitempty"           json:"start_time,omitempty"`
	EndTime      int64           `bson:"end_time,omitempty"             json:"end_time,omitempty"`
	LogFile      string          `bson:"log_file"                       json:"log_file"`

	// destinations to distribute images
	Releases []RepoImage `bson:"releases"                 json:"releases"`
}

ReleaseImage 线上镜像分发任务

func (*ReleaseImage) SetImage

func (ri *ReleaseImage) SetImage(image string)

func (*ReleaseImage) ToSubTask

func (ri *ReleaseImage) ToSubTask() (map[string]interface{}, error)

type ReleaseImageItem

type ReleaseImageItem struct {
	RepoID string `bson:"id" json:"id"`
	Image  string `bson:"image" json:"image"`
}

type RenderInfo

type RenderInfo struct {
	Name        string `bson:"name"                     json:"name"`
	Revision    int64  `bson:"revision"                 json:"revision"`
	ProductTmpl string `bson:"product_tmpl"             json:"product_tmpl"`
	Description string `bson:"description"              json:"description"`
}

type Repo

type Repo struct {
	Source  string `bson:"source" json:"source"`
	Address string `bson:"address" json:"address"`
	Owner   string `bson:"owner" json:"owner"`
	Name    string `bson:"name" json:"name"`
}

type RepoCoverage

type RepoCoverage struct {
	Repo

	NoStmt       int `bson:"no_stmt" json:"no_stmt"`
	NoMissedStmt int `bson:"no_missed_stmt" json:"no_missed_stmt"`
}

type RepoImage

type RepoImage struct {
	RepoID    string `json:"repo_id" bson:"repo_id"`
	Name      string `json:"name" bson:"name" yaml:"name"`
	Username  string `json:"-" yaml:"username"`
	Password  string `json:"-" yaml:"password"`
	Host      string `json:"host" yaml:"host"`
	Namespace string `json:"namespace" yaml:"namespace"`
}

type RepoStaticCheck

type RepoStaticCheck struct {
	Repo
	SecurityMeasureCount int `bson:"security_measure_count" json:"security_measure_count"`
	IssueMeasureCount    int `bson:"issue_measure_count" json:"issue_measure_count"`
}

type Repository

type Repository struct {
	// Source is github, gitlab
	Source        string `bson:"source,omitempty"          json:"source,omitempty"`
	RepoOwner     string `bson:"repo_owner"                json:"repo_owner"`
	RepoName      string `bson:"repo_name"                 json:"repo_name"`
	RemoteName    string `bson:"remote_name,omitempty"     json:"remote_name,omitempty"`
	Branch        string `bson:"branch"                    json:"branch"`
	PR            int    `bson:"pr,omitempty"              json:"pr,omitempty"`
	Tag           string `bson:"tag,omitempty"             json:"tag,omitempty"`
	CommitID      string `bson:"commit_id,omitempty"       json:"commit_id,omitempty"`
	CommitMessage string `bson:"commit_message,omitempty"  json:"commit_message,omitempty"`
	CheckoutPath  string `bson:"checkout_path,omitempty"   json:"checkout_path,omitempty"`
	SubModules    bool   `bson:"submodules,omitempty"      json:"submodules,omitempty"`
	// UseDefault defines if the repo can be configured in start pipeline task page
	UseDefault bool `bson:"use_default,omitempty"          json:"use_default,omitempty"`
	// IsPrimary used to generated image and package name, each build has one primary repo
	IsPrimary  bool `bson:"is_primary"                     json:"is_primary"`
	CodehostID int  `bson:"codehost_id"                    json:"codehost_id"`
	// add
	OauthToken  string `bson:"oauth_token"                  json:"oauth_token"`
	Address     string `bson:"address"                      json:"address"`
	AuthorName  string `bson:"author_name,omitempty"        json:"author_name,omitempty"`
	CheckoutRef string `bson:"checkout_ref,omitempty"       json:"checkout_ref,omitempty"`
	Username    string `bson:"username,omitempty"           json:"username,omitempty"`
	Password    string `bson:"password,omitempty"           json:"password,omitempty"`
	ProjectUUID string `bson:"project_uuid,omitempty"       json:"project_uuid,omitempty"`
	RepoUUID    string `bson:"repo_uuid,omitempty"          json:"repo_uuid,omitempty"`
	RepoID      string `bson:"repo_id,omitempty"            json:"repo_id,omitempty"`
}

type Resource

type Resource struct {
	Name      string `json:"name" bson:"name"`
	Kind      string `json:"kind" bson:"kind"`
	Container string `json:"container" bson:"container"`
	Origin    string `json:"origin" bson:"origin"`
}

type S3Config

type S3Config struct {
	Ak       string
	Sk       string
	Endpoint string
	Bucket   string
	Path     string
	Protocol string
	Provider int8
}

type SSH

type SSH struct {
	ID         string `json:"id"`
	Name       string `json:"name"`
	UserName   string `json:"user_name"`
	IP         string `json:"ip"`
	IsProd     bool   `json:"is_prod"`
	Label      string `json:"label"`
	PrivateKey string `json:"private_key"`
}

type Security

type Security struct {
	TaskType   config.TaskType `bson:"type"                          json:"type"`
	Enabled    bool            `bson:"enabled"                       json:"enabled"`
	TaskStatus config.Status   `bson:"status"                        json:"status"`
	ImageName  string          `bson:"image_name"                    json:"image_name"`
	ImageID    string          `bson:"image_id"                      json:"image_id"`
	Timeout    int             `bson:"timeout,omitempty"             json:"timeout,omitempty"`
	Error      string          `bson:"error,omitempty"               json:"error,omitempty"`
	StartTime  int64           `bson:"start_time,omitempty"          json:"start_time,omitempty"`
	EndTime    int64           `bson:"end_time,omitempty"            json:"end_time,omitempty"`
	LogFile    string          `bson:"log_file"                      json:"log_file"`
	Summary    map[string]int  `bson:"summary"                       json:"summary"`
}

func (*Security) SetImageName

func (s *Security) SetImageName(imageName string)

func (*Security) ToSubTask

func (s *Security) ToSubTask() (map[string]interface{}, error)

type ServiceConfig

type ServiceConfig struct {
	ConfigName string `bson:"config_name"           json:"config_name"`
	Revision   int64  `bson:"revision"              json:"revision"`
}

type ServiceTaskArgs

type ServiceTaskArgs struct {
	ProductName        string   `bson:"product_name"            json:"product_name"`
	ServiceName        string   `bson:"service_name"            json:"service_name"`
	Revision           int64    `bson:"revision"                json:"revision"`
	BuildName          string   `bson:"build_name"              json:"build_name"`
	EnvNames           []string `bson:"env_names"               json:"env_names"`
	ServiceTaskCreator string   `bson:"service_task_creator"    json:"service_task_creator"`
	Namespace          string   `bson:"namespace"               json:"namespace"`
	K8sNamespace       string   `bson:"k8s_namespace"           json:"k8s_namespace"`
	Updatable          bool     `bson:"updatable"               json:"updatable"`
}

type Stage

type Stage struct {
	// 注意: 同一个stage暂时不能运行不同类型的Task
	TaskType    config.TaskType                   `bson:"type"               json:"type"`
	Status      config.Status                     `bson:"status"             json:"status"`
	RunParallel bool                              `bson:"run_parallel"       json:"run_parallel"`
	Desc        string                            `bson:"desc,omitempty"     json:"desc,omitempty"`
	SubTasks    map[string]map[string]interface{} `bson:"sub_tasks"          json:"sub_tasks"`
	AfterAll    bool                              `json:"after_all" bson:"after_all"`
}

type StaticCheckStatus

type StaticCheckStatus struct {
	StepStatus
	Repos []RepoStaticCheck `bson:"repos" json:"repos"`
}

type StepStatus

type StepStatus struct {
	StartTime int64         `bson:"start_time"                 json:"start_time"`
	EndTime   int64         `bson:"end_time"                   json:"end_time"`
	Status    config.Status `bson:"status"                     json:"status"`
}

type TargetArgs

type TargetArgs struct {
	Name             string            `bson:"name"                      json:"name"`
	ServiceName      string            `bson:"service_name"              json:"service_name"`
	Build            *BuildArgs        `bson:"build"                     json:"build"`
	Version          string            `bson:"version"                   json:"version"`
	Deploy           []DeployEnv       `bson:"deloy"                     json:"deploy"`
	Image            string            `bson:"image"                     json:"image"`
	BinFile          string            `bson:"bin_file"                  json:"bin_file"`
	Envs             []*KeyVal         `bson:"envs"                      json:"envs"`
	HasBuild         bool              `bson:"has_build"                 json:"has_build"`
	JenkinsBuildArgs *JenkinsBuildArgs `bson:"jenkins_build_args"        json:"jenkins_build_args"`
}

type Task

type Task struct {
	TaskID       int64                    `bson:"task_id"                   json:"task_id"`
	ProductName  string                   `bson:"product_name"              json:"product_name"`
	PipelineName string                   `bson:"pipeline_name"             json:"pipeline_name"`
	Namespace    string                   `bson:"namespace,omitempty"       json:"namespace,omitempty"`
	Type         config.PipelineType      `bson:"type"                      json:"type"`
	Status       config.Status            `bson:"status"                    json:"status,omitempty"`
	Description  string                   `bson:"description,omitempty"     json:"description,omitempty"`
	TaskCreator  string                   `bson:"task_creator"              json:"task_creator,omitempty"`
	TaskRevoker  string                   `bson:"task_revoker,omitempty"    json:"task_revoker,omitempty"`
	CreateTime   int64                    `bson:"create_time"               json:"create_time,omitempty"`
	StartTime    int64                    `bson:"start_time"                json:"start_time,omitempty"`
	EndTime      int64                    `bson:"end_time"                  json:"end_time,omitempty"`
	SubTasks     []map[string]interface{} `bson:"sub_tasks"                 json:"sub_tasks"`
	Stages       []*Stage                 `bson:"stages"                    json:"stages"`
	ReqID        string                   `bson:"req_id,omitempty"          json:"req_id,omitempty"`
	AgentHost    string                   `bson:"agent_host,omitempty"      json:"agent_host,omitempty"`
	DockerHost   string                   `bson:"-"                         json:"docker_host,omitempty"`
	TeamID       int                      `bson:"team_id,omitempty"         json:"team_id,omitempty"`
	TeamName     string                   `bson:"team,omitempty"            json:"team,omitempty"`
	IsDeleted    bool                     `bson:"is_deleted"                json:"is_deleted"`
	IsArchived   bool                     `bson:"is_archived"               json:"is_archived"`
	AgentID      string                   `bson:"agent_id"        json:"agent_id"`
	// 是否允许同时运行多次
	MultiRun bool `bson:"multi_run"                 json:"multi_run"`
	// target 服务名称, k8s为容器名称, 物理机为服务名
	Target string `bson:"target,omitempty"                    json:"target"`
	// 使用预定义编译管理模块中的内容生成SubTasks,
	// 查询条件为 服务模板名称: ServiceTmpl, 版本: BuildModuleVer
	// 如果为空,则使用pipeline自定义SubTasks
	BuildModuleVer string `bson:"build_module_ver,omitempty"                 json:"build_module_ver"`
	ServiceName    string `bson:"service_name,omitempty"              json:"service_name,omitempty"`
	// TaskArgs 单服务工作流任务参数
	TaskArgs *TaskArgs `bson:"task_args,omitempty"         json:"task_args,omitempty"`
	// WorkflowArgs 多服务工作流任务参数
	WorkflowArgs *WorkflowTaskArgs `bson:"workflow_args"         json:"workflow_args,omitempty"`
	// TestArgs 测试任务参数
	TestArgs *TestTaskArgs `bson:"test_args,omitempty"         json:"test_args,omitempty"`
	// ServiceTaskArgs 脚本部署工作流任务参数
	ServiceTaskArgs *ServiceTaskArgs `bson:"service_args,omitempty"         json:"service_args,omitempty"`
	// ConfigPayload 系统配置信息
	ConfigPayload *ConfigPayload `json:"config_payload,omitempty"`
	Error         string         `bson:"error,omitempty"                json:"error,omitempty"`
	// OrgID 单租户ID
	OrgID      int                 `bson:"org_id,omitempty"          json:"org_id,omitempty"`
	Services   [][]*ProductService `bson:"services"                  json:"services"`
	Render     *RenderInfo         `bson:"render"                    json:"render"`
	StorageURI string              `bson:"storage_uri,omitempty" json:"storage_uri,omitempty"`
	// interface{} 为types.TestReport
	TestReports map[string]interface{} `bson:"test_reports,omitempty" json:"test_reports,omitempty"`

	RwLock sync.Mutex `bson:"-" json:"-"`

	ResetImage bool `json:"resetImage" bson:"resetImage"`

	TriggerBy *TriggerBy `json:"trigger_by,omitempty" bson:"trigger_by,omitempty"`

	Features        []string `bson:"features" json:"features"`
	IsRestart       bool     `bson:"is_restart"                      json:"is_restart"`
	StorageEndpoint string   `bson:"storage_endpoint"            json:"storage_endpoint"`
}

func (Task) TableName

func (Task) TableName() string

type TaskArgs

type TaskArgs struct {
	ProductName    string        `bson:"product_name"            json:"product_name"`
	PipelineName   string        `bson:"pipeline_name"           json:"pipeline_name"`
	Builds         []*Repository `bson:"builds"                  json:"builds"`
	BuildArgs      []*KeyVal     `bson:"build_args"              json:"build_args"`
	Deploy         DeployArgs    `bson:"deploy"                  json:"deploy"`
	Test           TestArgs      `bson:"test"                    json:"test,omitempty"`
	HookPayload    *HookPayload  `bson:"hook_payload"            json:"hook_payload,omitempty"`
	TaskCreator    string        `bson:"task_creator"            json:"task_creator,omitempty"`
	ReqID          string        `bson:"req_id"                  json:"req_id"`
	IsQiNiu        bool          `bson:"is_qiniu"                json:"is_qiniu"`
	NotificationID string        `bson:"notification_id"         json:"notification_id"`
}

type TestArgs

type TestArgs struct {
	Namespace      string        `bson:"namespace" json:"namespace"`
	TestModuleName string        `bson:"test_module_name" json:"test_module_name"`
	Envs           []*KeyVal     `bson:"envs" json:"envs"`
	Builds         []*Repository `bson:"builds" json:"builds"`
}

type TestConfig

type TestConfig struct {
	KubeNamespace string
}

type TestTaskArgs

type TestTaskArgs struct {
	ProductName     string `bson:"product_name"            json:"product_name"`
	TestName        string `bson:"test_name"               json:"test_name"`
	TestTaskCreator string `bson:"test_task_creator"       json:"test_task_creator"`
	NotificationID  string `bson:"notification_id"         json:"notification_id"`
	ReqID           string `bson:"req_id"                  json:"req_id"`
	// webhook触发测试任务时,触发任务的repo、prID和commitID
	MergeRequestID string `bson:"merge_request_id" json:"merge_request_id"`
	CommitID       string `bson:"commit_id"        json:"commit_id"`
	Source         string `bson:"source"           json:"source"`
	CodehostID     int    `bson:"codehost_id"      json:"codehost_id"`
	RepoOwner      string `bson:"repo_owner"       json:"repo_owner"`
	RepoName       string `bson:"repo_name"        json:"repo_name"`
}

type Testing

type Testing struct {
	TaskType     config.TaskType `bson:"type"                            json:"type"`
	Enabled      bool            `bson:"enabled"                         json:"enabled"`
	TaskStatus   config.Status   `bson:"status"                          json:"status"`
	TestName     string          `bson:"test_name"                       json:"test_name"`
	Timeout      int             `bson:"timeout,omitempty"               json:"timeout,omitempty"`
	Error        string          `bson:"error,omitempty"                 json:"error,omitempty"`
	StartTime    int64           `bson:"start_time,omitempty"            json:"start_time,omitempty"`
	EndTime      int64           `bson:"end_time,omitempty"              json:"end_time,omitempty"`
	JobCtx       JobCtx          `bson:"job_ctx"                         json:"job_ctx"`
	InstallItems []*Item         `bson:"install_items"                   json:"install_items"`
	InstallCtx   []*Install      `bson:"-"                               json:"install_ctx"`
	BuildOS      string          `bson:"build_os"                        json:"build_os,omitempty"`
	ImageFrom    string          `bson:"image_from"                      json:"image_from,omitempty"`
	ImageID      string          `bson:"image_id"                        json:"image_id"`
	// ResReq defines job requested resources
	ResReq         setting.Request      `bson:"res_req"                         json:"res_req"`
	LogFile        string               `bson:"log_file"                        json:"log_file"`
	TestModuleName string               `bson:"test_module_name"                json:"test_module_name"`
	ReportReady    bool                 `bson:"report_ready"                    json:"report_ready"`
	IsRestart      bool                 `bson:"is_restart"                      json:"is_restart"`
	Registries     []*RegistryNamespace `bson:"-"                               json:"registries"`
}

func (*Testing) ToSubTask

func (t *Testing) ToSubTask() (map[string]interface{}, error)

type TriggerBy

type TriggerBy struct {
	// 触发此次任务的代码库信息
	CodehostID int    `bson:"codehost_id,omitempty"      json:"codehost_id,omitempty"`
	RepoOwner  string `bson:"repo_owner,omitempty"       json:"repo_owner,omitempty"`
	RepoName   string `bson:"repo_name,omitempty"        json:"repo_name,omitempty"`
	Source     string `json:"source,omitempty" bson:"source,omitempty"`
	// 触发此次任务的merge request id,用于判断多个任务对应的commit是否属于同一个merge request
	MergeRequestID string `json:"merge_request_id,omitempty" bson:"merge_request_id,omitempty"`
	// 触发此次任务的commit id
	CommitID string `json:"commit_id,omitempty" bson:"commit_id,omitempty"`
}

type UTStatus

type UTStatus struct {
	StepStatus

	Repos []RepoCoverage `bson:"repos" json:"repos"`
}

type VersionArgs

type VersionArgs struct {
	Enabled bool     `bson:"enabled" json:"enabled"`
	Version string   `bson:"version" json:"version"`
	Desc    string   `bson:"desc"    json:"desc"`
	Labels  []string `bson:"labels"  json:"labels"`
}

type WorkflowTaskArgs

type WorkflowTaskArgs struct {
	WorkflowName    string `bson:"workflow_name"                json:"workflow_name"`
	ProductTmplName string `bson:"product_tmpl_name"            json:"product_tmpl_name"`
	Description     string `bson:"description,omitempty"        json:"description,omitempty"`
	//为了兼容老数据,namespace可能会存多个环境名称,用逗号隔开
	Namespace          string          `bson:"namespace"                    json:"namespace"`
	BaseNamespace      string          `bson:"base_namespace,omitempty"     json:"base_namespace,omitempty"`
	EnvRecyclePolicy   string          `bson:"env_recycle_policy,omitempty" json:"env_recycle_policy,omitempty"`
	EnvUpdatePolicy    string          `bson:"env_update_policy,omitempty"  json:"env_update_policy,omitempty"`
	Target             []*TargetArgs   `bson:"targets"                      json:"targets"`
	Artifact           []*ArtifactArgs `bson:"artifact_args"                json:"artifact_args"`
	Tests              []*TestArgs     `bson:"tests"                        json:"tests"`
	VersionArgs        *VersionArgs    `bson:"version_args,omitempty"       json:"version_args,omitempty"`
	ReqID              string          `bson:"req_id"                       json:"req_id"`
	RegistryID         string          `bson:"registry_id,omitempty"        json:"registry_id,omitempty"`
	DistributeEnabled  bool            `bson:"distribute_enabled"           json:"distribute_enabled"`
	WorklowTaskCreator string          `bson:"workflow_task_creator"        json:"workflow_task_creator"`
	// Ignore docker build cache
	IgnoreCache bool `json:"ignore_cache" bson:"ignore_cache"`
	// Ignore workspace cache and reset volume
	ResetCache bool `json:"reset_cache" bson:"reset_cache"`

	// NotificationId is the id of scmnotify.Notification
	NotificationID string `bson:"notification_id" json:"notification_id"`

	// webhook触发工作流任务时,触发任务的repo信息、prID和commitID
	MergeRequestID string `bson:"merge_request_id" json:"merge_request_id"`
	CommitID       string `bson:"commit_id"        json:"commit_id"`
	Source         string `bson:"source"           json:"source"`
	CodehostID     int    `bson:"codehost_id"      json:"codehost_id"`
	RepoOwner      string `bson:"repo_owner"       json:"repo_owner"`
	RepoName       string `bson:"repo_name"        json:"repo_name"`

	//github check run
	HookPayload *HookPayload `bson:"hook_payload"            json:"hook_payload,omitempty"`
	// 请求模式,openAPI表示外部客户调用
	RequestMode string `json:"request_mode,omitempty"`
	IsParallel  bool   `json:"is_parallel" bson:"is_parallel"`
}

Jump to

Keyboard shortcuts

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