Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/KubernetesClient/KubernetesClientConfiguration.ConfigFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ public static string RenewAzureToken(string tenantId, string clientId, string ap
throw new KubeConfigException("Refresh not supported.");
}

public static Process CreateRunnableExternalProcess(ExternalExecution config)
public static Process CreateRunnableExternalProcess(ExternalExecution config, EventHandler<DataReceivedEventArgs> captureStdError = null)
{
if (config == null)
{
Expand Down Expand Up @@ -535,7 +535,7 @@ public static Process CreateRunnableExternalProcess(ExternalExecution config)
}

process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.RedirectStandardError = captureStdError != null;
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;

Expand All @@ -560,14 +560,15 @@ public static ExecCredentialResponse ExecuteExternalCommand(ExternalExecution co
throw new ArgumentNullException(nameof(config));
}

var process = CreateRunnableExternalProcess(config);
var captureStdError = ExecStdError;
var process = CreateRunnableExternalProcess(config, captureStdError);

try
{
process.Start();
if (ExecStdError != null)
if (captureStdError != null)
{
process.ErrorDataReceived += (s, e) => ExecStdError.Invoke(s, e);
process.ErrorDataReceived += captureStdError.Invoke;
process.BeginErrorReadLine();
}
}
Expand Down