-
Notifications
You must be signed in to change notification settings - Fork 336
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
add kumactl delete command #343
Conversation
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.
Thanks a lot for your first contribution to Kuma!
I've left some comments to give you an idea what to expect from code review.
Looking forward to the next step!
4f5d20c
to
473234d
Compare
473234d
to
fefcbf1
Compare
fefcbf1
to
387ff9a
Compare
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.
@pradeepmurugesan I like the progress!
Let's fix these minor comments first.
Next, I'd like us to try to have a single delete
command for resources of all types.
a123085
to
5f2cad4
Compare
@yskopets thanks for reviewing.. Fixed the comments. 👍 Kindly review.. |
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.
A few minor changes
5f2cad4
to
ae78bee
Compare
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.
@pradeepmurugesan Perfect!
It's a great milestone!
Next, let's try to implement a single kumactl delete
command for all resource types.
We will reuse the logic you've already implemented and parametrise it with a resource type.
- let's have
kubectl delete
to accept 2 args:<type>
and<name>
- let's validate
<type>
against a well-known list (mesh
,dataplane
,proxytemplate
,traffic-log
,traffic-permission
) - next, we need to map
<type>
(from command line) onto a respectiveKuma
Resource
(i.e.,MeshResource
,TrafficLogResource
, etc)- the simplest solution would be to have a
switch
statement (i.e.case "mesh": return &mesh.MeshResource{}
) - it's ok to start from it - better approach, is to reuse registry if all supported
Resources
(pkg/core/resources/registry.Global()
)
- the simplest solution would be to have a
- after that, we can pass
Resource
instance as a parameter to delete logic
I hope this clarifies what kind of solution we would like to have in the end.
Thanks again for your time and willingness to contribute to Kuma!
@yskopets refactored for the existing functionality. I feel like implementing the other options like |
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.
@pradeepmurugesan Great!
Please go ahead with the remaining resource types.
41ba22a
to
f505a47
Compare
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.
👍Almost there!
Just a few final changes.
Implemented the support for delete command. The delete command takes the mesh name as a parameter. Check if the the given mesh name exists and then delete. * returns an error in case of no mesh with the given name. Fix kumahq#279
…all resource types Right now the design is to handle the resource types via subcommands. Refactored so that the delete command accepts a resourceType arg. Based on the passed resource type arg the corresponding resource will be deleted. * returns an error in case of no mesh with the given name. Fix kumahq#279
Implemented the support for deleting dataplane. Check if the the given dataplane exists and thdataplane. * returns an error in case of no dataplane with the given name. Fix kumahq#279
Implemented the support for deleting proxytemplate. Check if the the given proxytemplate exists and then delete. * returns an error in case of no proxytemplate with the given name. Fix kumahq#279
Implemented the support for deleting traffic-log. Check if the the given traffic-log exists and then delete. * returns an error in case of no traffic-log with the given name. Fix kumahq#279
Implemented the support for deleting trafficpermission. Check if the the given trafficpermission exists and then delete. * returns an error in case of no trafficpermission with the given name. Fix kumahq#279
0d6d7f2
to
491d978
Compare
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.
Perfect! 👏
I'm asking for 2 more minor changes, but mostly to trigger CI build on your next commit. After that, it's ready to be merged!
Thanks a lot for your contribution!
Expect a nice Kuma
T-shirt shortly! 🎉
app/kumactl/cmd/delete/delete.go
Outdated
|
||
func NewDeleteCmd(pctx *kumactl_cmd.RootContext) *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "delete", |
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.
Let's change Use: "delete"
to Use: "delete TYPE NAME"
app/kumactl/cmd/delete/delete.go
Outdated
resourceType = mesh.TrafficPermissionType | ||
|
||
default: | ||
return errors.Errorf("unknown resource type: %s. Allowed types: mesh, dataplane, proxytemplate, traffic-log, traffic-permission", resourceTypeArg) |
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.
Let's slightly change this error message to keep it in sync with Use
, namely
unknown TYPE: %s. Allowed values: mesh, dataplane, proxytemplate, traffic-log, traffic-permission
Summary
Implemented the support for delete command. The delete command takes the mesh name as a parameter.
Check if the the given mesh name exists and then delete.
Full changelog
Issues resolved
Fix #279