Make Manifest() return manifest.Manifest

Return manifest.Manifest from the Manifest() function without
serializing.  The caller then has to call the manifest.Serialize()
function using the depsolved packages.

This moves towards changing the order of actions required to generate a
manifest.  With this change, the manifest creation and depsolving can be
done independently, but this still requires instantiating the manifest
object twice (InstantiateManifest() is called in PackageSets() and
Manifest()), which we don't want to have to do.
This commit is contained in:
Achilleas Koutsou 2023-04-12 19:54:03 +02:00 committed by Simon de Vlieger
parent db431a565d
commit 12e8ab3ac6
20 changed files with 145 additions and 80 deletions

View file

@ -2542,7 +2542,16 @@ func (api *API) composeHandler(writer http.ResponseWriter, request *http.Request
if err != nil {
errors := responseError{
ID: "ManifestCreationFailed",
Msg: fmt.Sprintf("failed to create osbuild manifest: %v", err),
Msg: fmt.Sprintf("failed to initialize osbuild manifest: %v", err),
}
statusResponseError(writer, http.StatusBadRequest, errors)
return
}
mf, err := manifest.Serialize(packageSets)
if err != nil {
errors := responseError{
ID: "ManifestCreationFailed",
Msg: fmt.Sprintf("failed to serialize osbuild manifest: %v", err),
}
statusResponseError(writer, http.StatusBadRequest, errors)
return
@ -2559,15 +2568,15 @@ func (api *API) composeHandler(writer http.ResponseWriter, request *http.Request
if testMode == "1" {
// Create a failed compose
err = api.store.PushTestCompose(composeID, manifest, imageType, bp, size, targets, false, packages)
err = api.store.PushTestCompose(composeID, mf, imageType, bp, size, targets, false, packages)
} else if testMode == "2" {
// Create a successful compose
err = api.store.PushTestCompose(composeID, manifest, imageType, bp, size, targets, true, packages)
err = api.store.PushTestCompose(composeID, mf, imageType, bp, size, targets, true, packages)
} else {
var jobId uuid.UUID
jobId, err = api.workers.EnqueueOSBuild(api.archName, &worker.OSBuildJob{
Manifest: manifest,
Manifest: mf,
Targets: targets,
PipelineNames: &worker.PipelineNames{
Build: imageType.BuildPipelines(),
@ -2575,7 +2584,7 @@ func (api *API) composeHandler(writer http.ResponseWriter, request *http.Request
},
}, "")
if err == nil {
err = api.store.PushCompose(composeID, manifest, imageType, bp, size, targets, jobId, packages)
err = api.store.PushCompose(composeID, mf, imageType, bp, size, targets, jobId, packages)
}
}