cloudapi: move manifest seed into an image request
The goal of this commit is primarily to simplify the API of the enqueue methods. This way, basically everything needed to generate manifests is in the imageRequest structure, which simplifies the amount of structures that we need to think about. Signed-off-by: Ondřej Budai <ondrej@budai.cz>
This commit is contained in:
parent
7385cab165
commit
28ef0bc855
2 changed files with 10 additions and 8 deletions
|
|
@ -141,6 +141,7 @@ type imageRequest struct {
|
|||
imageOptions distro.ImageOptions
|
||||
targets []*target.Target
|
||||
blueprint blueprint.Blueprint
|
||||
manifestSeed int64
|
||||
}
|
||||
|
||||
func (h *apiHandlers) PostCompose(ctx echo.Context) error {
|
||||
|
|
@ -271,17 +272,18 @@ func (h *apiHandlers) PostCompose(ctx echo.Context) error {
|
|||
imageOptions: imageOptions,
|
||||
targets: irTargets,
|
||||
blueprint: bp,
|
||||
manifestSeed: manifestSeed,
|
||||
})
|
||||
}
|
||||
|
||||
var id uuid.UUID
|
||||
if request.Koji != nil {
|
||||
id, err = h.server.enqueueKojiCompose(uint64(request.Koji.TaskId), request.Koji.Server, request.Koji.Name, request.Koji.Version, request.Koji.Release, manifestSeed, irs, channel)
|
||||
id, err = h.server.enqueueKojiCompose(uint64(request.Koji.TaskId), request.Koji.Server, request.Koji.Name, request.Koji.Version, request.Koji.Release, irs, channel)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
id, err = h.server.enqueueCompose(manifestSeed, irs, channel)
|
||||
id, err = h.server.enqueueCompose(irs, channel)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ func (s *Server) Shutdown() {
|
|||
s.goroutinesGroup.Wait()
|
||||
}
|
||||
|
||||
func (s *Server) enqueueCompose(manifestSeed int64, irs []imageRequest, channel string) (uuid.UUID, error) {
|
||||
func (s *Server) enqueueCompose(irs []imageRequest, channel string) (uuid.UUID, error) {
|
||||
var id uuid.UUID
|
||||
if len(irs) != 1 {
|
||||
return id, HTTPError(ErrorInvalidNumberOfImageBuilds)
|
||||
|
|
@ -129,7 +129,7 @@ func (s *Server) enqueueCompose(manifestSeed int64, irs []imageRequest, channel
|
|||
arch := ir.imageType.Arch()
|
||||
distribution := arch.Distro()
|
||||
|
||||
manifestSource, _, err := ir.imageType.Manifest(&ibp, ir.imageOptions, ir.repositories, manifestSeed)
|
||||
manifestSource, _, err := ir.imageType.Manifest(&ibp, ir.imageOptions, ir.repositories, ir.manifestSeed)
|
||||
if err != nil {
|
||||
logrus.Warningf("ErrorEnqueueingJob, failed generating manifest: %v", err)
|
||||
return id, HTTPErrorWithInternal(ErrorEnqueueingJob, err)
|
||||
|
|
@ -226,14 +226,14 @@ func (s *Server) enqueueCompose(manifestSeed int64, irs []imageRequest, channel
|
|||
|
||||
s.goroutinesGroup.Add(1)
|
||||
go func() {
|
||||
serializeManifest(s.goroutinesCtx, manifestSource, s.workers, depsolveJobID, containerResolveJobID, ostreeResolveJobID, manifestJobID, manifestSeed)
|
||||
serializeManifest(s.goroutinesCtx, manifestSource, s.workers, depsolveJobID, containerResolveJobID, ostreeResolveJobID, manifestJobID, ir.manifestSeed)
|
||||
defer s.goroutinesGroup.Done()
|
||||
}()
|
||||
|
||||
return id, nil
|
||||
}
|
||||
|
||||
func (s *Server) enqueueKojiCompose(taskID uint64, server, name, version, release string, manifestSeed int64, irs []imageRequest, channel string) (uuid.UUID, error) {
|
||||
func (s *Server) enqueueKojiCompose(taskID uint64, server, name, version, release string, irs []imageRequest, channel string) (uuid.UUID, error) {
|
||||
var id uuid.UUID
|
||||
kojiDirectory := "osbuild-cg/osbuild-composer-koji-" + uuid.New().String()
|
||||
|
||||
|
|
@ -256,7 +256,7 @@ func (s *Server) enqueueKojiCompose(taskID uint64, server, name, version, releas
|
|||
arch := ir.imageType.Arch()
|
||||
distribution := arch.Distro()
|
||||
|
||||
manifestSource, _, err := ir.imageType.Manifest(&ibp, ir.imageOptions, ir.repositories, manifestSeed)
|
||||
manifestSource, _, err := ir.imageType.Manifest(&ibp, ir.imageOptions, ir.repositories, ir.manifestSeed)
|
||||
if err != nil {
|
||||
logrus.Errorf("ErrorEnqueueingJob, failed generating manifest: %v", err)
|
||||
return id, HTTPErrorWithInternal(ErrorEnqueueingJob, err)
|
||||
|
|
@ -380,7 +380,7 @@ func (s *Server) enqueueKojiCompose(taskID uint64, server, name, version, releas
|
|||
// copy the image request while passing it into the goroutine to prevent data races
|
||||
s.goroutinesGroup.Add(1)
|
||||
go func(ir imageRequest) {
|
||||
serializeManifest(s.goroutinesCtx, manifestSource, s.workers, depsolveJobID, containerResolveJobID, ostreeResolveJobID, manifestJobID, manifestSeed)
|
||||
serializeManifest(s.goroutinesCtx, manifestSource, s.workers, depsolveJobID, containerResolveJobID, ostreeResolveJobID, manifestJobID, ir.manifestSeed)
|
||||
defer s.goroutinesGroup.Done()
|
||||
}(ir)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue