Skip to content

Commit

Permalink
Fix fabric8io#2174: Warn for multiple values in KUBECONFIG variable
Browse files Browse the repository at this point in the history
Changed loglevel to warn in case of multiple kubeconfig are found in `KUBECONFIG`
environment variable.
  • Loading branch information
rohanKanojia committed Apr 30, 2020
1 parent 2f857a9 commit d507aba
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit d507aba

Please sign in to comment.