Skip to content

Commit

Permalink
[StepActions] when using a stepTemplate the ref gets removed
Browse files Browse the repository at this point in the history
  • Loading branch information
garethjevans authored and tekton-robot committed Mar 28, 2024
1 parent c2ab0b3 commit 5222fbe
Show file tree
Hide file tree
Showing 2 changed files with 33 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, Results: s.Results, Params: s.Params}
newStep := Step{Script: s.Script, OnError: s.OnError, Timeout: s.Timeout, StdoutConfig: s.StdoutConfig, StderrConfig: s.StderrConfig, Results: s.Results, Params: s.Params, Ref: s.Ref}
newStep.SetContainerFields(merged)
steps[i] = newStep
}
Expand Down
32 changes: 32 additions & 0 deletions pkg/apis/pipeline/v1/merge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ package v1_test
import (
"testing"

"k8s.io/utils/pointer"

"github.com/google/go-cmp/cmp"
v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
"github.com/tektoncd/pipeline/test/diff"
Expand Down Expand Up @@ -152,6 +154,36 @@ func TestMergeStepsWithStepTemplate(t *testing.T) {
Name: "param",
}},
}},
}, {
name: "ref-should-not-be-removed",
template: &v1.StepTemplate{
SecurityContext: &corev1.SecurityContext{
RunAsNonRoot: pointer.Bool(true),
},
},
steps: []v1.Step{{
Ref: &v1.Ref{Name: "my-step-action"},
OnError: "foo",
Results: []v1.StepResult{{
Name: "result",
}},
Params: v1.Params{{
Name: "param",
}},
}},
expected: []v1.Step{{
SecurityContext: &corev1.SecurityContext{
RunAsNonRoot: pointer.Bool(true),
},
Ref: &v1.Ref{Name: "my-step-action"},
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 5222fbe

Please sign in to comment.