...
1
2
3 package exec
4
5 import (
6 "github.com/Microsoft/hcsshim/internal/conpty"
7 "github.com/Microsoft/hcsshim/internal/jobobject"
8 "golang.org/x/sys/windows"
9 )
10
11 type ExecOpts func(e *execConfig) error
12
13 type execConfig struct {
14 dir string
15 env []string
16 stdout, stderr, stdin bool
17
18 job *jobobject.JobObject
19 cpty *conpty.Pty
20 token windows.Token
21 processFlags uint32
22 }
23
24
25 func WithDir(dir string) ExecOpts {
26 return func(e *execConfig) error {
27 e.dir = dir
28 return nil
29 }
30 }
31
32
33
34 func WithStdio(stdout, stderr, stdin bool) ExecOpts {
35 return func(e *execConfig) error {
36 e.stdout = stdout
37 e.stderr = stderr
38 e.stdin = stdin
39 return nil
40 }
41 }
42
43
44 func WithEnv(env []string) ExecOpts {
45 return func(e *execConfig) error {
46 e.env = env
47 return nil
48 }
49 }
50
51
52 func WithJobObject(job *jobobject.JobObject) ExecOpts {
53 return func(e *execConfig) error {
54 e.job = job
55 return nil
56 }
57 }
58
59
60 func WithConPty(cpty *conpty.Pty) ExecOpts {
61 return func(e *execConfig) error {
62 e.cpty = cpty
63 return nil
64 }
65 }
66
67
68 func WithToken(token windows.Token) ExecOpts {
69 return func(e *execConfig) error {
70 e.token = token
71 return nil
72 }
73 }
74
75
76 func WithProcessFlags(flags uint32) ExecOpts {
77 return func(e *execConfig) error {
78 e.processFlags = flags
79 return nil
80 }
81 }
82
View as plain text