worker/koji-finalize: handle multiple upload targets
Enhance the `koji-finalize` job implementation to be able to cope with multiple upload targets being specified for an `OSBuildJob`. Implement a convenience method `OSBuildJobResult.TargetResultsByName()` for filtering the target results attached to the job result by their name. Cover the method with an unit test. And lastly use this method in the `koji-finalize` job to find the appropriate Koji upload target results. This is a preparation for enabling cloud uploads for Koji composes.
This commit is contained in:
parent
58696e849f
commit
77a1672b79
3 changed files with 123 additions and 5 deletions
|
|
@ -153,13 +153,15 @@ func (impl *KojiFinalizeJobImpl) Run(job worker.Job) error {
|
|||
// multiple
|
||||
buildRPMs = rpmmd.DeduplicateRPMs(buildRPMs)
|
||||
|
||||
// TODO: support multiple upload targets
|
||||
if len(buildArgs.TargetResults) != 1 {
|
||||
kojiFinalizeJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorKojiFinalize, "Koji compose OSBuild job result must contain exactly one target result")
|
||||
kojiTargetResults := buildArgs.TargetResultsByName(target.TargetNameKoji)
|
||||
// Only a single Koji target is allowed per osbuild job
|
||||
if len(kojiTargetResults) != 1 {
|
||||
kojiFinalizeJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorKojiFinalize, "Exactly one Koji target results are expected per osbuild job")
|
||||
return nil
|
||||
}
|
||||
kojiTarget := buildArgs.TargetResults[0]
|
||||
kojiTargetOptions := kojiTarget.Options.(*target.KojiTargetResultOptions)
|
||||
|
||||
kojiTargetResult := kojiTargetResults[0]
|
||||
kojiTargetOptions := kojiTargetResult.Options.(*target.KojiTargetResultOptions)
|
||||
|
||||
buildRoots = append(buildRoots, koji.BuildRoot{
|
||||
ID: uint64(i),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue