From df2c0c09bb64dffd2e2b1de229d2253cb7015fe1 Mon Sep 17 00:00:00 2001 From: Achilleas Koutsou Date: Tue, 16 May 2023 17:00:23 +0200 Subject: [PATCH] cloudapi: remove usage of ImageType.PackageSets() Still not using the new process for generating the manifest exactly. This commit only replaces the call to PackageSets() with a call to Manifest() to get the Content.PackageSets. This is essentially the same as before, when we were initialising the manifest object twice. The Manifest() function does a tiny bit more work than PackageSets(), but it's minimal and we gain the benefit of only having a single code path and, although it's run twice, it's always run in the same way. --- internal/cloudapi/v2/server.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/internal/cloudapi/v2/server.go b/internal/cloudapi/v2/server.go index f2522b483..57a182188 100644 --- a/internal/cloudapi/v2/server.go +++ b/internal/cloudapi/v2/server.go @@ -107,8 +107,13 @@ func (s *Server) enqueueCompose(distribution distro.Distro, bp blueprint.Bluepri } ir := irs[0] + manifestSource, _, err := ir.imageType.Manifest(&bp, ir.imageOptions, ir.repositories, manifestSeed) + if err != nil { + return id, HTTPErrorWithInternal(ErrorEnqueueingJob, err) + } + depsolveJobID, err := s.workers.EnqueueDepsolve(&worker.DepsolveJob{ - PackageSets: ir.imageType.PackageSets(bp, ir.imageOptions, ir.repositories), + PackageSets: manifestSource.Content.PackageSets, ModulePlatformID: distribution.ModulePlatformID(), Arch: ir.arch.Name(), Releasever: distribution.Releasever(), @@ -205,8 +210,13 @@ func (s *Server) enqueueKojiCompose(taskID uint64, server, name, version, releas var kojiFilenames []string var buildIDs []uuid.UUID for _, ir := range irs { + manifestSource, _, err := ir.imageType.Manifest(&bp, ir.imageOptions, ir.repositories, manifestSeed) + if err != nil { + return id, HTTPErrorWithInternal(ErrorEnqueueingJob, err) + } + depsolveJobID, err := s.workers.EnqueueDepsolve(&worker.DepsolveJob{ - PackageSets: ir.imageType.PackageSets(bp, ir.imageOptions, ir.repositories), + PackageSets: manifestSource.Content.PackageSets, ModulePlatformID: distribution.ModulePlatformID(), Arch: ir.arch.Name(), Releasever: distribution.Releasever(),