Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions test/e2e/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,12 @@ func (s *CLISuite) TestWorkflowLint() {
assert.Contains(t, output, "no linting errors found")
})
})
s.Run("LintFileEmptyTemplateSteps", func() {
s.Given().RunCli([]string{"lint", "smoke/empty-template-steps.yaml"}, func(t *testing.T, output string, err error) {
require.NoError(t, err)
assert.Contains(t, output, "no linting errors found")
})
})
s.Run("LintFileEmptyParamDAG", func() {
s.Given().RunCli([]string{"lint", "expectedfailures/empty-parameter-dag.yaml"}, func(t *testing.T, output string, err error) {
require.EqualError(t, err, "exit status 1")
Expand All @@ -718,6 +724,12 @@ func (s *CLISuite) TestWorkflowLint() {
assert.Contains(t, output, "templates.abc.steps[0].a templates.whalesay inputs.parameters.message was not supplied")
})
})
s.Run("LintFileMisreferenceTemplate", func() {
s.Given().RunCli([]string{"lint", "expectedfailures/misreference-template-name.yaml"}, func(t *testing.T, output string, err error) {
require.EqualError(t, err, "exit status 1")
assert.Contains(t, output, "templates.steps-with-misreference.steps[1].hello2 template name 'hell0' undefined")
})
})
s.Run("LintFileWithTemplate", func() {
s.Given().
WorkflowTemplate("@smoke/workflow-template-whalesay-template.yaml").
Expand Down
32 changes: 32 additions & 0 deletions test/e2e/expectedfailures/misreference-template-name.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: steps-with-misreference-
spec:
podMetadata:
labels:
test: steps-with-misreference
podPriorityClassName: lowest
entrypoint: steps-with-misreference
templates:
- name: steps-with-misreference
steps:
- - name: hello1
template: hello
arguments:
parameters:
- name: message
value: "hello1"
- - name: hello2
template: hell0
arguments:
parameters:
- name: message
value: "hello2"
- name: hello
inputs:
parameters:
- name: message
container:
image: argoproj/argosay:v2
args: ["echo", "{{inputs.parameters.message}}"]
33 changes: 33 additions & 0 deletions test/e2e/smoke/empty-template-steps.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: empty-array-in-steps
spec:
podMetadata:
labels:
test: empty-array-in-steps
podPriorityClassName: lowest
entrypoint: steps-with-empty-array
templates:
- name: steps-with-empty-array
steps:
- - name: hello1
template: hello
arguments:
parameters:
- name: message
value: "hello1"
- []
- - name: hello2
template: hello
arguments:
parameters:
- name: message
value: "hello2"
- name: hello
inputs:
parameters:
- name: message
container:
image: argoproj/argosay:v2
args: ["echo", "{{inputs.parameters.message}}"]
6 changes: 3 additions & 3 deletions workflow/templateresolution/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ func (tplCtx *TemplateContext) GetTemplateByName(ctx context.Context, name strin
tplCtx.log.WithField("name", name).Debug(ctx, "Getting the template by name")

tmpl := tplCtx.tmplBase.GetTemplateByName(name)
if tmpl == nil {
return nil, errors.Errorf(errors.CodeNotFound, "template %s not found", name)
}

podMetadata := tplCtx.tmplBase.GetPodMetadata()
tplCtx.addPodMetadata(podMetadata, tmpl)

if tmpl == nil {
return nil, errors.Errorf(errors.CodeNotFound, "template %s not found", name)
}
return tmpl.DeepCopy(), nil
}

Expand Down
Loading