Skip to content

Commit

Permalink
[TEP-0047] add display name to pipeline spec and task spec
Browse files Browse the repository at this point in the history
New fields are added to Pipeline, Task, and PipelineTask for display names, as well as a new field on PipelineTask for description. These "human readable" fields can be used to populate a UI in the future.
  • Loading branch information
nanjingfm committed Mar 5, 2023
1 parent eb0486a commit 925b286
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 0 deletions.
9 changes: 9 additions & 0 deletions docs/pipelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ A `Pipeline` definition supports the following fields:
- [`workspaces`](#specifying-workspaces) - Specifies a set of Workspaces that the `Pipeline` requires.
- [`tasks`](#adding-tasks-to-the-pipeline):
- [`name`](#adding-tasks-to-the-pipeline) - the name of this `Task` within the context of this `Pipeline`.
- [`displayName`](#adding-tasks-to-the-pipeline) - a user-facing name of this `Task` within the context of this `Pipeline`.
- [`description`](#adding-tasks-to-the-pipeline) - a description of this `Task` within the context of this `Pipeline`.
- [`taskRef`](#adding-tasks-to-the-pipeline) - a reference to a `Task` definition.
- [`taskSpec`](#adding-tasks-to-the-pipeline) - a specification of a `Task`.
- [`resources`](#specifying-resources-in-pipelinetasks) - Specifies the [`PipelineResource`](resources.md) that
Expand All @@ -113,10 +115,13 @@ A `Pipeline` definition supports the following fields:
multiple `TaskRuns` or `Runs`.
- [`results`](#emitting-results-from-a-pipeline) - Specifies the location to which the `Pipeline` emits its execution
results.
- [`displayName`](#specifying-a-display-name) - is a user-facing name of the pipeline that may be used to populate a UI.
- [`description`](#adding-a-description) - Holds an informative description of the `Pipeline` object.
- [`finally`](#adding-finally-to-the-pipeline) - Specifies one or more `Tasks` to be executed in parallel after
all other tasks have completed.
- [`name`](#adding-finally-to-the-pipeline) - the name of this `Task` within the context of this `Pipeline`.
- [`displayName`](#adding-finally-to-the-pipeline) - a user-facing name of this `Task` within the context of this `Pipeline`.
- [`description`](#adding-finally-to-the-pipeline) - a description of this `Task` within the context of this `Pipeline`.
- [`taskRef`](#adding-finally-to-the-pipeline) - a reference to a `Task` definition.
- [`taskSpec`](#adding-finally-to-the-pipeline) - a specification of a `Task`.
- [`retries`](#using-the-retries-field) - Specifies the number of times to retry the execution of a `Task` after
Expand Down Expand Up @@ -1183,6 +1188,10 @@ In particular:
> Consider using replacement features instead. Read more in [documentation](migrating-v1alpha1-to-v1beta1.md#replacing-pipelineresources-with-tasks)
> and [TEP-0074](https://github.com/tektoncd/community/blob/main/teps/0074-deprecate-pipelineresources.md).

## Specifying a display name

The `displayName` field is an optional field that allows you to add a user-facing name of the `Pipeline` that can be used to populate a UI.

## Adding a description

The `description` field is an optional field and can be used to provide description of the `Pipeline`.
Expand Down
5 changes: 5 additions & 0 deletions docs/tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ weight: 201
- [Specifying `Volumes`](#specifying-volumes)
- [Specifying a `Step` template](#specifying-a-step-template)
- [Specifying `Sidecars`](#specifying-sidecars)
- [Specifying a `DisplayName`](#specifying-a-display-name)
- [Adding a description](#adding-a-description)
- [Using variable substitution](#using-variable-substitution)
- [Substituting parameters and resources](#substituting-parameters-and-resources)
Expand Down Expand Up @@ -1072,6 +1073,10 @@ was executing before receiving a "stop" signal, the `Sidecar` keeps
running, eventually causing the `TaskRun` to time out with an error.
For more information, see [issue 1347](https://github.com/tektoncd/pipeline/issues/1347).

### Specifying a display name

The `displayName` field is an optional field that allows you to add a user-facing name to the task that may be used to populate a UI.

### Adding a description

The `description` field is an optional field that allows you to add an informative description to the `Task`.
Expand Down
14 changes: 14 additions & 0 deletions pkg/apis/pipeline/v1/pipeline_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ func (*Pipeline) GetGroupVersionKind() schema.GroupVersionKind {

// PipelineSpec defines the desired state of Pipeline.
type PipelineSpec struct {
// DisplayName is a user-facing name of the pipeline that may be
// used to populate a UI.
// +optional
DisplayName string `json:"displayName,omitempty"`
// Description is a user-facing description of the pipeline that may be
// used to populate a UI.
// +optional
Expand Down Expand Up @@ -159,6 +163,16 @@ type PipelineTask struct {
// the execution order of tasks relative to one another.
Name string `json:"name,omitempty"`

// DisplayName is the display name of this task within the context of a Pipeline.
// This display name may be used to populate a UI.
// +optional
DisplayName string `json:"displayName,omitempty"`

// Description is the description of this task within the context of a Pipeline.
// This description may be used to populate a UI.
// +optional
Description string `json:"description,omitempty"`

// TaskRef is a reference to a task definition.
// +optional
TaskRef *TaskRef `json:"taskRef,omitempty"`
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/pipeline/v1/task_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ type TaskSpec struct {
// +listType=atomic
Params ParamSpecs `json:"params,omitempty"`

// DisplayName is a user-facing name of the task that may be
// used to populate a UI.
// +optional
DisplayName string `json:"displayName,omitempty"`

// Description is a user-facing description of the task that may be
// used to populate a UI.
// +optional
Expand Down
6 changes: 6 additions & 0 deletions pkg/apis/pipeline/v1beta1/pipeline_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func (p *Pipeline) ConvertTo(ctx context.Context, to apis.Convertible) error {

// ConvertTo implements apis.Convertible
func (ps *PipelineSpec) ConvertTo(ctx context.Context, sink *v1.PipelineSpec) error {
sink.DisplayName = ps.DisplayName
sink.Description = ps.Description
sink.Tasks = nil
for _, t := range ps.Tasks {
Expand Down Expand Up @@ -103,6 +104,7 @@ func (p *Pipeline) ConvertFrom(ctx context.Context, from apis.Convertible) error

// ConvertFrom implements apis.Convertible
func (ps *PipelineSpec) ConvertFrom(ctx context.Context, source *v1.PipelineSpec) error {
ps.DisplayName = source.DisplayName
ps.Description = source.Description
ps.Tasks = nil
for _, t := range source.Tasks {
Expand Down Expand Up @@ -145,6 +147,8 @@ func (ps *PipelineSpec) ConvertFrom(ctx context.Context, source *v1.PipelineSpec

func (pt PipelineTask) convertTo(ctx context.Context, sink *v1.PipelineTask) error {
sink.Name = pt.Name
sink.DisplayName = pt.DisplayName
sink.Description = pt.Description
if pt.TaskRef != nil {
sink.TaskRef = &v1.TaskRef{}
pt.TaskRef.convertTo(ctx, sink.TaskRef)
Expand Down Expand Up @@ -189,6 +193,8 @@ func (pt PipelineTask) convertTo(ctx context.Context, sink *v1.PipelineTask) err

func (pt *PipelineTask) convertFrom(ctx context.Context, source v1.PipelineTask) error {
pt.Name = source.Name
pt.DisplayName = source.DisplayName
pt.Description = source.Description
if source.TaskRef != nil {
newTaskRef := TaskRef{}
newTaskRef.convertFrom(ctx, *source.TaskRef)
Expand Down
14 changes: 14 additions & 0 deletions pkg/apis/pipeline/v1beta1/pipeline_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ func (*Pipeline) GetGroupVersionKind() schema.GroupVersionKind {

// PipelineSpec defines the desired state of Pipeline.
type PipelineSpec struct {
// DisplayName is a user-facing name of the pipeline that may be
// used to populate a UI.
// +optional
DisplayName string `json:"displayName,omitempty"`
// Description is a user-facing description of the pipeline that may be
// used to populate a UI.
// +optional
Expand Down Expand Up @@ -197,6 +201,16 @@ type PipelineTask struct {
// the execution order of tasks relative to one another.
Name string `json:"name,omitempty"`

// DisplayName is the display name of this task within the context of a Pipeline.
// This display name may be used to populate a UI.
// +optional
DisplayName string `json:"displayName,omitempty"`

// Description is the description of this task within the context of a Pipeline.
// This description may be used to populate a UI.
// +optional
Description string `json:"description,omitempty"`

// TaskRef is a reference to a task definition.
// +optional
TaskRef *TaskRef `json:"taskRef,omitempty"`
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/pipeline/v1beta1/task_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ func (ts *TaskSpec) ConvertTo(ctx context.Context, sink *v1.TaskSpec) error {
p.convertTo(ctx, &new)
sink.Params = append(sink.Params, new)
}
sink.DisplayName = ts.DisplayName
sink.Description = ts.Description
return nil
}
Expand Down Expand Up @@ -144,6 +145,7 @@ func (ts *TaskSpec) ConvertFrom(ctx context.Context, source *v1.TaskSpec) error
new.convertFrom(ctx, p)
ts.Params = append(ts.Params, new)
}
ts.DisplayName = source.DisplayName
ts.Description = source.Description
return nil
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/pipeline/v1beta1/task_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ type TaskSpec struct {
// +listType=atomic
Params ParamSpecs `json:"params,omitempty"`

// DisplayName is a user-facing name of the task that may be
// used to populate a UI.
// +optional
DisplayName string `json:"displayName,omitempty"`

// Description is a user-facing description of the task that may be
// used to populate a UI.
// +optional
Expand Down

0 comments on commit 925b286

Please sign in to comment.