pipelineymlv1

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

All struct fields are required, unless "Optional" explicitly declared.

Index

Constants

View Source
const (
	RES_TYPE_GIT            builtinResType = "git"
	RES_TYPE_BUILDPACK      builtinResType = "buildpack"
	RES_TYPE_BP_COMPILE     builtinResType = "bp-compile"
	RES_TYPE_BP_IMAGE       builtinResType = "bp-image"
	RES_TYPE_DICE           builtinResType = "dice"
	RES_TYPE_ABILITY        builtinResType = "ability"
	RES_TYPE_ADDON_REGISTRY builtinResType = "addon-registry"
	RES_TYPE_DICEHUB        builtinResType = "dicehub"
	RES_TYPE_IT             builtinResType = "it"
	RES_TYPE_SONAR          builtinResType = "sonar"
	RES_TYPE_FLINK          builtinResType = "flink"
	RES_TYPE_SPARK          builtinResType = "spark"
	RES_TYPE_UT             builtinResType = "ut"
)

builtinResType declaration 如有更新,请进入 gogenerate 目录重新运行 go generate 并提交

View Source
const (
	GIT_BRANCH = "git-branch"
	GLOBAL_ENV = "global-env"
)
View Source
const (
	BuiltinResourceTypeDefaultDockerImagePrefix = "registry.cn-hangzhou.aliyuncs.com/terminus"
	BuiltinResourceTypeDefaultDockerImageTag    = "latest"
)
View Source
const DockerImageResType = "docker-image"

Variables

Functions

func ApplyKVsWithPriority

func ApplyKVsWithPriority(kvs ...map[string]string) map[string]string

ApplyKVsWithPriority generates a result map with the rule that the latter will overwrite the former. For example:

  priority: e1 > e2 > e3
	 you should pass param `envs` as: e3, e2, e1

func GenerateFlowUUID

func GenerateFlowUUID(yUUID string) string

func GenerateStageUUID

func GenerateStageUUID(stageName string, index int, yUUID string) string

func GenerateTaskUUID

func GenerateTaskUUID(stageIndex int, stageName string, taskIndex int, taskName string, yUUID string) string

GenerateTaskUUID have some constrains 如果存在多个 job 执行器,需要同时满足约束

func InsertStage

func InsertStage(s *[]*Stage, index int, data *Stage) error

func Map2MetadataFields

func Map2MetadataFields(m map[string]string) []metadata.MetadataField

func MetadataFields2Map

func MetadataFields2Map(metas []metadata.MetadataField) map[string]string

func RenderPlaceholders

func RenderPlaceholders(input string, placeholders []metadata.MetadataField) (string, error)

func ResourceDir

func ResourceDir(suffix string) string

Types

type Config

type Config struct {
	ImageResource ImageResource      `json:"image_resource,omitempty" mapstructure:"image_resource"`
	Inputs        []TaskInputConfig  `json:"inputs,omitempty"`
	Outputs       []TaskOutputConfig `json:"outputs,omitempty"`
	Envs          map[string]string  `json:"envs,omitempty"`
	Run           Run                `json:"run"`
}

type CustomTask

type CustomTask struct {
	Task    string      `json:"task"`
	Config  Config      `json:"config"`
	Filters Filters     `json:"filters,omitempty"`
	Disable *bool       `json:"disable,omitempty"`
	Timeout interface{} `json:"timeout,omitempty"`
	Pause   *bool       `json:"pause,omitempty"`

	GlobalEnvs map[string]string `json:"-"`
	Branch     string            `json:"-"`
	TaskConfig TaskConfig        `json:"-"`
	Status     string            `json:"-"`
}

func (*CustomTask) GetCustomTaskRunPathArgs

func (t *CustomTask) GetCustomTaskRunPathArgs() []string

func (*CustomTask) GetEnvs

func (t *CustomTask) GetEnvs() map[string]string

func (*CustomTask) GetResource

func (t *CustomTask) GetResource() *Resource

func (*CustomTask) GetResourceType

func (t *CustomTask) GetResourceType() string

func (*CustomTask) GetStatus

func (t *CustomTask) GetStatus() string

func (*CustomTask) GetTaskConfig

func (t *CustomTask) GetTaskConfig() TaskConfig

func (*CustomTask) GetTaskParams

func (t *CustomTask) GetTaskParams() Params

func (*CustomTask) GetTimeout

func (t *CustomTask) GetTimeout() (time.Duration, error)

func (*CustomTask) GetVersion

