-
Notifications
You must be signed in to change notification settings - Fork 41
/
exec.go
72 lines (59 loc) · 1.88 KB
/
exec.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package runrunc
import (
"io"
"os"
"code.cloudfoundry.org/garden"
"code.cloudfoundry.org/guardian/rundmc/goci"
"code.cloudfoundry.org/guardian/rundmc/users"
"code.cloudfoundry.org/lager/v3"
specs "github.com/opencontainers/runtime-spec/specs-go"
)
//counterfeiter:generate . UidGenerator
type UidGenerator interface {
Generate() string
}
//counterfeiter:generate . Mkdirer
type Mkdirer interface {
MkdirAs(rootFSPathFile string, uid, gid int, mode os.FileMode, recreate bool, path ...string) error
}
//counterfeiter:generate . BundleLoader
type BundleLoader interface {
Load(log lager.Logger, handle string) (goci.Bndl, error)
}
//counterfeiter:generate . ExecRunner
type ExecRunner interface {
Run(
log lager.Logger, processID, sandboxHandle string,
pio garden.ProcessIO, tty bool, procJSON io.Reader, extraCleanup func() error,
) (garden.Process, error)
RunPea(
log lager.Logger, processID string, bundle goci.Bndl, sandboxHandle string,
pio garden.ProcessIO, tty bool, procJSON io.Reader, extraCleanup func() error,
) (garden.Process, error)
Attach(log lager.Logger, sandboxHandle, processID string, io garden.ProcessIO) (garden.Process, error)
}
//counterfeiter:generate . ProcessBuilder
type ProcessBuilder interface {
BuildProcess(bndl goci.Bndl, processSpec garden.ProcessSpec, user *users.ExecUser) *specs.Process
}
//counterfeiter:generate . Waiter
type Waiter interface {
Wait() (int, error)
}
//counterfeiter:generate . Runner
type Runner interface {
Run(log lager.Logger)
}
//counterfeiter:generate . PidGetter
type PidGetter interface {
GetPid(log lager.Logger, containerHandle string) (int, error)
}
//counterfeiter:generate . WaitWatcher
type WaitWatcher interface { // get it??
OnExit(log lager.Logger, process Waiter, onExit Runner)
}
type Watcher struct{}
func (w Watcher) OnExit(log lager.Logger, process Waiter, onExit Runner) {
process.Wait()
onExit.Run(log)
}