kojiapi: include image type exports in Koji job args
Koji image request handling now reads the exports defined by each image type. All APIs now support reading the exports defined by each image type. The worker still falls back to "assembler" in case the call comes from an older version of composer.
This commit is contained in:
parent
14a74cf173
commit
1a3447ed38
3 changed files with 18 additions and 2 deletions
|
|
@ -85,15 +85,27 @@ func (impl *OSBuildKojiJobImpl) Run(job worker.Job) error {
|
|||
return err
|
||||
}
|
||||
|
||||
exports := []string{"assembler"} // NOTE: Koji API doesn't support new image types yet
|
||||
if initArgs.KojiError == "" {
|
||||
exports := args.Exports
|
||||
if len(exports) == 0 {
|
||||
// job did not define exports, likely coming from an older version of composer
|
||||
// fall back to default "assembler"
|
||||
exports = []string{"assembler"}
|
||||
} else if len(exports) > 1 {
|
||||
// this worker only supports returning one (1) export
|
||||
return fmt.Errorf("at most one build artifact can be exported")
|
||||
}
|
||||
result.OSBuildOutput, err = RunOSBuild(args.Manifest, impl.Store, outputDirectory, exports, os.Stderr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// NOTE: Currently OSBuild supports multiple exports, but this isn't used
|
||||
// by any of the image types and it can't be specified during the request.
|
||||
// Use the first (and presumably only) export for the imagePath.
|
||||
exportPath := exports[0]
|
||||
if result.OSBuildOutput.Success {
|
||||
f, err := os.Open(path.Join(outputDirectory, args.ImageName))
|
||||
f, err := os.Open(path.Join(outputDirectory, exportPath, args.ImageName))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@ func (h *apiHandlers) PostCompose(ctx echo.Context) error {
|
|||
manifest distro.Manifest
|
||||
arch string
|
||||
filename string
|
||||
exports []string
|
||||
}
|
||||
|
||||
imageRequests := make([]imageRequest, len(request.ImageRequests))
|
||||
|
|
@ -138,6 +139,7 @@ func (h *apiHandlers) PostCompose(ctx echo.Context) error {
|
|||
imageRequests[i].manifest = manifest
|
||||
imageRequests[i].arch = arch.Name()
|
||||
imageRequests[i].filename = imageType.Filename()
|
||||
imageRequests[i].exports = imageType.Exports()
|
||||
|
||||
kojiFilenames[i] = fmt.Sprintf(
|
||||
"%s-%s-%s.%s%s",
|
||||
|
|
@ -165,6 +167,7 @@ func (h *apiHandlers) PostCompose(ctx echo.Context) error {
|
|||
id, err := h.server.workers.EnqueueOSBuildKoji(ir.arch, &worker.OSBuildKojiJob{
|
||||
Manifest: ir.manifest,
|
||||
ImageName: ir.filename,
|
||||
Exports: ir.exports,
|
||||
KojiServer: request.Koji.Server,
|
||||
KojiDirectory: kojiDirectory,
|
||||
KojiFilename: kojiFilenames[i],
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ type KojiInitJobResult struct {
|
|||
type OSBuildKojiJob struct {
|
||||
Manifest distro.Manifest `json:"manifest"`
|
||||
ImageName string `json:"image_name"`
|
||||
Exports []string `json:"exports"`
|
||||
KojiServer string `json:"koji_server"`
|
||||
KojiDirectory string `json:"koji_directory"`
|
||||
KojiFilename string `json:"koji_filename"`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue