From 50f2abe1a96668680270f8cb643b9317b9772521 Mon Sep 17 00:00:00 2001 From: vinamra28 Date: Tue, 25 Aug 2020 21:28:45 +0530 Subject: [PATCH 1/2] Display Workspaces in the output of Pipeline describe command The workspaces declared in the Pipeline will be displayed in the output of pipeline describe command. When we will do `tkn pipeline desc ` workspace name and description will be displayed in the output. Signed-off-by: vinamra28 --- pkg/cmd/pipeline/describe.go | 10 +++ pkg/cmd/pipeline/describe_test.go | 79 +++++++++++++++++++ ...lineDescribeV1beta1_task_conditions.golden | 4 + ...ipelineDescribeV1beta1_with_results.golden | 4 + ...th_spec_multiple_resource_param_run.golden | 4 + ...lineDescribeV1beta1_with_workspaces.golden | 33 ++++++++ .../TestPipelineDescribe_empty.golden | 4 + ...with_multiple_v1alpha1_pipelineruns.golden | 4 + .../TestPipelineDescribe_with_run.golden | 4 + ...th_spec_multiple_resource_param_run.golden | 4 + ...scribe_with_spec_resource_param_run.golden | 4 + .../TestPipelineDescribe_with_spec_run.golden | 4 + test/builder/builder.go | 11 +++ 13 files changed, 169 insertions(+) create mode 100644 pkg/cmd/pipeline/testdata/TestPipelineDescribeV1beta1_with_workspaces.golden diff --git a/pkg/cmd/pipeline/describe.go b/pkg/cmd/pipeline/describe.go index 4b64e66e3..12e4beb1b 100644 --- a/pkg/cmd/pipeline/describe.go +++ b/pkg/cmd/pipeline/describe.go @@ -81,6 +81,16 @@ const describeTemplate = `{{decorate "bold" "Name"}}: {{ .PipelineName }} {{- end }} {{- end }} +{{decorate "workspaces" ""}}{{decorate "underline bold" "Workspaces\n"}} +{{- if eq (len .Pipeline.Spec.Workspaces) 0 }} + No workspaces +{{- else }} + NAME DESCRIPTION +{{- range $workspace := .Pipeline.Spec.Workspaces }} + {{ decorate "bullet" $workspace.Name }} {{ formatDesc $workspace.Description }} +{{- end }} +{{- end }} + {{decorate "tasks" ""}}{{decorate "underline bold" "Tasks\n"}} {{- $tl := len .Pipeline.Spec.Tasks }}{{ if eq $tl 0 }} No tasks diff --git a/pkg/cmd/pipeline/describe_test.go b/pkg/cmd/pipeline/describe_test.go index 84ea9b9c9..426a28e55 100644 --- a/pkg/cmd/pipeline/describe_test.go +++ b/pkg/cmd/pipeline/describe_test.go @@ -881,3 +881,82 @@ func TestPipelineDescribeV1beta1_with_results(t *testing.T) { } golden.Assert(t, got, fmt.Sprintf("%s.golden", t.Name())) } + +func TestPipelineDescribeV1beta1_with_workspaces(t *testing.T) { + clock := clockwork.NewFakeClock() + pipelines := []*v1beta1.Pipeline{ + { + ObjectMeta: metav1.ObjectMeta{ + Name: "pipeline", + Namespace: "ns", + }, + Spec: v1beta1.PipelineSpec{ + Resources: []v1beta1.PipelineDeclaredResource{ + { + Name: "name", + Type: v1alpha1.PipelineResourceTypeGit, + }, + }, + Tasks: []v1beta1.PipelineTask{ + { + Name: "task-1", + TaskRef: &v1beta1.TaskRef{ + Name: "task-1", + }, + }, + { + Name: "task-2", + TaskRef: &v1beta1.TaskRef{ + Name: "task-2", + }, + }, + }, + Results: []v1beta1.PipelineResult{ + { + Name: "result-1", + Description: "This is a description for result 1", + }, + { + Name: "result-2", + Description: "This is a description for result 2", + }, + { + Name: "result-3", + }, + }, + Workspaces: []v1beta1.PipelineWorkspaceDeclaration{ + { + Name: "test", + Description: "test workspace", + }, + }, + }, + }, + } + namespaces := []*corev1.Namespace{ + { + ObjectMeta: metav1.ObjectMeta{ + Name: "ns", + }, + }, + } + + version := "v1beta1" + tdc := testDynamic.Options{} + dynamic, err := tdc.Client( + cb.UnstructuredV1beta1P(pipelines[0], version), + ) + if err != nil { + t.Errorf("unable to create dynamic client: %v", err) + } + cs, _ := test.SeedV1beta1TestData(t, pipelinev1beta1test.Data{Namespaces: namespaces, Pipelines: pipelines}) + cs.Pipeline.Resources = cb.APIResourceList(version, []string{"pipeline", "pipelinerun"}) + p := &test.Params{Tekton: cs.Pipeline, Clock: clock, Kube: cs.Kube, Dynamic: dynamic} + pipeline := Command(p) + + got, err := test.ExecuteCommand(pipeline, "desc", "-n", "ns", "pipeline") + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + golden.Assert(t, got, fmt.Sprintf("%s.golden", t.Name())) +} diff --git a/pkg/cmd/pipeline/testdata/TestPipelineDescribeV1beta1_task_conditions.golden b/pkg/cmd/pipeline/testdata/TestPipelineDescribeV1beta1_task_conditions.golden index c68181803..db6e5eb9d 100644 --- a/pkg/cmd/pipeline/testdata/TestPipelineDescribeV1beta1_task_conditions.golden +++ b/pkg/cmd/pipeline/testdata/TestPipelineDescribeV1beta1_task_conditions.golden @@ -14,6 +14,10 @@ Results No results +Workspaces + + No workspaces + Tasks NAME TASKREF RUNAFTER TIMEOUT CONDITIONS PARAMS diff --git a/pkg/cmd/pipeline/testdata/TestPipelineDescribeV1beta1_with_results.golden b/pkg/cmd/pipeline/testdata/TestPipelineDescribeV1beta1_with_results.golden index 5628826cc..d1bc82319 100644 --- a/pkg/cmd/pipeline/testdata/TestPipelineDescribeV1beta1_with_results.golden +++ b/pkg/cmd/pipeline/testdata/TestPipelineDescribeV1beta1_with_results.golden @@ -17,6 +17,10 @@ Results result-2 This is a descripti... result-3 +Workspaces + + No workspaces + Tasks NAME TASKREF RUNAFTER TIMEOUT CONDITIONS PARAMS diff --git a/pkg/cmd/pipeline/testdata/TestPipelineDescribeV1beta1_with_spec_multiple_resource_param_run.golden b/pkg/cmd/pipeline/testdata/TestPipelineDescribeV1beta1_with_spec_multiple_resource_param_run.golden index c3ed7138c..a34f7eefb 100644 --- a/pkg/cmd/pipeline/testdata/TestPipelineDescribeV1beta1_with_spec_multiple_resource_param_run.golden +++ b/pkg/cmd/pipeline/testdata/TestPipelineDescribeV1beta1_with_spec_multiple_resource_param_run.golden @@ -22,6 +22,10 @@ Results No results +Workspaces + + No workspaces + Tasks NAME TASKREF RUNAFTER TIMEOUT CONDITIONS PARAMS diff --git a/pkg/cmd/pipeline/testdata/TestPipelineDescribeV1beta1_with_workspaces.golden b/pkg/cmd/pipeline/testdata/TestPipelineDescribeV1beta1_with_workspaces.golden new file mode 100644 index 000000000..7fdd1dac5 --- /dev/null +++ b/pkg/cmd/pipeline/testdata/TestPipelineDescribeV1beta1_with_workspaces.golden @@ -0,0 +1,33 @@ +Name: pipeline +Namespace: ns + +Resources + + NAME TYPE + name git + +Params + + No params + +Results + + NAME DESCRIPTION + result-1 This is a descripti... + result-2 This is a descripti... + result-3 + +Workspaces + + NAME DESCRIPTION + test test workspace + +Tasks + + NAME TASKREF RUNAFTER TIMEOUT CONDITIONS PARAMS + task-1 task-1 --- --- --- + task-2 task-2 --- --- --- + +PipelineRuns + + No pipelineruns diff --git a/pkg/cmd/pipeline/testdata/TestPipelineDescribe_empty.golden b/pkg/cmd/pipeline/testdata/TestPipelineDescribe_empty.golden index f9d2758b0..97a24d391 100644 --- a/pkg/cmd/pipeline/testdata/TestPipelineDescribe_empty.golden +++ b/pkg/cmd/pipeline/testdata/TestPipelineDescribe_empty.golden @@ -13,6 +13,10 @@ Results No results +Workspaces + + No workspaces + Tasks No tasks diff --git a/pkg/cmd/pipeline/testdata/TestPipelineDescribe_with_multiple_v1alpha1_pipelineruns.golden b/pkg/cmd/pipeline/testdata/TestPipelineDescribe_with_multiple_v1alpha1_pipelineruns.golden index 3d3cbf106..a28c1de30 100644 --- a/pkg/cmd/pipeline/testdata/TestPipelineDescribe_with_multiple_v1alpha1_pipelineruns.golden +++ b/pkg/cmd/pipeline/testdata/TestPipelineDescribe_with_multiple_v1alpha1_pipelineruns.golden @@ -16,6 +16,10 @@ Results No results +Workspaces + + No workspaces + Tasks NAME TASKREF RUNAFTER TIMEOUT CONDITIONS PARAMS diff --git a/pkg/cmd/pipeline/testdata/TestPipelineDescribe_with_run.golden b/pkg/cmd/pipeline/testdata/TestPipelineDescribe_with_run.golden index 38d4f18d9..65ffcb05a 100644 --- a/pkg/cmd/pipeline/testdata/TestPipelineDescribe_with_run.golden +++ b/pkg/cmd/pipeline/testdata/TestPipelineDescribe_with_run.golden @@ -13,6 +13,10 @@ Results No results +Workspaces + + No workspaces + Tasks No tasks diff --git a/pkg/cmd/pipeline/testdata/TestPipelineDescribe_with_spec_multiple_resource_param_run.golden b/pkg/cmd/pipeline/testdata/TestPipelineDescribe_with_spec_multiple_resource_param_run.golden index 62d7bee84..2357b5e65 100644 --- a/pkg/cmd/pipeline/testdata/TestPipelineDescribe_with_spec_multiple_resource_param_run.golden +++ b/pkg/cmd/pipeline/testdata/TestPipelineDescribe_with_spec_multiple_resource_param_run.golden @@ -23,6 +23,10 @@ Results No results +Workspaces + + No workspaces + Tasks NAME TASKREF RUNAFTER TIMEOUT CONDITIONS PARAMS diff --git a/pkg/cmd/pipeline/testdata/TestPipelineDescribe_with_spec_resource_param_run.golden b/pkg/cmd/pipeline/testdata/TestPipelineDescribe_with_spec_resource_param_run.golden index 5496642ff..74c7f7cb7 100644 --- a/pkg/cmd/pipeline/testdata/TestPipelineDescribe_with_spec_resource_param_run.golden +++ b/pkg/cmd/pipeline/testdata/TestPipelineDescribe_with_spec_resource_param_run.golden @@ -16,6 +16,10 @@ Results No results +Workspaces + + No workspaces + Tasks NAME TASKREF RUNAFTER TIMEOUT CONDITIONS PARAMS diff --git a/pkg/cmd/pipeline/testdata/TestPipelineDescribe_with_spec_run.golden b/pkg/cmd/pipeline/testdata/TestPipelineDescribe_with_spec_run.golden index 576fa80bc..8d505929a 100644 --- a/pkg/cmd/pipeline/testdata/TestPipelineDescribe_with_spec_run.golden +++ b/pkg/cmd/pipeline/testdata/TestPipelineDescribe_with_spec_run.golden @@ -14,6 +14,10 @@ Results No results +Workspaces + + No workspaces + Tasks NAME TASKREF RUNAFTER TIMEOUT CONDITIONS PARAMS diff --git a/test/builder/builder.go b/test/builder/builder.go index 29554757f..c34cee82b 100644 --- a/test/builder/builder.go +++ b/test/builder/builder.go @@ -670,6 +670,16 @@ const describeTemplate = `{{decorate "bold" "Name"}}: {{ .PipelineName }} {{- end }} {{- end }} +{{decorate "workspaces" ""}}{{decorate "underline bold" "Workspaces\n"}} +{{- if eq (len .Pipeline.Spec.Workspaces) 0 }} + No workspaces +{{- else }} + NAME DESCRIPTION +{{- range $workspace := .Pipeline.Spec.Workspaces }} + {{ decorate "bullet" $workspace.Name }} {{ formatDesc $workspace.Description }} +{{- end }} +{{- end }} + {{decorate "tasks" ""}}{{decorate "underline bold" "Tasks\n"}} {{- $tl := len .Pipeline.Spec.Tasks }}{{ if eq $tl 0 }} No tasks @@ -719,6 +729,7 @@ func GetPipelineDescribeOutput(t *testing.T, cs *framework.Clients, pname string "formatDuration": formatted.Duration, "formatCondition": formatted.Condition, "formatTimeout": formatted.Timeout, + "formatDesc": formatted.FormatDesc, "formatParam": formatted.Param, "decorate": formatted.DecorateAttr, "join": strings.Join, From 9b7e53d721da38af13b265c51dd3a52220ca8b1f Mon Sep 17 00:00:00 2001 From: vinamra28 Date: Wed, 26 Aug 2020 09:17:23 +0530 Subject: [PATCH 2/2] Display Workspaces in the output of PipelineRun describe command The workspaces declared in the PipelineRun will be displayed in the output of pipelinerun describe command. When we will do `tkn pipelinerun desc ` workspace name, subpath and workspace binding will be displayed in the output. Signed-off-by: vinamra28 --- pkg/cmd/pipelinerun/describe_test.go | 143 ++++++++++++++++++ .../TestPipelineRunDescribeV1beta1.golden | 4 + ...cribeV1beta1_taskrun_with_no_status.golden | 4 + ...neRunDescribe_cancelled_pipelinerun.golden | 4 + ...tPipelineRunDescribe_custom_timeout.golden | 4 + .../TestPipelineRunDescribe_failed.golden | 4 + ...nDescribe_failed_withoutPRCondition.golden | 4 + ...nDescribe_failed_withoutTRCondition.golden | 4 + .../TestPipelineRunDescribe_last.golden | 4 + ...TestPipelineRunDescribe_lastV1beta1.golden | 4 + ...nDescribe_multiple_taskrun_ordering.golden | 4 + ...tPipelineRunDescribe_no_resourceref.golden | 4 + ...estPipelineRunDescribe_only_taskrun.golden | 4 + ...ineRunDescribe_v1beta1_with_results.golden | 4 + ...RunDescribe_v1beta1_with_workspaces.golden | 36 +++++ ...eRunDescribe_with_resources_taskrun.golden | 4 + ...lineRunDescribe_without_pipelineref.golden | 4 + ...elineRunDescribe_without_start_time.golden | 4 + ...neRunDescribe_without_tr_start_time.golden | 4 + ...estPipelineRunDescribe_zero_timeout.golden | 4 + pkg/pipelinerun/description/description.go | 16 ++ 21 files changed, 267 insertions(+) create mode 100644 pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_v1beta1_with_workspaces.golden diff --git a/pkg/cmd/pipelinerun/describe_test.go b/pkg/cmd/pipelinerun/describe_test.go index 56e0656fc..b56020281 100644 --- a/pkg/cmd/pipelinerun/describe_test.go +++ b/pkg/cmd/pipelinerun/describe_test.go @@ -1773,3 +1773,146 @@ func TestPipelineRunDescribe_zero_timeout(t *testing.T) { golden.Assert(t, actual, fmt.Sprintf("%s.golden", t.Name())) } + +func TestPipelineRunDescribe_v1beta1_with_workspaces(t *testing.T) { + clock := clockwork.NewFakeClock() + pipelinerunname := "pipeline-run" + taskRuns := []*v1beta1.TaskRun{ + { + ObjectMeta: metav1.ObjectMeta{ + Namespace: "ns", + Name: "tr-1", + Labels: map[string]string{"tekton.dev/task": "task-1"}, + }, + Spec: v1beta1.TaskRunSpec{ + TaskRef: &v1beta1.TaskRef{ + Name: "task-1", + }, + }, + Status: v1beta1.TaskRunStatus{ + Status: duckv1beta1.Status{ + Conditions: duckv1beta1.Conditions{ + { + Status: corev1.ConditionFalse, + Reason: v1beta1.PipelineRunReasonFailed.String(), + }, + }, + }, + TaskRunStatusFields: v1beta1.TaskRunStatusFields{ + StartTime: &metav1.Time{Time: clock.Now()}, + CompletionTime: &metav1.Time{Time: clock.Now().Add(5 * time.Minute)}, + }, + }, + }, + } + + prun := []*v1beta1.PipelineRun{ + { + ObjectMeta: metav1.ObjectMeta{ + Name: pipelinerunname, + Namespace: "ns", + }, + Spec: v1beta1.PipelineRunSpec{ + PipelineRef: &v1beta1.PipelineRef{ + Name: "pipeline", + }, + Resources: []v1beta1.PipelineResourceBinding{ + { + Name: "res-1", + ResourceRef: &v1beta1.PipelineResourceRef{ + Name: "test-res", + }, + }, + }, + Params: []v1beta1.Param{ + { + Name: "p-1", + Value: v1beta1.ArrayOrString{ + Type: v1beta1.ParamTypeString, + StringVal: "somethingdifferent", + }, + }, + }, + Workspaces: []v1beta1.WorkspaceBinding{ + { + Name: "test", + SubPath: "test", + EmptyDir: &corev1.EmptyDirVolumeSource{}, + }, + { + Name: "configmap", + ConfigMap: &corev1.ConfigMapVolumeSource{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: "bar"}, + }, + }, + { + Name: "secret", + Secret: &corev1.SecretVolumeSource{ + SecretName: "foobar", + }, + }, + }, + }, + Status: v1beta1.PipelineRunStatus{ + Status: duckv1beta1.Status{ + Conditions: duckv1beta1.Conditions{ + { + Status: corev1.ConditionTrue, + Reason: v1beta1.PipelineRunReasonSuccessful.String(), + Message: "Completed", + }, + }, + }, + PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{ + StartTime: &metav1.Time{Time: clock.Now().Add(-10 * time.Minute)}, + CompletionTime: &metav1.Time{Time: clock.Now().Add(10 * time.Minute)}, + TaskRuns: map[string]*v1beta1.PipelineRunTaskRunStatus{ + "tr-1": { + PipelineTaskName: "t-1", + Status: &taskRuns[0].Status, + }, + }, + PipelineResults: []v1beta1.PipelineRunResult{ + { + Name: "result-1", + Value: "value-1", + }, + { + Name: "result-2", + Value: "value-2", + }, + }, + }, + }, + }, + } + + namespaces := []*corev1.Namespace{ + { + ObjectMeta: metav1.ObjectMeta{ + Name: "ns", + }, + }, + } + + version := "v1beta1" + tdc := testDynamic.Options{} + dynamic, err := tdc.Client( + cb.UnstructuredV1beta1PR(prun[0], version), + cb.UnstructuredV1beta1TR(taskRuns[0], version), + ) + if err != nil { + t.Errorf("unable to create dynamic client: %v", err) + } + cs, _ := test.SeedV1beta1TestData(t, pipelinev1beta1test.Data{Namespaces: namespaces, PipelineRuns: prun, TaskRuns: taskRuns}) + cs.Pipeline.Resources = cb.APIResourceList(version, []string{"pipelinerun", "taskrun"}) + p := &test.Params{Tekton: cs.Pipeline, Kube: cs.Kube, Dynamic: dynamic} + + pipelinerun := Command(p) + got, err := test.ExecuteCommand(pipelinerun, "desc", "-n", "ns", "--last") + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + golden.Assert(t, got, fmt.Sprintf("%s.golden", t.Name())) +} diff --git a/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribeV1beta1.golden b/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribeV1beta1.golden index 5d58add4f..fe1ba5eb1 100644 --- a/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribeV1beta1.golden +++ b/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribeV1beta1.golden @@ -23,6 +23,10 @@ Results No results +Workspaces + + No workspaces + Taskruns NAME TASK NAME STARTED DURATION STATUS diff --git a/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribeV1beta1_taskrun_with_no_status.golden b/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribeV1beta1_taskrun_with_no_status.golden index 37a869e67..da32fe703 100644 --- a/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribeV1beta1_taskrun_with_no_status.golden +++ b/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribeV1beta1_taskrun_with_no_status.golden @@ -23,6 +23,10 @@ Results No results +Workspaces + + No workspaces + Taskruns NAME TASK NAME STARTED DURATION STATUS diff --git a/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_cancelled_pipelinerun.golden b/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_cancelled_pipelinerun.golden index c29bd96ad..1c4488a5f 100644 --- a/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_cancelled_pipelinerun.golden +++ b/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_cancelled_pipelinerun.golden @@ -26,6 +26,10 @@ Results No results +Workspaces + + No workspaces + Taskruns NAME TASK NAME STARTED DURATION STATUS diff --git a/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_custom_timeout.golden b/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_custom_timeout.golden index 6b92788fc..21456eb66 100644 --- a/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_custom_timeout.golden +++ b/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_custom_timeout.golden @@ -20,6 +20,10 @@ Results No results +Workspaces + + No workspaces + Taskruns No taskruns diff --git a/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_failed.golden b/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_failed.golden index d6bbd7d5c..60af74529 100644 --- a/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_failed.golden +++ b/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_failed.golden @@ -27,6 +27,10 @@ Results No results +Workspaces + + No workspaces + Taskruns NAME TASK NAME STARTED DURATION STATUS diff --git a/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_failed_withoutPRCondition.golden b/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_failed_withoutPRCondition.golden index 3ede0a0e4..08fabb1f2 100644 --- a/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_failed_withoutPRCondition.golden +++ b/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_failed_withoutPRCondition.golden @@ -23,6 +23,10 @@ Results No results +Workspaces + + No workspaces + Taskruns NAME TASK NAME STARTED DURATION STATUS diff --git a/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_failed_withoutTRCondition.golden b/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_failed_withoutTRCondition.golden index 9c836ef3a..0ee4f4ec5 100644 --- a/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_failed_withoutTRCondition.golden +++ b/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_failed_withoutTRCondition.golden @@ -27,6 +27,10 @@ Results No results +Workspaces + + No workspaces + Taskruns NAME TASK NAME STARTED DURATION STATUS diff --git a/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_last.golden b/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_last.golden index 019ef67d2..ad6a55e43 100644 --- a/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_last.golden +++ b/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_last.golden @@ -22,6 +22,10 @@ Results No results +Workspaces + + No workspaces + Taskruns NAME TASK NAME STARTED DURATION STATUS diff --git a/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_lastV1beta1.golden b/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_lastV1beta1.golden index 0e38a9302..a45bbc9cf 100644 --- a/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_lastV1beta1.golden +++ b/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_lastV1beta1.golden @@ -23,6 +23,10 @@ Results No results +Workspaces + + No workspaces + Taskruns NAME TASK NAME STARTED DURATION STATUS diff --git a/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_multiple_taskrun_ordering.golden b/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_multiple_taskrun_ordering.golden index edada9fe5..33f97f800 100644 --- a/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_multiple_taskrun_ordering.golden +++ b/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_multiple_taskrun_ordering.golden @@ -22,6 +22,10 @@ Results No results +Workspaces + + No workspaces + Taskruns NAME TASK NAME STARTED DURATION STATUS diff --git a/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_no_resourceref.golden b/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_no_resourceref.golden index 37fb6caf3..0125ded27 100644 --- a/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_no_resourceref.golden +++ b/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_no_resourceref.golden @@ -25,6 +25,10 @@ Results No results +Workspaces + + No workspaces + Taskruns NAME TASK NAME STARTED DURATION STATUS diff --git a/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_only_taskrun.golden b/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_only_taskrun.golden index 478572fa1..5fe484120 100644 --- a/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_only_taskrun.golden +++ b/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_only_taskrun.golden @@ -22,6 +22,10 @@ Results No results +Workspaces + + No workspaces + Taskruns NAME TASK NAME STARTED DURATION STATUS diff --git a/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_v1beta1_with_results.golden b/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_v1beta1_with_results.golden index debe54a67..5fa45eed4 100644 --- a/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_v1beta1_with_results.golden +++ b/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_v1beta1_with_results.golden @@ -23,6 +23,10 @@ Results result-1 value-1 result-2 value-2 +Workspaces + + No workspaces + Taskruns NAME TASK NAME STARTED DURATION STATUS diff --git a/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_v1beta1_with_workspaces.golden b/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_v1beta1_with_workspaces.golden new file mode 100644 index 000000000..38bcf7793 --- /dev/null +++ b/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_v1beta1_with_workspaces.golden @@ -0,0 +1,36 @@ +Name: pipeline-run +Namespace: ns +Pipeline Ref: pipeline + +Status + +STARTED DURATION STATUS +10 minutes ago 20 minutes Succeeded + +Resources + + NAME RESOURCE REF + res-1 test-res + +Params + + NAME VALUE + p-1 somethingdifferent + +Results + + NAME VALUE + result-1 value-1 + result-2 value-2 + +Workspaces + + NAME SUB PATH WORKSPACE BINDING + test test EmptyDir (emptyDir=) + configmap --- ConfigMap (config=bar) + secret --- Secret (secret=foobar) + +Taskruns + + NAME TASK NAME STARTED DURATION STATUS + tr-1 t-1 0 seconds ago 5 minutes Failed diff --git a/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_with_resources_taskrun.golden b/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_with_resources_taskrun.golden index bab0d05b5..4b89b95bc 100644 --- a/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_with_resources_taskrun.golden +++ b/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_with_resources_taskrun.golden @@ -25,6 +25,10 @@ Results No results +Workspaces + + No workspaces + Taskruns NAME TASK NAME STARTED DURATION STATUS diff --git a/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_without_pipelineref.golden b/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_without_pipelineref.golden index 6614cf062..1a2dada53 100644 --- a/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_without_pipelineref.golden +++ b/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_without_pipelineref.golden @@ -20,6 +20,10 @@ Results No results +Workspaces + + No workspaces + Taskruns No taskruns diff --git a/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_without_start_time.golden b/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_without_start_time.golden index ca4a0611b..2682c3668 100644 --- a/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_without_start_time.golden +++ b/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_without_start_time.golden @@ -22,6 +22,10 @@ Results No results +Workspaces + + No workspaces + Taskruns No taskruns diff --git a/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_without_tr_start_time.golden b/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_without_tr_start_time.golden index 4618687ba..583ed07ee 100644 --- a/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_without_tr_start_time.golden +++ b/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_without_tr_start_time.golden @@ -22,6 +22,10 @@ Results No results +Workspaces + + No workspaces + Taskruns NAME TASK NAME STARTED DURATION STATUS diff --git a/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_zero_timeout.golden b/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_zero_timeout.golden index 51505f3dc..ad51d3931 100644 --- a/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_zero_timeout.golden +++ b/pkg/cmd/pipelinerun/testdata/TestPipelineRunDescribe_zero_timeout.golden @@ -19,6 +19,10 @@ Results No results +Workspaces + + No workspaces + Taskruns No taskruns diff --git a/pkg/pipelinerun/description/description.go b/pkg/pipelinerun/description/description.go index 07ee233d6..74330d9fa 100644 --- a/pkg/pipelinerun/description/description.go +++ b/pkg/pipelinerun/description/description.go @@ -97,6 +97,21 @@ STARTED DURATION STATUS {{- end }} {{- end }} +{{decorate "workspaces" ""}}{{decorate "underline bold" "Workspaces\n"}} + +{{- if eq (len .PipelineRun.Spec.Workspaces) 0 }} + No workspaces +{{- else }} + NAME SUB PATH WORKSPACE BINDING +{{- range $workspace := .PipelineRun.Spec.Workspaces }} +{{- if not $workspace.SubPath }} + {{ decorate "bullet" $workspace.Name }} {{ "---" }} {{ formatWorkspace $workspace }} +{{- else }} + {{ decorate "bullet" $workspace.Name }} {{ $workspace.SubPath }} {{ formatWorkspace $workspace }} +{{- end }} +{{- end }} +{{- end }} + {{decorate "taskruns" ""}}{{decorate "underline bold" "Taskruns\n"}} {{- $l := len .TaskrunList }}{{ if eq $l 0 }} No taskruns @@ -173,6 +188,7 @@ func PrintPipelineRunDescription(s *cli.Stream, prName string, p cli.Params) err "formatDuration": formatted.Duration, "formatCondition": formatted.Condition, "formatResult": formatted.Result, + "formatWorkspace": formatted.Workspace, "hasFailed": hasFailed, "pipelineRefExists": pipelineRefExists, "pipelineResourceRefExists": pipelineResourceRefExists,