From 285cd30af264d62cc48f0116632cf5dba933a5b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hozza?= Date: Thu, 21 Sep 2023 16:49:03 +0200 Subject: [PATCH] Worker/osbuild: include Manifest info in Koji target result MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Copy the Manifest info data from the Manifest job result to the Koji target result, so that this information can be then imported to Koji build metadata by the koji-finalize job. Signed-off-by: Tomáš Hozza --- cmd/osbuild-worker/jobimpl-osbuild.go | 25 +++++++++++++++++++++++++ internal/target/koji_target.go | 22 +++++++++++++++++++--- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/cmd/osbuild-worker/jobimpl-osbuild.go b/cmd/osbuild-worker/jobimpl-osbuild.go index d9fc6f76a..2e5d34d2c 100644 --- a/cmd/osbuild-worker/jobimpl-osbuild.go +++ b/cmd/osbuild-worker/jobimpl-osbuild.go @@ -349,6 +349,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error { } // In case the manifest is empty, try to get it from dynamic args + var manifestInfo *worker.ManifestInfo if len(jobArgs.Manifest) == 0 { if job.NDynamicArgs() > 0 { var manifestJR worker.ManifestJobByIDResult @@ -374,6 +375,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error { return nil } jobArgs.Manifest = manifestJR.Manifest + manifestInfo = &manifestJR.ManifestInfo } if len(jobArgs.Manifest) == 0 { @@ -901,6 +903,28 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error { } logWithId.Info("[Koji] 🎉 osbuild output log successfully uploaded") + // Attach the manifest info to the koji target result, so that it + // it can be imported to the Koji build by the koji-finalize job. + var kojiManifestInfo *target.ManifestInfo + if manifestInfo != nil { + kojiManifestInfo = &target.ManifestInfo{ + OSBuildComposerVersion: manifestInfo.OSBuildComposerVersion, + } + for _, composerDep := range manifestInfo.OSBuildComposerDeps { + dep := &target.OSBuildComposerDepModule{ + Path: composerDep.Path, + Version: composerDep.Version, + } + if composerDep.Replace != nil { + dep.Replace = &target.OSBuildComposerDepModule{ + Path: composerDep.Replace.Path, + Version: composerDep.Replace.Version, + } + } + kojiManifestInfo.OSBuildComposerDeps = append(kojiManifestInfo.OSBuildComposerDeps, dep) + } + } + targetResult.Options = &target.KojiTargetResultOptions{ Image: &target.KojiOutputInfo{ Filename: jobTarget.ImageName, @@ -920,6 +944,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error { Checksum: osbuildOutputHash, Size: osbuildOutputSize, }, + OSBuildManifestInfo: kojiManifestInfo, } case *target.OCITargetOptions: diff --git a/internal/target/koji_target.go b/internal/target/koji_target.go index ef0755afb..e24f8344e 100644 --- a/internal/target/koji_target.go +++ b/internal/target/koji_target.go @@ -42,10 +42,26 @@ type KojiOutputInfo struct { Size uint64 `json:"size"` } +type OSBuildComposerDepModule struct { + Path string `json:"path"` + Version string `json:"version"` + Replace *OSBuildComposerDepModule `json:"replace,omitempty"` +} + +// ManifestInfo contains information about the environment in which +// the manifest was produced and which could affect its content. +type ManifestInfo struct { + OSBuildComposerVersion string `json:"osbuild_composer_version"` + // List of relevant modules used by osbuild-composer which + // could affect the manifest content. + OSBuildComposerDeps []*OSBuildComposerDepModule `json:"osbuild_composer_deps,omitempty"` +} + type KojiTargetResultOptions struct { - Image *KojiOutputInfo `json:"image"` - Log *KojiOutputInfo `json:"log,omitempty"` - OSBuildManifest *KojiOutputInfo `json:"osbuild_manifest,omitempty"` + Image *KojiOutputInfo `json:"image"` + Log *KojiOutputInfo `json:"log,omitempty"` + OSBuildManifest *KojiOutputInfo `json:"osbuild_manifest,omitempty"` + OSBuildManifestInfo *ManifestInfo `json:"osbuild_manifest_info,omitempty"` } func (o *KojiTargetResultOptions) UnmarshalJSON(data []byte) error {