cloudapi: Return the compose status of all root compose jobs
This returns the status using the same structure as it does for requesting individual statuses for the jobs. Related: RHEL-60120
This commit is contained in:
parent
24b939d4c7
commit
325a018c75
4 changed files with 72 additions and 0 deletions
|
|
@ -2,6 +2,7 @@
|
|||
package v2
|
||||
|
||||
import (
|
||||
"cmp"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
|
@ -295,6 +296,30 @@ func (h *apiHandlers) targetResultToUploadStatus(jobId uuid.UUID, t *target.Targ
|
|||
return us, nil
|
||||
}
|
||||
|
||||
// GetComposeList returns a list of the root job UUIDs
|
||||
func (h *apiHandlers) GetComposeList(ctx echo.Context) error {
|
||||
jobs, err := h.server.workers.AllRootJobIDs()
|
||||
if err != nil {
|
||||
return HTTPErrorWithInternal(ErrorGettingComposeList, err)
|
||||
}
|
||||
|
||||
// Gather up the details of each job
|
||||
var stats []ComposeStatus
|
||||
for _, jid := range jobs {
|
||||
s, err := h.getJobIDComposeStatus(jid)
|
||||
if err != nil {
|
||||
// TODO log this error?
|
||||
continue
|
||||
}
|
||||
stats = append(stats, s)
|
||||
}
|
||||
slices.SortFunc(stats, func(a, b ComposeStatus) int {
|
||||
return cmp.Compare(a.Id, b.Id)
|
||||
})
|
||||
|
||||
return ctx.JSON(http.StatusOK, stats)
|
||||
}
|
||||
|
||||
func (h *apiHandlers) GetComposeStatus(ctx echo.Context, id string) error {
|
||||
return h.server.EnsureJobChannel(h.getComposeStatusImpl)(ctx, id)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue