osbuild: add extraEnv argument to RunOSBuild
This adds the ability to supply extra environment variables to the osbuild process.
This commit is contained in:
parent
31072c1189
commit
2c0594629f
3 changed files with 8 additions and 3 deletions
|
|
@ -55,7 +55,7 @@ func RunPlayground(img image.ImageKind, d distro.Distro, arch distro.Arch, repos
|
|||
|
||||
store := path.Join(state_dir, "osbuild-store")
|
||||
|
||||
_, err = osbuild.RunOSBuild(bytes, store, "./", manifest.GetExports(), manifest.GetCheckpoints(), false, os.Stdout)
|
||||
_, err = osbuild.RunOSBuild(bytes, store, "./", manifest.GetExports(), manifest.GetCheckpoints(), nil, false, os.Stdout)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "could not run osbuild: %s", err.Error())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -307,7 +307,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
}
|
||||
|
||||
// Run osbuild and handle two kinds of errors
|
||||
osbuildJobResult.OSBuildOutput, err = osbuild.RunOSBuild(jobArgs.Manifest, impl.Store, outputDirectory, exports, nil, true, os.Stderr)
|
||||
osbuildJobResult.OSBuildOutput, err = osbuild.RunOSBuild(jobArgs.Manifest, impl.Store, outputDirectory, exports, nil, nil, true, os.Stderr)
|
||||
// First handle the case when "running" osbuild failed
|
||||
if err != nil {
|
||||
osbuildJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorBuildJob, "osbuild build failed")
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import (
|
|||
// Note that osbuild returns non-zero when the pipeline fails. This function
|
||||
// does not return an error in this case. Instead, the failure is communicated
|
||||
// with its corresponding logs through osbuild.Result.
|
||||
func RunOSBuild(manifest []byte, store, outputDirectory string, exports, checkpoints []string, result bool, errorWriter io.Writer) (*Result, error) {
|
||||
func RunOSBuild(manifest []byte, store, outputDirectory string, exports, checkpoints, extraEnv []string, result bool, errorWriter io.Writer) (*Result, error) {
|
||||
var stdoutBuffer bytes.Buffer
|
||||
var res Result
|
||||
|
||||
|
|
@ -39,6 +39,11 @@ func RunOSBuild(manifest []byte, store, outputDirectory string, exports, checkpo
|
|||
} else {
|
||||
cmd.Stdout = os.Stdout
|
||||
}
|
||||
|
||||
if len(extraEnv) > 0 {
|
||||
cmd.Env = append(os.Environ(), extraEnv...)
|
||||
}
|
||||
|
||||
cmd.Stderr = errorWriter
|
||||
stdin, err := cmd.StdinPipe()
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue