Worker/koji-finalize: add cloud target results to image/build metadata

Add any non-Koji upload target results attached to an OSBuild result, to
the image extra metadata. This will make it easy to locate any image
from Koji uploaded to cloud, in the target cloud environment.

The rationale behind including only non-Koji target results is that one
can find it only in Koji, so there is no added value in including the
Koji target results at all.

Extend the `koji.sh` to check the target results in image metadata when
testing Koji scenario with cloud upload.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
This commit is contained in:
Tomáš Hozza 2023-09-19 18:00:23 +02:00 committed by Tomáš Hozza
parent e0ec3a2a1c
commit 4f51d44762
5 changed files with 201 additions and 0 deletions

View file

@ -10,6 +10,7 @@ import (
"github.com/osbuild/images/pkg/rpmmd"
"github.com/osbuild/osbuild-composer/internal/target"
"github.com/osbuild/osbuild-composer/internal/worker/clienterrors"
"golang.org/x/exp/slices"
)
//
@ -97,6 +98,19 @@ func (j *OSBuildJobResult) TargetResultsByName(name target.TargetName) []*target
return targetResults
}
// TargetResultsFilterByName iterates over TargetResults attached to the Job result and
// returns a slice of Target results excluding the provided names (types). If there were
// no TargetResults left after filtering, the returned slice will be empty.
func (j *OSBuildJobResult) TargetResultsFilterByName(excludeNames []target.TargetName) []*target.TargetResult {
targetResults := []*target.TargetResult{}
for _, targetResult := range j.TargetResults {
if !slices.Contains(excludeNames, targetResult.Name) {
targetResults = append(targetResults, targetResult)
}
}
return targetResults
}
func (j *FileResolveJobResult) ResolutionErrors() []*clienterrors.Error {
resolutionErrors := []*clienterrors.Error{}