executor.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package executor
  2. import (
  3. "context"
  4. "io"
  5. "net"
  6. "github.com/moby/buildkit/snapshot"
  7. "github.com/moby/buildkit/solver/pb"
  8. )
  9. type Meta struct {
  10. Args []string
  11. Env []string
  12. User string
  13. Cwd string
  14. Hostname string
  15. Tty bool
  16. ReadonlyRootFS bool
  17. ExtraHosts []HostIP
  18. NetMode pb.NetMode
  19. SecurityMode pb.SecurityMode
  20. }
  21. type Mountable interface {
  22. Mount(ctx context.Context, readonly bool) (snapshot.Mountable, error)
  23. }
  24. type Mount struct {
  25. Src Mountable
  26. Selector string
  27. Dest string
  28. Readonly bool
  29. }
  30. type WinSize struct {
  31. Rows uint32
  32. Cols uint32
  33. }
  34. type ProcessInfo struct {
  35. Meta Meta
  36. Stdin io.ReadCloser
  37. Stdout, Stderr io.WriteCloser
  38. Resize <-chan WinSize
  39. }
  40. type Executor interface {
  41. // Run will start a container for the given process with rootfs, mounts.
  42. // `id` is an optional name for the container so it can be referenced later via Exec.
  43. // `started` is an optional channel that will be closed when the container setup completes and has started running.
  44. Run(ctx context.Context, id string, rootfs Mount, mounts []Mount, process ProcessInfo, started chan<- struct{}) error
  45. // Exec will start a process in container matching `id`. An error will be returned
  46. // if the container failed to start (via Run) or has exited before Exec is called.
  47. Exec(ctx context.Context, id string, process ProcessInfo) error
  48. }
  49. type HostIP struct {
  50. Host string
  51. IP net.IP
  52. }