store: move adding the local target to weldr

The automatic local target is only needed when accessing the API via
weldr.

In the store, the target was only added when `stateDir` was not `nil`.
This is only used for testing which doesn't exercise the branch in
weldr. Thus, the same check is not needed there.
This commit is contained in:
Lars Karlitski 2020-03-23 18:07:46 +01:00
parent 7594cb262e
commit 3544590036
3 changed files with 30 additions and 16 deletions

View file

@ -1407,11 +1407,18 @@ func (api *API) composeHandler(writer http.ResponseWriter, request *http.Request
return
}
var uploadTarget *target.Target
var targets []*target.Target
if isRequestVersionAtLeast(params, 1) && cr.Upload != nil {
uploadTarget = uploadRequestToTarget(*cr.Upload, imageType)
t := uploadRequestToTarget(*cr.Upload, imageType)
targets = append(targets, t)
}
targets = append(targets, target.NewLocalTarget(
&target.LocalTargetOptions{
Filename: imageType.Filename(),
},
))
bp := api.store.GetBlueprintCommitted(cr.BlueprintName)
if bp == nil {
errors := responseError{
@ -1437,7 +1444,7 @@ func (api *API) composeHandler(writer http.ResponseWriter, request *http.Request
Status: true,
}
err = api.store.PushCompose(api.distro, api.arch, imageType, reply.BuildID, bp, api.repos, packages, buildPackages, cr.Size, uploadTarget)
err = api.store.PushCompose(api.distro, api.arch, imageType, reply.BuildID, bp, api.repos, packages, buildPackages, cr.Size, targets)
// TODO: we should probably do some kind of blueprint validation in future
// for now, let's just 500 and bail out