Until now, all jobs were put as "osbuild" jobs into the job queue and the worker API hard-coded sending an osbuild manifest and upload targets. Change the API to take a "type" and "args" keys, which are equivalent to the job-queue's type and args. Workers continue to support only osbuild jobs, but this makes other jobs possible in the future.
52 lines
1.2 KiB
Go
52 lines
1.2 KiB
Go
package worker
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"github.com/google/uuid"
|
|
"github.com/osbuild/osbuild-composer/internal/common"
|
|
"github.com/osbuild/osbuild-composer/internal/distro"
|
|
"github.com/osbuild/osbuild-composer/internal/osbuild"
|
|
"github.com/osbuild/osbuild-composer/internal/target"
|
|
)
|
|
|
|
//
|
|
// JSON-serializable types for the jobqueue
|
|
//
|
|
|
|
type OSBuildJob struct {
|
|
Manifest distro.Manifest `json:"manifest"`
|
|
Targets []*target.Target `json:"targets,omitempty"`
|
|
}
|
|
|
|
type OSBuildJobResult struct {
|
|
OSBuildOutput *osbuild.Result `json:"osbuild_output,omitempty"`
|
|
}
|
|
|
|
//
|
|
// JSON-serializable types for the HTTP API
|
|
//
|
|
|
|
type statusResponse struct {
|
|
Status string `json:"status"`
|
|
}
|
|
|
|
type requestJobResponse struct {
|
|
Id uuid.UUID `json:"id"`
|
|
Location string `json:"location"`
|
|
ArtifactLocation string `json:"artifact_location"`
|
|
Type string `json:"type"`
|
|
Args json.RawMessage `json:"args,omitempty"`
|
|
}
|
|
|
|
type getJobResponse struct {
|
|
Canceled bool `json:"canceled"`
|
|
}
|
|
|
|
type updateJobRequest struct {
|
|
Status common.ImageBuildState `json:"status"`
|
|
Result *osbuild.Result `json:"result"`
|
|
}
|
|
|
|
type updateJobResponse struct {
|
|
}
|