func (t *CustomTask) GetVersion() Version

func (*CustomTask) IsDisable

func (t *CustomTask) IsDisable() bool

func (*CustomTask) IsPause

func (t *CustomTask) IsPause() bool

func (*CustomTask) IsResourceTask

func (t *CustomTask) IsResourceTask() bool

func (*CustomTask) Name

func (t *CustomTask) Name() string

func (*CustomTask) OutputToContext

func (t *CustomTask) OutputToContext() []string

func (*CustomTask) RequiredContext

func (t *CustomTask) RequiredContext(y PipelineYml) []string

func (*CustomTask) Resources

func (t *CustomTask) Resources() []string

func (*CustomTask) SetStatus

func (t *CustomTask) SetStatus(status string)

func (*CustomTask) Type

func (*CustomTask) Validate

func (t *CustomTask) Validate() error

type Filter

type Filter struct {
	Type    string   `json:"type"`
	Key     string   `json:"key"` // used for "global-env" filter type
	Onlys   []string `json:"onlys,omitempty" mapstructure:"onlys"`
	Excepts []string `json:"excepts,omitempty" mapstructure:"excepts"`
}

type Filters

type Filters []Filter

type GetRequest

type GetRequest struct {
	Source  Source  `json:"source"`
	Params  Params  `json:"params"`
	Version Version `json:"version"`
}

type GetTask

type GetTask struct {
	Get string `json:"get"`
	// contains filtered or unexported fields
}

func (*GetTask) GetCustomTaskRunPathArgs

func (get *GetTask) GetCustomTaskRunPathArgs() []string

func (*GetTask) GetEnvs

func (get *GetTask) GetEnvs() map[string]string

func (*GetTask) GetParams

func (get *GetTask) GetParams() Params

func (*GetTask) GetResource

func (get *GetTask) GetResource() *Resource

func (*GetTask) GetResourceType

func (get *GetTask) GetResourceType() string

func (*GetTask) GetStatus

func (get *GetTask) GetStatus() string

func (*GetTask) GetTaskConfig

func (get *GetTask) GetTaskConfig() TaskConfig

func (*GetTask) GetTaskParams

func (get *GetTask) GetTaskParams() Params

func (*GetTask) GetTimeout

func (get *GetTask) GetTimeout() (time.Duration, error)

func (*GetTask) GetVersion

func (get *GetTask) GetVersion() Version

func (*GetTask) IsDisable

func (get *GetTask) IsDisable() bool

func (*GetTask) IsPause

func (get *GetTask) IsPause() bool

func (*GetTask) IsResourceTask

func (get *GetTask) IsResourceTask() bool

func (*GetTask) Name

func (get *GetTask) Name() string

func (*GetTask) OutputToContext

func (get *GetTask) OutputToContext() []string

func (*GetTask) RequiredContext

func (get *GetTask) RequiredContext(y PipelineYml) []string

TODO more intelligent check

func (*GetTask) SetStatus

func (get *GetTask) SetStatus(status string)

func (*GetTask) Type

func (get *GetTask) Type() steptasktype.StepTaskType

func (*GetTask) Validate

func (get *GetTask) Validate() error

type ImageResource

type ImageResource struct {
	Type   string `json:"type"`
	Source Source `json:"source"`
}

type OpOption

type OpOption func(*Option)

func WithAgentContainerPath

func WithAgentContainerPath(agentContainerPath string) OpOption

func WithAgentHostPath

func WithAgentHostPath(agentHostPath string) OpOption

func WithAlreadyTransformed

func WithAlreadyTransformed(already bool) OpOption

func WithBranch

func WithBranch(branch string) OpOption

func WithBuiltinResourceTypeDockerImagePrefixAndTag

func WithBuiltinResourceTypeDockerImagePrefixAndTag(prefix, tag string) OpOption

func WithClusterName

func WithClusterName(clusterName string) OpOption

func WithContainerResLimit

func WithContainerResLimit(cpu, mem float64) OpOption

func WithNFSRealPath

func WithNFSRealPath(realPath string) OpOption

func WithPlaceholders

func WithPlaceholders(placeholders []metadata.MetadataField) OpOption

func WithRenderPlaceholder

func WithRenderPlaceholder(render bool) OpOption

type Option

type Option struct {
	// contains filtered or unexported fields
}

type Params

type Params map[string]interface{}

type Pipeline

