Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix an NPE bug in command handling if there is no directory for the kubeconfig file. #3244

Merged
merged 1 commit into from
May 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion util/src/main/java/io/kubernetes/client/util/KubeConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,14 @@ private JsonElement runExec(String command, List<String> args, List<Map<String,
if (command.contains("/") || command.contains("\\")) {
// Spec is unclear on what should be treated as a “relative command path”.
// This clause should cover anything not resolved from $PATH / %Path%.
Path resolvedCommand = file.toPath().getParent().resolve(command).normalize();
Path resolvedCommand;
if (file != null) {
// If we know where the Kubeconfig was located, use that as the base.
resolvedCommand = file.toPath().getParent().resolve(command).normalize();
} else {
// Otherwise, try the current working directory
resolvedCommand = Paths.get(command).normalize();
}
if (!Files.exists(resolvedCommand)) {
log.error("No such file: {}", resolvedCommand);
return null;
Expand Down