distro: make the osbuild package internal to the distros
Rather than Manifest() returning an osbuild.Manifest object, introduce a new distro.Manifest object which represents it as an opaque, JSON serializable object. This new type has the following properties: 1) its serialization is compatible with the input to osbuild, 2) any valid osbuild input can be deserialized into it, and 3) marshalling and unmarshaling to and from JSON is lossless. This means that even as we change the subset of valid osbulid manifests that we support, we can still load any previous state from disk, and it will continue to work just as before, even though we can no longer deserialize it into our internal notion of osbuild.Manifest. This fixes the underlying problem of which #685 was a symptom. Signed-off-by: Tom Gundersen <teg@jklm.no>
This commit is contained in:
parent
4aced4e749
commit
0417c6d8bb
18 changed files with 101 additions and 86 deletions
|
|
@ -1670,16 +1670,16 @@ func (api *API) composeHandler(writer http.ResponseWriter, request *http.Request
|
|||
testMode := q.Get("test")
|
||||
if testMode == "1" {
|
||||
// Create a failed compose
|
||||
err = api.store.PushTestCompose(composeID, *manifest, imageType, bp, size, targets, false)
|
||||
err = api.store.PushTestCompose(composeID, manifest, imageType, bp, size, targets, false)
|
||||
} else if testMode == "2" {
|
||||
// Create a successful compose
|
||||
err = api.store.PushTestCompose(composeID, *manifest, imageType, bp, size, targets, true)
|
||||
err = api.store.PushTestCompose(composeID, manifest, imageType, bp, size, targets, true)
|
||||
} else {
|
||||
var jobId uuid.UUID
|
||||
|
||||
jobId, err = api.workers.Enqueue(manifest, targets)
|
||||
if err == nil {
|
||||
err = api.store.PushCompose(composeID, *manifest, imageType, bp, size, targets, jobId)
|
||||
err = api.store.PushCompose(composeID, manifest, imageType, bp, size, targets, jobId)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/common"
|
||||
"github.com/osbuild/osbuild-composer/internal/osbuild"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro"
|
||||
"github.com/osbuild/osbuild-composer/internal/target"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/blueprint"
|
||||
|
|
@ -438,6 +438,8 @@ func TestCompose(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
imgType, err := arch.GetImageType("qcow2")
|
||||
require.NoError(t, err)
|
||||
manifest, err := imgType.Manifest(nil, distro.ImageOptions{}, nil, nil, nil)
|
||||
require.NoError(t, err)
|
||||
expectedComposeLocal := &store.Compose{
|
||||
Blueprint: &blueprint.Blueprint{
|
||||
Name: "test",
|
||||
|
|
@ -450,6 +452,7 @@ func TestCompose(t *testing.T) {
|
|||
ImageBuild: store.ImageBuild{
|
||||
QueueStatus: common.IBWaiting,
|
||||
ImageType: imgType,
|
||||
Manifest: manifest,
|
||||
Targets: []*target.Target{
|
||||
{
|
||||
// skip Uuid and Created fields - they are ignored
|
||||
|
|
@ -473,6 +476,7 @@ func TestCompose(t *testing.T) {
|
|||
ImageBuild: store.ImageBuild{
|
||||
QueueStatus: common.IBWaiting,
|
||||
ImageType: imgType,
|
||||
Manifest: manifest,
|
||||
Targets: []*target.Target{
|
||||
{
|
||||
Name: "org.osbuild.aws",
|
||||
|
|
@ -533,8 +537,6 @@ func TestCompose(t *testing.T) {
|
|||
}
|
||||
|
||||
require.NotNilf(t, composeStruct.ImageBuild.Manifest, "%s: the compose in the store did not contain a blueprint", c.Path)
|
||||
// TODO: find some (reasonable) way to verify the contents of the pipeline
|
||||
composeStruct.ImageBuild.Manifest = osbuild.Manifest{}
|
||||
|
||||
if diff := cmp.Diff(composeStruct, *c.ExpectedCompose, test.IgnoreDates(), test.IgnoreUuids(), test.Ignore("Targets.Options.Location"), test.CompareImageTypes()); diff != "" {
|
||||
t.Errorf("%s: compose in store isn't the same as expected, diff:\n%s", c.Path, diff)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue