diff --git a/pipeline/frontend/yaml/linter/linter.go b/pipeline/frontend/yaml/linter/linter.go index 79cfa1168..86d633c24 100644 --- a/pipeline/frontend/yaml/linter/linter.go +++ b/pipeline/frontend/yaml/linter/linter.go @@ -161,11 +161,37 @@ func (l *Linter) lintContainers(config *WorkflowConfig, area string) error { if err := l.lintContainerDeprecations(config, container, area); err != nil { linterErr = multierr.Append(linterErr, err) } + if err := l.lintDependsOn(config, container, area); err != nil { + linterErr = multierr.Append(linterErr, err) + } } return linterErr } +func (l *Linter) lintDependsOn(config *WorkflowConfig, c *types.Container, area string) error { + if area != "steps" { + return nil + } + + var linterErr error +check: + for _, dep := range c.DependsOn { + for _, step := range config.Workflow.Steps.ContainerList { + if dep == step.Name { + continue check + } + } + linterErr = multierr.Append(linterErr, + newLinterError( + "One or more of the specified dependencies do not exist", + config.File, fmt.Sprintf("%s.%s.depends_on", area, c.Name), false, + ), + ) + } + return linterErr +} + func (l *Linter) lintImage(config *WorkflowConfig, c *types.Container, area string) error { if len(c.Image) == 0 { return newLinterError("Invalid or missing image", config.File, fmt.Sprintf("%s.%s", area, c.Name), false) diff --git a/pipeline/frontend/yaml/linter/linter_test.go b/pipeline/frontend/yaml/linter/linter_test.go index 9f78fc9c6..836b44e0a 100644 --- a/pipeline/frontend/yaml/linter/linter_test.go +++ b/pipeline/frontend/yaml/linter/linter_test.go @@ -185,6 +185,10 @@ func TestLintErrors(t *testing.T) { from: "steps: { build: { image: golang, secrets: [ 'mysql_username' ] } }", want: "Usage of `secrets` is deprecated, use `environment` in combination with `from_secret`", }, + { + from: "steps: { build: { image: golang }, publish: { image: golang, depends_on: [ binary ] } }", + want: "One or more of the specified dependencies do not exist", + }, } for _, test := range testdata {