@@ -317,8 +317,18 @@ func (b *debugProgressBar) SetProgress(subLevel int, msg string, done int, total
317
317
return nil
318
318
}
319
319
320
+ type OSBuildOptions struct {
321
+ StoreDir string
322
+ OutputDir string
323
+ ExtraEnv []string
324
+ }
325
+
320
326
// XXX: merge variant back into images/pkg/osbuild/osbuild-exec.go
321
- func RunOSBuild (pb ProgressBar , manifest []byte , store , outputDirectory string , exports , extraEnv []string ) error {
327
+ func RunOSBuild (pb ProgressBar , manifest []byte , exports []string , opts * OSBuildOptions ) error {
328
+ if opts == nil {
329
+ opts = & OSBuildOptions {}
330
+ }
331
+
322
332
// To keep maximum compatibility keep the old behavior to run osbuild
323
333
// directly and show all messages unless we have a "real" progress bar.
324
334
//
@@ -328,20 +338,20 @@ func RunOSBuild(pb ProgressBar, manifest []byte, store, outputDirectory string,
328
338
// just run with the new runOSBuildWithProgress() helper.
329
339
switch pb .(type ) {
330
340
case * terminalProgressBar , * debugProgressBar :
331
- return runOSBuildWithProgress (pb , manifest , store , outputDirectory , exports , extraEnv )
341
+ return runOSBuildWithProgress (pb , manifest , exports , opts )
332
342
default :
333
- return runOSBuildNoProgress (pb , manifest , store , outputDirectory , exports , extraEnv )
343
+ return runOSBuildNoProgress (pb , manifest , exports , opts )
334
344
}
335
345
}
336
346
337
- func runOSBuildNoProgress (pb ProgressBar , manifest []byte , store , outputDirectory string , exports , extraEnv []string ) error {
338
- _ , err := osbuild .RunOSBuild (manifest , store , outputDirectory , exports , nil , extraEnv , false , os .Stderr )
347
+ func runOSBuildNoProgress (pb ProgressBar , manifest []byte , exports []string , opts * OSBuildOptions ) error {
348
+ _ , err := osbuild .RunOSBuild (manifest , opts . StoreDir , opts . OutputDir , exports , nil , opts . ExtraEnv , false , os .Stderr )
339
349
return err
340
350
}
341
351
342
352
var osbuildCmd = "osbuild"
343
353
344
- func runOSBuildWithProgress (pb ProgressBar , manifest []byte , store , outputDirectory string , exports , extraEnv []string ) (err error ) {
354
+ func runOSBuildWithProgress (pb ProgressBar , manifest []byte , exports []string , opts * OSBuildOptions ) (err error ) {
345
355
rp , wp , err := os .Pipe ()
346
356
if err != nil {
347
357
return fmt .Errorf ("cannot create pipe for osbuild: %w" , err )
@@ -351,8 +361,8 @@ func runOSBuildWithProgress(pb ProgressBar, manifest []byte, store, outputDirect
351
361
352
362
cmd := exec .Command (
353
363
osbuildCmd ,
354
- "--store" , store ,
355
- "--output-directory" , outputDirectory ,
364
+ "--store" , opts . StoreDir ,
365
+ "--output-directory" , opts . OutputDir ,
356
366
"--monitor=JSONSeqMonitor" ,
357
367
"--monitor-fd=3" ,
358
368
"-" ,
@@ -362,7 +372,7 @@ func runOSBuildWithProgress(pb ProgressBar, manifest []byte, store, outputDirect
362
372
}
363
373
364
374
var stdio bytes.Buffer
365
- cmd .Env = append (os .Environ (), extraEnv ... )
375
+ cmd .Env = append (os .Environ (), opts . ExtraEnv ... )
366
376
cmd .Stdin = bytes .NewBuffer (manifest )
367
377
cmd .Stdout = & stdio
368
378
cmd .Stderr = & stdio
0 commit comments