Skip to content

Commit

Permalink
Display Workspaces in the output of PipelineRun describe command
Browse files Browse the repository at this point in the history
The workspaces declared in the PipelineRun will be displayed in the output of pipelinerun describe command. When we will do `tkn pipelinerun desc <name>` workspace name, subpath and workspace binding will be displayed in the output.

Signed-off-by: vinamra28 <vinjain@redhat.com>
  • Loading branch information
vinamra28 authored and tekton-robot committed Aug 26, 2020
1 parent ffd3d04 commit a77f5ff
Show file tree
Hide file tree
Showing 21 changed files with 267 additions and 0 deletions.
143 changes: 143 additions & 0 deletions pkg/cmd/pipelinerun/describe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ Results

No results

Workspaces

No workspaces

Taskruns

NAME TASK NAME STARTED DURATION STATUS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ Results

No results

Workspaces

No workspaces

Taskruns

NAME TASK NAME STARTED DURATION STATUS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ Results

No results

Workspaces

No workspaces

Taskruns

NAME TASK NAME STARTED DURATION STATUS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ Results

No results

Workspaces

No workspaces

Taskruns

No taskruns
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ Results

No results

Workspaces

No workspaces

Taskruns

NAME TASK NAME STARTED DURATION STATUS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ Results

No results

Workspaces

No workspaces

Taskruns

NAME TASK NAME STARTED DURATION STATUS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ Results

No results

Workspaces

No workspaces

Taskruns

NAME TASK NAME STARTED DURATION STATUS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ Results

No results

Workspaces

No workspaces

Taskruns

NAME TASK NAME STARTED DURATION STATUS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ Results

No results

Workspaces

No workspaces

Taskruns

NAME TASK NAME STARTED DURATION STATUS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ Results

No results

Workspaces

No workspaces

Taskruns

NAME TASK NAME STARTED DURATION STATUS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ Results

No results

Workspaces

No workspaces

Taskruns

NAME TASK NAME STARTED DURATION STATUS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ Results

No results

Workspaces

No workspaces

Taskruns

NAME TASK NAME STARTED DURATION STATUS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ Results
result-1 value-1
result-2 value-2

Workspaces

No workspaces

Taskruns

NAME TASK NAME STARTED DURATION STATUS
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ Results

No results

Workspaces

No workspaces

Taskruns

NAME TASK NAME STARTED DURATION STATUS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ Results

No results

Workspaces

No workspaces

Taskruns

No taskruns
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ Results

No results

Workspaces

No workspaces

Taskruns

No taskruns
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ Results

No results

Workspaces

No workspaces

Taskruns

NAME TASK NAME STARTED DURATION STATUS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ Results

No results

Workspaces

No workspaces

Taskruns

No taskruns
Loading

0 comments on commit a77f5ff

Please sign in to comment.