Files
unitdore/runtime/runtime.go
sgcommand aa7d85822c Initial commit: unitdore scaffold + syncup/edit commands
- config: load/save/add unit, Unit struct
- runtime: podman + docker discovery and exists check
- cmd: syncup (discover + reconcile), edit, cobra root
- PLAN.md: full project plan
2026-04-03 14:39:09 +02:00

34 lines
724 B
Go

package runtime
// Container represents a discovered running container.
type Container struct {
Name string
Image string
Command string
Runtime string // "podman" or "docker"
}
// Runtime is the interface all container runtimes must implement.
type Runtime interface {
Name() string
ListRunning() ([]Container, error)
Exists(name string) (bool, error)
}
// Available returns all supported runtimes (callers skip those with no binary).
func Available() []Runtime {
return []Runtime{&Podman{}, &Docker{}}
}
// Get returns a runtime by name ("podman" or "docker").
func Get(name string) Runtime {
switch name {
case "podman":
return &Podman{}
case "docker":
return &Docker{}
default:
return nil
}
}