Skip to content
Merged
Show file tree
Hide file tree
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
25 changes: 17 additions & 8 deletions src/SSHDebugPS/Podman/PodmanHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
Expand All @@ -17,7 +18,7 @@ public class PodmanHelper
{
private const string podmanPSCommand = "ps";
private const string podmanPSArgs = "-f status=running --no-trunc --format \"{{json .}}\"";

private const int win32ErrorFileNotFound = 2;

internal static IEnumerable<PodmanContainerInstance> GetLocalPodmanContainers(string hostname, out int totalContainers)
{
Expand All @@ -28,17 +29,25 @@ internal static IEnumerable<PodmanContainerInstance> GetLocalPodmanContainers(st
PodmanCommandSettings settings = new PodmanCommandSettings(hostname, false);
settings.SetCommand(podmanPSCommand, podmanPSArgs);

DockerHelper.RunContainerCommand(settings, delegate (string args)
try
{
if (args.Trim()[0] == '{')
DockerHelper.RunContainerCommand(settings, delegate (string args)
{
if (PodmanContainerInstance.TryCreate(args, out PodmanContainerInstance containerInstance))
if (args.Trim()[0] == '{')
{
containers.Add(containerInstance);
if (PodmanContainerInstance.TryCreate(args, out PodmanContainerInstance containerInstance))
{
containers.Add(containerInstance);
}
containerCount++;
}
containerCount++;
}
});
});
}
catch (CommandFailedException ex) when (ex.InnerException is Win32Exception win32Exception &&
win32Exception.NativeErrorCode == win32ErrorFileNotFound)
{
throw new CommandFailedException(UIResources.PodmanExecutableNotFound, ex);
}

totalContainers = containerCount;
return containers;
Expand Down
9 changes: 9 additions & 0 deletions src/SSHDebugPS/UI/UIResources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/SSHDebugPS/UI/UIResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,10 @@
<data name="Podman_ConnectionToolTip" xml:space="preserve">
<value>Location from which to run the Podman CLI. To manage remote connections, in the menu go to Tools -&gt; Options and find Cross Platform -&gt; Connection Manager.</value>
</data>
<data name="PodmanExecutableNotFound" xml:space="preserve">
<value>Podman was not found. Install Podman, ensure podman.exe is available on PATH, and restart Visual Studio.</value>
<comment>{Locked="Podman"} {Locked="podman.exe"} {Locked="PATH"} {Locked="Visual Studio"}</comment>
</data>
<data name="Podman_HostnameAutomationName" xml:space="preserve">
<value>Optional Podman Host name</value>
</data>
Expand Down
Loading