Skip to content

Commit

Permalink
Remove input and output resource in clustertask describe command
Browse files Browse the repository at this point in the history
As Pipelineresources have been removed in 0.46 pipeline
so this patch removes input and output resource in the
clustertask describe command

Closes part of: #1657

Signed-off-by: Shiv Verma <[email protected]>
  • Loading branch information
pratap0007 committed Apr 14, 2023
1 parent 0595617 commit a6cc853
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 163 deletions.
44 changes: 0 additions & 44 deletions pkg/cmd/clustertask/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package clustertask

import (
"fmt"
"sort"
"text/tabwriter"
"text/template"

Expand Down Expand Up @@ -46,27 +45,6 @@ const describeTemplate = `{{decorate "bold" "Name"}}: {{ .ClusterTask.Name }}
{{- end }}
{{- end }}
{{- if .ClusterTask.Spec.Resources }}
{{decorate "inputresources" ""}}{{decorate "underline bold" "Input Resources\n"}}
{{- if ne (len .ClusterTask.Spec.Resources.Inputs) 0 }}
NAME TYPE
{{- range $ir := .ClusterTask.Spec.Resources.Inputs }}
{{decorate "bullet" $ir.Name }} {{ $ir.Type }}
{{- end }}
{{- end }}
{{- if ne (len .ClusterTask.Spec.Resources.Outputs) 0 }}
{{decorate "outputresources" ""}}{{decorate "underline bold" "Output Resources\n"}}
NAME TYPE
{{- range $or := .ClusterTask.Spec.Resources.Outputs }}
{{decorate "bullet" $or.Name }} {{ $or.Type }}
{{- end }}
{{- end }}
{{- end }}
{{- if ne (len .ClusterTask.Spec.Params) 0 }}
{{decorate "params" ""}}{{decorate "underline bold" "Params\n"}}
Expand Down Expand Up @@ -197,11 +175,6 @@ func printClusterTaskDescription(s *cli.Stream, cs *cli.Clients, ctname, namespa
return fmt.Errorf("failed to get ClusterTask %s", ctname)
}

if clustertask.Spec.Resources != nil {
clustertask.Spec.Resources.Inputs = sortResourcesByTypeAndName(clustertask.Spec.Resources.Inputs)
clustertask.Spec.Resources.Outputs = sortResourcesByTypeAndName(clustertask.Spec.Resources.Outputs)
}

opts := metav1.ListOptions{
LabelSelector: fmt.Sprintf("tekton.dev/clusterTask=%s", ctname),
}
Expand Down Expand Up @@ -242,23 +215,6 @@ func printClusterTaskDescription(s *cli.Stream, cs *cli.Clients, ctname, namespa
return w.Flush()
}

// this will sort the ClusterTask Resource by Type and then by Name
func sortResourcesByTypeAndName(tres []v1beta1.TaskResource) []v1beta1.TaskResource {
sort.Slice(tres, func(i, j int) bool {
if tres[j].Type < tres[i].Type {
return false
}

if tres[j].Type > tres[i].Type {
return true
}

return tres[j].Name > tres[i].Name
})

return tres
}

func askClusterTaskName(opts *options.DescribeOptions, clusterTaskNames []string) error {
if len(clusterTaskNames) == 0 {
return fmt.Errorf("no ClusterTasks found")
Expand Down
98 changes: 0 additions & 98 deletions pkg/cmd/clustertask/describe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,30 +45,6 @@ func Test_ClusterTaskDescribe(t *testing.T) {
CreationTimestamp: metav1.Time{Time: clock.Now().Add(1 * time.Minute)},
},
Spec: v1beta1.TaskSpec{
Resources: &v1beta1.TaskResources{
Inputs: []v1beta1.TaskResource{
{
ResourceDeclaration: v1beta1.ResourceDeclaration{
Name: "my-repo",
Type: v1beta1.PipelineResourceTypeGit,
},
},
{
ResourceDeclaration: v1beta1.ResourceDeclaration{
Name: "my-image",
Type: v1beta1.PipelineResourceTypeImage,
},
},
},
Outputs: []v1beta1.TaskResource{
{
ResourceDeclaration: v1beta1.ResourceDeclaration{
Name: "code-image",
Type: v1beta1.PipelineResourceTypeImage,
},
},
},
},
Params: []v1beta1.ParamSpec{
{
Name: "myarg",
Expand Down Expand Up @@ -108,24 +84,6 @@ func Test_ClusterTaskDescribe(t *testing.T) {
},
Spec: v1beta1.TaskSpec{
Description: "a test description",
Resources: &v1beta1.TaskResources{
Inputs: []v1beta1.TaskResource{
{
ResourceDeclaration: v1beta1.ResourceDeclaration{
Name: "my-repo",
Type: v1beta1.PipelineResourceTypeGit,
},
},
},
Outputs: []v1beta1.TaskResource{
{
ResourceDeclaration: v1beta1.ResourceDeclaration{
Name: "code-image",
Type: v1beta1.PipelineResourceTypeImage,
},
},
},
},
Params: []v1beta1.ParamSpec{
{
Name: "myarg",
Expand Down Expand Up @@ -179,28 +137,6 @@ func Test_ClusterTaskDescribe(t *testing.T) {
},
},
},
Resources: &v1beta1.TaskRunResources{
Inputs: []v1beta1.TaskResourceBinding{
{
PipelineResourceBinding: v1beta1.PipelineResourceBinding{
Name: "my-repo",
ResourceRef: &v1beta1.PipelineResourceRef{
Name: "git",
},
},
},
},
Outputs: []v1beta1.TaskResourceBinding{
{
PipelineResourceBinding: v1beta1.PipelineResourceBinding{
Name: "my-image",
ResourceRef: &v1beta1.PipelineResourceRef{
Name: "image",
},
},
},
},
},
},
Status: v1beta1.TaskRunStatus{
Status: duckv1.Status{
Expand Down Expand Up @@ -240,18 +176,6 @@ func Test_ClusterTaskDescribe(t *testing.T) {
},
},
},
Resources: &v1beta1.TaskRunResources{
Inputs: []v1beta1.TaskResourceBinding{
{
PipelineResourceBinding: v1beta1.PipelineResourceBinding{
Name: "my-repo",
ResourceRef: &v1beta1.PipelineResourceRef{
Name: "git",
},
},
},
},
},
},
Status: v1beta1.TaskRunStatus{
Status: duckv1.Status{
Expand Down Expand Up @@ -298,28 +222,6 @@ func Test_ClusterTaskDescribe(t *testing.T) {
},
},
},
Resources: &v1beta1.TaskRunResources{
Inputs: []v1beta1.TaskResourceBinding{
{
PipelineResourceBinding: v1beta1.PipelineResourceBinding{
Name: "my-repo",
ResourceRef: &v1beta1.PipelineResourceRef{
Name: "git",
},
},
},
},
Outputs: []v1beta1.TaskResourceBinding{
{
PipelineResourceBinding: v1beta1.PipelineResourceBinding{
Name: "my-image",
ResourceRef: &v1beta1.PipelineResourceRef{
Name: "image",
},
},
},
},
},
},
Status: v1beta1.TaskRunStatus{
Status: duckv1.Status{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,6 @@ Command "describe" is deprecated, ClusterTasks are deprecated, this command will
Name: clustertask-one-everything
Description: a test description

Input Resources

NAME TYPE
my-repo git

Output Resources

NAME TYPE
code-image image

Params

NAME TYPE DESCRIPTION DEFAULT VALUE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
Command "describe" is deprecated, ClusterTasks are deprecated, this command will be removed in future releases.
Name: clustertask-full

Input Resources

NAME TYPE
my-repo git
my-image image

Output Resources

NAME TYPE
code-image image

Params

NAME TYPE DESCRIPTION DEFAULT VALUE
Expand Down

0 comments on commit a6cc853

Please sign in to comment.