danielfoehrKn / kubeswitch

The kubectx for operators.
https://danielfoehrkn.medium.com/the-case-of-kubeswitch-aff4b6a04ae7
Apache License 2.0
839 stars 79 forks source link

Flag 'kubeconfig-path' not reading multiple files in folder #141

Open lucasvc opened 1 month ago

lucasvc commented 1 month ago

I have the following file structure

/
└── home
    └── lucasvc
        └── .kube
            └── configs
                ├── cl_A-dev-1.yaml
                ├── cl_A-stage-1.yaml
                ├── cl_B-dev-1.yaml
                └── cl_B-stage-1.yaml

For two different clusters (cl_A and cl_B) and two environments for each cluster (dev and stage). When executing

switch --kubeconfig-path /home/lucasvc/.kube/configs/

I got a 0/0.

Also tried debug list,

$ switch --debug --kubeconfig-path /home/lucasvc/.kube/configs/ list-contexts
DEBU[0000] Using kubeconfig path from flag /home/lucasvc/.kube/configs/
DEBU[0000] Starting search for store: filesystem         store=filesystem

empty list.

If I set a KUBECONFIG environment variable listing all the configuration files, on open switch allows the selection of the cluster/environment. And with debug list,

$ switch --debug list-contexts
DEBU[0000] Adding kubeconfig path from KUBECONFIG env /home/lucasvc/.kube/configs/cl_A-dev-1.yaml.yaml:/home/lucasvc/.kube/configs/cl_A-stage-1.yaml:/home/lucasvc/.kube/configs/cl_B-dev-1.yaml:/home/lucasvc/.kube/configs/cl_B-stage-1.yaml
DEBU[0000] Adding kubeconfig path from KUBECONFIG env /home/lucasvc/.kube/configs/cl_A-dev-1.yaml.yaml:/home/lucasvc/.kube/configs/cl_A-stage-1.yaml:/home/lucasvc/.kube/configs/cl_B-dev-1.yaml:/home/lucasvc/.kube/configs/cl_B-stage-1.yaml
DEBU[0000] Adding kubeconfig path from KUBECONFIG env /home/lucasvc/.kube/configs/cl_A-dev-1.yaml.yaml:/home/lucasvc/.kube/configs/cl_A-stage-1.yaml:/home/lucasvc/.kube/configs/cl_B-dev-1.yaml:/home/lucasvc/.kube/configs/cl_B-stage-1.yaml
DEBU[0000] Adding kubeconfig path from KUBECONFIG env /home/lucasvc/.kube/configs/cl_A-dev-1.yaml.yaml:/home/lucasvc/.kube/configs/cl_A-stage-1.yaml:/home/lucasvc/.kube/configs/cl_B-dev-1.yaml:/home/lucasvc/.kube/configs/cl_B-stage-1.yaml
DEBU[0000] Starting search for store: filesystem         store=filesystem
DEBU[0000] GetKubeconfigForPath: /home/lucasvc/.kube/configs/cl_A-dev-1.yaml.yaml not cached  store=filesystem
DEBU[0000] GetKubeconfigForPath: /home/lucasvc/.kube/configs/cl_A-stage-1.yaml not cached  store=filesystem
DEBU[0000] GetKubeconfigForPath: /home/lucasvc/.kube/configs/cl_B-dev-1.yaml not cached  store=filesystem
DEBU[0000] GetKubeconfigForPath: /home/lucasvc/.kube/configs/cl_B-stage-1.yaml not cached  store=filesystem
cl_B-dev-1
cl_B-stage-1
cl_A-dev-1
cl_A-stage-1