@@ -76,7 +76,7 @@ func dboxGetVersion() (version string, err error) {
76
76
return splitted [1 ], nil
77
77
}
78
78
79
- func (d * dbox ) RunCommand (command string , args []string , engineFlags []string , useEngine bool , captureOutput bool , muteOutput bool ) ([]byte , error ) {
79
+ func (d * dbox ) RunCommand (command string , args []string , engineFlags []string , useEngine bool , captureOutput bool , muteOutput bool , rootFull bool ) ([]byte , error ) {
80
80
entrypoint := apx .Cnf .DistroboxPath
81
81
if useEngine {
82
82
entrypoint = d .EngineBinary
@@ -113,6 +113,12 @@ func (d *dbox) RunCommand(command string, args []string, engineFlags []string, u
113
113
cmd .Args = append (cmd .Args , strings .Join (engineFlags , " " ))
114
114
}
115
115
116
+ // NOTE: the root flag is not being used by the Apx CLI, but it's useful
117
+ // for those using Apx as a library, e.g. VSO.
118
+ if rootFull {
119
+ cmd .Args = append (cmd .Args , "--root" )
120
+ }
121
+
116
122
cmd .Args = append (cmd .Args , args ... )
117
123
118
124
if os .Getenv ("APX_VERBOSE" ) == "1" {
@@ -129,11 +135,11 @@ func (d *dbox) RunCommand(command string, args []string, engineFlags []string, u
129
135
return nil , err
130
136
}
131
137
132
- func (d * dbox ) ListContainers () ([]dboxContainer , error ) {
138
+ func (d * dbox ) ListContainers (rootFull bool ) ([]dboxContainer , error ) {
133
139
output , err := d .RunCommand ("ps" , []string {
134
140
"-a" ,
135
141
"--format" , "{{.ID}}|{{.CreatedAt}}|{{.Status}}|{{.Labels}}|{{.Names}}" ,
136
- }, []string {}, true , true , false )
142
+ }, []string {}, true , true , false , rootFull )
137
143
if err != nil {
138
144
return nil , err
139
145
}
@@ -178,8 +184,8 @@ func (d *dbox) ListContainers() ([]dboxContainer, error) {
178
184
return containers , nil
179
185
}
180
186
181
- func (d * dbox ) GetContainer (name string ) (* dboxContainer , error ) {
182
- containers , err := d .ListContainers ()
187
+ func (d * dbox ) GetContainer (name string , rootFull bool ) (* dboxContainer , error ) {
188
+ containers , err := d .ListContainers (rootFull )
183
189
if err != nil {
184
190
return nil , err
185
191
}
@@ -194,15 +200,15 @@ func (d *dbox) GetContainer(name string) (*dboxContainer, error) {
194
200
return nil , errors .New ("container not found" )
195
201
}
196
202
197
- func (d * dbox ) ContainerDelete (name string ) error {
203
+ func (d * dbox ) ContainerDelete (name string , rootFull bool ) error {
198
204
_ , err := d .RunCommand ("rm" , []string {
199
205
"--force" ,
200
206
name ,
201
- }, []string {}, false , false , true )
207
+ }, []string {}, false , false , true , rootFull )
202
208
return err
203
209
}
204
210
205
- func (d * dbox ) CreateContainer (name string , image string , additionalPackages []string , labels map [string ]string , withInit bool ) error {
211
+ func (d * dbox ) CreateContainer (name string , image string , additionalPackages []string , labels map [string ]string , withInit bool , rootFull bool ) error {
206
212
args := []string {
207
213
"--image" , image ,
208
214
"--name" , name ,
@@ -229,24 +235,24 @@ func (d *dbox) CreateContainer(name string, image string, additionalPackages []s
229
235
}
230
236
engineFlags = append (engineFlags , "--label=manager=apx" )
231
237
232
- _ , err := d .RunCommand ("create" , args , engineFlags , false , true , true )
238
+ _ , err := d .RunCommand ("create" , args , engineFlags , false , true , true , rootFull )
233
239
// fmt.Println(string(out))
234
240
return err
235
241
}
236
242
237
- func (d * dbox ) RunContainerCommand (name string , command []string ) error {
243
+ func (d * dbox ) RunContainerCommand (name string , command []string , rootFull bool ) error {
238
244
args := []string {
239
245
"--name" , name ,
240
246
"--" ,
241
247
}
242
248
243
249
args = append (args , command ... )
244
250
245
- _ , err := d .RunCommand ("run" , args , []string {}, false , false , false )
251
+ _ , err := d .RunCommand ("run" , args , []string {}, false , false , false , rootFull )
246
252
return err
247
253
}
248
254
249
- func (d * dbox ) ContainerExec (name string , captureOutput bool , muteOutput bool , args ... string ) (string , error ) {
255
+ func (d * dbox ) ContainerExec (name string , captureOutput bool , muteOutput bool , rootFull bool , args ... string ) (string , error ) {
250
256
finalArgs := []string {
251
257
// "--verbose",
252
258
name ,
@@ -256,22 +262,22 @@ func (d *dbox) ContainerExec(name string, captureOutput bool, muteOutput bool, a
256
262
finalArgs = append (finalArgs , args ... )
257
263
engineFlags := []string {}
258
264
259
- out , err := d .RunCommand ("enter" , finalArgs , engineFlags , false , captureOutput , muteOutput )
265
+ out , err := d .RunCommand ("enter" , finalArgs , engineFlags , false , captureOutput , muteOutput , rootFull )
260
266
return string (out ), err
261
267
}
262
268
263
- func (d * dbox ) ContainerEnter (name string ) error {
269
+ func (d * dbox ) ContainerEnter (name string , rootFull bool ) error {
264
270
finalArgs := []string {
265
271
name ,
266
272
}
267
273
268
274
engineFlags := []string {}
269
275
270
- _ , err := d .RunCommand ("enter" , finalArgs , engineFlags , false , false , false )
276
+ _ , err := d .RunCommand ("enter" , finalArgs , engineFlags , false , false , false , rootFull )
271
277
return err
272
278
}
273
279
274
- func (d * dbox ) ContainerExport (name string , delete bool , args ... string ) error {
280
+ func (d * dbox ) ContainerExport (name string , delete bool , rootFull bool , args ... string ) error {
275
281
finalArgs := []string {"distrobox-export" }
276
282
277
283
if delete {
@@ -280,26 +286,26 @@ func (d *dbox) ContainerExport(name string, delete bool, args ...string) error {
280
286
281
287
finalArgs = append (finalArgs , args ... )
282
288
283
- _ , err := d .ContainerExec (name , false , true , finalArgs ... )
289
+ _ , err := d .ContainerExec (name , false , true , rootFull , finalArgs ... )
284
290
return err
285
291
}
286
292
287
- func (d * dbox ) ContainerExportDesktopEntry (containerName string , appName string , label string ) error {
293
+ func (d * dbox ) ContainerExportDesktopEntry (containerName string , appName string , label string , rootFull bool ) error {
288
294
args := []string {"--app" , appName , "--export-label" , label }
289
- return d .ContainerExport (containerName , false , args ... )
295
+ return d .ContainerExport (containerName , false , rootFull , args ... )
290
296
}
291
297
292
- func (d * dbox ) ContainerUnexportDesktopEntry (containerName string , appName string ) error {
298
+ func (d * dbox ) ContainerUnexportDesktopEntry (containerName string , appName string , rootFull bool ) error {
293
299
args := []string {"--app" , appName }
294
- return d .ContainerExport (containerName , true , args ... )
300
+ return d .ContainerExport (containerName , true , rootFull , args ... )
295
301
}
296
302
297
- func (d * dbox ) ContainerExportBin (containerName string , binary string , exportPath string ) error {
303
+ func (d * dbox ) ContainerExportBin (containerName string , binary string , exportPath string , rootFull bool ) error {
298
304
args := []string {"--bin" , binary , "--export-path" , exportPath }
299
- return d .ContainerExport (containerName , false , args ... )
305
+ return d .ContainerExport (containerName , false , rootFull , args ... )
300
306
}
301
307
302
- func (d * dbox ) ContainerUnexportBin (containerName string , binary string , exportPath string ) error {
308
+ func (d * dbox ) ContainerUnexportBin (containerName string , binary string , exportPath string , rootFull bool ) error {
303
309
args := []string {"--bin" , binary , "--export-path" , exportPath }
304
- return d .ContainerExport (containerName , true , args ... )
310
+ return d .ContainerExport (containerName , true , rootFull , args ... )
305
311
}
0 commit comments