type Pipeline struct {
	Version string   `json:"version"`
	Stages  []*Stage `json:"stages,omitempty"`

	Envs map[string]string `json:"envs,omitempty"`

	Resources     []Resource     `json:"resources,omitempty"`
	ResourceTypes []ResourceType `json:"resource_types,omitempty"`

	Triggers []Trigger `json:"triggers,omitempty"`
}

type PipelineMetadata

type PipelineMetadata struct {
	ContextDir string // context dir related with instanceID, under nfs mount point or oss path dir

	PlaceHolderEnvs map[string]string
	// contains filtered or unexported fields
}

PipelineMetadata contains extra info needs by parse process.

type PipelineYml

type PipelineYml struct {
	// contains filtered or unexported fields
}

func New

func New(b []byte) *PipelineYml

func (*PipelineYml) FindDockerImageByResourceName

func (y *PipelineYml) FindDockerImageByResourceName(name string) (repository, tag string, err error)

func (*PipelineYml) FindResourceByName

func (y *PipelineYml) FindResourceByName(name string) (Resource, bool)

func (*PipelineYml) GetBpArgs

func (y *PipelineYml) GetBpArgs(sourceId int) map[string]string

func (*PipelineYml) GetBpRepoArgs

func (y *PipelineYml) GetBpRepoArgs(sourceId int) map[string]string

func (*PipelineYml) GetGlobalEnvs

func (y *PipelineYml) GetGlobalEnvs() map[string]string

func (*PipelineYml) GetInstanceID

func (y *PipelineYml) GetInstanceID() string

func (*PipelineYml) GetMetadata

func (y *PipelineYml) GetMetadata() PipelineMetadata

func (*PipelineYml) GetOptions

func (y *PipelineYml) GetOptions() *Option

func (*PipelineYml) GetPlaceHolderTransformedEnvs

func (y *PipelineYml) GetPlaceHolderTransformedEnvs() map[string]string

func (*PipelineYml) GetPlaceholders

func (y *PipelineYml) GetPlaceholders() []metadata.MetadataField

func (*PipelineYml) GetResourceID

func (y *PipelineYml) GetResourceID(taskName string) int

func (*PipelineYml) GetTaskDisableStatus

func (y *PipelineYml) GetTaskDisableStatus(taskUUID string) (bool, error)

func (*PipelineYml) GetTaskEnvs

func (y *PipelineYml) GetTaskEnvs(taskUUID string) (map[string]string, error)

func (*PipelineYml) GetTaskForceBuildpackStatus

func (y *PipelineYml) GetTaskForceBuildpackStatus(taskUUID string) bool

func (*PipelineYml) GetTaskPauseStatus

func (y *PipelineYml) GetTaskPauseStatus(taskUUID string) (bool, error)

func (*PipelineYml) GetTriggerScheduleCron

func (y *PipelineYml) GetTriggerScheduleCron() (string, bool)

可以有多个 schedule cron 声明,但只能有一个生效

func (*PipelineYml) InsertDiceHub

func (y *PipelineYml) InsertDiceHub() error

func (*PipelineYml) JSON

func (y *PipelineYml) JSON() (string, error)

func (*PipelineYml) JSONPretty

func (y *PipelineYml) JSONPretty() (string, error)

func (*PipelineYml) Object

func (y *PipelineYml) Object() *Pipeline

func (*PipelineYml) Parse

func (y *PipelineYml) Parse(ops ...OpOption) error

Parse parse yaml file, and validate fields content.

func (*PipelineYml) ParseWithAllFields

func (y *PipelineYml) ParseWithAllFields(ops ...OpOption) error

func (*PipelineYml) ReRender

func (y *PipelineYml) ReRender() error

ReRender 用于更改了结构体数据后重新渲染,保证其他字段同步

func (*PipelineYml) SetPipelineID

func (y *PipelineYml) SetPipelineID(pipelineID uint64)

func (*PipelineYml) StringData

func (y *PipelineYml) StringData() string

func (*PipelineYml) UpdatePipelineOnBpArgs

func (y *PipelineYml) UpdatePipelineOnBpArgs(resource string, bp_args, bp_repo_args map[string]string) error

Update bp_args, docker_args.

func (*PipelineYml) UpdatePipelineOnGlobal

func (y *PipelineYml) UpdatePipelineOnGlobal(kvs map[string]string) error

UpdatePipelineOnGlobal update pipeline object and byteData together.

func (*PipelineYml) UpdatePipelineOnTask

func (y *PipelineYml) UpdatePipelineOnTask(expectUUID string, params TaskUpdateParams) error

UpdatePipelineOnTask update pipeline object and byteData together.

