weldr: use "Worker Server" target instead of setting ImageName

Stop relying on the server interpreting the set `ImageName` in the
`OSBuildJob` as a signal to upload the image back to the worker server
and add an explicit "Worker Server" upload target to the job.
This commit is contained in:
Tomas Hozza 2022-06-29 16:49:09 +02:00 committed by Tom Gundersen
parent a12827865d
commit 165a05ab43
2 changed files with 67 additions and 4 deletions

View file

@ -2247,10 +2247,16 @@ func (api *API) composeHandler(writer http.ResponseWriter, request *http.Request
composeID := uuid.New()
var targets []*target.Target
// Always instruct the worker to upload the artifact back to the server
workerServerTarget := target.NewWorkerServerTarget()
workerServerTarget.ImageName = imageType.Filename()
workerServerTarget.OsbuildArtifact.ExportFilename = imageType.Filename()
targets = append(targets, workerServerTarget)
if isRequestVersionAtLeast(params, 1) && cr.Upload != nil {
t := uploadRequestToTarget(*cr.Upload, imageType)
targets = append(targets, t)
}
// Check for test parameter
q, err := url.ParseQuery(request.URL.RawQuery)
if err != nil {
@ -2348,10 +2354,9 @@ func (api *API) composeHandler(writer http.ResponseWriter, request *http.Request
var jobId uuid.UUID
jobId, err = api.workers.EnqueueOSBuild(api.archName, &worker.OSBuildJob{
Manifest: manifest,
Targets: targets,
ImageName: imageType.Filename(),
Exports: imageType.Exports(),
Manifest: manifest,
Targets: targets,
Exports: imageType.Exports(),
PipelineNames: &worker.PipelineNames{
Build: imageType.BuildPipelines(),
Payload: imageType.PayloadPipelines(),