store: make PushCompose() take a manifest

Code that's calling PushCompose() had to depsolve packages and fetch the
right ImageType from a distro, but not create the osbuild manifest. That
was left for PushCompose to do. Move it out of there to the callers, so
that the store is mainly concerned with storing things.

This also simplifies the argument list of PushCompose().
This commit is contained in:
Lars Karlitski 2020-04-17 19:22:09 +02:00 committed by Tom Gundersen
parent 2b7adb3200
commit 37b42d452b
4 changed files with 46 additions and 22 deletions

View file

@ -204,8 +204,19 @@ func (api *API) submit(writer http.ResponseWriter, request *http.Request, _ http
return
}
size := imageType.Size(0)
manifest, err := imageType.Manifest(nil, repoConfigs, packages, buildPackages, size)
if err != nil {
writer.WriteHeader(http.StatusBadRequest)
_, err := writer.Write([]byte(err.Error()))
if err != nil {
panic("Failed to write response")
}
return
}
// Push the requested compose to the store
composeID, err := api.store.PushCompose(imageType, &blueprint.Blueprint{}, repoConfigs, packages, buildPackages, 0, nil)
composeID, err := api.store.PushCompose(manifest, imageType.Name(), &blueprint.Blueprint{}, 0, nil)
if err != nil {
if api.logger != nil {
api.logger.Println("RCM API failed to push compose:", err)