func (*PipelineYml) UpdatePipelineWorkspaceOnBpArgs

func (y *PipelineYml) UpdatePipelineWorkspaceOnBpArgs(env string) error

Update workspace into bp_args

func (*PipelineYml) ValidateResTypes

func (y *PipelineYml) ValidateResTypes() error

func (*PipelineYml) Version

func (y *PipelineYml) Version() string

func (*PipelineYml) YAML

func (y *PipelineYml) YAML() (string, error)

type PutTask

type PutTask struct {
	Put       string `json:"put"`
	GetParams Params `json:"get_params,omitempty" mapstructure:"get_params"`
	// contains filtered or unexported fields
}

func (*PutTask) GetCustomTaskRunPathArgs

func (put *PutTask) GetCustomTaskRunPathArgs() []string

func (*PutTask) GetEnvs

func (put *PutTask) GetEnvs() map[string]string

func (*PutTask) GetResource

func (put *PutTask) GetResource() *Resource

func (*PutTask) GetResourceType

func (put *PutTask) GetResourceType() string

func (*PutTask) GetStatus

func (put *PutTask) GetStatus() string

func (*PutTask) GetTaskConfig

func (put *PutTask) GetTaskConfig() TaskConfig

func (*PutTask) GetTaskParams

func (put *PutTask) GetTaskParams() Params

func (*PutTask) GetTimeout

func (put *PutTask) GetTimeout() (time.Duration, error)

func (*PutTask) GetVersion

func (put *PutTask) GetVersion() Version

func (*PutTask) IsDisable

func (put *PutTask) IsDisable() bool

func (*PutTask) IsPause

func (put *PutTask) IsPause() bool

func (*PutTask) IsResourceTask

func (put *PutTask) IsResourceTask() bool

func (*PutTask) Name

func (put *PutTask) Name() string

func (*PutTask) OutputToContext

func (put *PutTask) OutputToContext() []string

func (*PutTask) RequiredContext

func (put *PutTask) RequiredContext(y PipelineYml) []string

TODO more intelligent check

func (*PutTask) SetStatus

func (put *PutTask) SetStatus(status string)

func (*PutTask) Type

func (put *PutTask) Type() steptasktype.StepTaskType

func (*PutTask) Validate

func (put *PutTask) Validate() error

type Resource

type Resource struct {
	Name string `json:"name"`
	Type string `json:"type"`
	// Optional
	Source Source `json:"source"`
}

type ResourceType

type ResourceType struct {
	Name   string `json:"name"`
	Type   string `json:"type"`
	Source Source `json:"source"`
}

type Run

type Run struct {
	Path string   `json:"path"`
	Args []string `json:"args"`
}

type Schedule

type Schedule struct {
	Cron    string  `json:"cron"`
	Filters Filters `json:"filters,omitempty"`
}

type Source

type Source map[string]interface{}

type Stage

type Stage struct {
	Name        string       `json:"name,omitempty"`
	TaskConfigs []TaskConfig `json:"tasks,omitempty"`
	Tasks       []StepTask   `json:"-"`
}

type StepTask

type StepTask interface {
	Type() steptasktype.StepTaskType
	Name() string
	GetEnvs() map[string]string
	Validate() error
	OutputToContext() []string
	// includes required resources and explicit context
	RequiredContext(y PipelineYml) []string

	IsResourceTask() bool
	// if IsResourceTask, GetResourceType will return resource type name.
	GetResourceType() string

	IsDisable() bool
	IsPause() bool

	GetStatus() string
	SetStatus(status string)

	GetTaskParams() Params
	GetTaskConfig() TaskConfig
	GetCustomTaskRunPathArgs() []string
	GetResource() *Resource
	GetVersion() Version

	GetTimeout() (time.Duration, error)
}

type TaskConfig

type TaskConfig map[string]interface{}

type TaskInputConfig

type TaskInputConfig struct {
	Name string `json:"name" yaml:"name"`
}

type TaskOutputConfig

type TaskOutputConfig struct {
	Name string `json:"name" yaml:"name"`
	Path string `json:"path" yaml:"path"`
}

type TaskUpdateParams

type TaskUpdateParams struct {
	Envs           *map[string]string // 环境变量
	Disable        *bool              // 是否禁用
	ForceBuildpack *bool              // 是否强制打包
	Pause          *bool              // 是否暂停

}

type Trigger

type Trigger struct {
	Schedule Schedule `json:"schedule"`
}

type Version

type Version map[string]string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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