Skip to content

Commit cdb5ac0

Browse files
croissanneochosi
authored andcommitted
cloudapi: add job progress to compose status
Adds the job progress to the image status(es) inside of a compose status. The spec only allows for one level of subprogress.
1 parent 1a19093 commit cdb5ac0

File tree

4 files changed

+299
-215
lines changed

4 files changed

+299
-215
lines changed

internal/cloudapi/v2/handler.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ func (h *apiHandlers) getJobIDComposeStatus(jobId uuid.UUID) (ComposeStatus, err
426426
Error: composeStatusErrorFromJobError(jobError),
427427
UploadStatus: us0, // add the first upload status to the old top-level field
428428
UploadStatuses: uploadStatuses,
429+
Progress: progressFromJobResult(result.Progress),
429430
},
430431
}, nil
431432
} else if jobType == worker.JobTypeKojiFinalize {
@@ -484,6 +485,7 @@ func (h *apiHandlers) getJobIDComposeStatus(jobId uuid.UUID) (ComposeStatus, err
484485
buildJobStatuses = append(buildJobStatuses, ImageStatus{
485486
Status: imageStatusFromKojiJobStatus(buildInfo.JobStatus, &initResult, &buildJobResult),
486487
Error: composeStatusErrorFromJobError(buildJobError),
488+
Progress: progressFromJobResult(buildJobResult.Progress),
487489
UploadStatus: us0, // add the first upload status to the old top-level field
488490
UploadStatuses: uploadStatuses,
489491
})
@@ -513,6 +515,23 @@ func (h *apiHandlers) getJobIDComposeStatus(jobId uuid.UUID) (ComposeStatus, err
513515
}
514516
}
515517

518+
func progressFromJobResult(jobProgress *worker.JobProgress) *Progress {
519+
var progress *Progress
520+
if jobProgress != nil {
521+
progress = &Progress{
522+
Done: jobProgress.Done,
523+
Total: jobProgress.Total,
524+
}
525+
if jobProgress.SubProgress != nil {
526+
progress.SubProgress = &SubProgress{
527+
Done: jobProgress.SubProgress.Done,
528+
Total: jobProgress.SubProgress.Total,
529+
}
530+
}
531+
}
532+
return progress
533+
}
534+
516535
func composeStatusErrorFromJobError(jobError *clienterrors.Error) *ComposeStatusError {
517536
if jobError == nil {
518537
return nil

0 commit comments

Comments
 (0)