From d507aba1f790f2fe787cb557050621e8d653713c Mon Sep 17 00:00:00 2001 From: Rohan Kumar Date: Thu, 30 Apr 2020 15:26:59 +0530 Subject: [PATCH] Fix #2174: Warn for multiple values in KUBECONFIG variable Changed loglevel to warn in case of multiple kubeconfig are found in `KUBECONFIG` environment variable. --- CHANGELOG.md | 1 + .../src/main/java/io/fabric8/kubernetes/client/Config.java | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 56058ab6e95..86492fd05e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ * Fix #2124: Raw Watch on CustomResource does not work if name specified #### Improvements +* Fix #2174: Change log level to warn for multiple `kubeconfig` warning * Fix #2088: Support networking.k8s.io/v1beta1 alongside extensions/v1beta1 #### Dependency Upgrade diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/Config.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/Config.java index 0a14ac80d6a..9926c28b551 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/Config.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/Config.java @@ -474,13 +474,13 @@ private static boolean tryKubeConfig(Config config, String context) { String[] fileNames = fileName.split(File.pathSeparator); if (fileNames.length > 1) { - LOGGER.debug("Found multiple Kubernetes config files [{}], using the first one: [{}].", fileNames, fileNames[0]); + LOGGER.warn("Found multiple Kubernetes config files [{}], using the first one: [{}]. If not desired file, please change it by doing `export KUBECONFIG=/path/to/kubeconfig` on Unix systems or `$Env:KUBECONFIG=/path/to/kubeconfig` on Windows.", fileNames, fileNames[0]); fileName = fileNames[0]; } File kubeConfigFile = new File(fileName); if (kubeConfigFile.isFile()) { - LOGGER.debug("Found for Kubernetes config at: ["+kubeConfigFile.getPath()+"]."); + LOGGER.debug("Found for Kubernetes config at: [{}].", kubeConfigFile.getPath()); String kubeconfigContents; try (FileReader reader = new FileReader(kubeConfigFile)){ kubeconfigContents = IOHelpers.readFully(reader);