From c6a0bedc8055195077d2b37ba0618797946228ca Mon Sep 17 00:00:00 2001 From: Priti Desai Date: Wed, 10 Jan 2024 18:10:14 -0800 Subject: [PATCH] displayName in matrix Implementing proposal TEP-0150. Adding a functionality where the existing displayName can be used to configure unique names for each instance using the params from each combination such that the matrix instances in the Tekton Dashboard are rendered to distinguishable names. Also, repurposing an existing name field as part of the matrix.include[].name. If specified, a fully resolved name field is available in the childReferences. Signed-off-by: Priti Desai --- docs/matrix.md | 78 +++ docs/pipeline-api.md | 24 + docs/pipelines.md | 8 + .../beta/pipelinerun-with-matrix.yaml | 13 + pkg/apis/pipeline/v1/openapi_generated.go | 7 + pkg/apis/pipeline/v1/pipelinerun_types.go | 3 + pkg/apis/pipeline/v1/swagger.json | 4 + .../pipeline/v1beta1/openapi_generated.go | 7 + .../pipeline/v1beta1/pipelinerun_types.go | 3 + pkg/apis/pipeline/v1beta1/swagger.json | 4 + .../pipelinerun/pipelinerun_test.go | 26 + pkg/reconciler/pipelinerun/resources/apply.go | 12 +- .../pipelinerun/resources/apply_test.go | 8 +- .../pipelinerun/resources/pipelinerunstate.go | 53 +- .../resources/pipelinerunstate_test.go | 509 +++++++++++++++++- 15 files changed, 737 insertions(+), 22 deletions(-) diff --git a/docs/matrix.md b/docs/matrix.md index 7ecfaaaecf9..6db2baaf27b 100644 --- a/docs/matrix.md +++ b/docs/matrix.md @@ -155,6 +155,84 @@ Combinations generated { "IMAGE": "image-3", "DOCKERFILE": "path/to/Dockerfile3} ``` +## DisplayName + +Matrix creates multiple `taskRuns` with the same `pipelineTask`. Each `taskRun` has its unique combination `params` based +on the `matrix` specifications. These `params` can now be surfaced and used to configure unique name of each `matrix` +instance such that it is easier to distinguish all the instances based on their inputs. + +```yaml +pipelineSpec: + tasks: + - name: platforms-and-browsers + displayName: "Platforms and Browsers: $(params.platform) and $(params.browser)" + matrix: + params: + - name: platform + value: + - linux + - mac + - windows + - name: browser + value: + - chrome + - safari + - firefox + taskRef: + name: platform-browsers +``` + +The `displayName` is available as part of `pipelineRun.status.childReferences` with each `taskRun`. +This allows the clients to consume `displayName` wherever needed: + +```json +[ + { + "apiVersion": "tekton.dev/v1", + "displayName": "Platforms and Browsers: linux and chrome", + "kind": "TaskRun", + "name": "matrixed-pr-vcx79-platforms-and-browsers-0", + "pipelineTaskName": "platforms-and-browsers" + }, + { + "apiVersion": "tekton.dev/v1", + "displayName": "Platforms and Browsers: mac and safari", + "kind": "TaskRun", + "name": "matrixed-pr-vcx79-platforms-and-browsers-1", + "pipelineTaskName": "platforms-and-browsers" + } +] +``` + +### `matrix.include[].name` + +`matrix.include[]` section allows specifying a `name` along with a list of `params`. This `name` field is available as +part of the `pipelineRun.status.childReferences[].displayName` if specified. + +`displayName` and `matrix.include[].name` can co-exist but `matrix.include[].name` takes higher precedence. It is also +possible for the pipeline author to specify `params` in `matrix.include[].name` which are resolved in the `childReferences`. + +```yaml +- name: platforms-and-browsers-with-include + matrix: + include: + - name: "Platform: $(params.platform)" + params: + - name: platform + value: linux111 + params: + - name: browser + value: chrome +``` + +### Precedence Order + +| specification | precedence | `childReferences[].displayName` | +|-----------------------------------------------------------|---------------------------------|---------------------------------| +| `tasks[].displayName` | `tasks[].displayName` | `tasks[].displayName` | +| `tasks[].matrix.include[].name` | `tasks[].matrix.include[].name` | `tasks[].matrix.include[].name` | +| `tasks[].displayName` and `tasks[].matrix.include[].name` | `tasks[].matrix.include[].name` | `tasks[].matrix.include[].name` | + ## Concurrency Control The default maximum count of `TaskRuns` or `Runs` from a given `Matrix` is **256**. To customize the maximum count of diff --git a/docs/pipeline-api.md b/docs/pipeline-api.md index 88796c3e34a..00a01429251 100644 --- a/docs/pipeline-api.md +++ b/docs/pipeline-api.md @@ -1333,6 +1333,18 @@ string +displayName
+ +string + + + +

DisplayName is a user-facing name of the pipelineTask that may be +used to populate a UI.

+ + + + pipelineTaskName
string @@ -9513,6 +9525,18 @@ string +displayName
+ +string + + + +

DisplayName is a user-facing name of the pipelineTask that may be +used to populate a UI.

+ + + + pipelineTaskName
string diff --git a/docs/pipelines.md b/docs/pipelines.md index 2de52d549c0..3013d45e3cb 100644 --- a/docs/pipelines.md +++ b/docs/pipelines.md @@ -434,6 +434,10 @@ Specifying task results in the `displayName` does not introduce an inherent reso pipeline author is responsible for specifying dependency explicitly either using [runAfter](#using-the-runafter-field) or rely on [whenExpressions](#guard-task-execution-using-when-expressions) or [task results in params](#using-results). +Fully resolved `displayName` is also available in the status as part of the `pipelineRun.status.childReferences`. The +clients such as the dashboard, CLI, etc. can retrieve the `displayName` from the `childReferences`. The `displayName` mainly +drives a better user experience and at the same time it is not validated for the content or length by the controller. + ### Specifying Remote Tasks **([beta feature](https://github.com/tektoncd/pipeline/blob/main/docs/install.md#beta-features))** @@ -1542,6 +1546,10 @@ The `displayName` also allows you to parameterize the human-readable name of you [params](#specifying-parameters), [the task results](#consuming-task-execution-results-in-finally), and [the context variables](#context-variables). +Fully resolved `displayName` is also available in the status as part of the `pipelineRun.status.childReferences`. The +clients such as the dashboard, CLI, etc. can retrieve the `displayName` from the `childReferences`. The `displayName` mainly +drives a better user experience and at the same time it is not validated for the content or length by the controller. + ### Specifying `Workspaces` in `finally` tasks `finally` tasks can specify [workspaces](workspaces.md) which `PipelineTasks` might have utilized diff --git a/examples/v1/pipelineruns/beta/pipelinerun-with-matrix.yaml b/examples/v1/pipelineruns/beta/pipelinerun-with-matrix.yaml index c9a70f9c121..b32c7596280 100644 --- a/examples/v1/pipelineruns/beta/pipelinerun-with-matrix.yaml +++ b/examples/v1/pipelineruns/beta/pipelinerun-with-matrix.yaml @@ -25,6 +25,7 @@ spec: pipelineSpec: tasks: - name: platforms-and-browsers + displayName: "Platform: $(params.platform) with Browser: $(params.browser)" matrix: params: - name: platform @@ -52,6 +53,18 @@ spec: value: chrome taskRef: name: platform-browsers + - name: matrix-and-params-include + matrix: + include: + - name: "Platform: $(params.platform) with Browser: $(params.browser)" + params: + - name: platform + value: linux + params: + - name: browser + value: chrome + taskRef: + name: platform-browsers - name: matrix-params-with-empty-array-skipped matrix: params: diff --git a/pkg/apis/pipeline/v1/openapi_generated.go b/pkg/apis/pipeline/v1/openapi_generated.go index d6f61ef5faf..44ffe232808 100644 --- a/pkg/apis/pipeline/v1/openapi_generated.go +++ b/pkg/apis/pipeline/v1/openapi_generated.go @@ -409,6 +409,13 @@ func schema_pkg_apis_pipeline_v1_ChildStatusReference(ref common.ReferenceCallba Format: "", }, }, + "displayName": { + SchemaProps: spec.SchemaProps{ + Description: "DisplayName is a user-facing name of the pipelineTask that may be used to populate a UI.", + Type: []string{"string"}, + Format: "", + }, + }, "pipelineTaskName": { SchemaProps: spec.SchemaProps{ Description: "PipelineTaskName is the name of the PipelineTask this is referencing.", diff --git a/pkg/apis/pipeline/v1/pipelinerun_types.go b/pkg/apis/pipeline/v1/pipelinerun_types.go index 951a0d42621..9c9bcd85566 100644 --- a/pkg/apis/pipeline/v1/pipelinerun_types.go +++ b/pkg/apis/pipeline/v1/pipelinerun_types.go @@ -484,6 +484,9 @@ type ChildStatusReference struct { runtime.TypeMeta `json:",inline"` // Name is the name of the TaskRun or Run this is referencing. Name string `json:"name,omitempty"` + // DisplayName is a user-facing name of the pipelineTask that may be + // used to populate a UI. + DisplayName string `json:"displayName,omitempty"` // PipelineTaskName is the name of the PipelineTask this is referencing. PipelineTaskName string `json:"pipelineTaskName,omitempty"` diff --git a/pkg/apis/pipeline/v1/swagger.json b/pkg/apis/pipeline/v1/swagger.json index 397a1ae46e1..7a3df781f90 100644 --- a/pkg/apis/pipeline/v1/swagger.json +++ b/pkg/apis/pipeline/v1/swagger.json @@ -158,6 +158,10 @@ "apiVersion": { "type": "string" }, + "displayName": { + "description": "DisplayName is a user-facing name of the pipelineTask that may be used to populate a UI.", + "type": "string" + }, "kind": { "type": "string" }, diff --git a/pkg/apis/pipeline/v1beta1/openapi_generated.go b/pkg/apis/pipeline/v1beta1/openapi_generated.go index c55315ac140..3c8449a1bc8 100644 --- a/pkg/apis/pipeline/v1beta1/openapi_generated.go +++ b/pkg/apis/pipeline/v1beta1/openapi_generated.go @@ -433,6 +433,13 @@ func schema_pkg_apis_pipeline_v1beta1_ChildStatusReference(ref common.ReferenceC Format: "", }, }, + "displayName": { + SchemaProps: spec.SchemaProps{ + Description: "DisplayName is a user-facing name of the pipelineTask that may be used to populate a UI.", + Type: []string{"string"}, + Format: "", + }, + }, "pipelineTaskName": { SchemaProps: spec.SchemaProps{ Description: "PipelineTaskName is the name of the PipelineTask this is referencing.", diff --git a/pkg/apis/pipeline/v1beta1/pipelinerun_types.go b/pkg/apis/pipeline/v1beta1/pipelinerun_types.go index 4c7ae064567..c3a111a978b 100644 --- a/pkg/apis/pipeline/v1beta1/pipelinerun_types.go +++ b/pkg/apis/pipeline/v1beta1/pipelinerun_types.go @@ -432,6 +432,9 @@ type ChildStatusReference struct { runtime.TypeMeta `json:",inline"` // Name is the name of the TaskRun or Run this is referencing. Name string `json:"name,omitempty"` + // DisplayName is a user-facing name of the pipelineTask that may be + // used to populate a UI. + DisplayName string `json:"displayName,omitempty"` // PipelineTaskName is the name of the PipelineTask this is referencing. PipelineTaskName string `json:"pipelineTaskName,omitempty"` diff --git a/pkg/apis/pipeline/v1beta1/swagger.json b/pkg/apis/pipeline/v1beta1/swagger.json index b8624cf62ce..516cec3a070 100644 --- a/pkg/apis/pipeline/v1beta1/swagger.json +++ b/pkg/apis/pipeline/v1beta1/swagger.json @@ -158,6 +158,10 @@ "apiVersion": { "type": "string" }, + "displayName": { + "description": "DisplayName is a user-facing name of the pipelineTask that may be used to populate a UI.", + "type": "string" + }, "kind": { "type": "string" }, diff --git a/pkg/reconciler/pipelinerun/pipelinerun_test.go b/pkg/reconciler/pipelinerun/pipelinerun_test.go index 837b7982607..92cac27d9ac 100644 --- a/pkg/reconciler/pipelinerun/pipelinerun_test.go +++ b/pkg/reconciler/pipelinerun/pipelinerun_test.go @@ -10695,30 +10695,37 @@ status: - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-matrix-include-0 + displayName: common-package go117-context pipelineTaskName: matrix-include - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-matrix-include-1 + displayName: common-package go117-context pipelineTaskName: matrix-include - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-matrix-include-2 + displayName: common-package s390x-no-race go117-context pipelineTaskName: matrix-include - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-matrix-include-3 + displayName: common-package pipelineTaskName: matrix-include - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-matrix-include-4 + displayName: common-package pipelineTaskName: matrix-include - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-matrix-include-5 + displayName: common-package s390x-no-race pipelineTaskName: matrix-include - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-matrix-include-6 + displayName: non-existent-arch pipelineTaskName: matrix-include `), }, { @@ -10888,30 +10895,37 @@ status: - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-matrix-include-0 + displayName: common-package go117-context pipelineTaskName: matrix-include - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-matrix-include-1 + displayName: common-package go117-context pipelineTaskName: matrix-include - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-matrix-include-2 + displayName: common-package s390x-no-race go117-context pipelineTaskName: matrix-include - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-matrix-include-3 + displayName: common-package pipelineTaskName: matrix-include - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-matrix-include-4 + displayName: common-package pipelineTaskName: matrix-include - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-matrix-include-5 + displayName: common-package s390x-no-race pipelineTaskName: matrix-include - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-matrix-include-6 + displayName: non-existent-arch pipelineTaskName: matrix-include `), }} @@ -11129,14 +11143,17 @@ status: - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-matrix-include-0 + displayName: build-1 pipelineTaskName: matrix-include - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-matrix-include-1 + displayName: build-2 pipelineTaskName: matrix-include - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-matrix-include-2 + displayName: build-3 pipelineTaskName: matrix-include `), }, @@ -14292,14 +14309,17 @@ status: - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-matrix-emitting-results-0 + displayName: build-1 pipelineTaskName: matrix-emitting-results - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-matrix-emitting-results-1 + displayName: build-2 pipelineTaskName: matrix-emitting-results - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-matrix-emitting-results-2 + displayName: build-3 pipelineTaskName: matrix-emitting-results - apiVersion: tekton.dev/v1 kind: TaskRun @@ -14456,14 +14476,17 @@ status: - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-matrix-emitting-results-0 + displayName: build-1 pipelineTaskName: matrix-emitting-results - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-matrix-emitting-results-1 + displayName: build-2 pipelineTaskName: matrix-emitting-results - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-matrix-emitting-results-2 + displayName: build-3 pipelineTaskName: matrix-emitting-results - apiVersion: tekton.dev/v1 kind: TaskRun @@ -14615,14 +14638,17 @@ status: - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-matrix-emitting-results-0 + displayName: build-1 pipelineTaskName: matrix-emitting-results - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-matrix-emitting-results-1 + displayName: build-2 pipelineTaskName: matrix-emitting-results - apiVersion: tekton.dev/v1 kind: TaskRun name: pr-matrix-emitting-results-2 + displayName: build-3 pipelineTaskName: matrix-emitting-results - apiVersion: tekton.dev/v1 kind: TaskRun diff --git a/pkg/reconciler/pipelinerun/resources/apply.go b/pkg/reconciler/pipelinerun/resources/apply.go index d0dae45cf79..8bddc8d6415 100644 --- a/pkg/reconciler/pipelinerun/resources/apply.go +++ b/pkg/reconciler/pipelinerun/resources/apply.go @@ -147,6 +147,12 @@ func GetContextReplacements(pipelineName string, pr *v1.PipelineRun) map[string] // ApplyContexts applies the substitution from $(context.(pipelineRun|pipeline).*) with the specified values. // Currently supports only name substitution. Uses "" as a default if name is not specified. func ApplyContexts(spec *v1.PipelineSpec, pipelineName string, pr *v1.PipelineRun) *v1.PipelineSpec { + for i := range spec.Tasks { + spec.Tasks[i].DisplayName = substitution.ApplyReplacements(spec.Tasks[i].DisplayName, GetContextReplacements(pipelineName, pr)) + } + for i := range spec.Finally { + spec.Finally[i].DisplayName = substitution.ApplyReplacements(spec.Finally[i].DisplayName, GetContextReplacements(pipelineName, pr)) + } return ApplyReplacements(spec, GetContextReplacements(pipelineName, pr), map[string][]string{}, map[string]map[string]string{}) } @@ -297,6 +303,8 @@ func ApplyReplacements(p *v1.PipelineSpec, replacements map[string]string, array for j := range p.Tasks[i].Matrix.Include { p.Tasks[i].Matrix.Include[j].Params = p.Tasks[i].Matrix.Include[j].Params.ReplaceVariables(replacements, nil, nil) } + } else { + p.Tasks[i].DisplayName = substitution.ApplyReplacements(p.Tasks[i].DisplayName, replacements) } for j := range p.Tasks[i].Workspaces { p.Tasks[i].Workspaces[j].SubPath = substitution.ApplyReplacements(p.Tasks[i].Workspaces[j].SubPath, replacements) @@ -305,7 +313,6 @@ func ApplyReplacements(p *v1.PipelineSpec, replacements map[string]string, array if p.Tasks[i].TaskRef != nil && p.Tasks[i].TaskRef.Params != nil { p.Tasks[i].TaskRef.Params = p.Tasks[i].TaskRef.Params.ReplaceVariables(replacements, arrayReplacements, objectReplacements) } - p.Tasks[i].DisplayName = substitution.ApplyReplacements(p.Tasks[i].DisplayName, replacements) p.Tasks[i] = propagateParams(p.Tasks[i], replacements, arrayReplacements, objectReplacements) } @@ -316,6 +323,8 @@ func ApplyReplacements(p *v1.PipelineSpec, replacements map[string]string, array for j := range p.Finally[i].Matrix.Include { p.Finally[i].Matrix.Include[j].Params = p.Finally[i].Matrix.Include[j].Params.ReplaceVariables(replacements, nil, nil) } + } else { + p.Finally[i].DisplayName = substitution.ApplyReplacements(p.Finally[i].DisplayName, replacements) } for j := range p.Finally[i].Workspaces { p.Finally[i].Workspaces[j].SubPath = substitution.ApplyReplacements(p.Finally[i].Workspaces[j].SubPath, replacements) @@ -324,7 +333,6 @@ func ApplyReplacements(p *v1.PipelineSpec, replacements map[string]string, array if p.Finally[i].TaskRef != nil && p.Finally[i].TaskRef.Params != nil { p.Finally[i].TaskRef.Params = p.Finally[i].TaskRef.Params.ReplaceVariables(replacements, arrayReplacements, objectReplacements) } - p.Finally[i].DisplayName = substitution.ApplyReplacements(p.Finally[i].DisplayName, replacements) p.Finally[i] = propagateParams(p.Finally[i], replacements, arrayReplacements, objectReplacements) } diff --git a/pkg/reconciler/pipelinerun/resources/apply_test.go b/pkg/reconciler/pipelinerun/resources/apply_test.go index c14723cc6fb..8eaf242a5c1 100644 --- a/pkg/reconciler/pipelinerun/resources/apply_test.go +++ b/pkg/reconciler/pipelinerun/resources/apply_test.go @@ -1739,12 +1739,12 @@ func TestApplyParameters(t *testing.T) { }, } { tt := tt // capture range variable - ctx := context.Background() - if tt.wc != nil { - ctx = tt.wc(ctx) - } t.Run(tt.name, func(t *testing.T) { t.Parallel() + ctx := context.Background() + if tt.wc != nil { + ctx = tt.wc(ctx) + } run := &v1.PipelineRun{ Spec: v1.PipelineRunSpec{ Params: tt.params, diff --git a/pkg/reconciler/pipelinerun/resources/pipelinerunstate.go b/pkg/reconciler/pipelinerun/resources/pipelinerunstate.go index cc2b22730da..7b5d550310d 100644 --- a/pkg/reconciler/pipelinerun/resources/pipelinerunstate.go +++ b/pkg/reconciler/pipelinerun/resources/pipelinerunstate.go @@ -19,12 +19,14 @@ package resources import ( "context" "fmt" + "strings" "time" "github.com/tektoncd/pipeline/pkg/apis/pipeline" v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/pkg/reconciler/pipeline/dag" + "github.com/tektoncd/pipeline/pkg/substitution" "go.uber.org/zap" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -240,8 +242,53 @@ func (facts *PipelineRunFacts) GetChildReferences() []v1.ChildStatusReference { return childRefs } +func (t *ResolvedPipelineTask) getDisplayName(customeRun *v1beta1.CustomRun, taskRun *v1.TaskRun, c v1.ChildStatusReference) v1.ChildStatusReference { + replacements := make(map[string]string) + if taskRun != nil { + for _, p := range taskRun.Spec.Params { + if p.Value.Type == v1.ParamTypeString { + replacements[fmt.Sprintf("%s.%s", v1.ParamsPrefix, p.Name)] = p.Value.StringVal + } + } + } + if customeRun != nil { + for _, p := range customeRun.Spec.Params { + if p.Value.Type == v1beta1.ParamTypeString { + replacements[fmt.Sprintf("%s.%s", v1.ParamsPrefix, p.Name)] = p.Value.StringVal + } + } + } + + if t.PipelineTask.DisplayName != "" { + c.DisplayName = substitution.ApplyReplacements(t.PipelineTask.DisplayName, replacements) + } + if t.PipelineTask.Matrix != nil { + var dn string + for _, i := range t.PipelineTask.Matrix.Include { + if i.Name == "" { + continue + } + match := true + for _, ip := range i.Params { + v, ok := replacements[fmt.Sprintf("%s.%s", v1.ParamsPrefix, ip.Name)] + if !ok || (ip.Value.Type == v1.ParamTypeString && ip.Value.StringVal != v) { + match = false + break + } + } + if match { + dn = fmt.Sprintf("%s %s", dn, substitution.ApplyReplacements(i.Name, replacements)) + } + } + if dn != "" { + c.DisplayName = strings.TrimSpace(dn) + } + } + return c +} + func (t *ResolvedPipelineTask) getChildRefForRun(customRun *v1beta1.CustomRun) v1.ChildStatusReference { - return v1.ChildStatusReference{ + c := v1.ChildStatusReference{ TypeMeta: runtime.TypeMeta{ APIVersion: v1beta1.SchemeGroupVersion.String(), Kind: pipeline.CustomRunControllerName, @@ -250,10 +297,11 @@ func (t *ResolvedPipelineTask) getChildRefForRun(customRun *v1beta1.CustomRun) v PipelineTaskName: t.PipelineTask.Name, WhenExpressions: t.PipelineTask.When, } + return t.getDisplayName(customRun, nil, c) } func (t *ResolvedPipelineTask) getChildRefForTaskRun(taskRun *v1.TaskRun) v1.ChildStatusReference { - return v1.ChildStatusReference{ + c := v1.ChildStatusReference{ TypeMeta: runtime.TypeMeta{ APIVersion: v1.SchemeGroupVersion.String(), Kind: pipeline.TaskRunControllerName, @@ -262,6 +310,7 @@ func (t *ResolvedPipelineTask) getChildRefForTaskRun(taskRun *v1.TaskRun) v1.Chi PipelineTaskName: t.PipelineTask.Name, WhenExpressions: t.PipelineTask.When, } + return t.getDisplayName(nil, taskRun, c) } // getNextTasks returns a list of tasks which should be executed next i.e. diff --git a/pkg/reconciler/pipelinerun/resources/pipelinerunstate_test.go b/pkg/reconciler/pipelinerun/resources/pipelinerunstate_test.go index c709a6ae218..447805d9ab6 100644 --- a/pkg/reconciler/pipelinerun/resources/pipelinerunstate_test.go +++ b/pkg/reconciler/pipelinerun/resources/pipelinerunstate_test.go @@ -3193,7 +3193,8 @@ func TestPipelineRunState_GetChildReferences(t *testing.T) { state: PipelineRunState{{ TaskRunNames: []string{"single-task-run"}, PipelineTask: &v1.PipelineTask{ - Name: "single-task-1", + Name: "single-task-1", + DisplayName: "Human readable name for single-task-1", TaskRef: &v1.TaskRef{ Name: "single-task", Kind: "Task", @@ -3217,6 +3218,8 @@ func TestPipelineRunState_GetChildReferences(t *testing.T) { }, Name: "single-task-run", PipelineTaskName: "single-task-1", + DisplayName: "Human readable name for single-task-1", + WhenExpressions: []v1.WhenExpression{{ Input: "foo", Operator: selection.In, @@ -3230,7 +3233,8 @@ func TestPipelineRunState_GetChildReferences(t *testing.T) { CustomRunNames: []string{"single-custom-task-run"}, CustomTask: true, PipelineTask: &v1.PipelineTask{ - Name: "single-custom-task-1", + Name: "single-custom-task-1", + DisplayName: "Single Custom Task 1", TaskRef: &v1.TaskRef{ APIVersion: "example.dev/v0", Kind: "Example", @@ -3255,6 +3259,7 @@ func TestPipelineRunState_GetChildReferences(t *testing.T) { }, Name: "single-custom-task-run", PipelineTaskName: "single-custom-task-1", + DisplayName: "Single Custom Task 1", WhenExpressions: []v1.WhenExpression{{ Input: "foo", Operator: selection.In, @@ -3267,7 +3272,8 @@ func TestPipelineRunState_GetChildReferences(t *testing.T) { state: PipelineRunState{{ TaskRunNames: []string{"single-task-run"}, PipelineTask: &v1.PipelineTask{ - Name: "single-task-1", + Name: "single-task-1", + DisplayName: "Single Task 1", TaskRef: &v1.TaskRef{ Name: "single-task", Kind: "Task", @@ -3282,7 +3288,8 @@ func TestPipelineRunState_GetChildReferences(t *testing.T) { CustomRunNames: []string{"single-custom-task-run"}, CustomTask: true, PipelineTask: &v1.PipelineTask{ - Name: "single-custom-task-1", + Name: "single-custom-task-1", + DisplayName: "Single Custom Task 1", TaskRef: &v1.TaskRef{ APIVersion: "example.dev/v0", Kind: "Example", @@ -3302,6 +3309,7 @@ func TestPipelineRunState_GetChildReferences(t *testing.T) { }, Name: "single-task-run", PipelineTaskName: "single-task-1", + DisplayName: "Single Task 1", }, { TypeMeta: runtime.TypeMeta{ APIVersion: "tekton.dev/v1beta1", @@ -3309,6 +3317,7 @@ func TestPipelineRunState_GetChildReferences(t *testing.T) { }, Name: "single-custom-task-run", PipelineTaskName: "single-custom-task-1", + DisplayName: "Single Custom Task 1", }}, }, { @@ -3316,7 +3325,8 @@ func TestPipelineRunState_GetChildReferences(t *testing.T) { state: PipelineRunState{{ TaskRunNames: []string{"task-run-0", "task-run-1", "task-run-2", "task-run-3"}, PipelineTask: &v1.PipelineTask{ - Name: "matrixed-task", + Name: "matrixed-task", + DisplayName: "Matrixed Task", TaskRef: &v1.TaskRef{ Name: "task", Kind: "Task", @@ -3345,7 +3355,8 @@ func TestPipelineRunState_GetChildReferences(t *testing.T) { state: PipelineRunState{{ TaskRunNames: []string{"matrixed-task-run-0"}, PipelineTask: &v1.PipelineTask{ - Name: "matrixed-task", + Name: "matrixed-task", + DisplayName: "Matrixed Task $(params.foobar) and $(params.quxbaz)", TaskRef: &v1.TaskRef{ Name: "task", Kind: "Task", @@ -3368,15 +3379,51 @@ func TestPipelineRunState_GetChildReferences(t *testing.T) { TaskRuns: []*v1.TaskRun{{ TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1"}, ObjectMeta: metav1.ObjectMeta{Name: "matrixed-task-run-0"}, + Spec: v1.TaskRunSpec{ + Params: v1.Params{{ + Name: "foobar", + Value: v1.ParamValue{Type: "string", StringVal: "foo"}, + }, { + Name: "quxbaz", + Value: v1.ParamValue{Type: "string", StringVal: "qux"}, + }}, + }, }, { TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1"}, ObjectMeta: metav1.ObjectMeta{Name: "matrixed-task-run-1"}, + Spec: v1.TaskRunSpec{ + Params: v1.Params{{ + Name: "foobar", + Value: v1.ParamValue{Type: "string", StringVal: "foo"}, + }, { + Name: "quxbaz", + Value: v1.ParamValue{Type: "string", StringVal: "baz"}, + }}, + }, }, { TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1"}, ObjectMeta: metav1.ObjectMeta{Name: "matrixed-task-run-2"}, + Spec: v1.TaskRunSpec{ + Params: v1.Params{{ + Name: "foobar", + Value: v1.ParamValue{Type: "string", StringVal: "bar"}, + }, { + Name: "quxbaz", + Value: v1.ParamValue{Type: "string", StringVal: "qux"}, + }}, + }, }, { TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1"}, ObjectMeta: metav1.ObjectMeta{Name: "matrixed-task-run-3"}, + Spec: v1.TaskRunSpec{ + Params: v1.Params{{ + Name: "foobar", + Value: v1.ParamValue{Type: "string", StringVal: "bar"}, + }, { + Name: "quxbaz", + Value: v1.ParamValue{Type: "string", StringVal: "baz"}, + }}, + }, }}, }}, childRefs: []v1.ChildStatusReference{{ @@ -3385,6 +3432,7 @@ func TestPipelineRunState_GetChildReferences(t *testing.T) { Kind: "TaskRun", }, Name: "matrixed-task-run-0", + DisplayName: "Matrixed Task foo and qux", PipelineTaskName: "matrixed-task", WhenExpressions: []v1.WhenExpression{{ Input: "foo", @@ -3397,6 +3445,7 @@ func TestPipelineRunState_GetChildReferences(t *testing.T) { Kind: "TaskRun", }, Name: "matrixed-task-run-1", + DisplayName: "Matrixed Task foo and baz", PipelineTaskName: "matrixed-task", WhenExpressions: []v1.WhenExpression{{ Input: "foo", @@ -3409,6 +3458,7 @@ func TestPipelineRunState_GetChildReferences(t *testing.T) { Kind: "TaskRun", }, Name: "matrixed-task-run-2", + DisplayName: "Matrixed Task bar and qux", PipelineTaskName: "matrixed-task", WhenExpressions: []v1.WhenExpression{{ Input: "foo", @@ -3421,6 +3471,7 @@ func TestPipelineRunState_GetChildReferences(t *testing.T) { Kind: "TaskRun", }, Name: "matrixed-task-run-3", + DisplayName: "Matrixed Task bar and baz", PipelineTaskName: "matrixed-task", WhenExpressions: []v1.WhenExpression{{ Input: "foo", @@ -3460,7 +3511,8 @@ func TestPipelineRunState_GetChildReferences(t *testing.T) { name: "matrixed-custom-task", state: PipelineRunState{{ PipelineTask: &v1.PipelineTask{ - Name: "matrixed-task", + Name: "matrixed-task", + DisplayName: "Matrixed Task with Custom Run $(params.foobar) and $(params.quxbaz)", TaskRef: &v1.TaskRef{ APIVersion: "example.dev/v0", Kind: "Example", @@ -3481,10 +3533,10 @@ func TestPipelineRunState_GetChildReferences(t *testing.T) { }, CustomTask: true, CustomRuns: []*v1beta1.CustomRun{ - customRunWithName("matrixed-run-0"), - customRunWithName("matrixed-run-1"), - customRunWithName("matrixed-run-2"), - customRunWithName("matrixed-run-3"), + customRunWithName("matrixed-run-0", "foo", "qux"), + customRunWithName("matrixed-run-1", "foo", "baz"), + customRunWithName("matrixed-run-2", "bar", "qux"), + customRunWithName("matrixed-run-3", "bar", "baz"), }, }}, childRefs: []v1.ChildStatusReference{{ @@ -3493,6 +3545,7 @@ func TestPipelineRunState_GetChildReferences(t *testing.T) { Kind: "CustomRun", }, Name: "matrixed-run-0", + DisplayName: "Matrixed Task with Custom Run foo and qux", PipelineTaskName: "matrixed-task", WhenExpressions: []v1.WhenExpression{{ Input: "foo", @@ -3505,6 +3558,7 @@ func TestPipelineRunState_GetChildReferences(t *testing.T) { Kind: "CustomRun", }, Name: "matrixed-run-1", + DisplayName: "Matrixed Task with Custom Run foo and baz", PipelineTaskName: "matrixed-task", WhenExpressions: []v1.WhenExpression{{ Input: "foo", @@ -3517,6 +3571,7 @@ func TestPipelineRunState_GetChildReferences(t *testing.T) { Kind: "CustomRun", }, Name: "matrixed-run-2", + DisplayName: "Matrixed Task with Custom Run bar and qux", PipelineTaskName: "matrixed-task", WhenExpressions: []v1.WhenExpression{{ Input: "foo", @@ -3529,6 +3584,7 @@ func TestPipelineRunState_GetChildReferences(t *testing.T) { Kind: "CustomRun", }, Name: "matrixed-run-3", + DisplayName: "Matrixed Task with Custom Run bar and baz", PipelineTaskName: "matrixed-task", WhenExpressions: []v1.WhenExpression{{ Input: "foo", @@ -3543,7 +3599,8 @@ func TestPipelineRunState_GetChildReferences(t *testing.T) { { TaskRunNames: []string{"task-generate-results"}, PipelineTask: &v1.PipelineTask{ - Name: "task1", + Name: "task1", + DisplayName: "Task 1", }, TaskRuns: []*v1.TaskRun{ { @@ -3583,7 +3640,8 @@ func TestPipelineRunState_GetChildReferences(t *testing.T) { { TaskRunNames: []string{"task-reference-previous-result"}, PipelineTask: &v1.PipelineTask{ - Name: "task2", + Name: "task2", + DisplayName: "Task 2 with $(tasks.task1.results.string-result) and $(tasks.task1.results.array-result[1])", When: []v1.WhenExpression{ { Input: "$(tasks.task1.results.string-result)", @@ -3620,6 +3678,7 @@ func TestPipelineRunState_GetChildReferences(t *testing.T) { }, Name: "task-generate-results", PipelineTaskName: "task1", + DisplayName: "Task 1", }, { TypeMeta: runtime.TypeMeta{ @@ -3627,6 +3686,7 @@ func TestPipelineRunState_GetChildReferences(t *testing.T) { Kind: "TaskRun", }, Name: "task-reference-previous-result", + DisplayName: "Task 2 with value1 and array-value2", PipelineTaskName: "task2", WhenExpressions: []v1.WhenExpression{ { @@ -3642,6 +3702,418 @@ func TestPipelineRunState_GetChildReferences(t *testing.T) { }, }, }, + }, { + name: "matrixed-task-with-displayName-and-include", + state: PipelineRunState{{ + TaskRunNames: []string{"matrixed-task-run-0"}, + PipelineTask: &v1.PipelineTask{ + Name: "matrixed-task", + DisplayName: "Matrixed Task $(params.foobar) and $(params.quxbaz)", + TaskRef: &v1.TaskRef{ + Name: "task", + Kind: "Task", + APIVersion: "v1", + }, + Matrix: &v1.Matrix{ + Params: v1.Params{{ + Name: "foobar", + Value: v1.ParamValue{Type: v1.ParamTypeArray, ArrayVal: []string{"foo", "bar"}}, + }, { + Name: "quxbaz", + Value: v1.ParamValue{Type: v1.ParamTypeArray, ArrayVal: []string{"qux", "baz"}}, + }}, + Include: v1.IncludeParamsList{{ + Name: "Execute a random case for foo", + Params: v1.Params{{ + Name: "foobar", + Value: v1.ParamValue{Type: v1.ParamTypeString, StringVal: "foo"}, + }, { + Name: "random", + Value: v1.ParamValue{Type: v1.ParamTypeString, StringVal: "random"}, + }}, + }, { + Name: "Does not exist", + Params: v1.Params{{ + Name: "foobar", + Value: v1.ParamValue{Type: v1.ParamTypeString, StringVal: "foo-does-not-exist"}, + }}, + }}, + }, + }, + TaskRuns: []*v1.TaskRun{{ + TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1"}, + ObjectMeta: metav1.ObjectMeta{Name: "matrixed-task-run-0"}, + Spec: v1.TaskRunSpec{ + Params: v1.Params{{ + Name: "foobar", + Value: v1.ParamValue{Type: "string", StringVal: "foo"}, + }, { + Name: "quxbaz", + Value: v1.ParamValue{Type: "string", StringVal: "qux"}, + }, { + Name: "random", + Value: v1.ParamValue{Type: v1.ParamTypeString, StringVal: "random"}, + }}, + }, + }, { + TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1"}, + ObjectMeta: metav1.ObjectMeta{Name: "matrixed-task-run-1"}, + Spec: v1.TaskRunSpec{ + Params: v1.Params{{ + Name: "foobar", + Value: v1.ParamValue{Type: "string", StringVal: "foo"}, + }, { + Name: "quxbaz", + Value: v1.ParamValue{Type: "string", StringVal: "baz"}, + }, { + Name: "random", + Value: v1.ParamValue{Type: v1.ParamTypeString, StringVal: "random"}, + }}, + }, + }, { + TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1"}, + ObjectMeta: metav1.ObjectMeta{Name: "matrixed-task-run-2"}, + Spec: v1.TaskRunSpec{ + Params: v1.Params{{ + Name: "foobar", + Value: v1.ParamValue{Type: "string", StringVal: "bar"}, + }, { + Name: "quxbaz", + Value: v1.ParamValue{Type: "string", StringVal: "qux"}, + }}, + }, + }, { + TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1"}, + ObjectMeta: metav1.ObjectMeta{Name: "matrixed-task-run-3"}, + Spec: v1.TaskRunSpec{ + Params: v1.Params{{ + Name: "foobar", + Value: v1.ParamValue{Type: "string", StringVal: "bar"}, + }, { + Name: "quxbaz", + Value: v1.ParamValue{Type: "string", StringVal: "baz"}, + }}, + }, + }, { + TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1"}, + ObjectMeta: metav1.ObjectMeta{Name: "matrixed-task-run-4"}, + Spec: v1.TaskRunSpec{ + Params: v1.Params{{ + Name: "foobar", + Value: v1.ParamValue{Type: "string", StringVal: "foo-does-not-exist"}, + }}, + }, + }}, + }}, + childRefs: []v1.ChildStatusReference{{ + TypeMeta: runtime.TypeMeta{ + APIVersion: "tekton.dev/v1", + Kind: "TaskRun", + }, + Name: "matrixed-task-run-0", + DisplayName: "Execute a random case for foo", + PipelineTaskName: "matrixed-task", + }, { + TypeMeta: runtime.TypeMeta{ + APIVersion: "tekton.dev/v1", + Kind: "TaskRun", + }, + Name: "matrixed-task-run-1", + DisplayName: "Execute a random case for foo", + PipelineTaskName: "matrixed-task", + }, { + TypeMeta: runtime.TypeMeta{ + APIVersion: "tekton.dev/v1", + Kind: "TaskRun", + }, + Name: "matrixed-task-run-2", + DisplayName: "Matrixed Task bar and qux", + PipelineTaskName: "matrixed-task", + }, { + TypeMeta: runtime.TypeMeta{ + APIVersion: "tekton.dev/v1", + Kind: "TaskRun", + }, + Name: "matrixed-task-run-3", + DisplayName: "Matrixed Task bar and baz", + PipelineTaskName: "matrixed-task", + }, { + TypeMeta: runtime.TypeMeta{ + APIVersion: "tekton.dev/v1", + Kind: "TaskRun", + }, + Name: "matrixed-task-run-4", + DisplayName: "Does not exist", + PipelineTaskName: "matrixed-task", + }}, + }, { + name: "matrixed-task-with-displayname-and-some-include-name", + state: PipelineRunState{{ + TaskRunNames: []string{"matrixed-task-run-0"}, + PipelineTask: &v1.PipelineTask{ + Name: "matrixed-task", + DisplayName: "Matrixed Task $(params.foobar) and $(params.quxbaz)", + TaskRef: &v1.TaskRef{ + Name: "task", + Kind: "Task", + APIVersion: "v1", + }, + Matrix: &v1.Matrix{ + Params: v1.Params{{ + Name: "foobar", + Value: v1.ParamValue{Type: v1.ParamTypeArray, ArrayVal: []string{"foo", "bar"}}, + }, { + Name: "quxbaz", + Value: v1.ParamValue{Type: v1.ParamTypeArray, ArrayVal: []string{"qux", "baz"}}, + }}, + Include: v1.IncludeParamsList{{ + Name: "additional name for foo", + Params: v1.Params{{ + Name: "foobar", + Value: v1.ParamValue{Type: v1.ParamTypeString, StringVal: "foo"}, + }, { + Name: "random1", + Value: v1.ParamValue{Type: v1.ParamTypeString, StringVal: "random"}, + }}, + }, { + Name: "one more additional name for foo", + Params: v1.Params{{ + Name: "foobar", + Value: v1.ParamValue{Type: v1.ParamTypeString, StringVal: "foo"}, + }, { + Name: "random2", + Value: v1.ParamValue{Type: v1.ParamTypeString, StringVal: "random"}, + }}, + }}, + }, + }, + TaskRuns: []*v1.TaskRun{{ + TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1"}, + ObjectMeta: metav1.ObjectMeta{Name: "matrixed-task-run-0"}, + Spec: v1.TaskRunSpec{ + Params: v1.Params{{ + Name: "foobar", + Value: v1.ParamValue{Type: "string", StringVal: "foo"}, + }, { + Name: "quxbaz", + Value: v1.ParamValue{Type: "string", StringVal: "qux"}, + }, { + Name: "random1", + Value: v1.ParamValue{Type: v1.ParamTypeString, StringVal: "random"}, + }, { + Name: "random2", + Value: v1.ParamValue{Type: v1.ParamTypeString, StringVal: "random"}, + }}, + }, + }, { + TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1"}, + ObjectMeta: metav1.ObjectMeta{Name: "matrixed-task-run-1"}, + Spec: v1.TaskRunSpec{ + Params: v1.Params{{ + Name: "foobar", + Value: v1.ParamValue{Type: "string", StringVal: "foo"}, + }, { + Name: "quxbaz", + Value: v1.ParamValue{Type: "string", StringVal: "baz"}, + }, { + Name: "random1", + Value: v1.ParamValue{Type: v1.ParamTypeString, StringVal: "random"}, + }, { + Name: "random2", + Value: v1.ParamValue{Type: v1.ParamTypeString, StringVal: "random"}, + }}, + }, + }, { + TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1"}, + ObjectMeta: metav1.ObjectMeta{Name: "matrixed-task-run-2"}, + Spec: v1.TaskRunSpec{ + Params: v1.Params{{ + Name: "foobar", + Value: v1.ParamValue{Type: "string", StringVal: "bar"}, + }, { + Name: "quxbaz", + Value: v1.ParamValue{Type: "string", StringVal: "qux"}, + }}, + }, + }, { + TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1"}, + ObjectMeta: metav1.ObjectMeta{Name: "matrixed-task-run-3"}, + Spec: v1.TaskRunSpec{ + Params: v1.Params{{ + Name: "foobar", + Value: v1.ParamValue{Type: "string", StringVal: "bar"}, + }, { + Name: "quxbaz", + Value: v1.ParamValue{Type: "string", StringVal: "baz"}, + }}, + }, + }}, + }}, + childRefs: []v1.ChildStatusReference{{ + TypeMeta: runtime.TypeMeta{ + APIVersion: "tekton.dev/v1", + Kind: "TaskRun", + }, + Name: "matrixed-task-run-0", + DisplayName: "additional name for foo one more additional name for foo", + PipelineTaskName: "matrixed-task", + }, { + TypeMeta: runtime.TypeMeta{ + APIVersion: "tekton.dev/v1", + Kind: "TaskRun", + }, + Name: "matrixed-task-run-1", + DisplayName: "additional name for foo one more additional name for foo", + PipelineTaskName: "matrixed-task", + }, { + TypeMeta: runtime.TypeMeta{ + APIVersion: "tekton.dev/v1", + Kind: "TaskRun", + }, + Name: "matrixed-task-run-2", + DisplayName: "Matrixed Task bar and qux", + PipelineTaskName: "matrixed-task", + }, { + TypeMeta: runtime.TypeMeta{ + APIVersion: "tekton.dev/v1", + Kind: "TaskRun", + }, + Name: "matrixed-task-run-3", + DisplayName: "Matrixed Task bar and baz", + PipelineTaskName: "matrixed-task", + }}, + }, { + name: "matrixed-task-with-displayname-and-some-include-name", + state: PipelineRunState{{ + TaskRunNames: []string{"matrixed-task-run-0"}, + PipelineTask: &v1.PipelineTask{ + Name: "matrixed-task", + TaskRef: &v1.TaskRef{ + Name: "task", + Kind: "Task", + APIVersion: "v1", + }, + Matrix: &v1.Matrix{ + Params: v1.Params{{ + Name: "foobar", + Value: v1.ParamValue{Type: v1.ParamTypeArray, ArrayVal: []string{"foo", "bar"}}, + }, { + Name: "quxbaz", + Value: v1.ParamValue{Type: v1.ParamTypeArray, ArrayVal: []string{"qux", "baz"}}, + }}, + Include: v1.IncludeParamsList{{ + Name: "task running foo and random", + Params: v1.Params{{ + Name: "foobar", + Value: v1.ParamValue{Type: v1.ParamTypeString, StringVal: "foo"}, + }, { + Name: "random1", + Value: v1.ParamValue{Type: v1.ParamTypeString, StringVal: "random"}, + }}, + }, { + Params: v1.Params{{ + Name: "foobar", + Value: v1.ParamValue{Type: v1.ParamTypeString, StringVal: "bar"}, + }, { + Name: "random2", + Value: v1.ParamValue{Type: v1.ParamTypeString, StringVal: "random"}, + }}, + }}, + }, + }, + TaskRuns: []*v1.TaskRun{{ + TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1"}, + ObjectMeta: metav1.ObjectMeta{Name: "matrixed-task-run-0"}, + Spec: v1.TaskRunSpec{ + Params: v1.Params{{ + Name: "foobar", + Value: v1.ParamValue{Type: "string", StringVal: "foo"}, + }, { + Name: "quxbaz", + Value: v1.ParamValue{Type: "string", StringVal: "qux"}, + }, { + Name: "random1", + Value: v1.ParamValue{Type: v1.ParamTypeString, StringVal: "random"}, + }}, + }, + }, { + TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1"}, + ObjectMeta: metav1.ObjectMeta{Name: "matrixed-task-run-1"}, + Spec: v1.TaskRunSpec{ + Params: v1.Params{{ + Name: "foobar", + Value: v1.ParamValue{Type: "string", StringVal: "foo"}, + }, { + Name: "quxbaz", + Value: v1.ParamValue{Type: "string", StringVal: "baz"}, + }, { + Name: "random1", + Value: v1.ParamValue{Type: v1.ParamTypeString, StringVal: "random"}, + }}, + }, + }, { + TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1"}, + ObjectMeta: metav1.ObjectMeta{Name: "matrixed-task-run-2"}, + Spec: v1.TaskRunSpec{ + Params: v1.Params{{ + Name: "foobar", + Value: v1.ParamValue{Type: "string", StringVal: "bar"}, + }, { + Name: "quxbaz", + Value: v1.ParamValue{Type: "string", StringVal: "qux"}, + }, { + Name: "random2", + Value: v1.ParamValue{Type: v1.ParamTypeString, StringVal: "random"}, + }}, + }, + }, { + TypeMeta: metav1.TypeMeta{APIVersion: "tekton.dev/v1"}, + ObjectMeta: metav1.ObjectMeta{Name: "matrixed-task-run-3"}, + Spec: v1.TaskRunSpec{ + Params: v1.Params{{ + Name: "foobar", + Value: v1.ParamValue{Type: "string", StringVal: "bar"}, + }, { + Name: "quxbaz", + Value: v1.ParamValue{Type: "string", StringVal: "baz"}, + }, { + Name: "random2", + Value: v1.ParamValue{Type: v1.ParamTypeString, StringVal: "random"}, + }}, + }, + }}, + }}, + childRefs: []v1.ChildStatusReference{{ + TypeMeta: runtime.TypeMeta{ + APIVersion: "tekton.dev/v1", + Kind: "TaskRun", + }, + Name: "matrixed-task-run-0", + DisplayName: "task running foo and random", + PipelineTaskName: "matrixed-task", + }, { + TypeMeta: runtime.TypeMeta{ + APIVersion: "tekton.dev/v1", + Kind: "TaskRun", + }, + Name: "matrixed-task-run-1", + DisplayName: "task running foo and random", + PipelineTaskName: "matrixed-task", + }, { + TypeMeta: runtime.TypeMeta{ + APIVersion: "tekton.dev/v1", + Kind: "TaskRun", + }, + Name: "matrixed-task-run-2", + PipelineTaskName: "matrixed-task", + }, { + TypeMeta: runtime.TypeMeta{ + APIVersion: "tekton.dev/v1", + Kind: "TaskRun", + }, + Name: "matrixed-task-run-3", + PipelineTaskName: "matrixed-task", + }}, }, } for _, tc := range testCases { @@ -3702,10 +4174,19 @@ func TestConvertResultsMapToTaskRunResults(t *testing.T) { } } -func customRunWithName(name string) *v1beta1.CustomRun { +func customRunWithName(name, p1, p2 string) *v1beta1.CustomRun { return &v1beta1.CustomRun{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, + Spec: v1beta1.CustomRunSpec{ + Params: v1beta1.Params{{ + Name: "foobar", + Value: v1beta1.ParamValue{Type: "string", StringVal: p1}, + }, { + Name: "quxbaz", + Value: v1beta1.ParamValue{Type: "string", StringVal: p2}, + }}, + }, } }