upload/koji: don't depend on rpmmd.RPM for build metadata
The use of rpmmd.RPM is exclusive to the Koji upload implementation. Consolidate the metadata structure for RPMs into the koji package codebase, together with any required functions for converting osbuild stage metadata. The respective code in osbuild/images will be eventually removed. Signed-off-by: Tomáš Hozza <thozza@redhat.com>
This commit is contained in:
parent
0ca81d5af4
commit
0bafc0915d
6 changed files with 288 additions and 17 deletions
|
|
@ -24,7 +24,6 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/osbuild/images/pkg/platform"
|
||||
"github.com/osbuild/images/pkg/rpmmd"
|
||||
"github.com/osbuild/osbuild-composer/internal/upload/koji"
|
||||
)
|
||||
|
||||
|
|
@ -166,7 +165,7 @@ func TestKojiImport(t *testing.T) {
|
|||
Arch: "noarch",
|
||||
},
|
||||
Tools: []koji.Tool{},
|
||||
RPMs: []rpmmd.RPM{},
|
||||
RPMs: []koji.RPM{},
|
||||
},
|
||||
}
|
||||
output := []koji.BuildOutput{
|
||||
|
|
@ -178,7 +177,7 @@ func TestKojiImport(t *testing.T) {
|
|||
ChecksumType: koji.ChecksumTypeMD5,
|
||||
Checksum: hash,
|
||||
Type: koji.BuildOutputTypeImage,
|
||||
RPMs: []rpmmd.RPM{},
|
||||
RPMs: []koji.RPM{},
|
||||
Extra: &koji.BuildOutputExtra{
|
||||
ImageOutput: koji.ImageExtraInfo{
|
||||
Arch: "noarch",
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import (
|
|||
|
||||
"github.com/google/uuid"
|
||||
"github.com/osbuild/images/pkg/platform"
|
||||
"github.com/osbuild/images/pkg/rpmmd"
|
||||
"github.com/osbuild/osbuild-composer/internal/upload/koji"
|
||||
)
|
||||
|
||||
|
|
@ -85,7 +84,7 @@ func main() {
|
|||
Arch: arch,
|
||||
},
|
||||
Tools: []koji.Tool{},
|
||||
RPMs: []rpmmd.RPM{},
|
||||
RPMs: []koji.RPM{},
|
||||
},
|
||||
}
|
||||
output := []koji.BuildOutput{
|
||||
|
|
@ -97,7 +96,7 @@ func main() {
|
|||
ChecksumType: koji.ChecksumTypeMD5,
|
||||
Checksum: hash,
|
||||
Type: koji.BuildOutputTypeImage,
|
||||
RPMs: []rpmmd.RPM{},
|
||||
RPMs: []koji.RPM{},
|
||||
Extra: &koji.BuildOutputExtra{
|
||||
ImageOutput: koji.ImageExtraInfo{
|
||||
Arch: arch,
|
||||
|
|
|
|||
|
|
@ -8,8 +8,6 @@ import (
|
|||
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/osbuild/images/pkg/osbuild"
|
||||
"github.com/osbuild/images/pkg/rpmmd"
|
||||
"github.com/osbuild/osbuild-composer/internal/target"
|
||||
"github.com/osbuild/osbuild-composer/internal/upload/koji"
|
||||
"github.com/osbuild/osbuild-composer/internal/worker"
|
||||
|
|
@ -143,16 +141,16 @@ func (impl *KojiFinalizeJobImpl) Run(job worker.Job) error {
|
|||
}
|
||||
|
||||
for i, buildResult := range osbuildResults {
|
||||
buildRPMs := make([]rpmmd.RPM, 0)
|
||||
buildRPMs := make([]koji.RPM, 0)
|
||||
// collect packages from stages in build pipelines
|
||||
for _, plName := range buildResult.PipelineNames.Build {
|
||||
buildPipelineMd := buildResult.OSBuildOutput.Metadata[plName]
|
||||
buildRPMs = append(buildRPMs, osbuild.OSBuildMetadataToRPMs(buildPipelineMd)...)
|
||||
buildRPMs = append(buildRPMs, koji.OSBuildMetadataToRPMs(buildPipelineMd)...)
|
||||
}
|
||||
// this dedupe is usually not necessary since we generally only have
|
||||
// one rpm stage in one build pipeline, but it's not invalid to have
|
||||
// multiple
|
||||
buildRPMs = rpmmd.DeduplicateRPMs(buildRPMs)
|
||||
buildRPMs = koji.DeduplicateRPMs(buildRPMs)
|
||||
|
||||
kojiTargetResults := buildResult.TargetResultsByName(target.TargetNameKoji)
|
||||
// Only a single Koji target is allowed per osbuild job
|
||||
|
|
@ -183,14 +181,14 @@ func (impl *KojiFinalizeJobImpl) Run(job worker.Job) error {
|
|||
})
|
||||
|
||||
// collect packages from stages in payload pipelines
|
||||
imageRPMs := make([]rpmmd.RPM, 0)
|
||||
imageRPMs := make([]koji.RPM, 0)
|
||||
for _, plName := range buildResult.PipelineNames.Payload {
|
||||
payloadPipelineMd := buildResult.OSBuildOutput.Metadata[plName]
|
||||
imageRPMs = append(imageRPMs, osbuild.OSBuildMetadataToRPMs(payloadPipelineMd)...)
|
||||
imageRPMs = append(imageRPMs, koji.OSBuildMetadataToRPMs(payloadPipelineMd)...)
|
||||
}
|
||||
|
||||
// deduplicate
|
||||
imageRPMs = rpmmd.DeduplicateRPMs(imageRPMs)
|
||||
imageRPMs = koji.DeduplicateRPMs(imageRPMs)
|
||||
|
||||
imgOutputExtraInfo := koji.ImageExtraInfo{
|
||||
Arch: buildResult.Arch,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue