Skip to content

Commit 6fadadb

Browse files
committed
Fix a bug in command handling if there is no directory for the kubeconfig file.
1 parent ef07a5b commit 6fadadb

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

util/src/main/java/io/kubernetes/client/util/KubeConfig.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,14 @@ private JsonElement runExec(String command, List<String> args, List<Map<String,
330330
if (command.contains("/") || command.contains("\\")) {
331331
// Spec is unclear on what should be treated as a “relative command path”.
332332
// This clause should cover anything not resolved from $PATH / %Path%.
333-
Path resolvedCommand = file.toPath().getParent().resolve(command).normalize();
333+
Path resolvedCommand;
334+
if (file != null) {
335+
// If we know where the Kubeconfig was located, use that as the base.
336+
resolvedCommand = file.toPath().getParent().resolve(command).normalize();
337+
} else {
338+
// Otherwise, try the current working directory
339+
resolvedCommand = Paths.get(command).normalize();
340+
}
334341
if (!Files.exists(resolvedCommand)) {
335342
log.error("No such file: {}", resolvedCommand);
336343
return null;

0 commit comments

Comments
 (0)