manifest: serialize to OSBuildManifest instead of distro.Manifest

Copy the Marshal and Unmarshal functions from distro.Manifest to
manifest.OSBuildManifest to keep the same behaviour.

The Version() function isn't used, so let's drop it.
This commit is contained in:
Achilleas Koutsou 2023-04-27 14:27:48 +02:00 committed by Simon de Vlieger
parent 8f69088af1
commit 5498764725
5 changed files with 23 additions and 11 deletions

View file

@ -321,9 +321,9 @@ func (t *imageType) Manifest(customizations *blueprint.Customizations,
ret, err := manifest.Serialize(packageSpecs)
if err != nil {
return ret, nil, err
return distro.Manifest(ret), nil, err
}
return ret, warnings, err
return distro.Manifest(ret), warnings, err
}
// checkOptions checks the validity and compatibility of options and customizations for the image type.

View file

@ -223,9 +223,9 @@ func (t *imageType) Manifest(customizations *blueprint.Customizations,
ret, err := manifest.Serialize(packageSpecs)
if err != nil {
return ret, nil, err
return distro.Manifest(ret), nil, err
}
return ret, warnings, err
return distro.Manifest(ret), warnings, err
}
func (t *imageType) PackageSets(bp blueprint.Blueprint, options distro.ImageOptions, repos []rpmmd.RepoConfig) map[string][]rpmmd.PackageSet {

View file

@ -256,9 +256,9 @@ func (t *imageType) Manifest(customizations *blueprint.Customizations,
ret, err := manifest.Serialize(packageSpecs)
if err != nil {
return ret, nil, err
return distro.Manifest(ret), nil, err
}
return ret, warnings, err
return distro.Manifest(ret), warnings, err
}
func (t *imageType) PackageSets(bp blueprint.Blueprint, options distro.ImageOptions, repos []rpmmd.RepoConfig) map[string][]rpmmd.PackageSet {

View file

@ -256,9 +256,9 @@ func (t *imageType) Manifest(customizations *blueprint.Customizations,
ret, err := manifest.Serialize(packageSpecs)
if err != nil {
return ret, nil, err
return distro.Manifest(ret), nil, err
}
return ret, warnings, err
return distro.Manifest(ret), warnings, err
}
func (t *imageType) PackageSets(bp blueprint.Blueprint, options distro.ImageOptions, repos []rpmmd.RepoConfig) map[string][]rpmmd.PackageSet {

View file

@ -4,7 +4,6 @@ import (
"encoding/json"
"github.com/osbuild/osbuild-composer/internal/container"
"github.com/osbuild/osbuild-composer/internal/distro"
"github.com/osbuild/osbuild-composer/internal/osbuild"
"github.com/osbuild/osbuild-composer/internal/ostree"
"github.com/osbuild/osbuild-composer/internal/rpmmd"
@ -20,9 +19,22 @@ const (
)
// An OSBuildManifest is an opaque JSON object, which is a valid input to osbuild
// TODO: use this instead of distro.Manifest below
type OSBuildManifest []byte
func (m OSBuildManifest) MarshalJSON() ([]byte, error) {
return json.RawMessage(m).MarshalJSON()
}
func (m *OSBuildManifest) UnmarshalJSON(payload []byte) error {
var raw json.RawMessage
err := (&raw).UnmarshalJSON(payload)
if err != nil {
return err
}
*m = OSBuildManifest(raw)
return nil
}
type Manifest struct {
pipelines []Pipeline
}
@ -54,7 +66,7 @@ func (m Manifest) GetPackageSetChains() map[string][]rpmmd.PackageSet {
return chains
}
func (m Manifest) Serialize(packageSets map[string][]rpmmd.PackageSpec) (distro.Manifest, error) {
func (m Manifest) Serialize(packageSets map[string][]rpmmd.PackageSpec) (OSBuildManifest, error) {
pipelines := make([]osbuild.Pipeline, 0)
packages := make([]rpmmd.PackageSpec, 0)
commits := make([]ostree.CommitSpec, 0)