Skip to content

Conversation

@jmgilman
Copy link
Collaborator

@jmgilman jmgilman commented Jan 2, 2026

Move duplicated code from podmanRuntime and appleRuntime into the shared baseRuntime struct using a strategy pattern. This eliminates ~90 lines of duplicate code and ensures consistent behavior between runtimes.

Changes:

  • Add containerParser interface for runtime-specific JSON parsing
  • Move Run, Exec, Stop, Start, Remove, Get, List, Build methods to baseRuntime
  • Add listArgs field to baseRuntime for runtime-specific list commands (Podman uses "ps -a", Apple uses "list")
  • Concrete runtimes now only implement JSON parsing via containerParser
  • Fix Apple runtime to parse CreatedAt timestamp (was always zero before)

The refactoring ensures both runtimes behave identically for all operations, with only the JSON parsing differing based on each CLI's output format.

Move duplicated code from podmanRuntime and appleRuntime into the shared
baseRuntime struct using a strategy pattern. This eliminates ~90 lines
of duplicate code and ensures consistent behavior between runtimes.

Changes:
- Add containerParser interface for runtime-specific JSON parsing
- Move Run, Exec, Stop, Start, Remove, Get, List, Build methods to baseRuntime
- Add listArgs field to baseRuntime for runtime-specific list commands
  (Podman uses "ps -a", Apple uses "list")
- Concrete runtimes now only implement JSON parsing via containerParser
- Fix Apple runtime to parse CreatedAt timestamp (was always zero before)

The refactoring ensures both runtimes behave identically for all operations,
with only the JSON parsing differing based on each CLI's output format.
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jan 2, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
headjack 0bd7116 Commit Preview URL

Branch Preview URL
Jan 02 2026, 11:39 PM

@GilmanLab GilmanLab deleted a comment from chatgpt-codex-connector bot Jan 2, 2026
Add defensive nil checks for r.parser in Get() and List() methods to
prevent panics if a runtime is constructed without initializing the
parser field. Returns ErrNoParser sentinel error instead of panicking.
@jmgilman jmgilman merged commit 4bd7b9e into master Jan 2, 2026
2 checks passed
@jmgilman jmgilman deleted the claude/review-container-interface-MUn79 branch January 2, 2026 23:41
jmgilman added a commit that referenced this pull request Jan 3, 2026
…time

Current behavior:
podmanRuntime and appleRuntime had ~90 lines of duplicated code with identical implementations for Run, Exec, Stop, Start, Remove, Get, List, and Build methods

New behavior:
All common functionality moved to shared baseRuntime struct using strategy pattern. Concrete runtimes only implement JSON parsing via containerParser interface. Apple runtime now correctly parses CreatedAt timestamp instead of always returning zero value.

Closes: #33
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