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 {