AKS Get-Credentials doesn't handle KUBECONFIG with multiple files
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 3.5k
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 60
Description
**Describe the bug**
When a user's `KUBECONFIG` environment variable contains more than one file, then `az aks get-credentials...` mistakenly treats the value as a single path.
As per [the official documentation](https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/#the-kubeconfig-environment-variable) this colon-delimited format is explicitly supported on Mac and Linux.
This behaviour appears to have been introduced by https://github.com/Azure/azure-cli/pull/18704 and is present in v2.26.0 and above.
e.g.
If my `KUBECONFIG` looks like so:
`KUBECONFIG=/home/me/.kube/config:/home/me/.kube/anotherconfig:/home/me/.kube/yetanotherconfig`
Then when I run `az aks get-credentials...` then it will attempt to write the file to a file at the path `/home/me/.kube/config:/home/me/.kube/anotherconfig:/home/me/.kube/yetanotherconfig` rather than one of the single files contained within.
**To Reproduce**
```sh
$ KUBECONFIG=/home/me/.kube/config:/home/me/.kube/anotherconfig
$ az aks get-credentials ...
$ cat "/home/me/.kube/config:/home/me/.kube/anotherconfig"
```
**Expected behavior**
`az aks get-credentials...` should write AKS credentials to _one_ of the files contained within `KUBECONFIG` only, but not sure how it should choose which to use.
**Environment summary**
Install method: homebrew
Mac Version: 11.4
```
$ az --version
azure-cli 2.26.0
core 2.26.0
telemetry 1.0.6
Python location '/usr/local/Cellar/azure-cli/2.26.0/libexec/bin/python'
Extensions directory '/Users/paddy/.azure/cliextensions'
Python (Darwin) 3.8.11 (default, Jun 29 2021, 03:08:07)
[Clang 12.0.5 (clang-1205.0.22.9)]
```
**Additional Context**
N/A
Contributor guide
Assessment
This issue has not been assessed yet.