worker: require workers to declare job types they accept

For now, workers must send `[ "osbuild" ]`.
This commit is contained in:
Lars Karlitski 2020-09-20 17:40:18 +02:00 committed by Tom Gundersen
parent d3c99b8e93
commit ba6a480e32
5 changed files with 21 additions and 4 deletions

View file

@ -252,12 +252,16 @@ func (h *apiHandlers) GetStatus(ctx echo.Context) error {
}
func (h *apiHandlers) RequestJob(ctx echo.Context) error {
var body struct{}
var body api.RequestJobJSONRequestBody
err := ctx.Bind(&body)
if err != nil {
return err
}
if len(body.Types) != 1 || body.Types[0] != "osbuild" {
return echo.NewHTTPError(http.StatusBadRequest, "invalid job types")
}
token, jobId, jobArgs, err := h.server.RequestJob(ctx.Request().Context())
if err != nil {
return err