cloudapi: Request depsolve from osbuild-worker
and return the response to the client. This uses the worker to depsolve the requested packages. The result is returned to the client as a list of packages using the same PackageMetadata schema as the ComposeStatus response. It will also time out after 5 minutes and return an error, using the same timeout constant as depsolving during manifest generation. Related: RHEL-60125
This commit is contained in:
parent
e06e62ca03
commit
02d0b8ec01
4 changed files with 165 additions and 3 deletions
|
|
@ -1354,3 +1354,52 @@ func uploadStatusFromJobStatus(js *worker.JobStatus, je *clienterrors.Error) Upl
|
|||
}
|
||||
return UploadStatusValueSuccess
|
||||
}
|
||||
|
||||
// PostDepsolveBlueprint depsolves the packages in a blueprint and returns
|
||||
// the results as a list of rpmmd.PackageSpecs
|
||||
func (h *apiHandlers) PostDepsolveBlueprint(ctx echo.Context) error {
|
||||
var request DepsolveRequest
|
||||
err := ctx.Bind(&request)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Depsolve the requested blueprint
|
||||
// Any errors returned are suitable as a response
|
||||
deps, err := request.Depsolve(h.server.distros, h.server.repos, h.server.workers)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return ctx.JSON(http.StatusOK,
|
||||
DepsolveResponse{
|
||||
Packages: packageSpecToPackageMetadata(deps),
|
||||
})
|
||||
}
|
||||
|
||||
// packageSpecToPackageMetadata converts the rpmmd.PackageSpec to PackageMetadata
|
||||
// This is used to return package information from the blueprint depsolve request
|
||||
// using the common PackageMetadata format from the openapi schema.
|
||||
func packageSpecToPackageMetadata(pkgspecs []rpmmd.PackageSpec) []PackageMetadata {
|
||||
packages := make([]PackageMetadata, 0)
|
||||
for _, rpm := range pkgspecs {
|
||||
// Set epoch if it is not 0
|
||||
|
||||
var epoch *string
|
||||
if rpm.Epoch > 0 {
|
||||
epoch = common.ToPtr(strconv.FormatUint(uint64(rpm.Epoch), 10))
|
||||
}
|
||||
packages = append(packages,
|
||||
PackageMetadata{
|
||||
Type: "rpm",
|
||||
Name: rpm.Name,
|
||||
Version: rpm.Version,
|
||||
Release: rpm.Release,
|
||||
Epoch: epoch,
|
||||
Arch: rpm.Arch,
|
||||
Checksum: common.ToPtr(rpm.Checksum),
|
||||
},
|
||||
)
|
||||
}
|
||||
return packages
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue