Skip to content

Commit

Permalink
fix: Support terminating with templateRef. Fixes #7214 (#7657)
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Collins <alex_collins@intuit.com>
  • Loading branch information
alexec committed Jan 27, 2022
1 parent db7d90a commit e69f2d7
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/apis/workflow/v1alpha1/workflow_types.go
Expand Up @@ -2630,6 +2630,11 @@ func (wf *Workflow) GetTemplateByName(name string) *Template {
}
}
}
for _, t := range wf.Status.StoredTemplates {
if t.Name == name {
return &t
}
}
return nil
}

Expand Down
35 changes: 35 additions & 0 deletions pkg/apis/workflow/v1alpha1/workflow_types_test.go
Expand Up @@ -32,6 +32,41 @@ func TestWorkflows(t *testing.T) {
})
}

func TestGetTemplateByName(t *testing.T) {
t.Run("Spec", func(t *testing.T) {
wf := &Workflow{
Spec: WorkflowSpec{
Templates: []Template{
{Name: "my-tmpl"},
},
},
}
assert.NotNil(t, wf.GetTemplateByName("my-tmpl"))
})
t.Run("StoredWorkflowSpec", func(t *testing.T) {
wf := &Workflow{
Status: WorkflowStatus{
StoredWorkflowSpec: &WorkflowSpec{
Templates: []Template{
{Name: "my-tmpl"},
},
},
},
}
assert.NotNil(t, wf.GetTemplateByName("my-tmpl"))
})
t.Run("StoredTemplates", func(t *testing.T) {
wf := &Workflow{
Status: WorkflowStatus{
StoredTemplates: map[string]Template{
"": {Name: "my-tmpl"},
},
},
}
assert.NotNil(t, wf.GetTemplateByName("my-tmpl"))
})
}

func TestWorkflowCreatedAfter(t *testing.T) {
t0 := time.Time{}
t1 := t0.Add(time.Second)
Expand Down

0 comments on commit e69f2d7

Please sign in to comment.