Skip to content

Commit

Permalink
TEP-0142: Introduce StepResults in Steps
Browse files Browse the repository at this point in the history
This PR introduces `StepResults` in Steps.
  • Loading branch information
chitrangpatel committed Nov 22, 2023
1 parent 23581c5 commit 6499d9b
Show file tree
Hide file tree
Showing 30 changed files with 1,359 additions and 614 deletions.
189 changes: 113 additions & 76 deletions docs/pipeline-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -3214,7 +3214,7 @@ this field is false and so declared workspaces are required.</p>
<h3 id="tekton.dev/v1.PropertySpec">PropertySpec
</h3>
<p>
(<em>Appears on:</em><a href="#tekton.dev/v1.ParamSpec">ParamSpec</a>, <a href="#tekton.dev/v1.TaskResult">TaskResult</a>, <a href="#tekton.dev/v1alpha1.StepActionResult">StepActionResult</a>)
(<em>Appears on:</em><a href="#tekton.dev/v1.ParamSpec">ParamSpec</a>, <a href="#tekton.dev/v1.StepResult">StepResult</a>, <a href="#tekton.dev/v1.TaskResult">TaskResult</a>)
</p>
<div>
<p>PropertySpec defines the struct for object keys</p>
Expand Down Expand Up @@ -3506,7 +3506,7 @@ string
<h3 id="tekton.dev/v1.ResultsType">ResultsType
(<code>string</code> alias)</h3>
<p>
(<em>Appears on:</em><a href="#tekton.dev/v1.PipelineResult">PipelineResult</a>, <a href="#tekton.dev/v1.TaskResult">TaskResult</a>, <a href="#tekton.dev/v1.TaskRunResult">TaskRunResult</a>, <a href="#tekton.dev/v1alpha1.StepActionResult">StepActionResult</a>)
(<em>Appears on:</em><a href="#tekton.dev/v1.PipelineResult">PipelineResult</a>, <a href="#tekton.dev/v1.StepResult">StepResult</a>, <a href="#tekton.dev/v1.TaskResult">TaskResult</a>, <a href="#tekton.dev/v1.TaskRunResult">TaskRunResult</a>)
</p>
<div>
<p>ResultsType indicates the type of a result;
Expand Down Expand Up @@ -4441,6 +4441,24 @@ Params
<p>Params declares parameters passed to this step action.</p>
</td>
</tr>
<tr>
<td>
<code>results</code><br/>
<em>
<a href="#tekton.dev/v1.StepResult">
[]StepResult
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>Results declares StepResults produced by the Step.</p>
<p>This is field is at an ALPHA stability level and gated by &ldquo;enable-step-actions&rdquo; feature flag.</p>
<p>It can be used in an inlined Step when used to store Results to $(step.results.resultName.path).
It cannot be used when referencing StepActions using [v1.Step.Ref].
The Results declared by the StepActions will be stored here instead.</p>
</td>
</tr>
</tbody>
</table>
<h3 id="tekton.dev/v1.StepOutputConfig">StepOutputConfig
Expand Down Expand Up @@ -4473,6 +4491,77 @@ string
</tr>
</tbody>
</table>
<h3 id="tekton.dev/v1.StepResult">StepResult
</h3>
<p>
(<em>Appears on:</em><a href="#tekton.dev/v1.Step">Step</a>, <a href="#tekton.dev/v1alpha1.StepActionSpec">StepActionSpec</a>, <a href="#tekton.dev/v1beta1.Step">Step</a>)
</p>
<div>
<p>StepResult used to describe the Results of a Step.</p>
<p>This is field is at an ALPHA stability level and gated by &ldquo;enable-step-actions&rdquo; feature flag.</p>
</div>
<table>
<thead>
<tr>
<th>Field</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code>name</code><br/>
<em>
string
</em>
</td>
<td>
<p>Name the given name</p>
</td>
</tr>
<tr>
<td>
<code>type</code><br/>
<em>
<a href="#tekton.dev/v1.ResultsType">
ResultsType
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>Type is the user-specified type of the result. The possible type
is currently &ldquo;string&rdquo; and will support &ldquo;array&rdquo; in following work.</p>
</td>
</tr>
<tr>
<td>
<code>properties</code><br/>
<em>
<a href="#tekton.dev/v1.PropertySpec">
map[string]github.com/tektoncd/pipeline/pkg/apis/pipeline/v1.PropertySpec
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>Properties is the JSON Schema properties to support key-value pairs results.</p>
</td>
</tr>
<tr>
<td>
<code>description</code><br/>
<em>
string
</em>
</td>
<td>
<em>(Optional)</em>
<p>Description is a human-readable description of the result</p>
</td>
</tr>
</tbody>
</table>
<h3 id="tekton.dev/v1.StepState">StepState
</h3>
<p>
Expand Down Expand Up @@ -6616,8 +6705,8 @@ Params must be supplied as inputs in Steps unless they declare a defaultvalue.</
<td>
<code>results</code><br/>
<em>
<a href="#tekton.dev/v1alpha1.StepActionResult">
[]StepActionResult
<a href="#tekton.dev/v1.StepResult">
[]StepResult
</a>
</em>
</td>
Expand Down Expand Up @@ -7323,76 +7412,6 @@ Refer Go&rsquo;s ParseDuration documentation for expected format: <a href="https
<div>
<p>StepActionObject is implemented by StepAction</p>
</div>
<h3 id="tekton.dev/v1alpha1.StepActionResult">StepActionResult
</h3>
<p>
(<em>Appears on:</em><a href="#tekton.dev/v1alpha1.StepActionSpec">StepActionSpec</a>)
</p>
<div>
<p>StepActionResult used to describe the results of a task</p>
</div>
<table>
<thead>
<tr>
<th>Field</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code>name</code><br/>
<em>
string
</em>
</td>
<td>
<p>Name the given name</p>
</td>
</tr>
<tr>
<td>
<code>type</code><br/>
<em>
<a href="#tekton.dev/v1.ResultsType">
ResultsType
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>Type is the user-specified type of the result. The possible type
is currently &ldquo;string&rdquo; and will support &ldquo;array&rdquo; in following work.</p>
</td>
</tr>
<tr>
<td>
<code>properties</code><br/>
<em>
<a href="#tekton.dev/v1.PropertySpec">
map[string]github.com/tektoncd/pipeline/pkg/apis/pipeline/v1.PropertySpec
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>Properties is the JSON Schema properties to support key-value pairs results.</p>
</td>
</tr>
<tr>
<td>
<code>description</code><br/>
<em>
string
</em>
</td>
<td>
<em>(Optional)</em>
<p>Description is a human-readable description of the result</p>
</td>
</tr>
</tbody>
</table>
<h3 id="tekton.dev/v1alpha1.StepActionSpec">StepActionSpec
</h3>
<p>
Expand Down Expand Up @@ -7507,8 +7526,8 @@ Params must be supplied as inputs in Steps unless they declare a defaultvalue.</
<td>
<code>results</code><br/>
<em>
<a href="#tekton.dev/v1alpha1.StepActionResult">
[]StepActionResult
<a href="#tekton.dev/v1.StepResult">
[]StepResult
</a>
</em>
</td>
Expand Down Expand Up @@ -13333,6 +13352,24 @@ Params
<p>Params declares parameters passed to this step action.</p>
</td>
</tr>
<tr>
<td>
<code>results</code><br/>
<em>
<a href="#tekton.dev/v1.StepResult">
[]StepResult
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>Results declares StepResults produced by the Step.</p>
<p>This is field is at an ALPHA stability level and gated by &ldquo;enable-step-actions&rdquo; feature flag.</p>
<p>It can be used in an inlined Step when used to store Results to $(step.results.resultName.path).
It cannot be used when referencing StepActions using [v1beta1.Step.Ref].
The Results declared by the StepActions will be stored here instead.</p>
</td>
</tr>
</tbody>
</table>
<h3 id="tekton.dev/v1beta1.StepOutputConfig">StepOutputConfig
Expand Down
10 changes: 10 additions & 0 deletions pkg/apis/pipeline/v1/container_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,16 @@ type Step struct {
// +optional
// +listType=atomic
Params Params `json:"params,omitempty"`
// Results declares StepResults produced by the Step.
//
// This is field is at an ALPHA stability level and gated by "enable-step-actions" feature flag.
//
// It can be used in an inlined Step when used to store Results to $(step.results.resultName.path).
// It cannot be used when referencing StepActions using [v1.Step.Ref].
// The Results declared by the StepActions will be stored here instead.
// +optional
// +listType=atomic
Results []StepResult `json:"results,omitempty"`
}

// Ref can be used to refer to a specific instance of a StepAction.
Expand Down
75 changes: 74 additions & 1 deletion pkg/apis/pipeline/v1/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions pkg/apis/pipeline/v1/result_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,26 @@ func (tr *TaskResult) SetDefaults(context.Context) {
}
}
}

// SetDefaults set the default type for StepResult
func (sr *StepResult) SetDefaults(context.Context) {
if sr == nil {
return
}
if sr.Type == "" {
if sr.Properties != nil {
// Set type to object if `properties` is given
sr.Type = ResultsTypeObject
} else {
// ResultsTypeString is the default value
sr.Type = ResultsTypeString
}
}

// Set default type of object values to string
for key, propertySpec := range sr.Properties {
if propertySpec.Type == "" {
sr.Properties[key] = PropertySpec{Type: ParamType(ResultsTypeString)}
}
}
}
Loading

0 comments on commit 6499d9b

Please sign in to comment.