Documentation
¶
Index ¶
- Constants
- Variables
- func CheckEnvs(envs map[string]string) []error
- func ConvertGraphPipelineYmlContent(data []byte) ([]byte, error)
- func ConvertToGraphPipelineYml(data []byte) (*apistructs.PipelineYml, error)
- func DoRenderTemplateHandler(params map[string]interface{}, templateAction *apistructs.PipelineTemplateSpec, ...) (string, []apistructs.SnippetFormatOutputs, error)
- func DoRenderTemplateNotReplaceParamsValue(params map[string]interface{}, templateAction *apistructs.PipelineTemplateSpec, ...) (string, []apistructs.SnippetFormatOutputs, error)
- func DoRenderTemplateWithFormat(params map[string]interface{}, templateAction *apistructs.PipelineTemplateSpec, ...) (string, []apistructs.SnippetFormatOutputs, error)
- func GenerateYml(s *Spec) ([]byte, error)
- func GetParamDefaultValue(paramType string) interface{}
- func GetVersion(data []byte) (string, error)
- func IsCron(s *Spec) bool
- func ListAction(s *Spec) map[ActionAlias]*Action
- func ListNextCronTime(cronExpr string, ops ...CronVisitorOption) ([]time.Time, error)
- func RenderSecrets(input []byte, secrets map[string]string) ([]byte, error)
- func ReplacePipelineParams(pipeline string, params map[string]interface{}) string
- func UpgradeYmlFromV1(v1 []byte) ([]byte, error)
- type Action
- type ActionAlias
- type ActionCache
- type ActionType
- type CronCompensator
- type CronVisitor
- type CronVisitorOption
- type EnvInsertVisitor
- type EnvVisitor
- type HandleResult
- type MergeTrigger
- type NetworkHookInfo
- type Option
- func WithActionTypeMapping(mapping map[string]string) Option
- func WithAliasesToCheckRefOp(globalSnippetConfigLabels map[string]string, aliases ...ActionAlias) Option
- func WithAllowMissingCustomScriptOutputs(allow bool) Option
- func WithEnvs(envs map[string]string) Option
- func WithFlatParams(flatParams bool) Option
- func WithRefOpOutputs(outputs Outputs) Option
- func WithRefs(refs Refs) Option
- func WithRunParams(runParams []apistructs.PipelineRunParamWithValue) Option
- func WithSecrets(secrets map[string]string) Option
- func WithSecretsRecursiveRenderTimes(times int) Option
- type Outputs
- type ParamsVisitor
- type PipelineOutput
- type PipelineParam
- type PipelineYml
- type PushTrigger
- type RefOp
- type RefOpVisitor
- type Refs
- type Resources
- type SecretNotFoundSecret
- type SecretVisitor
- type SnippetConfig
- type SnippetPipelineYmlCache
- type Spec
- type Stage
- type StageVisitor
- type StorageConfig
- type TimeoutVisitor
- type TriggerConfig
- type VersionVisitor
- type Visitable
- type Visitor
Constants ¶
const ( Version1dot1 = "1.1" Version1dot0 = "1.0" Version1 = "1" )
const ( RefOpOutput = "OUTPUT" RefOpExEscape = "escape" )
const ( Snippet = "snippet" SnippetLogo = "http://terminus-paas.oss-cn-hangzhou.aliyuncs.com/paas-doc/2020/10/22/410935c6-e399-463a-b87b-0b774240d12e.png" SnippetDisplayName = "嵌套流水线" SnippetDesc = "嵌套流水线可以声明嵌套的其他 pipeline.yml" SnippetActionNameLinkAddr = "_" )
const (
TimeoutDuration4Forever = -1
)
Variables ¶
var DefaultCronCompensator = CronCompensator{ Enable: false, LatestFirst: true, StopIfLatterExecuted: true, }
Functions ¶
func ConvertGraphPipelineYmlContent ¶
ConvertGraphPipelineYmlContent: YAML(apistructs.PipelineYml) -> YAML(Spec)
func ConvertToGraphPipelineYml ¶
func ConvertToGraphPipelineYml(data []byte) (*apistructs.PipelineYml, error)
ConvertToGraphPipelineYml: YAML(Spec) -> apistructs.PipelineYml
func DoRenderTemplateHandler ¶
func DoRenderTemplateHandler(params map[string]interface{}, templateAction *apistructs.PipelineTemplateSpec, alias string, templateVersion apistructs.TemplateVersion, handler func(snippet string, params map[string]interface{}) (string, error)) (string, []apistructs.SnippetFormatOutputs, error)
func DoRenderTemplateNotReplaceParamsValue ¶
func DoRenderTemplateNotReplaceParamsValue(params map[string]interface{}, templateAction *apistructs.PipelineTemplateSpec, alias string, templateVersion apistructs.TemplateVersion) (string, []apistructs.SnippetFormatOutputs, error)
func DoRenderTemplateWithFormat ¶
func DoRenderTemplateWithFormat(params map[string]interface{}, templateAction *apistructs.PipelineTemplateSpec, alias string, templateVersion apistructs.TemplateVersion) (string, []apistructs.SnippetFormatOutputs, error)
func GenerateYml ¶
GenerateYml 根据 spec 重新生成 yaml 文本,一般用于对 spec 进行调整后重新生成 yaml 文本
func GetParamDefaultValue ¶
func GetParamDefaultValue(paramType string) interface{}
GetParamDefaultValue get default param value by type
func GetVersion ¶
func ListAction ¶
func ListAction(s *Spec) map[ActionAlias]*Action
func ListNextCronTime ¶
func ListNextCronTime(cronExpr string, ops ...CronVisitorOption) ([]time.Time, error)
func RenderSecrets ¶
RenderSecrets 将 ((xxx)) 替换为 secrets 中的值
input: ((a))((b))((c)) secrets: a=1,b=2 result: 12((c)) err: secret not found: ((c))
func ReplacePipelineParams ¶
func UpgradeYmlFromV1 ¶
UpgradeYmlFromV1 根据传入的 v1 yaml content 给出 v1.1 yaml content
Types ¶
type Action ¶
type Action struct {
Alias ActionAlias `yaml:"alias,omitempty"`
Description string `yaml:"description,omitempty"`
Version string `yaml:"version,omitempty"`
Params map[string]interface{} `yaml:"params,omitempty"`
Labels map[string]string `yaml:"labels,omitempty"`
Workspace string `yaml:"workspace,omitempty"`
Image string `yaml:"image,omitempty"`
Commands []string `yaml:"commands,omitempty"`
Loop *apistructs.PipelineTaskLoop `yaml:"loop,omitempty"`
Timeout int64 `yaml:"timeout,omitempty"` // unit: second
Resources Resources `yaml:"resources,omitempty"`
Type ActionType `yaml:"-"`
Caches []ActionCache `yaml:"caches,omitempty"` // action 构建缓存
SnippetConfig *SnippetConfig `yaml:"snippet_config,omitempty"` // snippet 类型的 action 的配置
If string `yaml:"if,omitempty"` // 条件执行
// TODO 在未来版本中,可能去除 stage,依赖关系则必须通过 Needs 来声明。
// 目前不开放给用户使用。由 parser 自动赋值。
// Needs 显式声明依赖的 actions。隐式依赖关系是下一个 stage 依赖之前所有 stage 里的 action。
// Needs 可以绕开 stage 限制,以 DAG 方式声明依赖关系。
// Needs 一旦声明,只包含声明的值,不会注入其他依赖。
Needs []ActionAlias `yaml:"-"`
// TODO 该字段目前是兼容字段。
// 在 1.1 版本中,Needs = NeedNamespaces
// 在 1.0 版本中,Needs <= NeedNamespaces
// 目前不开放给用户使用。由 parser 自动赋值。
// NeedNamespaces 显式声明依赖的 namespaces。隐式依赖关系是下一个 stage 依赖之前所有 stage 的 namespaces。
// NeedNamespaces 一旦声明,只包含声明的值,不会注入其他依赖。
NeedNamespaces []string `yaml:"-"`
// TODO 该字段目前是兼容字段,在未来版本中可以通过该字段扩展上下文。
// 目前不开放给用户使用。由 parser 自动赋值。
// Namespaces 显式声明 action 的命名空间,每个命名空间在流水线上下文目录下是唯一的,可以是目录或者文件。
// 隐式命名空间为一个 alias,对应流水线上下文目录下的一个目录。
// Namespaces 即使声明,同时会注入默认值 alias,也就是说每个 action 至少会有一个 namespace。
Namespaces []string `yaml:"namespaces,omitempty"`
}
func (*Action) GetActionTypeVersion ¶
example: git, git@1.0, git@1.1
type ActionAlias ¶
type ActionAlias string
func (ActionAlias) String ¶
func (a ActionAlias) String() string
type ActionCache ¶
type ActionType ¶
type ActionType string
func (ActionType) IsCustom ¶
func (t ActionType) IsCustom() bool
func (ActionType) IsSnippet ¶
func (t ActionType) IsSnippet() bool
func (ActionType) String ¶
func (t ActionType) String() string
type CronCompensator ¶
type CronVisitor ¶
type CronVisitor struct {
// contains filtered or unexported fields
}
func NewCronVisitor ¶
func NewCronVisitor(ops ...CronVisitorOption) *CronVisitor
func (*CronVisitor) Visit ¶
func (v *CronVisitor) Visit(s *Spec)
type CronVisitorOption ¶
type CronVisitorOption func(*CronVisitor)
func WithCronStartEndTime ¶
func WithCronStartEndTime(cronStartTime, cronEndTime *time.Time) CronVisitorOption
func WithListNextScheduleCount ¶
func WithListNextScheduleCount(count int) CronVisitorOption
type EnvInsertVisitor ¶
type EnvInsertVisitor struct {
// contains filtered or unexported fields
}
func NewEnvInsertVisitor ¶
func NewEnvInsertVisitor(envs map[string]string) *EnvInsertVisitor
func (*EnvInsertVisitor) Visit ¶
func (v *EnvInsertVisitor) Visit(s *Spec)
type EnvVisitor ¶
type EnvVisitor struct {
// contains filtered or unexported fields
}
func NewEnvVisitor ¶
func NewEnvVisitor(envs map[string]string) *EnvVisitor
func (*EnvVisitor) Visit ¶
func (v *EnvVisitor) Visit(s *Spec)
type HandleResult ¶
func (*HandleResult) AppendError ¶
func (r *HandleResult) AppendError(err error)
func (*HandleResult) AppendWarn ¶
func (r *HandleResult) AppendWarn(warn string)
type MergeTrigger ¶
type MergeTrigger struct {
Branches []string `yaml:"branches,omitempty"`
}
type NetworkHookInfo ¶
type NetworkHookInfo struct {
Hook string `json:"hook"` // hook type
Client string `json:"client"` // use network client
Labels map[string]interface{} `json:"labels"` // additional information
}
describe the use of network hook in the pipeline
type Option ¶
type Option func(*PipelineYml)
func WithActionTypeMapping ¶
func WithAliasesToCheckRefOp ¶
func WithAliasesToCheckRefOp(globalSnippetConfigLabels map[string]string, aliases ...ActionAlias) Option
WithAliasesToCheckRefOp 设置哪些 action alias 需要检查 ref op
func WithAllowMissingCustomScriptOutputs ¶
WithAllowMissingCustomScriptOutputs 设置是否允许 custom-script 的 outputs 不存在,即忽略错误。 Default: false,默认不忽略。 custom-script 的 outputs 在运行时才能确定,因此在 precheck 时该参数应该设置为 true。
func WithFlatParams ¶
func WithRefOpOutputs ¶
WithRefOpOutputs 设置可用的 ref op outputs
func WithRunParams ¶
func WithRunParams(runParams []apistructs.PipelineRunParamWithValue) Option
func WithSecrets ¶
type Outputs ¶
type Outputs map[ActionAlias]map[string]string
type ParamsVisitor ¶
type ParamsVisitor struct {
Data []byte
RunPipelineParams []apistructs.PipelineRunParam
}
func NewParamsVisitor ¶
func NewParamsVisitor(data []byte, runPipelineParam []apistructs.PipelineRunParam) *ParamsVisitor
func (*ParamsVisitor) Visit ¶
func (v *ParamsVisitor) Visit(s *Spec)
type PipelineOutput ¶
type PipelineParam ¶
type PipelineParam struct {
Name string `json:"name,omitempty" yaml:"name,omitempty"` // 名称
Required bool `json:"required,omitempty" yaml:"required,omitempty"` // 是否必须
Default interface{} `json:"default,omitempty" yaml:"default,omitempty"` // 默认值
Desc string `json:"desc,omitempty" yaml:"desc,omitempty"` // 描述
Type string `json:"type,omitempty" yaml:"type,omitempty"` // 类型
}
type PipelineYml ¶
type PipelineYml struct {
SnippetCaches []SnippetPipelineYmlCache // snippet 缓存
// contains filtered or unexported fields
}
func (*PipelineYml) Errors ¶
func (y *PipelineYml) Errors() []error
func (*PipelineYml) NeedUpgrade ¶
func (y *PipelineYml) NeedUpgrade() bool
func (*PipelineYml) Spec ¶
func (y *PipelineYml) Spec() *Spec
func (*PipelineYml) UpgradedYmlContent ¶
func (y *PipelineYml) UpgradedYmlContent() []byte
func (*PipelineYml) Warns ¶
func (y *PipelineYml) Warns() []string
type PushTrigger ¶
type RefOp ¶
type RefOp struct {
Ori string // ${alias:OPERATION:key}
Ref string // ref: alias or namespace
Op string // OPERATION
Key string // key
Ex string // Executor
IsAlias bool // 是否是 alias
IsNamespace bool // 是否是 namespace
RefStageIndex int // ref 所属 stage index
CurrentStageIndex int // 当前 action 的 stage index
}
RefOp split from ${alias:OPERATION:key}
type RefOpVisitor ¶
type RefOpVisitor struct {
// contains filtered or unexported fields
}
func NewRefOpVisitor ¶
func NewRefOpVisitor(aliases []ActionAlias, availableRefs Refs, availableOutputs Outputs, allowMissingCustomScriptOutputs bool, globalSnippetConfigLabels map[string]string) *RefOpVisitor
commitDetail 用作 snippet 校验 outputs bdl 用作 snippet 校验 outputs
func (*RefOpVisitor) Visit ¶
func (v *RefOpVisitor) Visit(s *Spec)
type SecretNotFoundSecret ¶
type SecretNotFoundSecret struct {
// contains filtered or unexported fields
}
func NewSecretNotFoundSecret ¶
func NewSecretNotFoundSecret(data []byte, secrets map[string]string) *SecretNotFoundSecret
func (*SecretNotFoundSecret) Visit ¶
func (v *SecretNotFoundSecret) Visit(s *Spec)
type SecretVisitor ¶
type SecretVisitor struct {
// contains filtered or unexported fields
}
SecretVisitor 占位符统一在 yaml 中进行文本渲染,不渲染结构体,保证引号统一处理
func NewSecretVisitor ¶
func NewSecretVisitor(data []byte, secrets map[string]string, recursiveRenderTimes int) *SecretVisitor
type SnippetConfig ¶
type SnippetConfig struct {
Source string `yaml:"source,omitempty"` // 来源 gittar dice test
Name string `yaml:"name,omitempty"` // 名称
Labels map[string]string `yaml:"labels,omitempty"` // 额外标签
}
func HandleSnippetConfigLabel ¶
func HandleSnippetConfigLabel(snippetConfig *SnippetConfig, globalSnippetConfigLabels map[string]string) SnippetConfig
HandleSnippetConfigLabel polish snippet config label
type SnippetPipelineYmlCache ¶
type SnippetPipelineYmlCache struct {
SnippetConfig SnippetConfig
PipelineYaml *apistructs.PipelineYml
}
type Spec ¶
type Spec struct {
Version string `yaml:"version"`
On *TriggerConfig `yaml:"on,omitempty"`
Storage *StorageConfig `yaml:"storage,omitempty"`
Envs map[string]string `yaml:"envs,omitempty"`
Cron string `yaml:"cron,omitempty"`
CronCompensator *CronCompensator `yaml:"cron_compensator,omitempty"`
Stages []*Stage `yaml:"stages"`
Params []*PipelineParam `yaml:"params,omitempty"` // 流水线输入
Outputs []*PipelineOutput `yaml:"outputs,omitempty"` // 流水线输出
// describe the use of network hooks in the pipeline
Lifecycle []*NetworkHookInfo `yaml:"lifecycle,omitempty"`
// contains filtered or unexported fields
}
Spec defines pipeline.yml.
func (*Spec) LoopStagesActions ¶
遍历 spec 中的 stages 的 actions
func (*Spec) ToSimplePipelineYmlActionSlice ¶
func (s *Spec) ToSimplePipelineYmlActionSlice() [][]*apistructs.PipelineYmlAction
type Stage ¶
type Stage struct {
Actions []typedActionMap `yaml:"stage"`
}
Stage represents a stage. Stages executes in series; Actions under a same stage executes in parallel.
type StageVisitor ¶
type StageVisitor struct {
// contains filtered or unexported fields
}
func NewStageVisitor ¶
func NewStageVisitor(flatParams bool) *StageVisitor
func (*StageVisitor) Visit ¶
func (v *StageVisitor) Visit(s *Spec)
type StorageConfig ¶
type StorageConfig struct {
Context string `json:"context"`
}
type TimeoutVisitor ¶
type TimeoutVisitor struct{}
func NewTimeoutVisitor ¶
func NewTimeoutVisitor() *TimeoutVisitor
func (*TimeoutVisitor) Visit ¶
func (v *TimeoutVisitor) Visit(s *Spec)
type TriggerConfig ¶
type TriggerConfig struct {
Push *PushTrigger `yaml:"push,omitempty"`
Merge *MergeTrigger `yaml:"merge,omitempty"`
}
type VersionVisitor ¶
type VersionVisitor struct{}
func NewVersionVisitor ¶
func NewVersionVisitor() *VersionVisitor
func (*VersionVisitor) Visit ¶
func (v *VersionVisitor) Visit(s *Spec)
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
All struct fields are required, unless "Optional" explicitly declared.
|
All struct fields are required, unless "Optional" explicitly declared. |
|
gogenerate
command
|
|