Make Manifest() return manifest.Manifest

Return manifest.Manifest from the Manifest() function without
serializing.  The caller then has to call the manifest.Serialize()
function using the depsolved packages.

This moves towards changing the order of actions required to generate a
manifest.  With this change, the manifest creation and depsolving can be
done independently, but this still requires instantiating the manifest
object twice (InstantiateManifest() is called in PackageSets() and
Manifest()), which we don't want to have to do.
This commit is contained in:
Achilleas Koutsou 2023-04-12 19:54:03 +02:00 committed by Simon de Vlieger
parent db431a565d
commit 12e8ab3ac6
20 changed files with 145 additions and 80 deletions

View file

@ -170,11 +170,13 @@ func makeManifestJob(name string, imgType distro.ImageType, cr composeRequest, d
err = fmt.Errorf("[%s] nil package specs", filename)
return
}
mf, _, err := imgType.Manifest(cr.Blueprint.Customizations, options, repos, packageSpecs, containerSpecs, seedArg)
manifest, _, err := imgType.Manifest(cr.Blueprint.Customizations, options, repos, packageSpecs, containerSpecs, seedArg)
if err != nil {
err = fmt.Errorf("[%s] failed: %s", filename, err)
return
}
mf, err := manifest.Serialize(packageSpecs)
request := composeRequest{
Distro: distribution.Name(),
Arch: archName,
@ -271,7 +273,7 @@ func depsolve(cacheDir string, imageType distro.ImageType, bp blueprint.Blueprin
return depsolvedSets, nil
}
func save(mf manifest.OSBuildManifest, pkgs map[string][]rpmmd.PackageSpec, containers []container.Spec, cr composeRequest, path, filename string) error {
func save(ms manifest.OSBuildManifest, pkgs map[string][]rpmmd.PackageSpec, containers []container.Spec, cr composeRequest, path, filename string) error {
data := struct {
ComposeRequest composeRequest `json:"compose-request"`
Manifest manifest.OSBuildManifest `json:"manifest"`
@ -279,7 +281,7 @@ func save(mf manifest.OSBuildManifest, pkgs map[string][]rpmmd.PackageSpec, cont
Containers []container.Spec `json:"containers,omitempty"`
NoImageInfo bool `json:"no-image-info"`
}{
cr, mf, pkgs, containers, true,
cr, ms, pkgs, containers, true,
}
b, err := json.MarshalIndent(data, "", " ")
if err != nil {