Ramilito / kubectl.nvim

⎈ Streamline your Kubernetes management within Neovim—control and monitor your cluster seamlessly, all without leaving your coding environment.
Apache License 2.0
292 stars 7 forks source link

integrate more features #3

Closed mosheavni closed 2 months ago

mosheavni commented 4 months ago

I haven't looked at the code yet but I believe that if the API is easy to use, I can start submitting PRs to help

Ramilito commented 4 months ago

Thank you for the suggestions! If you want to help out I'd love that! Unfortunately I'm not super happy with some parts of the code, some is good but others need to be refactored. I'll try to write some docs on the overall structure and try to refactor a bit soon.

I'll take a look at that, shouldn't be too difficult to create an edit and/or apply from a buffer although I'd really like some security measures before that, a confirmation and maybe a kubectl diff (like you suggest in the next bulletpoint) to really make sure we don't ruin anyone's production env 😓

  • also kubectl diff capability would be nice

This should be pretty straightforward, how do you suggest we do the diff? Current opened buffer using a :Kubectl diff command?

  • option to change namespace

I started doing that, which wasn't too hard, when I finished, I kind of figured a global filter would add more value, I have a PR up that I'm finishing up soon that allows you to press ctrl-f to filter similar to grep. You can filter on anything here including namespace. Either way, I'll add namespace scope to the TODO list since I guess that's a pretty fundamental feature, just not super high prio when the filter pr gets merged

  • option to change context

I like that, adding it to the TODO list, what shortcut should we use?

  • option to sort by: creationTimestamp, name, number of containers, status (maybe option to display only failing pod

I'll add sorting to the TODO list! Would you think that filtering is enough for the failing pods?

I haven't looked at the code yet but I believe that if the API is easy to use, I can start submitting PRs to help

I'd love the help and if you are okay with the code as is then feel free! I would maybe wait for the docs and a bit of refactoring If was you though 😅

mosheavni commented 4 months ago

This should be pretty straightforward, how do you suggest we do the diff? Current opened buffer using a :Kubectl diff command?

Well, I use the plugin https://github.com/will133/vim-dirdiff because when you apply a file you could have multiple resources in it and the kubernetes diff creates a directory of the differences. I set this env var: export KUBECTL_EXTERNAL_DIFF="kdiff" and kdiff is an executable shell that looks like this

#!/bin/bash
nvim -c "DirDiff $1 $2"
  • option to change context

I like that, adding it to the TODO list, what shortcut should we use?

Not sure I'd use a keymap, maybe an ex-command like :Kubectx?

  • option to sort by: creationTimestamp, name, number of containers, status (maybe option to display only failing pod

I'll add sorting to the TODO list! Would you think that filtering is enough for the failing pods?

You could start with that, k9s does it great. More filters could be added in the future

I have started working on some simple stuff like :Kubectl completions, and displaying the existing views you have for :Kubectl get deployment for example, meaning that there is a view existing for deployments (https://github.com/Ramilito/kubectl.nvim/blob/main/lua/kubectl/deployments/views.lua) and instead of just running the kubectl get deployments, just show the built-in view.

for the completion, I need to get the kubectl api-resources so I can offer the entire list of resources available, what's the best interface to use to get the api-resources and parse them? Thanks.

Ramilito commented 4 months ago

Refactoring is sort of done! ofc, can always be improved but I feel that it's pretty nice now.

I'll have to think about what to do with the diff and experiment a bit, I have a cli tool that is called kubediff that sort of does this pretty good but I'm hesitant to add further dependencies, will see how hard it's to do without any additional deps first.

Not sure I'd use a keymap, maybe an ex-command like :Kubectx?

That's a good point, a simple ex-command is probably better!

You could start with that, k9s does it great. More filters could be added in the future

Did a simple sorting by pressing s on a header column, it was easier implementation wise than doing it similar to k9s, not sure if it's better though, what do you think? Good enough?

for the completion, I need to get the kubectl api-resources so I can offer the entire list of resources available, what's the best interface to use to get the api-resources and parse them? Thanks.

There is two ways you can do it with the current api, first is calling the commands.exec_shell_command(cmd, args) directly or using the resourcebuilders fetch method. I think for this case, calling it directly is easiest.

Ramilito commented 2 months ago

This is sort of done, apply directories is still tbd but will create a new issue for it!