Skip to content

Commit

Permalink
Add deprecations for resources and clustertask
Browse files Browse the repository at this point in the history
This will add deprecations for flags related to resources in
start cmds of pipeline, task and clustertask

Also add deprecation for all clustertask commands as they
are deprecated

And add deprecation for tkn task create commands as clustertask
are deprecated

Part of tektoncd#1804
  • Loading branch information
piyush-garg committed Mar 23, 2023
1 parent 8b7b561 commit 2388fef
Show file tree
Hide file tree
Showing 69 changed files with 199 additions and 92 deletions.
1 change: 0 additions & 1 deletion docs/cmd/tkn.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ CLI for tekton pipelines

* [tkn bundle](tkn_bundle.md) - Manage Tekton Bundles
* [tkn chain](tkn_chain.md) - Manage Chains
* [tkn clustertask](tkn_clustertask.md) - Manage ClusterTasks
* [tkn clustertriggerbinding](tkn_clustertriggerbinding.md) - Manage ClusterTriggerBindings
* [tkn completion](tkn_completion.md) - Prints shell completion scripts
* [tkn eventlistener](tkn_eventlistener.md) - Manage EventListeners
Expand Down
2 changes: 0 additions & 2 deletions docs/cmd/tkn_clustertask_start.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,9 @@ For passing the workspaces via flags:
```
--dry-run preview TaskRun without running it
-h, --help help for start
-i, --inputresource strings pass the input resource name and ref as name=ref
-l, --labels strings pass labels as label=value.
-L, --last re-run the ClusterTask using last TaskRun values
--output string format of TaskRun (yaml or json)
-o, --outputresource strings pass the output resource name and ref as name=ref
-p, --param stringArray pass the param as key=value for string type, or key=value1,value2,... for array type, or key="key1:value1, key2:value2" for object type
--pod-template string local or remote file containing a PodTemplate definition
--prefix-name string specify a prefix for the TaskRun name (must be lowercase alphanumeric characters)
Expand Down
1 change: 0 additions & 1 deletion docs/cmd/tkn_pipeline_start.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ my-secret, my-empty-dir and my-volume-claim-template)
--pipeline-timeout string timeout for PipelineRun
--pod-template string local or remote file containing a PodTemplate definition
--prefix-name string specify a prefix for the PipelineRun name (must be lowercase alphanumeric characters)
-r, --resource strings pass the resource name and ref as name=ref
-s, --serviceaccount string pass the serviceaccount name
--showlog show logs right after starting the Pipeline
--skip-optional-workspace skips the prompt for optional workspaces
Expand Down
1 change: 0 additions & 1 deletion docs/cmd/tkn_task.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Manage Tasks
### SEE ALSO

* [tkn](tkn.md) - CLI for tekton pipelines
* [tkn task create](tkn_task_create.md) - Create a Task from ClusterTask
* [tkn task delete](tkn_task_delete.md) - Delete Tasks in a namespace
* [tkn task describe](tkn_task_describe.md) - Describe a Task in a namespace
* [tkn task list](tkn_task_list.md) - Lists Tasks in a namespace
Expand Down
2 changes: 0 additions & 2 deletions docs/cmd/tkn_task_start.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,9 @@ For passing the workspaces via flags:
--dry-run preview TaskRun without running it
-f, --filename string local or remote file name containing a Task definition to start a TaskRun
-h, --help help for start
-i, --inputresource strings pass the input resource name and ref as name=ref
-l, --labels strings pass labels as label=value.
-L, --last re-run the Task using last TaskRun values
--output string format of TaskRun (yaml or json)
-o, --outputresource strings pass the output resource name and ref as name=ref
-p, --param stringArray pass the param as key=value for string type, or key=value1,value2,... for array type, or key="key1:value1, key2:value2" for object type
--pod-template string local or remote file containing a PodTemplate definition
--prefix-name string specify a prefix for the TaskRun name (must be lowercase alphanumeric characters)
Expand Down
8 changes: 0 additions & 8 deletions docs/man/man1/tkn-clustertask-start.1
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ Start ClusterTasks
\fB\-h\fP, \fB\-\-help\fP[=false]
help for start

.PP
\fB\-i\fP, \fB\-\-inputresource\fP=[]
pass the input resource name and ref as name=ref

.PP
\fB\-l\fP, \fB\-\-labels\fP=[]
pass labels as label=value.
Expand All @@ -43,10 +39,6 @@ Start ClusterTasks
\fB\-\-output\fP=""
format of TaskRun (yaml or json)

.PP
\fB\-o\fP, \fB\-\-outputresource\fP=[]
pass the output resource name and ref as name=ref

.PP
\fB\-p\fP, \fB\-\-param\fP=[]
pass the param as key=value for string type, or key=value1,value2,... for array type, or key="key1:value1, key2:value2" for object type
Expand Down
4 changes: 0 additions & 4 deletions docs/man/man1/tkn-pipeline-start.1
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ Parameters, at least those that have no default value
\fB\-\-prefix\-name\fP=""
specify a prefix for the PipelineRun name (must be lowercase alphanumeric characters)

.PP
\fB\-r\fP, \fB\-\-resource\fP=[]
pass the resource name and ref as name=ref

.PP
\fB\-s\fP, \fB\-\-serviceaccount\fP=""
pass the serviceaccount name
Expand Down
8 changes: 0 additions & 8 deletions docs/man/man1/tkn-task-start.1
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ Start Tasks
\fB\-h\fP, \fB\-\-help\fP[=false]
help for start

.PP
\fB\-i\fP, \fB\-\-inputresource\fP=[]
pass the input resource name and ref as name=ref

.PP
\fB\-l\fP, \fB\-\-labels\fP=[]
pass labels as label=value.
Expand All @@ -47,10 +43,6 @@ Start Tasks
\fB\-\-output\fP=""
format of TaskRun (yaml or json)

.PP
\fB\-o\fP, \fB\-\-outputresource\fP=[]
pass the output resource name and ref as name=ref

.PP
\fB\-p\fP, \fB\-\-param\fP=[]
pass the param as key=value for string type, or key=value1,value2,... for array type, or key="key1:value1, key2:value2" for object type
Expand Down
2 changes: 1 addition & 1 deletion docs/man/man1/tkn-task.1
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ Manage Tasks

.SH SEE ALSO
.PP
\fBtkn(1)\fP, \fBtkn\-task\-create(1)\fP, \fBtkn\-task\-delete(1)\fP, \fBtkn\-task\-describe(1)\fP, \fBtkn\-task\-list(1)\fP, \fBtkn\-task\-logs(1)\fP, \fBtkn\-task\-sign(1)\fP, \fBtkn\-task\-start(1)\fP, \fBtkn\-task\-verify(1)\fP
\fBtkn(1)\fP, \fBtkn\-task\-delete(1)\fP, \fBtkn\-task\-describe(1)\fP, \fBtkn\-task\-list(1)\fP, \fBtkn\-task\-logs(1)\fP, \fBtkn\-task\-sign(1)\fP, \fBtkn\-task\-start(1)\fP, \fBtkn\-task\-verify(1)\fP
2 changes: 1 addition & 1 deletion docs/man/man1/tkn.1
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ CLI for tekton pipelines

.SH SEE ALSO
.PP
\fBtkn\-bundle(1)\fP, \fBtkn\-chain(1)\fP, \fBtkn\-clustertask(1)\fP, \fBtkn\-clustertriggerbinding(1)\fP, \fBtkn\-completion(1)\fP, \fBtkn\-eventlistener(1)\fP, \fBtkn\-hub(1)\fP, \fBtkn\-pipeline(1)\fP, \fBtkn\-pipelinerun(1)\fP, \fBtkn\-task(1)\fP, \fBtkn\-taskrun(1)\fP, \fBtkn\-triggerbinding(1)\fP, \fBtkn\-triggertemplate(1)\fP, \fBtkn\-version(1)\fP
\fBtkn\-bundle(1)\fP, \fBtkn\-chain(1)\fP, \fBtkn\-clustertriggerbinding(1)\fP, \fBtkn\-completion(1)\fP, \fBtkn\-eventlistener(1)\fP, \fBtkn\-hub(1)\fP, \fBtkn\-pipeline(1)\fP, \fBtkn\-pipelinerun(1)\fP, \fBtkn\-task(1)\fP, \fBtkn\-taskrun(1)\fP, \fBtkn\-triggerbinding(1)\fP, \fBtkn\-triggertemplate(1)\fP, \fBtkn\-version(1)\fP
1 change: 1 addition & 0 deletions pkg/cmd/clustertask/clustertask.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@ func Command(p cli.Params) *cobra.Command {
logCommand(p),
createCommand(p),
)
cmd.Deprecated = "ClusterTasks are deprecated, this command will be removed in future releases."
return cmd
}
1 change: 1 addition & 0 deletions pkg/cmd/clustertask/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ or
},
}
c.Flags().StringVarP(&opts.From, "from", "", "", "Create a ClusterTask from Task in a particular namespace")
c.Deprecated = "ClusterTasks are deprecated, this command will be removed in future releases."
return c
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/cmd/clustertask/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func TestCreate_TaskNotExist(t *testing.T) {
if err == nil {
t.Errorf("Expected error got nil")
}
expected := "Error: Task t-1 does not exist in namespace default\n"
expected := "Command \"create\" is deprecated, ClusterTasks are deprecated, this command will be removed in future releases.\nError: Task t-1 does not exist in namespace default\n"
test.AssertOutput(t, expected, out)
}

Expand Down Expand Up @@ -95,7 +95,7 @@ func TestCreate(t *testing.T) {
if err != nil {
t.Errorf("Unexpected error: %v", err)
}
expected := "ClusterTask ct-1 created from Task t-1 present in namespace default\n"
expected := "Command \"create\" is deprecated, ClusterTasks are deprecated, this command will be removed in future releases.\nClusterTask ct-1 created from Task t-1 present in namespace default\n"
test.AssertOutput(t, expected, out)
}

Expand Down Expand Up @@ -139,7 +139,7 @@ func TestCreate_InNamespace(t *testing.T) {
if err != nil {
t.Errorf("Unexpected error: %v", err)
}
expected := "ClusterTask t-1 created from Task t-1 present in namespace ns\n"
expected := "Command \"create\" is deprecated, ClusterTasks are deprecated, this command will be removed in future releases.\nClusterTask t-1 created from Task t-1 present in namespace ns\n"
test.AssertOutput(t, expected, out)
}

Expand Down Expand Up @@ -174,7 +174,7 @@ func TestCreate_WithoutFlag(t *testing.T) {
if err == nil {
t.Errorf("Expected error got nil")
}
expected := "Error: --from flag not passed\n"
expected := "Command \"create\" is deprecated, ClusterTasks are deprecated, this command will be removed in future releases.\nError: --from flag not passed\n"
test.AssertOutput(t, expected, out)
}

Expand Down
1 change: 1 addition & 0 deletions pkg/cmd/clustertask/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ or
c.Flags().BoolVarP(&opts.ForceDelete, "force", "f", false, "Whether to force deletion (default: false)")
c.Flags().BoolVarP(&opts.DeleteAll, "all", "", false, "Delete all ClusterTasks (default: false)")
c.Flags().BoolVarP(&opts.DeleteRelated, "trs", "", false, "Whether to delete ClusterTask(s) and related resources (TaskRuns) (default: false)")
c.Deprecated = "ClusterTasks are deprecated, this command will be removed in future releases."
return c
}
func deleteClusterTasks(opts *options.DeleteOptions, s *cli.Stream, p cli.Params, ctNames []string) error {
Expand Down
16 changes: 8 additions & 8 deletions pkg/cmd/clustertask/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func TestClusterTaskDelete(t *testing.T) {
input: seeds[0].pipelineClient,
inputStream: nil,
wantError: false,
want: "ClusterTasks deleted: \"tomatoes\"\n",
want: "Command \"delete\" is deprecated, ClusterTasks are deprecated, this command will be removed in future releases.\nClusterTasks deleted: \"tomatoes\"\n",
},
{
name: "With force delete flag",
Expand All @@ -184,7 +184,7 @@ func TestClusterTaskDelete(t *testing.T) {
input: seeds[1].pipelineClient,
inputStream: nil,
wantError: false,
want: "ClusterTasks deleted: \"tomatoes\"\n",
want: "Command \"delete\" is deprecated, ClusterTasks are deprecated, this command will be removed in future releases.\nClusterTasks deleted: \"tomatoes\"\n",
},
{
name: "Without force delete flag, reply no",
Expand All @@ -202,7 +202,7 @@ func TestClusterTaskDelete(t *testing.T) {
input: seeds[3].pipelineClient,
inputStream: strings.NewReader("y"),
wantError: false,
want: "Are you sure you want to delete ClusterTask(s) \"tomatoes\" (y/n): ClusterTasks deleted: \"tomatoes\"\n",
want: "Command \"delete\" is deprecated, ClusterTasks are deprecated, this command will be removed in future releases.\nAre you sure you want to delete ClusterTask(s) \"tomatoes\" (y/n): ClusterTasks deleted: \"tomatoes\"\n",
},
{
name: "Remove non existent resource",
Expand Down Expand Up @@ -238,7 +238,7 @@ func TestClusterTaskDelete(t *testing.T) {
input: seeds[4].pipelineClient,
inputStream: strings.NewReader("y"),
wantError: false,
want: "Are you sure you want to delete ClusterTask(s) \"tomatoes\" and related resources (y/n): TaskRuns deleted: \"task-run-1\", \"task-run-2\"\nClusterTasks deleted: \"tomatoes\"\n",
want: "Command \"delete\" is deprecated, ClusterTasks are deprecated, this command will be removed in future releases.\nAre you sure you want to delete ClusterTask(s) \"tomatoes\" and related resources (y/n): TaskRuns deleted: \"task-run-1\", \"task-run-2\"\nClusterTasks deleted: \"tomatoes\"\n",
},
{
name: "With force delete flag, reply yes, multiple clustertasks",
Expand All @@ -247,7 +247,7 @@ func TestClusterTaskDelete(t *testing.T) {
input: seeds[1].pipelineClient,
inputStream: strings.NewReader("y"),
wantError: false,
want: "ClusterTasks deleted: \"tomatoes2\", \"tomatoes3\"\n",
want: "Command \"delete\" is deprecated, ClusterTasks are deprecated, this command will be removed in future releases.\nClusterTasks deleted: \"tomatoes2\", \"tomatoes3\"\n",
},
{
name: "Without force delete flag, reply yes, multiple clustertasks",
Expand All @@ -256,7 +256,7 @@ func TestClusterTaskDelete(t *testing.T) {
input: seeds[2].pipelineClient,
inputStream: strings.NewReader("y"),
wantError: false,
want: "Are you sure you want to delete ClusterTask(s) \"tomatoes2\", \"tomatoes3\" (y/n): ClusterTasks deleted: \"tomatoes2\", \"tomatoes3\"\n",
want: "Command \"delete\" is deprecated, ClusterTasks are deprecated, this command will be removed in future releases.\nAre you sure you want to delete ClusterTask(s) \"tomatoes2\", \"tomatoes3\" (y/n): ClusterTasks deleted: \"tomatoes2\", \"tomatoes3\"\n",
},
{
name: "Delete all with prompt",
Expand All @@ -265,7 +265,7 @@ func TestClusterTaskDelete(t *testing.T) {
input: seeds[3].pipelineClient,
inputStream: strings.NewReader("y"),
wantError: false,
want: "Are you sure you want to delete all ClusterTasks (y/n): All ClusterTasks deleted\n",
want: "Command \"delete\" is deprecated, ClusterTasks are deprecated, this command will be removed in future releases.\nAre you sure you want to delete all ClusterTasks (y/n): All ClusterTasks deleted\n",
},
{
name: "Delete all with -f",
Expand All @@ -274,7 +274,7 @@ func TestClusterTaskDelete(t *testing.T) {
input: seeds[4].pipelineClient,
inputStream: nil,
wantError: false,
want: "All ClusterTasks deleted\n",
want: "Command \"delete\" is deprecated, ClusterTasks are deprecated, this command will be removed in future releases.\nAll ClusterTasks deleted\n",
},
{
name: "Error from using clustertask name with --all",
Expand Down
1 change: 1 addition & 0 deletions pkg/cmd/clustertask/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ or
}

f.AddFlags(c)
c.Deprecated = "ClusterTasks are deprecated, this command will be removed in future releases."
return c
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/clustertask/describe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ func TestClusterTaskDescribe_WithoutNameIfOnlyOneClusterTaskPresent(t *testing.T

func TestClusterTask_custom_output(t *testing.T) {
name := "clustertask"
expected := "clustertask.tekton.dev/" + name
expected := "Command \"describe\" is deprecated, ClusterTasks are deprecated, this command will be removed in future releases.\nclustertask.tekton.dev/" + name

clock := clockwork.NewFakeClock()

Expand Down Expand Up @@ -529,7 +529,7 @@ func TestClusterTask_custom_output(t *testing.T) {

func TestClusterTaskV1beta1_custom_output(t *testing.T) {
name := "clustertask"
expected := "clustertask.tekton.dev/" + name
expected := "Command \"describe\" is deprecated, ClusterTasks are deprecated, this command will be removed in future releases.\nclustertask.tekton.dev/" + name

clock := clockwork.NewFakeClock()

Expand Down
1 change: 1 addition & 0 deletions pkg/cmd/clustertask/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func listCommand(p cli.Params) *cobra.Command {
}
f.AddFlags(c)
c.Flags().BoolVar(&opts.NoHeaders, "no-headers", opts.NoHeaders, "do not print column headers with output (default print column headers with output)")
c.Deprecated = "ClusterTasks are deprecated, this command will be removed in future releases."
return c
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/clustertask/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ func TestClusterTaskList_Empty(t *testing.T) {
if err != nil {
t.Errorf("Unexpected error: %v", err)
}

test.AssertOutput(t, emptyMsg, output)
warning := "Command \"list\" is deprecated, ClusterTasks are deprecated, this command will be removed in future releases.\n"
test.AssertOutput(t, warning+emptyMsg, output)
}

func TestClusterTaskListOnlyClusterTasksv1beta1(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/clustertask/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Show logs for given ClusterTask and associated TaskRun:
c.Flags().BoolVarP(&opts.Follow, "follow", "f", false, "stream live logs")
c.Flags().BoolVarP(&opts.Timestamps, "timestamps", "t", false, "show logs with timestamp")
c.Flags().IntVarP(&opts.Limit, "limit", "", 5, "lists number of TaskRuns")

c.Deprecated = "ClusterTasks are deprecated, this command will be removed in future releases."
return c
}

Expand Down
16 changes: 8 additions & 8 deletions pkg/cmd/clustertask/logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,31 +76,31 @@ func TestClusterTaskLog(t *testing.T) {
input: cs,
dc: dc1,
wantError: true,
want: "Error: no TaskRuns found for ClusterTask task\n",
want: "Command \"logs\" is deprecated, ClusterTasks are deprecated, this command will be removed in future releases.\nError: no TaskRuns found for ClusterTask task\n",
},
{
name: "Specify notexist task name",
command: []string{"logs", "notexist", "-n", "ns"},
input: cs,
dc: dc1,
wantError: true,
want: "Error: clustertasks.tekton.dev \"notexist\" not found\n",
want: "Command \"logs\" is deprecated, ClusterTasks are deprecated, this command will be removed in future releases.\nError: clustertasks.tekton.dev \"notexist\" not found\n",
},
{
name: "Specify notexist taskrun name",
command: []string{"logs", "task", "notexist", "-n", "ns"},
input: cs,
dc: dc1,
wantError: true,
want: "Error: Unable to get TaskRun: taskruns.tekton.dev \"notexist\" not found\n",
want: "Command \"logs\" is deprecated, ClusterTasks are deprecated, this command will be removed in future releases.\nError: Unable to get TaskRun: taskruns.tekton.dev \"notexist\" not found\n",
},
{
name: "Specify negative number to limit",
command: []string{"logs", "task", "-n", "ns", "--limit", "-1"},
input: cs,
dc: dc1,
wantError: true,
want: "Error: limit was -1 but must be a positive number\n",
want: "Command \"logs\" is deprecated, ClusterTasks are deprecated, this command will be removed in future releases.\nError: limit was -1 but must be a positive number\n",
},
}

Expand Down Expand Up @@ -244,31 +244,31 @@ func TestClusterTaskLog_v1beta1(t *testing.T) {
input: cs,
dc: dc1,
wantError: true,
want: "Error: no TaskRuns found for ClusterTask task\n",
want: "Command \"logs\" is deprecated, ClusterTasks are deprecated, this command will be removed in future releases.\nError: no TaskRuns found for ClusterTask task\n",
},
{
name: "Specify notexist task name",
command: []string{"logs", "notexist", "-n", "ns"},
input: cs,
dc: dc1,
wantError: true,
want: "Error: clustertasks.tekton.dev \"notexist\" not found\n",
want: "Command \"logs\" is deprecated, ClusterTasks are deprecated, this command will be removed in future releases.\nError: clustertasks.tekton.dev \"notexist\" not found\n",
},
{
name: "Specify notexist taskrun name",
command: []string{"logs", "task", "notexist", "-n", "ns"},
input: cs,
dc: dc1,
wantError: true,
want: "Error: Unable to get TaskRun: taskruns.tekton.dev \"notexist\" not found\n",
want: "Command \"logs\" is deprecated, ClusterTasks are deprecated, this command will be removed in future releases.\nError: Unable to get TaskRun: taskruns.tekton.dev \"notexist\" not found\n",
},
{
name: "Specify negative number to limit",
command: []string{"logs", "task", "-n", "ns", "--limit", "-1"},
input: cs,
dc: dc1,
wantError: true,
want: "Error: limit was -1 but must be a positive number\n",
want: "Command \"logs\" is deprecated, ClusterTasks are deprecated, this command will be removed in future releases.\nError: limit was -1 but must be a positive number\n",
},
}

Expand Down
Loading

0 comments on commit 2388fef

Please sign in to comment.