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
This commit is contained in:
33
runtime/runtime.go
Normal file
33
runtime/runtime.go
Normal file
@@ -0,0 +1,33 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user