Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update all delete commands to support multiple arguments #577

Merged
merged 1 commit into from Jan 8, 2020
Merged

Update all delete commands to support multiple arguments #577

merged 1 commit into from Jan 8, 2020

Conversation

ghost
Copy link

@ghost ghost commented Jan 7, 2020

Changes

Fixes #572

This commit allows the user to delete multiple resources of the same kind at once. For example, to delete multiple tasks the user can issue the command tkn task delete foo bar baz -n mynamespace and all three tasks, foo, bar, and baz, will be deleted.

The user is only asked to confirm the multiple deletions a single time. Each deletion is handled individually, meaning that it's possible for some deletions to fail while the rest go on to succeed. However, if any deletions do fail then the command will end as an error.

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

  • Includes tests (if functionality changed/added)
  • Includes docs (if user facing)
  • Regenerate the manpages and docs with make docs and make man if needed.
  • Run the code checkers with make check
  • Commit messages follow commit message best practices

Release Notes

Users can now delete multiple resources at once by providing more than one name to delete commands

@tekton-robot tekton-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jan 7, 2020
@tekton-robot
Copy link
Contributor

The following is the coverage report on pkg/.
Say /test pull-tekton-cli-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/cmd/clustertask/delete.go 94.7% 96.0% 1.3
pkg/cmd/condition/delete.go 95.2% 96.2% 0.9
pkg/cmd/eventlistener/delete.go 95.2% 96.3% 1.1
pkg/cmd/pipeline/delete.go 90.6% 87.5% -3.1
pkg/cmd/pipelineresource/delete.go 0.0% 96.2% 96.2
pkg/cmd/pipelinerun/delete.go 95.2% 96.3% 1.1
pkg/cmd/task/delete.go 90.6% 87.5% -3.1
pkg/cmd/taskrun/delete.go 95.2% 96.3% 1.1
pkg/cmd/triggerbinding/delete.go 95.2% 96.3% 1.1
pkg/cmd/triggertemplate/delete.go 95.2% 96.3% 1.1
pkg/helper/options/delete.go 92.9% 94.7% 1.9

@ghost
Copy link
Author

ghost commented Jan 7, 2020

/test pull-tekton-cli-unit-tests

continue
}

fmt.Fprintf(s.Out, "ClusterTask deleted: %s\n", tName)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to print this just once using the entire list of resources instead of a new line each time? Something like:

tkn clustertask delete foo bar -n ns

results in

ClusterTasks deleted: [foo bar]

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the only counterpoint is that by printing them one after the other a user receives a continuous stream of status updates as the deletes occur:

ClusterTask X deleted
Error deleting clustertask Y: the foo bar bazzed
ClusterTask Z deleted
ClusterTask N deleted

In the alternative scenario the user sees the error message but has to wait until the end to see the complete list of successful deletions:

Error deleting clustertask Y: the foo bar bazzed
# some time later ...
ClusterTasks deleted: "X", "Z", "N"

I'm ambivalent - which do you prefer?

Copy link
Member

@danielhelfand danielhelfand Jan 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the alternative scenario the user sees the error message but has to wait until the end to see the complete list of successful deletions:

Error deleting clustertask Y: the foo bar bazzed
# some time later ...
ClusterTasks deleted: "X", "Z", "N"

I like this idea here of showing an error as it happens, but then showing successful deletions once all together.

pkg/cmd/condition/delete.go Outdated Show resolved Hide resolved
pkg/cmd/clustertask/delete.go Outdated Show resolved Hide resolved
pkg/cmd/eventlistener/delete.go Outdated Show resolved Hide resolved
pkg/cmd/pipeline/delete.go Outdated Show resolved Hide resolved
pkg/cmd/pipelinerun/delete.go Outdated Show resolved Hide resolved
pkg/cmd/task/delete.go Outdated Show resolved Hide resolved
pkg/cmd/taskrun/delete.go Outdated Show resolved Hide resolved
pkg/cmd/triggerbinding/delete.go Outdated Show resolved Hide resolved
pkg/cmd/triggertemplate/delete.go Outdated Show resolved Hide resolved
@tekton-robot
Copy link
Contributor

The following is the coverage report on pkg/.
Say /test pull-tekton-cli-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/cmd/clustertask/delete.go 94.7% 96.0% 1.3
pkg/cmd/condition/delete.go 95.2% 96.2% 0.9
pkg/cmd/eventlistener/delete.go 95.2% 96.3% 1.1
pkg/cmd/pipeline/delete.go 90.6% 87.5% -3.1
pkg/cmd/pipelineresource/delete.go 0.0% 96.2% 96.2
pkg/cmd/pipelinerun/delete.go 95.2% 96.3% 1.1
pkg/cmd/task/delete.go 90.6% 87.5% -3.1
pkg/cmd/taskrun/delete.go 95.2% 96.3% 1.1
pkg/cmd/triggerbinding/delete.go 95.2% 96.3% 1.1
pkg/cmd/triggertemplate/delete.go 95.2% 96.3% 1.1
pkg/helper/options/delete.go 92.9% 94.7% 1.9

