Skip to content

Commit

Permalink
Fix: Merge StepTemplate with Step containing Results and Params
Browse files Browse the repository at this point in the history
Prior to this, when we merged StepTemplate with the Spec, we would
lose the Results and Params because the merged Step would overwrite
the original Step. This PR adds the Results and Params when creating
the new Step so that we don't lose this information.

It fixes Issue #7754

Signed-off-by: Chitrang Patel <chitrang@google.com>
  • Loading branch information
chitrangpatel authored and tekton-robot committed Mar 27, 2024
1 parent b4b791b commit 3d2b5cb
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/apis/pipeline/v1/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func MergeStepsWithStepTemplate(template *StepTemplate, steps []Step) ([]Step, e
amendConflictingContainerFields(&merged, s)

// Pass through original step Script, for later conversion.
newStep := Step{Script: s.Script, OnError: s.OnError, Timeout: s.Timeout, StdoutConfig: s.StdoutConfig, StderrConfig: s.StderrConfig}
newStep := Step{Script: s.Script, OnError: s.OnError, Timeout: s.Timeout, StdoutConfig: s.StdoutConfig, StderrConfig: s.StderrConfig, Results: s.Results, Params: s.Params}
newStep.SetContainerFields(merged)
steps[i] = newStep
}
Expand Down
25 changes: 25 additions & 0 deletions pkg/apis/pipeline/v1/merge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,31 @@ func TestMergeStepsWithStepTemplate(t *testing.T) {
MountPath: "/workspace/data",
}},
}},
}, {
name: "results-and-params-should-not-be-removed",
template: &v1.StepTemplate{
Command: []string{"/somecmd"},
},
steps: []v1.Step{{
Image: "some-image",
OnError: "foo",
Results: []v1.StepResult{{
Name: "result",
}},
Params: v1.Params{{
Name: "param",
}},
}},
expected: []v1.Step{{
Command: []string{"/somecmd"}, Image: "some-image",
OnError: "foo",
Results: []v1.StepResult{{
Name: "result",
}},
Params: v1.Params{{
Name: "param",
}},
}},
}, {
name: "merge-env-by-step",
template: &v1.StepTemplate{
Expand Down

0 comments on commit 3d2b5cb

Please sign in to comment.