autocomplete icon indicating copy to clipboard operation
autocomplete copied to clipboard

[kubectl] kubectl resource auto complete should use caching

Open NimrodAvni78 opened this issue 3 years ago • 1 comments

Sanity checks

  • [X] My issue relates to a specific CLI completion spec (e.g. git checkout is missing options in git completion spec). If your issue is more general, please create your issue here: withfig/fig
  • [X] I have searched github.com/withfig/autocomplete/issues and there are no duplicates of my issue
  • [ ] I would like to work on this.

What CLI tool does this relate to?

kubectl

Which statement makes the most sense?

Something else

Issue Details

when trying preform an action on a kubernetes resource, fig.io reads all the existing resources with this resource type for example

kubectl scale deployment ...

but when deleting a word or just trying to type the command again it will try to fetch all the data again, even though it just fetched it a couple of seconds ago

i believe for that the kubectl plugin (any maybe other plugins, but thats outside the scope of this issue) will benefit to cache / store the results of the previous autocomplete suggestions (for every type of autocomplete which requires running a command against kubernetes and awaiting its response)

it can perform the fetch request to kubernetes in the background and update the cache asynchronously, the cache can also have a maximum TTL if we want to make sure to refresh the resuls after some time (can also be configurable in the settings menu)

NimrodAvni78 avatar Jan 27 '22 05:01 NimrodAvni78

Hey @NimrodAvni78 - we actually already provide support for caching in the completion spec standard. See the cache field on generators for more details.

It looks like this just requires adding a cache to the appropriate generators in the kubectl spec.

mschrage avatar Jan 28 '22 22:01 mschrage