@@ -24,6 +24,8 @@ const (
2424 MonitorLog = "LogMonitor"
2525)
2626
27+ var OSBuildCmd = "osbuild"
28+
2729type OSBuildOptions struct {
2830 StoreDir string
2931 OutputDir string
@@ -47,7 +49,7 @@ func NewOSBuildCmd(manifest []byte, exports, checkpoints []string, optsPtr *OSBu
4749
4850 // nolint: gosec
4951 cmd := exec .Command (
50- "osbuild" ,
52+ OSBuildCmd ,
5153 "--store" , opts .StoreDir ,
5254 "--output-directory" , opts .OutputDir ,
5355 fmt .Sprintf ("--cache-max-size=%v" , cacheMaxSize ),
@@ -82,14 +84,16 @@ func NewOSBuildCmd(manifest []byte, exports, checkpoints []string, optsPtr *OSBu
8284// Note that osbuild returns non-zero when the pipeline fails. This function
8385// does not return an error in this case. Instead, the failure is communicated
8486// with its corresponding logs through osbuild.Result.
85- func RunOSBuild (manifest []byte , exports , checkpoints []string , errorWriter io.Writer , opts * OSBuildOptions ) (* Result , error ) {
87+ func RunOSBuild (manifest []byte , exports , checkpoints []string , errorWriter io.Writer , optsPtr * OSBuildOptions ) (* Result , error ) {
88+ opts := common .ValueOrEmpty (optsPtr )
89+
8690 if err := CheckMinimumOSBuildVersion (); err != nil {
8791 return nil , err
8892 }
8993
9094 var stdoutBuffer bytes.Buffer
9195 var res Result
92- cmd := NewOSBuildCmd (manifest , exports , checkpoints , opts )
96+ cmd := NewOSBuildCmd (manifest , exports , checkpoints , & opts )
9397
9498 if opts .JSONOutput {
9599 cmd .Stdout = & stdoutBuffer
@@ -152,7 +156,7 @@ func CheckMinimumOSBuildVersion() error {
152156// OSBuildVersion returns the version of osbuild.
153157func OSBuildVersion () (string , error ) {
154158 var stdoutBuffer bytes.Buffer
155- cmd := exec .Command ("osbuild" , "--version" )
159+ cmd := exec .Command (OSBuildCmd , "--version" )
156160 cmd .Stdout = & stdoutBuffer
157161
158162 err := cmd .Run ()
@@ -169,7 +173,7 @@ func OSBuildVersion() (string, error) {
169173
170174// OSBuildInspect converts a manifest to an inspected manifest.
171175func OSBuildInspect (manifest []byte ) ([]byte , error ) {
172- cmd := exec .Command ("osbuild" , "--inspect" )
176+ cmd := exec .Command (OSBuildCmd , "--inspect" )
173177 cmd .Stdin = bytes .NewBuffer (manifest )
174178
175179 out , err := cmd .Output ()
0 commit comments