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:
parent
db431a565d
commit
12e8ab3ac6
20 changed files with 145 additions and 80 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -238,8 +238,12 @@ func main() {
|
|||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
ms, err := manifest.Serialize(depsolvedSets)
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
|
||||
bytes, err = json.Marshal(manifest)
|
||||
bytes, err = json.Marshal(ms)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,12 @@ func getManifest(bp blueprint.Blueprint, t distro.ImageType, a distro.Arch, d di
|
|||
}
|
||||
pkgSpecSets[name] = res
|
||||
}
|
||||
manifest, _, err := t.Manifest(bp.Customizations, distro.ImageOptions{}, repos, pkgSpecSets, nil, 0)
|
||||
mf, _, err := t.Manifest(bp.Customizations, distro.ImageOptions{}, repos, pkgSpecSets, nil, 0)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
manifest, err := mf.Serialize(pkgSpecSets)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -468,6 +468,7 @@ func generateManifest(ctx context.Context, workers *worker.Server, depsolveJobID
|
|||
jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorManifestGeneration, reason, nil)
|
||||
return
|
||||
}
|
||||
ms, err := manifest.Serialize(depsolveResults.PackageSpecs)
|
||||
|
||||
jobResult.Manifest = manifest
|
||||
jobResult.Manifest = ms
|
||||
}
|
||||
|
|
|
|||
|
|
@ -459,7 +459,7 @@ func TestKojiCompose(t *testing.T) {
|
|||
test.TestRoute(t, handler, false, "GET", fmt.Sprintf("/api/image-builder-composer/v2/composes/%v", finalizeID), ``, http.StatusOK, c.composeStatus, `href`, `id`)
|
||||
|
||||
// get the manifests
|
||||
test.TestRoute(t, handler, false, "GET", fmt.Sprintf("/api/image-builder-composer/v2/composes/%v/manifests", finalizeID), ``, http.StatusOK, `{"manifests":[{"version":"","pipelines":[],"sources":{}},{"version":"","pipelines":[],"sources":{}}],"kind":"ComposeManifests"}`, `href`, `id`)
|
||||
test.TestRoute(t, handler, false, "GET", fmt.Sprintf("/api/image-builder-composer/v2/composes/%v/manifests", finalizeID), ``, http.StatusOK, `{"manifests":[{"version":"2","pipelines":[],"sources":{}},{"version":"2","pipelines":[],"sources":{}}],"kind":"ComposeManifests"}`, `href`, `id`)
|
||||
|
||||
// get the logs
|
||||
test.TestRoute(t, handler, false, "GET", fmt.Sprintf("/api/image-builder-composer/v2/composes/%v/logs", finalizeID), ``, http.StatusOK, `{"kind":"ComposeLogs"}`, `koji`, `image_builds`, `href`, `id`)
|
||||
|
|
|
|||
|
|
@ -592,7 +592,7 @@ func TestComposeStatusSuccess(t *testing.T) {
|
|||
"kind": "ComposeManifests",
|
||||
"manifests": [
|
||||
{
|
||||
"version": "",
|
||||
"version": "2",
|
||||
"pipelines": [],
|
||||
"sources": {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ type ImageType interface {
|
|||
// specified in the given blueprint; it also returns any warnings (e.g.
|
||||
// deprecation notices) generated by the manifest.
|
||||
// The packageSpecSets must be labelled in the same way as the originating PackageSets.
|
||||
Manifest(b *blueprint.Customizations, options ImageOptions, repos []rpmmd.RepoConfig, packageSpecSets map[string][]rpmmd.PackageSpec, containers []container.Spec, seed int64) (manifest.OSBuildManifest, []string, error)
|
||||
Manifest(b *blueprint.Customizations, options ImageOptions, repos []rpmmd.RepoConfig, packageSpecSets map[string][]rpmmd.PackageSpec, containers []container.Spec, seed int64) (*manifest.Manifest, []string, error)
|
||||
}
|
||||
|
||||
// The ImageOptions specify options for a specific image build
|
||||
|
|
|
|||
|
|
@ -157,8 +157,10 @@ func TestImageTypePipelineNames(t *testing.T) {
|
|||
|
||||
m, _, err := imageType.Manifest(bp.Customizations, options, repos, packageSets, containers, seed)
|
||||
require.NoError(err)
|
||||
mf, err := m.Serialize(packageSets)
|
||||
require.NoError(err)
|
||||
pm := new(manifest)
|
||||
err = json.Unmarshal(m, pm)
|
||||
err = json.Unmarshal(mf, pm)
|
||||
require.NoError(err)
|
||||
|
||||
require.Equal(len(allPipelines), len(pm.Pipelines))
|
||||
|
|
|
|||
|
|
@ -144,12 +144,17 @@ func TestDistro_Manifest(t *testing.T, pipelinePath string, prefix string, regis
|
|||
imgPackageSpecSets = tt.PackageSpecSets
|
||||
}
|
||||
|
||||
got, _, err := imageType.Manifest(tt.ComposeRequest.Blueprint.Customizations,
|
||||
manifest, _, err := imageType.Manifest(tt.ComposeRequest.Blueprint.Customizations,
|
||||
options,
|
||||
repos,
|
||||
imgPackageSpecSets,
|
||||
tt.Containers,
|
||||
RandomTestSeed)
|
||||
if err != nil {
|
||||
t.Errorf("distro.Manifest() error = %v", err)
|
||||
return
|
||||
}
|
||||
got, err := manifest.Serialize(imgPackageSpecSets)
|
||||
|
||||
if (err == nil && tt.Manifest == nil) || (err != nil && tt.Manifest != nil) {
|
||||
t.Errorf("distro.Manifest() error = %v", err)
|
||||
|
|
|
|||
|
|
@ -262,7 +262,7 @@ func (t *imageType) Manifest(customizations *blueprint.Customizations,
|
|||
repos []rpmmd.RepoConfig,
|
||||
packageSpecs map[string][]rpmmd.PackageSpec,
|
||||
containers []container.Spec,
|
||||
seed int64) (manifest.OSBuildManifest, []string, error) {
|
||||
seed int64) (*manifest.Manifest, []string, error) {
|
||||
|
||||
bp := &blueprint.Blueprint{Name: "empty blueprint"}
|
||||
err := bp.Initialize()
|
||||
|
|
@ -324,11 +324,7 @@ func (t *imageType) Manifest(customizations *blueprint.Customizations,
|
|||
return nil, nil, err
|
||||
}
|
||||
|
||||
ret, err := manifest.Serialize(packageSpecs)
|
||||
if err != nil {
|
||||
return ret, nil, err
|
||||
}
|
||||
return ret, warnings, err
|
||||
return &manifest, warnings, err
|
||||
}
|
||||
|
||||
// checkOptions checks the validity and compatibility of options and customizations for the image type.
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ func (t *imageType) Manifest(customizations *blueprint.Customizations,
|
|||
repos []rpmmd.RepoConfig,
|
||||
packageSpecs map[string][]rpmmd.PackageSpec,
|
||||
containers []container.Spec,
|
||||
seed int64) (manifest.OSBuildManifest, []string, error) {
|
||||
seed int64) (*manifest.Manifest, []string, error) {
|
||||
|
||||
bp := &blueprint.Blueprint{Name: "empty blueprint"}
|
||||
err := bp.Initialize()
|
||||
|
|
@ -221,11 +221,7 @@ func (t *imageType) Manifest(customizations *blueprint.Customizations,
|
|||
return nil, nil, err
|
||||
}
|
||||
|
||||
ret, err := manifest.Serialize(packageSpecs)
|
||||
if err != nil {
|
||||
return ret, nil, err
|
||||
}
|
||||
return ret, warnings, err
|
||||
return &manifest, warnings, err
|
||||
}
|
||||
|
||||
func (t *imageType) PackageSets(bp blueprint.Blueprint, options distro.ImageOptions, repos []rpmmd.RepoConfig) map[string][]rpmmd.PackageSet {
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ func (t *imageType) Manifest(customizations *blueprint.Customizations,
|
|||
repos []rpmmd.RepoConfig,
|
||||
packageSpecs map[string][]rpmmd.PackageSpec,
|
||||
containers []container.Spec,
|
||||
seed int64) (manifest.OSBuildManifest, []string, error) {
|
||||
seed int64) (*manifest.Manifest, []string, error) {
|
||||
|
||||
bp := &blueprint.Blueprint{Name: "empty blueprint"}
|
||||
err := bp.Initialize()
|
||||
|
|
@ -255,11 +255,7 @@ func (t *imageType) Manifest(customizations *blueprint.Customizations,
|
|||
return nil, nil, err
|
||||
}
|
||||
|
||||
ret, err := manifest.Serialize(packageSpecs)
|
||||
if err != nil {
|
||||
return ret, nil, err
|
||||
}
|
||||
return ret, warnings, err
|
||||
return &manifest, warnings, err
|
||||
}
|
||||
|
||||
func (t *imageType) PackageSets(bp blueprint.Blueprint, options distro.ImageOptions, repos []rpmmd.RepoConfig) map[string][]rpmmd.PackageSet {
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ func (t *imageType) Manifest(customizations *blueprint.Customizations,
|
|||
repos []rpmmd.RepoConfig,
|
||||
packageSpecs map[string][]rpmmd.PackageSpec,
|
||||
containers []container.Spec,
|
||||
seed int64) (manifest.OSBuildManifest, []string, error) {
|
||||
seed int64) (*manifest.Manifest, []string, error) {
|
||||
|
||||
bp := &blueprint.Blueprint{Name: "empty blueprint"}
|
||||
err := bp.Initialize()
|
||||
|
|
@ -255,11 +255,7 @@ func (t *imageType) Manifest(customizations *blueprint.Customizations,
|
|||
return nil, nil, err
|
||||
}
|
||||
|
||||
ret, err := manifest.Serialize(packageSpecs)
|
||||
if err != nil {
|
||||
return ret, nil, err
|
||||
}
|
||||
return ret, warnings, err
|
||||
return &manifest, warnings, err
|
||||
}
|
||||
|
||||
func (t *imageType) PackageSets(bp blueprint.Blueprint, options distro.ImageOptions, repos []rpmmd.RepoConfig) map[string][]rpmmd.PackageSet {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package test_distro
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"sort"
|
||||
|
|
@ -11,7 +10,6 @@ import (
|
|||
"github.com/osbuild/osbuild-composer/internal/distro"
|
||||
"github.com/osbuild/osbuild-composer/internal/distroregistry"
|
||||
"github.com/osbuild/osbuild-composer/internal/manifest"
|
||||
"github.com/osbuild/osbuild-composer/internal/osbuild"
|
||||
"github.com/osbuild/osbuild-composer/internal/rpmmd"
|
||||
)
|
||||
|
||||
|
|
@ -244,7 +242,7 @@ func (t *TestImageType) Exports() []string {
|
|||
return distro.ExportsFallback()
|
||||
}
|
||||
|
||||
func (t *TestImageType) Manifest(b *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSpecSets map[string][]rpmmd.PackageSpec, containers []container.Spec, seed int64) (manifest.OSBuildManifest, []string, error) {
|
||||
func (t *TestImageType) Manifest(b *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSpecSets map[string][]rpmmd.PackageSpec, containers []container.Spec, seed int64) (*manifest.Manifest, []string, error) {
|
||||
mountpoints := b.GetFilesystems()
|
||||
|
||||
invalidMountpoints := []string{}
|
||||
|
|
@ -258,12 +256,8 @@ func (t *TestImageType) Manifest(b *blueprint.Customizations, options distro.Ima
|
|||
return nil, nil, fmt.Errorf("The following custom mountpoints are not supported %+q", invalidMountpoints)
|
||||
}
|
||||
|
||||
ret, err := json.Marshal(
|
||||
osbuild.Manifest{
|
||||
Sources: osbuild.Sources{},
|
||||
Pipelines: []osbuild.Pipeline{},
|
||||
})
|
||||
return ret, nil, err
|
||||
ret := manifest.Manifest{}
|
||||
return &ret, nil, nil
|
||||
}
|
||||
|
||||
// newTestDistro returns a new instance of TestDistro with the
|
||||
|
|
|
|||
|
|
@ -56,6 +56,11 @@ func FixtureBase() *Store {
|
|||
panic(fmt.Sprintf("failed to create a manifest: %v", err))
|
||||
}
|
||||
|
||||
mf, err := manifest.Serialize(nil)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("failed to create a manifest: %v", err))
|
||||
}
|
||||
|
||||
s := New(nil, dr, nil)
|
||||
|
||||
pkgs := []rpmmd.PackageSpec{
|
||||
|
|
@ -80,7 +85,7 @@ func FixtureBase() *Store {
|
|||
ImageBuild: ImageBuild{
|
||||
QueueStatus: common.IBWaiting,
|
||||
ImageType: imgType,
|
||||
Manifest: manifest,
|
||||
Manifest: mf,
|
||||
Targets: []*target.Target{awsTarget},
|
||||
JobCreated: date,
|
||||
},
|
||||
|
|
@ -91,7 +96,7 @@ func FixtureBase() *Store {
|
|||
ImageBuild: ImageBuild{
|
||||
QueueStatus: common.IBRunning,
|
||||
ImageType: imgType,
|
||||
Manifest: manifest,
|
||||
Manifest: mf,
|
||||
Targets: []*target.Target{},
|
||||
JobCreated: date,
|
||||
JobStarted: date,
|
||||
|
|
@ -103,7 +108,7 @@ func FixtureBase() *Store {
|
|||
ImageBuild: ImageBuild{
|
||||
QueueStatus: common.IBFinished,
|
||||
ImageType: imgType,
|
||||
Manifest: manifest,
|
||||
Manifest: mf,
|
||||
Targets: []*target.Target{awsTarget},
|
||||
JobCreated: date,
|
||||
JobStarted: date,
|
||||
|
|
@ -116,7 +121,7 @@ func FixtureBase() *Store {
|
|||
ImageBuild: ImageBuild{
|
||||
QueueStatus: common.IBFailed,
|
||||
ImageType: imgType,
|
||||
Manifest: manifest,
|
||||
Manifest: mf,
|
||||
Targets: []*target.Target{awsTarget},
|
||||
JobCreated: date,
|
||||
JobStarted: date,
|
||||
|
|
@ -129,7 +134,7 @@ func FixtureBase() *Store {
|
|||
ImageBuild: ImageBuild{
|
||||
QueueStatus: common.IBFinished,
|
||||
ImageType: imgType,
|
||||
Manifest: manifest,
|
||||
Manifest: mf,
|
||||
Targets: []*target.Target{awsTarget},
|
||||
JobCreated: date,
|
||||
JobStarted: date,
|
||||
|
|
@ -193,6 +198,11 @@ func FixtureFinished() *Store {
|
|||
panic(fmt.Sprintf("failed to create a manifest: %v", err))
|
||||
}
|
||||
|
||||
mf, err := manifest.Serialize(nil)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("failed to create a manifest: %v", err))
|
||||
}
|
||||
|
||||
s := New(nil, dr, nil)
|
||||
|
||||
pkgs := []rpmmd.PackageSpec{
|
||||
|
|
@ -217,7 +227,7 @@ func FixtureFinished() *Store {
|
|||
ImageBuild: ImageBuild{
|
||||
QueueStatus: common.IBFinished,
|
||||
ImageType: imgType,
|
||||
Manifest: manifest,
|
||||
Manifest: mf,
|
||||
Targets: []*target.Target{gcpTarget, awsTarget},
|
||||
JobCreated: date,
|
||||
},
|
||||
|
|
@ -228,7 +238,7 @@ func FixtureFinished() *Store {
|
|||
ImageBuild: ImageBuild{
|
||||
QueueStatus: common.IBFinished,
|
||||
ImageType: imgType,
|
||||
Manifest: manifest,
|
||||
Manifest: mf,
|
||||
Targets: []*target.Target{gcpTarget},
|
||||
JobCreated: date,
|
||||
JobStarted: date,
|
||||
|
|
@ -240,7 +250,7 @@ func FixtureFinished() *Store {
|
|||
ImageBuild: ImageBuild{
|
||||
QueueStatus: common.IBFailed,
|
||||
ImageType: imgType,
|
||||
Manifest: manifest,
|
||||
Manifest: mf,
|
||||
Targets: []*target.Target{gcpTarget, awsTarget},
|
||||
JobCreated: date,
|
||||
JobStarted: date,
|
||||
|
|
@ -253,7 +263,7 @@ func FixtureFinished() *Store {
|
|||
ImageBuild: ImageBuild{
|
||||
QueueStatus: common.IBFinished,
|
||||
ImageType: imgType,
|
||||
Manifest: manifest,
|
||||
Manifest: mf,
|
||||
Targets: []*target.Target{gcpTarget},
|
||||
JobCreated: date,
|
||||
JobStarted: date,
|
||||
|
|
|
|||
|
|
@ -52,7 +52,8 @@ func (suite *storeTest) SetupSuite() {
|
|||
suite.myDistro = test_distro.New()
|
||||
suite.myArch, _ = suite.myDistro.GetArch(test_distro.TestArchName)
|
||||
suite.myImageType, _ = suite.myArch.GetImageType(test_distro.TestImageTypeName)
|
||||
suite.myManifest, _, _ = suite.myImageType.Manifest(&suite.myCustomizations, suite.myImageOptions, suite.myRepoConfig, nil, nil, 0)
|
||||
manifest, _, _ := suite.myImageType.Manifest(&suite.myCustomizations, suite.myImageOptions, suite.myRepoConfig, nil, nil, 0)
|
||||
suite.myManifest, _ = manifest.Serialize(nil)
|
||||
suite.mySourceConfig = SourceConfig{
|
||||
Name: "testSourceConfig",
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2542,7 +2542,16 @@ func (api *API) composeHandler(writer http.ResponseWriter, request *http.Request
|
|||
if err != nil {
|
||||
errors := responseError{
|
||||
ID: "ManifestCreationFailed",
|
||||
Msg: fmt.Sprintf("failed to create osbuild manifest: %v", err),
|
||||
Msg: fmt.Sprintf("failed to initialize osbuild manifest: %v", err),
|
||||
}
|
||||
statusResponseError(writer, http.StatusBadRequest, errors)
|
||||
return
|
||||
}
|
||||
mf, err := manifest.Serialize(packageSets)
|
||||
if err != nil {
|
||||
errors := responseError{
|
||||
ID: "ManifestCreationFailed",
|
||||
Msg: fmt.Sprintf("failed to serialize osbuild manifest: %v", err),
|
||||
}
|
||||
statusResponseError(writer, http.StatusBadRequest, errors)
|
||||
return
|
||||
|
|
@ -2559,15 +2568,15 @@ func (api *API) composeHandler(writer http.ResponseWriter, request *http.Request
|
|||
|
||||
if testMode == "1" {
|
||||
// Create a failed compose
|
||||
err = api.store.PushTestCompose(composeID, manifest, imageType, bp, size, targets, false, packages)
|
||||
err = api.store.PushTestCompose(composeID, mf, imageType, bp, size, targets, false, packages)
|
||||
} else if testMode == "2" {
|
||||
// Create a successful compose
|
||||
err = api.store.PushTestCompose(composeID, manifest, imageType, bp, size, targets, true, packages)
|
||||
err = api.store.PushTestCompose(composeID, mf, imageType, bp, size, targets, true, packages)
|
||||
} else {
|
||||
var jobId uuid.UUID
|
||||
|
||||
jobId, err = api.workers.EnqueueOSBuild(api.archName, &worker.OSBuildJob{
|
||||
Manifest: manifest,
|
||||
Manifest: mf,
|
||||
Targets: targets,
|
||||
PipelineNames: &worker.PipelineNames{
|
||||
Build: imageType.BuildPipelines(),
|
||||
|
|
@ -2575,7 +2584,7 @@ func (api *API) composeHandler(writer http.ResponseWriter, request *http.Request
|
|||
},
|
||||
}, "")
|
||||
if err == nil {
|
||||
err = api.store.PushCompose(composeID, manifest, imageType, bp, size, targets, jobId, packages)
|
||||
err = api.store.PushCompose(composeID, mf, imageType, bp, size, targets, jobId, packages)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -886,11 +886,17 @@ func TestCompose(t *testing.T) {
|
|||
manifest, _, err := imgType.Manifest(nil, distro.ImageOptions{}, nil, nil, nil, 0)
|
||||
require.NoError(t, err)
|
||||
|
||||
mf, err := manifest.Serialize(nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
ostreeImgType, err := arch.GetImageType(test_distro.TestImageTypeOSTree)
|
||||
require.NoError(t, err)
|
||||
ostreeManifest, _, err := ostreeImgType.Manifest(nil, distro.ImageOptions{}, nil, nil, nil, 0)
|
||||
require.NoError(t, err)
|
||||
|
||||
omf, err := ostreeManifest.Serialize(nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
expectedComposeLocal := &store.Compose{
|
||||
Blueprint: &blueprint.Blueprint{
|
||||
Name: "test",
|
||||
|
|
@ -903,7 +909,7 @@ func TestCompose(t *testing.T) {
|
|||
ImageBuild: store.ImageBuild{
|
||||
QueueStatus: common.IBWaiting,
|
||||
ImageType: imgType,
|
||||
Manifest: manifest,
|
||||
Manifest: mf,
|
||||
Targets: []*target.Target{
|
||||
{
|
||||
ImageName: imgType.Filename(),
|
||||
|
|
@ -930,7 +936,7 @@ func TestCompose(t *testing.T) {
|
|||
ImageBuild: store.ImageBuild{
|
||||
QueueStatus: common.IBWaiting,
|
||||
ImageType: imgType,
|
||||
Manifest: manifest,
|
||||
Manifest: mf,
|
||||
Targets: []*target.Target{
|
||||
{
|
||||
ImageName: imgType.Filename(),
|
||||
|
|
@ -974,7 +980,7 @@ func TestCompose(t *testing.T) {
|
|||
ImageBuild: store.ImageBuild{
|
||||
QueueStatus: common.IBWaiting,
|
||||
ImageType: ostreeImgType,
|
||||
Manifest: ostreeManifest,
|
||||
Manifest: omf,
|
||||
Targets: []*target.Target{
|
||||
{
|
||||
ImageName: ostreeImgType.Filename(),
|
||||
|
|
@ -998,6 +1004,9 @@ func TestCompose(t *testing.T) {
|
|||
manifest2, _, err := imgType.Manifest(nil, distro.ImageOptions{}, nil, nil, nil, 0)
|
||||
require.NoError(t, err)
|
||||
|
||||
mf2, err := manifest2.Serialize(nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
expectedComposeGoodDistro := &store.Compose{
|
||||
Blueprint: &blueprint.Blueprint{
|
||||
Name: "test-distro-2",
|
||||
|
|
@ -1011,7 +1020,7 @@ func TestCompose(t *testing.T) {
|
|||
ImageBuild: store.ImageBuild{
|
||||
QueueStatus: common.IBWaiting,
|
||||
ImageType: imgType2,
|
||||
Manifest: manifest2,
|
||||
Manifest: mf2,
|
||||
Targets: []*target.Target{
|
||||
{
|
||||
ImageName: imgType2.Filename(),
|
||||
|
|
@ -1326,10 +1335,10 @@ func TestComposeLogs(t *testing.T) {
|
|||
}{
|
||||
{"/api/v0/compose/logs/30000000-0000-0000-0000-000000000002", "attachment; filename=30000000-0000-0000-0000-000000000002-logs.tar", "application/x-tar", "logs/osbuild.log", "The compose result is empty.\n"},
|
||||
{"/api/v1/compose/logs/30000000-0000-0000-0000-000000000002", "attachment; filename=30000000-0000-0000-0000-000000000002-logs.tar", "application/x-tar", "logs/osbuild.log", "The compose result is empty.\n"},
|
||||
{"/api/v0/compose/metadata/30000000-0000-0000-0000-000000000002", "attachment; filename=30000000-0000-0000-0000-000000000002-metadata.tar", "application/x-tar", "30000000-0000-0000-0000-000000000002.json", `{"version":"","pipelines":[],"sources":{}}`},
|
||||
{"/api/v1/compose/metadata/30000000-0000-0000-0000-000000000002", "attachment; filename=30000000-0000-0000-0000-000000000002-metadata.tar", "application/x-tar", "30000000-0000-0000-0000-000000000002.json", `{"version":"","pipelines":[],"sources":{}}`},
|
||||
{"/api/v0/compose/results/30000000-0000-0000-0000-000000000002", "attachment; filename=30000000-0000-0000-0000-000000000002.tar", "application/x-tar", "30000000-0000-0000-0000-000000000002.json", `{"version":"","pipelines":[],"sources":{}}`},
|
||||
{"/api/v1/compose/results/30000000-0000-0000-0000-000000000002", "attachment; filename=30000000-0000-0000-0000-000000000002.tar", "application/x-tar", "30000000-0000-0000-0000-000000000002.json", `{"version":"","pipelines":[],"sources":{}}`},
|
||||
{"/api/v0/compose/metadata/30000000-0000-0000-0000-000000000002", "attachment; filename=30000000-0000-0000-0000-000000000002-metadata.tar", "application/x-tar", "30000000-0000-0000-0000-000000000002.json", `{"version":"2","pipelines":[],"sources":{}}`},
|
||||
{"/api/v1/compose/metadata/30000000-0000-0000-0000-000000000002", "attachment; filename=30000000-0000-0000-0000-000000000002-metadata.tar", "application/x-tar", "30000000-0000-0000-0000-000000000002.json", `{"version":"2","pipelines":[],"sources":{}}`},
|
||||
{"/api/v0/compose/results/30000000-0000-0000-0000-000000000002", "attachment; filename=30000000-0000-0000-0000-000000000002.tar", "application/x-tar", "30000000-0000-0000-0000-000000000002.json", `{"version":"2","pipelines":[],"sources":{}}`},
|
||||
{"/api/v1/compose/results/30000000-0000-0000-0000-000000000002", "attachment; filename=30000000-0000-0000-0000-000000000002.tar", "application/x-tar", "30000000-0000-0000-0000-000000000002.json", `{"version":"2","pipelines":[],"sources":{}}`},
|
||||
}
|
||||
|
||||
tempdir := t.TempDir()
|
||||
|
|
@ -1989,6 +1998,9 @@ func TestComposePOST_ImageTypeDenylist(t *testing.T) {
|
|||
manifest, _, err := imgType.Manifest(nil, distro.ImageOptions{}, nil, nil, nil, 0)
|
||||
require.NoError(t, err)
|
||||
|
||||
mf, err := manifest.Serialize(nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
expectedComposeLocal := &store.Compose{
|
||||
Blueprint: &blueprint.Blueprint{
|
||||
Name: "test",
|
||||
|
|
@ -2001,7 +2013,7 @@ func TestComposePOST_ImageTypeDenylist(t *testing.T) {
|
|||
ImageBuild: store.ImageBuild{
|
||||
QueueStatus: common.IBWaiting,
|
||||
ImageType: imgType,
|
||||
Manifest: manifest,
|
||||
Manifest: mf,
|
||||
Targets: []*target.Target{
|
||||
{
|
||||
ImageName: imgType.Filename(),
|
||||
|
|
@ -2029,7 +2041,7 @@ func TestComposePOST_ImageTypeDenylist(t *testing.T) {
|
|||
ImageBuild: store.ImageBuild{
|
||||
QueueStatus: common.IBWaiting,
|
||||
ImageType: imgType2,
|
||||
Manifest: manifest,
|
||||
Manifest: mf,
|
||||
Targets: []*target.Target{
|
||||
{
|
||||
ImageName: imgType2.Filename(),
|
||||
|
|
|
|||
|
|
@ -36,8 +36,12 @@ func TestComposeStatusFromLegacyError(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatalf("error creating osbuild manifest: %v", err)
|
||||
}
|
||||
mf, err := manifest.Serialize(nil)
|
||||
if err != nil {
|
||||
t.Fatalf("error serializing osbuild manifest: %v", err)
|
||||
}
|
||||
|
||||
jobId, err := api.workers.EnqueueOSBuild(arch.Name(), &worker.OSBuildJob{Manifest: manifest}, "")
|
||||
jobId, err := api.workers.EnqueueOSBuild(arch.Name(), &worker.OSBuildJob{Manifest: mf}, "")
|
||||
require.NoError(t, err)
|
||||
|
||||
j, token, _, _, _, err := api.workers.RequestJob(context.Background(), arch.Name(), []string{worker.JobTypeOSBuild}, []string{""})
|
||||
|
|
@ -85,8 +89,12 @@ func TestComposeStatusFromJobError(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatalf("error creating osbuild manifest: %v", err)
|
||||
}
|
||||
mf, err := manifest.Serialize(nil)
|
||||
if err != nil {
|
||||
t.Fatalf("error serializing osbuild manifest: %v", err)
|
||||
}
|
||||
|
||||
jobId, err := api.workers.EnqueueOSBuild(arch.Name(), &worker.OSBuildJob{Manifest: manifest}, "")
|
||||
jobId, err := api.workers.EnqueueOSBuild(arch.Name(), &worker.OSBuildJob{Manifest: mf}, "")
|
||||
require.NoError(t, err)
|
||||
|
||||
j, token, _, _, _, err := api.workers.RequestJob(context.Background(), arch.Name(), []string{worker.JobTypeOSBuild}, []string{""})
|
||||
|
|
|
|||
|
|
@ -135,15 +135,19 @@ func TestCreate(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatalf("error creating osbuild manifest: %v", err)
|
||||
}
|
||||
mf, err := manifest.Serialize(nil)
|
||||
if err != nil {
|
||||
t.Fatalf("error creating osbuild manifest: %v", err)
|
||||
}
|
||||
server := newTestServer(t, t.TempDir(), time.Duration(0), "/api/worker/v1", false)
|
||||
handler := server.Handler()
|
||||
|
||||
_, err = server.EnqueueOSBuild(arch.Name(), &worker.OSBuildJob{Manifest: manifest}, "")
|
||||
_, err = server.EnqueueOSBuild(arch.Name(), &worker.OSBuildJob{Manifest: mf}, "")
|
||||
require.NoError(t, err)
|
||||
|
||||
test.TestRoute(t, handler, false, "POST", "/api/worker/v1/jobs",
|
||||
fmt.Sprintf(`{"types":["%s"],"arch":"%s"}`, worker.JobTypeOSBuild, test_distro.TestArchName), http.StatusCreated,
|
||||
fmt.Sprintf(`{"kind":"RequestJob","href":"/api/worker/v1/jobs","type":"%s","args":{"manifest":{"version":"","pipelines":[],"sources":{}}}}`, worker.JobTypeOSBuild), "id", "location", "artifact_location")
|
||||
fmt.Sprintf(`{"kind":"RequestJob","href":"/api/worker/v1/jobs","type":"%s","args":{"manifest":{"version":"2","pipelines":[],"sources":{}}}}`, worker.JobTypeOSBuild), "id", "location", "artifact_location")
|
||||
}
|
||||
|
||||
func TestCancel(t *testing.T) {
|
||||
|
|
@ -161,9 +165,13 @@ func TestCancel(t *testing.T) {
|
|||
t.Fatalf("error creating osbuild manifest: %v", err)
|
||||
}
|
||||
server := newTestServer(t, t.TempDir(), time.Duration(0), "/api/worker/v1", false)
|
||||
mf, err := manifest.Serialize(nil)
|
||||
if err != nil {
|
||||
t.Fatalf("error creating osbuild manifest: %v", err)
|
||||
}
|
||||
handler := server.Handler()
|
||||
|
||||
jobId, err := server.EnqueueOSBuild(arch.Name(), &worker.OSBuildJob{Manifest: manifest}, "")
|
||||
jobId, err := server.EnqueueOSBuild(arch.Name(), &worker.OSBuildJob{Manifest: mf}, "")
|
||||
require.NoError(t, err)
|
||||
|
||||
j, token, typ, args, dynamicArgs, err := server.RequestJob(context.Background(), arch.Name(), []string{worker.JobTypeOSBuild}, []string{""})
|
||||
|
|
@ -198,9 +206,13 @@ func TestUpdate(t *testing.T) {
|
|||
t.Fatalf("error creating osbuild manifest: %v", err)
|
||||
}
|
||||
server := newTestServer(t, t.TempDir(), time.Duration(0), "/api/worker/v1", false)
|
||||
mf, err := manifest.Serialize(nil)
|
||||
if err != nil {
|
||||
t.Fatalf("error creating osbuild manifest: %v", err)
|
||||
}
|
||||
handler := server.Handler()
|
||||
|
||||
jobId, err := server.EnqueueOSBuild(arch.Name(), &worker.OSBuildJob{Manifest: manifest}, "")
|
||||
jobId, err := server.EnqueueOSBuild(arch.Name(), &worker.OSBuildJob{Manifest: mf}, "")
|
||||
require.NoError(t, err)
|
||||
|
||||
j, token, typ, args, dynamicArgs, err := server.RequestJob(context.Background(), arch.Name(), []string{worker.JobTypeOSBuild}, []string{""})
|
||||
|
|
@ -226,10 +238,11 @@ func TestArgs(t *testing.T) {
|
|||
manifest, _, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, nil, nil, 0)
|
||||
require.NoError(t, err)
|
||||
|
||||
server := newTestServer(t, t.TempDir(), time.Duration(0), "/api/worker/v1", false)
|
||||
mf, err := manifest.Serialize(nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
job := worker.OSBuildJob{
|
||||
Manifest: manifest,
|
||||
Manifest: mf,
|
||||
PipelineNames: &worker.PipelineNames{
|
||||
Build: []string{"b"},
|
||||
Payload: []string{"x", "y", "z"},
|
||||
|
|
@ -246,6 +259,8 @@ func TestArgs(t *testing.T) {
|
|||
},
|
||||
},
|
||||
}
|
||||
|
||||
server := newTestServer(t, t.TempDir(), time.Duration(0), "/api/worker/v1", false)
|
||||
jobId, err := server.EnqueueOSBuild(arch.Name(), &job, "")
|
||||
require.NoError(t, err)
|
||||
|
||||
|
|
@ -274,9 +289,13 @@ func TestUpload(t *testing.T) {
|
|||
t.Fatalf("error creating osbuild manifest: %v", err)
|
||||
}
|
||||
server := newTestServer(t, t.TempDir(), time.Duration(0), "/api/worker/v1", true)
|
||||
mf, err := manifest.Serialize(nil)
|
||||
if err != nil {
|
||||
t.Fatalf("error creating osbuild manifest: %v", err)
|
||||
}
|
||||
handler := server.Handler()
|
||||
|
||||
jobID, err := server.EnqueueOSBuild(arch.Name(), &worker.OSBuildJob{Manifest: manifest}, "")
|
||||
jobID, err := server.EnqueueOSBuild(arch.Name(), &worker.OSBuildJob{Manifest: mf}, "")
|
||||
require.NoError(t, err)
|
||||
|
||||
j, token, typ, args, dynamicArgs, err := server.RequestJob(context.Background(), arch.Name(), []string{worker.JobTypeOSBuild}, []string{""})
|
||||
|
|
@ -305,8 +324,12 @@ func TestUploadNotAcceptingArtifacts(t *testing.T) {
|
|||
}
|
||||
server := newTestServer(t, t.TempDir(), time.Duration(0), "/api/worker/v1", false)
|
||||
handler := server.Handler()
|
||||
mf, _ := manifest.Serialize(nil)
|
||||
if err != nil {
|
||||
t.Fatalf("error creating osbuild manifest: %v", err)
|
||||
}
|
||||
|
||||
jobID, err := server.EnqueueOSBuild(arch.Name(), &worker.OSBuildJob{Manifest: manifest}, "")
|
||||
jobID, err := server.EnqueueOSBuild(arch.Name(), &worker.OSBuildJob{Manifest: mf}, "")
|
||||
require.NoError(t, err)
|
||||
|
||||
j, token, typ, args, dynamicArgs, err := server.RequestJob(context.Background(), arch.Name(), []string{worker.JobTypeOSBuild}, []string{""})
|
||||
|
|
@ -333,10 +356,15 @@ func TestUploadAlteredBasePath(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatalf("error creating osbuild manifest: %v", err)
|
||||
}
|
||||
mf, err := manifest.Serialize(nil)
|
||||
if err != nil {
|
||||
t.Fatalf("error creating osbuild manifest: %v", err)
|
||||
}
|
||||
|
||||
server := newTestServer(t, t.TempDir(), time.Duration(0), "/api/image-builder-worker/v1", true)
|
||||
handler := server.Handler()
|
||||
|
||||
jobID, err := server.EnqueueOSBuild(arch.Name(), &worker.OSBuildJob{Manifest: manifest}, "")
|
||||
jobID, err := server.EnqueueOSBuild(arch.Name(), &worker.OSBuildJob{Manifest: mf}, "")
|
||||
require.NoError(t, err)
|
||||
|
||||
j, token, typ, args, dynamicArgs, err := server.RequestJob(context.Background(), arch.Name(), []string{worker.JobTypeOSBuild}, []string{""})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue