cloudapi: Add DeleteCompose to delete a job by UUID

This adds the handler for DELETE /composes/{id} which will delete a job and
all of its dependencies, and any artifacts.

Related: RHEL-60120
This commit is contained in:
Brian C. Lane 2024-04-15 11:21:49 -07:00 committed by Tomáš Hozza
parent a569ac0f7b
commit 56fc58cca3
4 changed files with 111 additions and 2 deletions

View file

@ -385,6 +385,19 @@ func (s *Server) CleanupArtifacts() error {
return nil
}
// DeleteJob deletes a job and all of its dependencies
func (s *Server) DeleteJob(ctx context.Context, id uuid.UUID) error {
jobInfo, err := s.jobInfo(id, nil)
if err != nil {
return err
}
if jobInfo.JobStatus.Finished.IsZero() {
return fmt.Errorf("Cannot delete job before job is finished: %s", id)
}
return s.jobs.DeleteJob(ctx, id)
}
func (s *Server) OSBuildJobInfo(id uuid.UUID, result *OSBuildJobResult) (*JobInfo, error) {
jobInfo, err := s.jobInfo(id, result)
if err != nil {