courgette/internal/runner/driver.go

28 lines
594 B
Go

package runner
import (
"errors"
)
type ContainerDriver interface {
Pull(string) error
Start(string, string) error
Stop(string) error
Exec(string, string) CommandResult
}
// Represents the outcome of a command call made by the driver.
type CommandResult struct {
// Exit code of the underlying exec.Command call.
ExitCode int
// Error (or nil) returned by the attempt to run the command.
Error error
}
func NewDriver(driverType string) (ContainerDriver, error) {
if driverType == "podman" {
return &PodmanDriver{}, nil
}
return nil, errors.New("Unrecognized driver type.")
}