kubeswitch icon indicating copy to clipboard operation
kubeswitch copied to clipboard

Custom Store from CLI Command

Open jose-fully-ported opened this issue 1 year ago • 1 comments

It would be cool to have a custom store based on a custom command. One could set the backend like so:

kind: SwitchConfig
version: "v1alpha1"
kubeconfigStores:
  - kind: custom
    id: id-only-required-if-there-are-more-than-one-store
    config:
      command: custom-command
      env:
        KEY: value

The config contains a command - the command to run - as well as an optional map of environment variables for the command context.

Under the hood, the command should implement a specific interface:

  • list: outputs a json object of all clusters. There is a clusters key that has a list of cluster objects, with a name that can be displayed in the ui and an id that is the internal cluster id.
    {
      "clusters": [
        {"name": "test": "id": "some-id"}
      ]
    }
    
  • kubeconfig: Takes anid and writes a kubeconfig to stdout.

With these two, we'd create a custom store that calls the list command in StartSearch, and then again when returning a kubeconfig in GetKubeconfigForPath.

The KubeConfig would then be written to a path like custom_${id}-${name-slug}.


I am not sure how expired KubeConfigs might work - is there some tracking for that? - but this would provide folks the ability to customize where their KubeConfig comes from in the case of custom tooling.

Is this something you'd be interested in taking a pull request for?

jose-fully-ported avatar Oct 24 '23 19:10 jose-fully-ported

Hi, sorry for the delay. Yes, I would very much be interested in taking a pull request for that.

danielfoehrKn avatar Nov 29 '23 22:11 danielfoehrKn