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

add kumactl delete command #343

Merged
merged 9 commits into from
Oct 23, 2019
Merged

Conversation

pradeepmurugesan
Copy link
Contributor

@pradeepmurugesan pradeepmurugesan commented Oct 15, 2019

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.

  • returns an error in case of no mesh with the given name.

Full changelog

  • Implemented the delete command in kumactl

Issues resolved

Fix #279

Copy link
Contributor

@yskopets yskopets left a comment

Choose a reason for hiding this comment

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

@pradeepmurugesan Hi!

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!

app/kumactl/cmd/root.go Outdated Show resolved Hide resolved
app/kumactl/cmd/delete/delete.go Outdated Show resolved Hide resolved
app/kumactl/cmd/delete/say_hello.go Outdated Show resolved Hide resolved
app/kumactl/cmd/delete/delete_meshes.go Outdated Show resolved Hide resolved
app/kumactl/cmd/delete/say_hello.go Outdated Show resolved Hide resolved
app/kumactl/cmd/delete/delete_meshes.go Outdated Show resolved Hide resolved
@pradeepmurugesan pradeepmurugesan changed the title initial commit add kumactl delete command Oct 15, 2019
@pradeepmurugesan pradeepmurugesan marked this pull request as ready for review October 16, 2019 06:33
Copy link
Contributor

@yskopets yskopets left a 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.

app/kumactl/cmd/delete/delete_meshes.go Outdated Show resolved Hide resolved
app/kumactl/cmd/delete/delete_meshes.go Outdated Show resolved Hide resolved
app/kumactl/cmd/delete/delete_meshes.go Outdated Show resolved Hide resolved
app/kumactl/cmd/delete/delete_meshes.go Outdated Show resolved Hide resolved
app/kumactl/cmd/delete/delete_meshes_test.go Outdated Show resolved Hide resolved
app/kumactl/cmd/delete/delete_meshes_test.go Show resolved Hide resolved
app/kumactl/cmd/delete/delete_meshes_test.go Show resolved Hide resolved
app/kumactl/cmd/delete/delete_meshes_test.go Show resolved Hide resolved
@pradeepmurugesan pradeepmurugesan force-pushed the kuma-delete branch 2 times, most recently from a123085 to 5f2cad4 Compare October 16, 2019 16:57
@pradeepmurugesan
Copy link
Contributor Author

@yskopets thanks for reviewing.. Fixed the comments. 👍 Kindly review..

Copy link
Contributor

@yskopets yskopets left a 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

app/kumactl/cmd/delete/delete_meshes_test.go Outdated Show resolved Hide resolved
app/kumactl/cmd/delete/delete_meshes_test.go Outdated Show resolved Hide resolved
app/kumactl/cmd/delete/delete_meshes_test.go Outdated Show resolved Hide resolved
app/kumactl/cmd/delete/delete_meshes.go Outdated Show resolved Hide resolved
app/kumactl/cmd/delete/delete_meshes_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@yskopets yskopets left a 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 respective Kuma 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())
  • 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!

@pradeepmurugesan
Copy link
Contributor Author

@yskopets refactored for the existing functionality. deleting the mesh.

I feel like implementing the other options like dataplane, proxytemplate, traffic-log, traffic-permission once we sort out the design with mesh. Let me know if this is what you had in mind

Copy link
Contributor

@yskopets yskopets left a 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.

app/kumactl/cmd/delete/delete.go Outdated Show resolved Hide resolved
app/kumactl/cmd/delete/delete.go Outdated Show resolved Hide resolved
Copy link
Contributor

@yskopets yskopets left a 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.

app/kumactl/cmd/delete/delete.go Outdated Show resolved Hide resolved
app/kumactl/cmd/delete/delete.go Outdated Show resolved Hide resolved
app/kumactl/cmd/delete/delete.go Show resolved Hide resolved
app/kumactl/cmd/delete/delete_dataplane_test.go Outdated Show resolved Hide resolved
app/kumactl/cmd/delete/delete_dataplane_test.go Outdated Show resolved Hide resolved
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
Copy link
Contributor

@yskopets yskopets left a 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! 🎉


func NewDeleteCmd(pctx *kumactl_cmd.RootContext) *cobra.Command {
cmd := &cobra.Command{
Use: "delete",
Copy link
Contributor

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"

resourceType = mesh.TrafficPermissionType

default:
return errors.Errorf("unknown resource type: %s. Allowed types: mesh, dataplane, proxytemplate, traffic-log, traffic-permission", resourceTypeArg)
Copy link
Contributor

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

@yskopets yskopets merged commit 4798a1f into kumahq:master Oct 23, 2019
@pradeepmurugesan pradeepmurugesan deleted the kuma-delete branch October 23, 2019 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add kumactl delete command
2 participants