Let pipeline-compiler export step types (#1958)

This commit is contained in:
6543
2023-07-11 15:53:05 +02:00
committed by GitHub
parent fe7eb64bf9
commit b54f6ebad6
13 changed files with 100 additions and 32 deletions

View File

@@ -15,7 +15,6 @@ const (
defaultCloneName = "clone"
nameServices = "services"
namePipeline = "pipeline"
)
// Registry represents registry credentials
@@ -150,7 +149,7 @@ func (c *Compiler) Compile(conf *yaml_types.Workflow) (*backend_types.Config, er
Environment: c.cloneEnv,
}
name := fmt.Sprintf("%s_clone", c.prefix)
step := c.createProcess(name, container, defaultCloneName)
step := c.createProcess(name, container, backend_types.StepTypeClone)
stage := new(backend_types.Stage)
stage.Name = name
@@ -171,7 +170,7 @@ func (c *Compiler) Compile(conf *yaml_types.Workflow) (*backend_types.Config, er
stage.Alias = container.Name
name := fmt.Sprintf("%s_clone_%d", c.prefix, i)
step := c.createProcess(name, container, defaultCloneName)
step := c.createProcess(name, container, backend_types.StepTypeClone)
// only inject netrc if it's a trusted repo or a trusted plugin
if !c.netrcOnlyTrusted || c.trustedPipeline || (container.IsPlugin() && container.IsTrustedCloneImage()) {
@@ -202,7 +201,7 @@ func (c *Compiler) Compile(conf *yaml_types.Workflow) (*backend_types.Config, er
}
name := fmt.Sprintf("%s_%s_%d", c.prefix, nameServices, i)
step := c.createProcess(name, container, nameServices)
step := c.createProcess(name, container, backend_types.StepTypeService)
stage.Steps = append(stage.Steps, step)
}
config.Stages = append(config.Stages, stage)
@@ -233,7 +232,11 @@ func (c *Compiler) Compile(conf *yaml_types.Workflow) (*backend_types.Config, er
}
name := fmt.Sprintf("%s_step_%d", c.prefix, i)
step := c.createProcess(name, container, namePipeline)
stepType := backend_types.StepTypeCommands
if container.IsPlugin() {
stepType = backend_types.StepTypePlugin
}
step := c.createProcess(name, container, stepType)
stage.Steps = append(stage.Steps, step)
}
@@ -249,7 +252,7 @@ func (c *Compiler) setupCache(conf *yaml_types.Workflow, ir *backend_types.Confi
container := c.cacher.Restore(path.Join(c.metadata.Repo.Owner, c.metadata.Repo.Name), c.metadata.Curr.Commit.Branch, conf.Cache)
name := fmt.Sprintf("%s_restore_cache", c.prefix)
step := c.createProcess(name, container, "cache")
step := c.createProcess(name, container, backend_types.StepTypeCache)
stage := new(backend_types.Stage)
stage.Name = name
@@ -266,7 +269,7 @@ func (c *Compiler) setupCacheRebuild(conf *yaml_types.Workflow, ir *backend_type
container := c.cacher.Rebuild(path.Join(c.metadata.Repo.Owner, c.metadata.Repo.Name), c.metadata.Curr.Commit.Branch, conf.Cache)
name := fmt.Sprintf("%s_rebuild_cache", c.prefix)
step := c.createProcess(name, container, "cache")
step := c.createProcess(name, container, backend_types.StepTypeCache)
stage := new(backend_types.Stage)
stage.Name = name