@tekton-robot
Copy link
Contributor

The following is the coverage report on pkg/.
Say /test pull-tekton-cli-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/cmd/clustertask/delete.go 94.7% 96.0% 1.3
pkg/cmd/condition/delete.go 95.2% 96.2% 0.9
pkg/cmd/eventlistener/delete.go 95.2% 96.3% 1.1
pkg/cmd/pipeline/delete.go 90.6% 87.5% -3.1
pkg/cmd/pipelineresource/delete.go 0.0% 96.2% 96.2
pkg/cmd/pipelinerun/delete.go 95.2% 96.3% 1.1
pkg/cmd/task/delete.go 90.6% 87.5% -3.1
pkg/cmd/taskrun/delete.go 95.2% 96.3% 1.1
pkg/cmd/triggerbinding/delete.go 95.2% 96.3% 1.1
pkg/cmd/triggertemplate/delete.go 95.2% 96.3% 1.1
pkg/helper/options/delete.go 92.9% 94.7% 1.9

@ghost
Copy link
Author

ghost commented Jan 8, 2020

/test pull-tekton-cli-unit-tests

@ghost
Copy link
Author

ghost commented Jan 8, 2020

@danielhelfand thanks for the review; I've updated the code with the success message changes you suggested.

@chmouel
Copy link
Member

chmouel commented Jan 8, 2020

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Jan 8, 2020
@tekton-robot
Copy link
Contributor

The following is the coverage report on pkg/.
Say /test pull-tekton-cli-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/cmd/clustertask/delete.go 94.7% 96.3% 1.6
pkg/cmd/condition/delete.go 95.2% 96.6% 1.3
pkg/cmd/eventlistener/delete.go 95.2% 96.6% 1.3
pkg/cmd/pipeline/delete.go 90.6% 89.1% -1.5
pkg/cmd/pipelinerun/delete.go 95.2% 96.6% 1.3
pkg/cmd/task/delete.go 90.6% 89.1% -1.5
pkg/cmd/taskrun/delete.go 95.2% 96.6% 1.3
pkg/cmd/triggerbinding/delete.go 95.2% 96.6% 1.3
pkg/cmd/triggertemplate/delete.go 95.2% 96.6% 1.3
pkg/helper/options/delete.go 92.9% 93.3% 0.5

This commit allows the user to delete multiple resources of the same
kind at once. For example, to delete multiple tasks the user can issue
the command `tkn task delete foo bar baz -n mynamespace` and all three
tasks (foo, bar, and baz) will be deleted.

The user is only asked to confirm the multiple deletions a single time.
Each deletion is handled individually, meaning that it's possible for
some deletions to fail while the rest go on to succeed. If any deletes
do fail then the command will end as an error.
@tekton-robot tekton-robot removed the lgtm Indicates that a PR is ready to be merged. label Jan 8, 2020
@tekton-robot
Copy link
Contributor

The following is the coverage report on pkg/.
Say /test pull-tekton-cli-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/cmd/clustertask/delete.go 94.7% 96.3% 1.6
pkg/cmd/condition/delete.go 95.2% 96.6% 1.3
pkg/cmd/eventlistener/delete.go 95.2% 96.6% 1.3
pkg/cmd/pipeline/delete.go 90.6% 89.1% -1.5
pkg/cmd/pipelineresource/delete.go 0.0% 96.6% 96.6
pkg/cmd/pipelinerun/delete.go 95.2% 96.6% 1.3
pkg/cmd/task/delete.go 90.6% 89.1% -1.5
pkg/cmd/taskrun/delete.go 95.2% 96.6% 1.3
pkg/cmd/triggerbinding/delete.go 95.2% 96.6% 1.3
pkg/cmd/triggertemplate/delete.go 95.2% 96.6% 1.3
pkg/helper/options/delete.go 92.9% 93.3% 0.5

@ghost
Copy link
Author

ghost commented Jan 8, 2020

/test pull-tekton-cli-unit-tests

Copy link
Member

@danielhelfand danielhelfand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this, @sbwsg!

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 8, 2020
Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Jan 8, 2020
@tekton-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: danielhelfand, vdemeester

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [danielhelfand,vdemeester]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot merged commit 5a8d46a into tektoncd:master Jan 8, 2020
@ghost ghost deleted the delete-accepts-multiple-args branch January 8, 2020 19:06
@ghost ghost mentioned this pull request Jan 9, 2020
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cla: yes lgtm Indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tkn delete should accept multiple argument
5 participants