2017-11-21 08:08:36 +00:00
|
|
|
package executor
|
|
|
|
|
|
|
|
import (
|
2018-01-16 22:30:10 +00:00
|
|
|
"context"
|
2017-11-21 08:08:36 +00:00
|
|
|
"io"
|
2018-08-01 21:15:43 +00:00
|
|
|
"net"
|
2022-01-31 20:05:17 +00:00
|
|
|
"syscall"
|
2017-11-21 08:08:36 +00:00
|
|
|
|
2020-10-27 06:13:39 +00:00
|
|
|
"github.com/moby/buildkit/snapshot"
|
2018-08-04 19:42:01 +00:00
|
|
|
"github.com/moby/buildkit/solver/pb"
|
2017-11-21 08:08:36 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type Meta struct {
|
2018-03-26 13:51:08 +00:00
|
|
|
Args []string
|
|
|
|
Env []string
|
|
|
|
User string
|
|
|
|
Cwd string
|
2020-06-16 14:49:44 +00:00
|
|
|
Hostname string
|
2018-03-26 13:51:08 +00:00
|
|
|
Tty bool
|
|
|
|
ReadonlyRootFS bool
|
2018-08-04 19:42:01 +00:00
|
|
|
ExtraHosts []HostIP
|
2021-10-08 09:49:52 +00:00
|
|
|
Ulimit []*pb.Ulimit
|
2021-10-27 21:50:15 +00:00
|
|
|
CgroupParent string
|
2018-08-04 19:42:01 +00:00
|
|
|
NetMode pb.NetMode
|
2019-01-10 02:24:25 +00:00
|
|
|
SecurityMode pb.SecurityMode
|
2017-11-21 08:08:36 +00:00
|
|
|
}
|
|
|
|
|
2020-10-27 06:13:39 +00:00
|
|
|
type Mountable interface {
|
|
|
|
Mount(ctx context.Context, readonly bool) (snapshot.Mountable, error)
|
|
|
|
}
|
|
|
|
|
2017-11-21 08:08:36 +00:00
|
|
|
type Mount struct {
|
2020-10-27 06:13:39 +00:00
|
|
|
Src Mountable
|
2017-11-21 08:08:36 +00:00
|
|
|
Selector string
|
|
|
|
Dest string
|
|
|
|
Readonly bool
|
|
|
|
}
|
|
|
|
|
2020-07-30 23:44:42 +00:00
|
|
|
type WinSize struct {
|
2020-07-31 20:20:59 +00:00
|
|
|
Rows uint32
|
|
|
|
Cols uint32
|
2020-07-30 23:44:42 +00:00
|
|
|
}
|
|
|
|
|
2020-07-09 23:07:28 +00:00
|
|
|
type ProcessInfo struct {
|
|
|
|
Meta Meta
|
|
|
|
Stdin io.ReadCloser
|
|
|
|
Stdout, Stderr io.WriteCloser
|
2020-07-30 23:44:42 +00:00
|
|
|
Resize <-chan WinSize
|
2022-01-31 20:05:17 +00:00
|
|
|
Signal <-chan syscall.Signal
|
2020-07-09 23:07:28 +00:00
|
|
|
}
|
|
|
|
|
2017-11-21 08:08:36 +00:00
|
|
|
type Executor interface {
|
2020-07-13 20:16:05 +00:00
|
|
|
// Run will start a container for the given process with rootfs, mounts.
|
|
|
|
// `id` is an optional name for the container so it can be referenced later via Exec.
|
|
|
|
// `started` is an optional channel that will be closed when the container setup completes and has started running.
|
2020-11-02 07:55:46 +00:00
|
|
|
Run(ctx context.Context, id string, rootfs Mount, mounts []Mount, process ProcessInfo, started chan<- struct{}) error
|
2020-07-13 20:16:05 +00:00
|
|
|
// Exec will start a process in container matching `id`. An error will be returned
|
|
|
|
// if the container failed to start (via Run) or has exited before Exec is called.
|
2020-07-09 23:07:28 +00:00
|
|
|
Exec(ctx context.Context, id string, process ProcessInfo) error
|
2017-11-21 08:08:36 +00:00
|
|
|
}
|
2018-08-01 21:15:43 +00:00
|
|
|
|
|
|
|
type HostIP struct {
|
|
|
|
Host string
|
|
|
|
IP net.IP
|
|
|
|
}
|