Skip to content

Refactor Docker transport into shared base classes and strategy pattern#1579

Open
WardenGnaw wants to merge 3 commits into
feature/podmanfrom
dev/waan/podman
Open

Refactor Docker transport into shared base classes and strategy pattern#1579
WardenGnaw wants to merge 3 commits into
feature/podmanfrom
dev/waan/podman

Conversation

@WardenGnaw

Copy link
Copy Markdown
Member

Refactoring the DockerContainer code to be extensible for other Container tools such as Podman.

Key changes:

  • ContainerTransportSettingsBase shared abstract base eliminates duplication in transport settings (exe name, host flag, command format)
  • IContainerDiscoveryStrategy interface with Docker implementation keeps runtime-specific logic out of the ViewModel
  • ContainerRuntimeType enum threaded through port picker -> ConnectionManager -> dialog for future extensibility
  • XAML bindings changed from static resources to ViewModel properties so labels can vary per runtime

Extract shared container transport infrastructure to enable additional
container runtimes without duplicating Docker code.

Key changes:
- `ContainerTransportSettingsBase` shared abstract base eliminates
  duplication in transport settings (exe name, host flag, command format)
- `IContainerDiscoveryStrategy` interface with Docker implementation
  keeps runtime-specific logic out of the ViewModel
- `ContainerRuntimeType` enum threaded through port picker ->
  ConnectionManager -> dialog for future extensibility
- XAML bindings changed from static resources to ViewModel properties
  so labels can vary per runtime

No behavioral changes - Docker works exactly as before.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the SSHDebugPS Docker container picker and transport settings to enable future support for additional container runtimes (e.g., Podman) by centralizing transport-command composition and isolating discovery/runtime-specific behavior behind a strategy interface.

Changes:

  • Introduces ContainerTransportSettingsBase (+ derived base types) and updates Docker transport settings to inherit from the shared base classes.
  • Adds ContainerRuntimeType plumbing through the port picker and ConnectionManager into the container picker dialog/ViewModel.
  • Adds IContainerDiscoveryStrategy with a Docker implementation and updates XAML to bind label/tooltip text via the ViewModel.
Show a summary per file
File Description
src/SSHDebugPS/UI/ViewModels/ContainerPickerViewModel.cs Adds runtime type + discovery strategy selection; exposes runtime-specific label/tooltip text for XAML bindings.
src/SSHDebugPS/UI/ContainerPickerDialogWindow.xaml.cs Threads ContainerRuntimeType into the dialog so the ViewModel can choose the right strategy.
src/SSHDebugPS/UI/ContainerPickerDialogWindow.xaml Switches label/tooltip/automation-name text from static resources to ViewModel-bound properties.
src/SSHDebugPS/IContainerDiscoveryStrategy.cs Introduces the discovery strategy interface used by the picker ViewModel.
src/SSHDebugPS/Docker/DockerDiscoveryStrategy.cs Implements Docker container discovery + platform assignment behind the strategy interface.
src/SSHDebugPS/ContainerRuntimeType.cs Adds an enum to identify which container runtime to query.
src/SSHDebugPS/ConnectionManager.cs Updates container picker window launch API to accept a runtime type.
src/SSHDebugPS/Docker/DockerPortPicker.cs Passes runtime type into ConnectionManager.ShowContainerPickerWindow.
src/SSHDebugPS/ContainerTransportSettingsBase.cs Adds shared base classes for container transport/exec/copy/command settings.
src/SSHDebugPS/Docker/TransportSettings/DockerTransportSettings.cs Refactors Docker command settings to use shared transport settings base.
src/SSHDebugPS/Docker/TransportSettings/DockerContainerTransportSettings.cs Refactors Docker container/exec/copy settings to shared base classes; defines docker exe/host flag constants.
src/SSHDebugPS/Docker/DockerHelper.cs Generalizes the local command runner helper to accept IPipeTransportSettings.
src/SSHDebugPS/Docker/DockerExecutionManager.cs Generalizes base settings type and adds a virtual factory method for exec settings creation.
src/SSHDebugPS/Docker/DockerConnection.cs Broadens runner factory to accept IPipeTransportSettings instead of Docker-only settings.
src/SSHDebugPS/Docker/DockerContainerInstance.cs Makes construction/properties extensible for derived container instance types.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 15/15 changed files
  • Comments generated: 2

Comment thread src/SSHDebugPS/UI/ViewModels/ContainerPickerViewModel.cs Outdated
Comment thread src/SSHDebugPS/Docker/DockerExecutionManager.cs
- Remove unused _runtimeType field from ContainerPickerViewModel
- Add explicit type check in DockerExecutionManager.CreateExecSettings
  instead of unsafe cast

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread src/SSHDebugPS/ContainerRuntimeType.cs
Comment thread src/SSHDebugPS/Docker/DockerContainerInstance.cs
Comment thread src/SSHDebugPS/Docker/DockerDiscoveryStrategy.cs Outdated
Comment thread src/SSHDebugPS/Docker/TransportSettings/DockerTransportSettings.cs Outdated
Comment thread src/SSHDebugPS/Docker/DockerPortPicker.cs
Comment thread src/SSHDebugPS/UI/ContainerPickerDialogWindow.xaml.cs Outdated
Comment thread src/SSHDebugPS/UI/ViewModels/ContainerPickerViewModel.cs Outdated

@gregg-miskelly gregg-miskelly left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise LGTM

- Seal DockerDiscoveryStrategy, DockerCommandSettings,
  DockerContainerTransportSettings, DockerExecSettings, DockerCopySettings
- Use StringComparison.OrdinalIgnoreCase for Windows check in
  AssignPlatforms instead of ToTitleCase + Contains
- Remove default parameter values for ContainerRuntimeType to force
  explicit runtime selection by callers

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
string containerPlatform = string.Empty;
if (DockerHelper.TryGetContainerPlatform(hostname, container.Name, out containerPlatform))
{
container.Platform = new CultureInfo("en-US", false).TextInfo.ToTitleCase(containerPlatform);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CultureInfo("en-US", false)

I didn't think about this originally, but shouldn't this be CultureInfo.CurrentCulture instead of hard-coding en-US?

@gregg-miskelly gregg-miskelly left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise looks good to me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants