osbuild: move result serialization from common
In the same way `osbuild.Manifest` is the input to the osbuild API, `osbuild.Result` is the output. Move it to the `osbuild` package where it belongs. This is not a functional change. Signed-off-by: Tom Gundersen <teg@jklm.no>
This commit is contained in:
parent
360bf2aa04
commit
ac5f69e757
7 changed files with 23 additions and 18 deletions
|
|
@ -17,6 +17,7 @@ import (
|
|||
|
||||
"github.com/google/uuid"
|
||||
"github.com/osbuild/osbuild-composer/internal/common"
|
||||
"github.com/osbuild/osbuild-composer/internal/osbuild"
|
||||
"github.com/osbuild/osbuild-composer/internal/target"
|
||||
"github.com/osbuild/osbuild-composer/internal/upload/awsupload"
|
||||
"github.com/osbuild/osbuild-composer/internal/upload/azure"
|
||||
|
|
@ -86,7 +87,7 @@ func openAsStreamOptimizedVmdk(imagePath string) (*os.File, error) {
|
|||
return f, err
|
||||
}
|
||||
|
||||
func RunJob(job *worker.Job, store string, uploadFunc func(uuid.UUID, string, io.Reader) error) (*common.ComposeResult, error) {
|
||||
func RunJob(job *worker.Job, store string, uploadFunc func(uuid.UUID, string, io.Reader) error) (*osbuild.Result, error) {
|
||||
outputDirectory, err := ioutil.TempDir("/var/tmp", "osbuild-worker-*")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error creating temporary output directory: %v", err)
|
||||
|
|
@ -279,7 +280,7 @@ func main() {
|
|||
// This can happen in cases when OSBuild crashes and doesn't produce
|
||||
// a meaningful output. E.g. when the machine runs of disk space.
|
||||
if result == nil {
|
||||
result = &common.ComposeResult{
|
||||
result = &osbuild.Result{
|
||||
Success: false,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,20 +6,20 @@ import (
|
|||
"io"
|
||||
"os/exec"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/common"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro"
|
||||
"github.com/osbuild/osbuild-composer/internal/osbuild"
|
||||
)
|
||||
|
||||
type OSBuildError struct {
|
||||
Message string
|
||||
Result *common.ComposeResult
|
||||
Result *osbuild.Result
|
||||
}
|
||||
|
||||
func (e *OSBuildError) Error() string {
|
||||
return e.Message
|
||||
}
|
||||
|
||||
func RunOSBuild(manifest distro.Manifest, store, outputDirectory string, errorWriter io.Writer) (*common.ComposeResult, error) {
|
||||
func RunOSBuild(manifest distro.Manifest, store, outputDirectory string, errorWriter io.Writer) (*osbuild.Result, error) {
|
||||
cmd := exec.Command(
|
||||
"osbuild",
|
||||
"--store", store,
|
||||
|
|
@ -50,7 +50,7 @@ func RunOSBuild(manifest distro.Manifest, store, outputDirectory string, errorWr
|
|||
// FIXME: handle or comment this possible error
|
||||
_ = stdin.Close()
|
||||
|
||||
var result common.ComposeResult
|
||||
var result osbuild.Result
|
||||
err = json.NewDecoder(stdout).Decode(&result)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error decoding osbuild output: %#v", err)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue