Use KUBECONFIG environment variable for kubeconfig path with fallback to default #62
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
This PR introduces a feature that allows the
krs
CLI to use theKUBECONFIG
environment variable to determine the path to the kubeconfig file. If theKUBECONFIG
variable is not set or is empty, the CLI will default to using~/.kube/config
.Key Changes:
KUBECONFIG Environment Variable:
KUBECONFIG
environment variable to determine the kubeconfig file path.~/.kube/config
is used.get_kubeconfig
Function:get_kubeconfig()
is introduced to handle the retrieval of the kubeconfig path based on the environment variable.init
Command Update:init
command now uses theget_kubeconfig()
function to determine the kubeconfig file path, offering more flexibility for users.Why This Change?
KUBECONFIG
environment variable, the CLI becomes more intuitive and consistent with other Kubernetes tools.How to Test:
KUBECONFIG
environment variable to a custom kubeconfig file path:export KUBECONFIG=/path/to/your/kubeconfig
init
command to ensure that the specified kubeconfig file is used:KUBECONFIG
environment variable and rerun theinit
command to verify it defaults to~/.kube/config
:unset KUBECONFIG krs init