-
Notifications
You must be signed in to change notification settings - Fork 253
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
Refactor delete command code to be a bit more DRY #585
Conversation
While implementing multiple delete I noticed that each delete command was implementing its own error handling and messaging even though each was doing exactly the same thing. This made working on the code cumbersome - I had to double check that I'd added each of my changes correactly across every repition of the delete command. So this commit introduces a helper type, Deleter, that does most of the repetitive work and is reused across all the delete commands.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My only remark/question is : why the struct ? a function call would work too 😝
deleter.Delete(s, "ClusterTask", tNames, func(…))
That said, the function signature is then a bit weird 😛
Other than that, looks really good to me 😻
The following is the coverage report on pkg/.
|
Mostly because the function signature would be a bit gnarly when deleting both a resource and its relations I think. |
/test pull-tekton-cli-unit-tests |
} | ||
|
||
return multierr.Combine(errs...) | ||
d := deleter.New("PipelineRun", func(pipelineRunName string) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that this should happen in this pr, but it may be a good idea to have TaskRuns be a related resource for PipelineRuns.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
[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:
Approvers can indicate their approval by writing |
Changes
While implementing multiple delete I noticed that each delete command was implementing its own error handling and messaging even though each was doing exactly the same thing. This made working on the code more error-prone - I had to double check that I'd added each of my changes correctly across every repetition of the delete behaviour.
So this commit introduces a helper type,
Deleter
, that does most of the repetitive work and is now reused across all the delete commands.Submitter Checklist
make check