jobqueue: include image build id

The compose will soon move to a concept of including multiple image
builds per one compose, we need to accommodate extra identifier to
handle this scenario.
This commit is contained in:
Martin Sehnoutka 2020-02-10 09:36:09 +01:00 committed by Ondřej Budai
parent 73994eb06d
commit 80e01bb397
3 changed files with 44 additions and 33 deletions

View file

@ -89,15 +89,17 @@ func (api *API) addJobHandler(writer http.ResponseWriter, request *http.Request,
return
}
nextJob := api.store.PopCompose()
nextJob := api.store.PopJob()
writer.WriteHeader(http.StatusCreated)
json.NewEncoder(writer).Encode(Job{
ID: nextJob.ComposeID,
Distro: nextJob.Distro,
Pipeline: nextJob.Pipeline,
Targets: nextJob.Targets,
OutputType: nextJob.OutputType,
// FIXME: handle or comment this possible error
_ = json.NewEncoder(writer).Encode(Job{
ID: nextJob.ComposeID,
ImageBuildID: nextJob.ImageBuildID,
Distro: nextJob.Distro,
Pipeline: nextJob.Pipeline,
Targets: nextJob.Targets,
OutputType: nextJob.ImageType,
})
}
@ -121,7 +123,7 @@ func (api *API) updateJobHandler(writer http.ResponseWriter, request *http.Reque
return
}
err = api.store.UpdateCompose(id, body.Status, body.Image, body.Result)
err = api.store.UpdateImageBuildInCompose(id, body.ImageBuildID, body.Status, body.Image, body.Result)
if err != nil {
switch err.(type) {
case *store.NotFoundError: