@@ -82,30 +82,42 @@ func NewStdio(stdin, stdout, stderr string) Stdio {
8282 }
8383}
8484
85+ type ContainerOpts struct {
86+ Root string
87+ ID string
88+ Bundle string
89+ Runtime string
90+ RuntimeArgs []string
91+ Labels []string
92+ NoPivotRoot bool
93+ }
94+
8595// New returns a new container
86- func New (root , id , bundle , runtimeName string , runtimeArgs , labels [] string ) (Container , error ) {
96+ func New (opts ContainerOpts ) (Container , error ) {
8797 c := & container {
88- root : root ,
89- id : id ,
90- bundle : bundle ,
91- labels : labels ,
98+ root : opts . Root ,
99+ id : opts . ID ,
100+ bundle : opts . Bundle ,
101+ labels : opts . Labels ,
92102 processes : make (map [string ]* process ),
93- runtime : runtimeName ,
94- runtimeArgs : runtimeArgs ,
103+ runtime : opts .Runtime ,
104+ runtimeArgs : opts .RuntimeArgs ,
105+ noPivotRoot : opts .NoPivotRoot ,
95106 }
96- if err := os .Mkdir (filepath .Join (root , id ), 0755 ); err != nil {
107+ if err := os .Mkdir (filepath .Join (c . root , c . id ), 0755 ); err != nil {
97108 return nil , err
98109 }
99- f , err := os .Create (filepath .Join (root , id , StateFile ))
110+ f , err := os .Create (filepath .Join (c . root , c . id , StateFile ))
100111 if err != nil {
101112 return nil , err
102113 }
103114 defer f .Close ()
104115 if err := json .NewEncoder (f ).Encode (state {
105- Bundle : bundle ,
106- Labels : labels ,
107- Runtime : runtimeName ,
108- RuntimeArgs : runtimeArgs ,
116+ Bundle : c .bundle ,
117+ Labels : c .labels ,
118+ Runtime : c .runtime ,
119+ RuntimeArgs : c .runtimeArgs ,
120+ NoPivotRoot : opts .NoPivotRoot ,
109121 }); err != nil {
110122 return nil , err
111123 }
@@ -129,6 +141,7 @@ func Load(root, id string) (Container, error) {
129141 labels : s .Labels ,
130142 runtime : s .Runtime ,
131143 runtimeArgs : s .RuntimeArgs ,
144+ noPivotRoot : s .NoPivotRoot ,
132145 processes : make (map [string ]* process ),
133146 }
134147 dirs , err := ioutil .ReadDir (filepath .Join (root , id ))
@@ -177,6 +190,7 @@ type container struct {
177190 processes map [string ]* process
178191 labels []string
179192 oomFds []int
193+ noPivotRoot bool
180194}
181195
182196func (c * container ) ID () string {
0 commit comments