kojiapi: expose logs on the API
Add an API route that returns logs for a specific compose. For now, this contains the result of the job, in JSON. The idea is to put more and more of this information into structured APIs. This is a first step to make logs available at all. Amend koji-compose.py to check that the route exist and contains as many "image_logs" as images that were requested (currently always 1). Based on a patch by Chloe Kaubisch <chloe.kaubisch@gmail.com>.
This commit is contained in:
parent
263f8d6360
commit
e47b44329e
4 changed files with 96 additions and 0 deletions
|
|
@ -10,6 +10,11 @@ import (
|
|||
"net/http"
|
||||
)
|
||||
|
||||
// ComposeLogs defines model for ComposeLogs.
|
||||
type ComposeLogs struct {
|
||||
ImageLogs []interface{} `json:"image_logs"`
|
||||
}
|
||||
|
||||
// ComposeRequest defines model for ComposeRequest.
|
||||
type ComposeRequest struct {
|
||||
Distribution string `json:"distribution"`
|
||||
|
|
@ -76,6 +81,9 @@ type ServerInterface interface {
|
|||
// The status of a compose
|
||||
// (GET /compose/{id})
|
||||
GetComposeId(ctx echo.Context, id string) error
|
||||
// Get logs for a compose.
|
||||
// (GET /compose/{id}/logs)
|
||||
GetComposeIdLogs(ctx echo.Context, id string) error
|
||||
// status
|
||||
// (GET /status)
|
||||
GetStatus(ctx echo.Context) error
|
||||
|
|
@ -111,6 +119,22 @@ func (w *ServerInterfaceWrapper) GetComposeId(ctx echo.Context) error {
|
|||
return err
|
||||
}
|
||||
|
||||
// GetComposeIdLogs converts echo context to params.
|
||||
func (w *ServerInterfaceWrapper) GetComposeIdLogs(ctx echo.Context) error {
|
||||
var err error
|
||||
// ------------- Path parameter "id" -------------
|
||||
var id string
|
||||
|
||||
err = runtime.BindStyledParameter("simple", false, "id", ctx.Param("id"), &id)
|
||||
if err != nil {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter id: %s", err))
|
||||
}
|
||||
|
||||
// Invoke the callback with all the unmarshalled arguments
|
||||
err = w.Handler.GetComposeIdLogs(ctx, id)
|
||||
return err
|
||||
}
|
||||
|
||||
// GetStatus converts echo context to params.
|
||||
func (w *ServerInterfaceWrapper) GetStatus(ctx echo.Context) error {
|
||||
var err error
|
||||
|
|
@ -144,6 +168,7 @@ func RegisterHandlers(router EchoRouter, si ServerInterface) {
|
|||
|
||||
router.POST("/compose", wrapper.PostCompose)
|
||||
router.GET("/compose/:id", wrapper.GetComposeId)
|
||||
router.GET("/compose/:id/logs", wrapper.GetComposeIdLogs)
|
||||
router.GET("/status", wrapper.GetStatus)
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue