Skip to content

Commit b8e244a

Browse files
lbernicktekton-robot
authored andcommitted
Add StdoutConfig and StderrorConfig to v1 Step
These fields were previously added to v1beta1 Step, and should be present in the v1 API as well. This commit adds these fields to the v1 package.
1 parent 3f53972 commit b8e244a

File tree

8 files changed

+147
-3
lines changed

8 files changed

+147
-3
lines changed

pkg/apis/pipeline/v1/container_types.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,19 @@ type Step struct {
135135
// stopAndFail indicates exit the taskRun if the container exits with non-zero exit code
136136
// continue indicates continue executing the rest of the steps irrespective of the container exit code
137137
OnError string `json:"onError,omitempty"`
138+
// Stores configuration for the stdout stream of the step.
139+
// +optional
140+
StdoutConfig *StepOutputConfig `json:"stdoutConfig,omitempty"`
141+
// Stores configuration for the stderr stream of the step.
142+
// +optional
143+
StderrConfig *StepOutputConfig `json:"stderrConfig,omitempty"`
144+
}
145+
146+
// StepOutputConfig stores configuration for a step output stream.
147+
type StepOutputConfig struct {
148+
// Path to duplicate stdout stream to on container's local filesystem.
149+
// +optional
150+
Path string `json:"path,omitempty"`
138151
}
139152

140153
// ToK8sContainer converts the Step to a Kubernetes Container struct

pkg/apis/pipeline/v1/merge.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func MergeStepsWithStepTemplate(template *StepTemplate, steps []Step) ([]Step, e
5858
}
5959

6060
// Pass through original step Script, for later conversion.
61-
newStep := Step{Script: s.Script, OnError: s.OnError, Timeout: s.Timeout}
61+
newStep := Step{Script: s.Script, OnError: s.OnError, Timeout: s.Timeout, StdoutConfig: s.StdoutConfig, StderrConfig: s.StderrConfig}
6262
newStep.SetContainerFields(merged)
6363
steps[i] = newStep
6464
}

pkg/apis/pipeline/v1/merge_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,28 @@ func TestMergeStepsWithStepTemplate(t *testing.T) {
105105
Value: "NEW_VALUE",
106106
}},
107107
}},
108+
}, {
109+
name: "workspace-and-output-config",
110+
template: &v1.StepTemplate{
111+
VolumeMounts: []corev1.VolumeMount{{
112+
Name: "data",
113+
MountPath: "/workspace/data",
114+
}},
115+
},
116+
steps: []v1.Step{{
117+
Image: "some-image",
118+
StdoutConfig: &v1.StepOutputConfig{Path: "stdout.txt"},
119+
StderrConfig: &v1.StepOutputConfig{Path: "stderr.txt"},
120+
}},
121+
expected: []v1.Step{{
122+
Image: "some-image",
123+
StdoutConfig: &v1.StepOutputConfig{Path: "stdout.txt"},
124+
StderrConfig: &v1.StepOutputConfig{Path: "stderr.txt"},
125+
VolumeMounts: []corev1.VolumeMount{{
126+
Name: "data",
127+
MountPath: "/workspace/data",
128+
}},
129+
}},
108130
}} {
109131
t.Run(tc.name, func(t *testing.T) {
110132
result, err := v1.MergeStepsWithStepTemplate(tc.template, tc.steps)

pkg/apis/pipeline/v1/openapi_generated.go

Lines changed: 34 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/pipeline/v1/swagger.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,14 @@
523523
"description": "SecurityContext defines the security options the container should be run with. If set, the fields of SecurityContext override the equivalent fields of PodSecurityContext. More info: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/",
524524
"$ref": "#/definitions/v1.SecurityContext"
525525
},
526+
"stderrConfig": {
527+
"description": "Stores configuration for the stderr stream of the step.",
528+
"$ref": "#/definitions/v1.StepOutputConfig"
529+
},
530+
"stdoutConfig": {
531+
"description": "Stores configuration for the stdout stream of the step.",
532+
"$ref": "#/definitions/v1.StepOutputConfig"
533+
},
526534
"timeout": {
527535
"description": "Timeout is the time after which the step times out. Defaults to never. Refer to Go's ParseDuration documentation for expected format: https://golang.org/pkg/time/#ParseDuration",
528536
"$ref": "#/definitions/v1.Duration"
@@ -564,6 +572,16 @@
564572
}
565573
}
566574
},
575+
"v1.StepOutputConfig": {
576+
"description": "StepOutputConfig stores configuration for a step output stream.",
577+
"type": "object",
578+
"properties": {
579+
"path": {
580+
"description": "Path to duplicate stdout stream to on container's local filesystem.",
581+
"type": "string"
582+
}
583+
}
584+
},
567585
"v1.StepTemplate": {
568586
"description": "StepTemplate is a template for a Step",
569587
"type": "object",

pkg/apis/pipeline/v1/task_validation.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,16 @@ func validateStep(ctx context.Context, s Step, names sets.String) (errs *apis.Fi
256256
errs = errs.Also(version.ValidateEnabledAPIFields(ctx, "windows script support", config.AlphaAPIFields).ViaField("script"))
257257
}
258258
}
259+
// StdoutConfig is an alpha feature and will fail validation if it's used in a task spec
260+
// when the enable-api-fields feature gate is not "alpha".
261+
if s.StdoutConfig != nil {
262+
errs = errs.Also(version.ValidateEnabledAPIFields(ctx, "step stdout stream support", config.AlphaAPIFields).ViaField("stdoutconfig"))
263+
}
264+
// StderrConfig is an alpha feature and will fail validation if it's used in a task spec
265+
// when the enable-api-fields feature gate is not "alpha".
266+
if s.StderrConfig != nil {
267+
errs = errs.Also(version.ValidateEnabledAPIFields(ctx, "step stderr stream support", config.AlphaAPIFields).ViaField("stderrconfig"))
268+
}
259269
return errs
260270
}
261271

pkg/apis/pipeline/v1/task_validation_test.go

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1408,7 +1408,29 @@ func TestIncompatibleAPIVersions(t *testing.T) {
14081408
script-1`,
14091409
}},
14101410
},
1411-
}}
1411+
}, {
1412+
name: "stdout stream support requires alpha",
1413+
requiredVersion: "alpha",
1414+
spec: v1.TaskSpec{
1415+
Steps: []v1.Step{{
1416+
Image: "foo",
1417+
StdoutConfig: &v1.StepOutputConfig{
1418+
Path: "/tmp/stdout.txt",
1419+
},
1420+
}},
1421+
},
1422+
}, {
1423+
name: "stderr stream support requires alpha",
1424+
requiredVersion: "alpha",
1425+
spec: v1.TaskSpec{
1426+
Steps: []v1.Step{{
1427+
Image: "foo",
1428+
StderrConfig: &v1.StepOutputConfig{
1429+
Path: "/tmp/stderr.txt",
1430+
},
1431+
}},
1432+
}},
1433+
}
14121434
versions := []string{"alpha", "stable"}
14131435
for _, tt := range tests {
14141436
for _, version := range versions {

pkg/apis/pipeline/v1/zz_generated.deepcopy.go

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)