diff --git a/cmd/gen-manifests/main.go b/cmd/gen-manifests/main.go index a73052c4a..caefda587 100644 --- a/cmd/gen-manifests/main.go +++ b/cmd/gen-manifests/main.go @@ -170,7 +170,11 @@ func makeManifestJob(name string, imgType distro.ImageType, cr composeRequest, d err = fmt.Errorf("[%s] nil package specs", filename) return } - manifest, _, err := imgType.Manifest(cr.Blueprint.Customizations, options, repos, packageSpecs, containerSpecs, seedArg) + + if cr.Blueprint != nil { + bp = blueprint.Blueprint(*cr.Blueprint) + } + manifest, _, err := imgType.Manifest(&bp, options, repos, packageSpecs, containerSpecs, seedArg) if err != nil { err = fmt.Errorf("[%s] failed: %s", filename, err) return diff --git a/cmd/osbuild-pipeline/main.go b/cmd/osbuild-pipeline/main.go index 4fa1928ec..bd67b967b 100644 --- a/cmd/osbuild-pipeline/main.go +++ b/cmd/osbuild-pipeline/main.go @@ -229,7 +229,7 @@ func main() { composeRequest.OSTree.Ref = imageType.OSTreeRef() } - manifest, _, err := imageType.Manifest(composeRequest.Blueprint.Customizations, + manifest, _, err := imageType.Manifest(&composeRequest.Blueprint, options, repos, depsolvedSets, diff --git a/cmd/osbuild-store-dump/main.go b/cmd/osbuild-store-dump/main.go index 94be4969d..4e00508a6 100644 --- a/cmd/osbuild-store-dump/main.go +++ b/cmd/osbuild-store-dump/main.go @@ -32,7 +32,7 @@ func getManifest(bp blueprint.Blueprint, t distro.ImageType, a distro.Arch, d di } pkgSpecSets[name] = res } - mf, _, err := t.Manifest(bp.Customizations, distro.ImageOptions{}, repos, pkgSpecSets, nil, 0) + mf, _, err := t.Manifest(&bp, distro.ImageOptions{}, repos, pkgSpecSets, nil, 0) if err != nil { panic(err) } diff --git a/internal/cloudapi/v2/server.go b/internal/cloudapi/v2/server.go index a3fd5773e..be055add6 100644 --- a/internal/cloudapi/v2/server.go +++ b/internal/cloudapi/v2/server.go @@ -181,7 +181,7 @@ func (s *Server) enqueueCompose(distribution distro.Distro, bp blueprint.Bluepri s.goroutinesGroup.Add(1) go func() { - generateManifest(s.goroutinesCtx, s.workers, depsolveJobID, containerResolveJob, ostreeResolveJobID, manifestJobID, ir.imageType, ir.repositories, ir.imageOptions, manifestSeed, bp.Customizations) + generateManifest(s.goroutinesCtx, s.workers, depsolveJobID, containerResolveJob, ostreeResolveJobID, manifestJobID, ir.imageType, ir.repositories, ir.imageOptions, manifestSeed, &bp) defer s.goroutinesGroup.Done() }() @@ -304,7 +304,7 @@ func (s *Server) enqueueKojiCompose(taskID uint64, server, name, version, releas // copy the image request while passing it into the goroutine to prevent data races s.goroutinesGroup.Add(1) go func(ir imageRequest) { - generateManifest(s.goroutinesCtx, s.workers, depsolveJobID, containerResolveJob, ostreeResolveJobID, manifestJobID, ir.imageType, ir.repositories, ir.imageOptions, manifestSeed, bp.Customizations) + generateManifest(s.goroutinesCtx, s.workers, depsolveJobID, containerResolveJob, ostreeResolveJobID, manifestJobID, ir.imageType, ir.repositories, ir.imageOptions, manifestSeed, &bp) defer s.goroutinesGroup.Done() }(ir) } @@ -325,7 +325,7 @@ func (s *Server) enqueueKojiCompose(taskID uint64, server, name, version, releas return id, nil } -func generateManifest(ctx context.Context, workers *worker.Server, depsolveJobID, containerResolveJobID, ostreeResolveJobID, manifestJobID uuid.UUID, imageType distro.ImageType, repos []rpmmd.RepoConfig, options distro.ImageOptions, seed int64, b *blueprint.Customizations) { +func generateManifest(ctx context.Context, workers *worker.Server, depsolveJobID, containerResolveJobID, ostreeResolveJobID, manifestJobID uuid.UUID, imageType distro.ImageType, repos []rpmmd.RepoConfig, options distro.ImageOptions, seed int64, b *blueprint.Blueprint) { ctx, cancel := context.WithTimeout(ctx, time.Minute*5) defer cancel() diff --git a/internal/distro/distro.go b/internal/distro/distro.go index 79847c092..0a2a3e058 100644 --- a/internal/distro/distro.go +++ b/internal/distro/distro.go @@ -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.Manifest, []string, error) + Manifest(bp *blueprint.Blueprint, 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 diff --git a/internal/distro/distro_test.go b/internal/distro/distro_test.go index 66687c8a0..02b6736cb 100644 --- a/internal/distro/distro_test.go +++ b/internal/distro/distro_test.go @@ -155,7 +155,7 @@ func TestImageTypePipelineNames(t *testing.T) { packageSets[plName] = minimalPackageSet } - m, _, err := imageType.Manifest(bp.Customizations, options, repos, packageSets, containers, seed) + m, _, err := imageType.Manifest(&bp, options, repos, packageSets, containers, seed) require.NoError(err) mf, err := m.Serialize(packageSets) require.NoError(err) diff --git a/internal/distro/distro_test_common/distro_test_common.go b/internal/distro/distro_test_common/distro_test_common.go index 1042b030c..4ef8338fd 100644 --- a/internal/distro/distro_test_common/distro_test_common.go +++ b/internal/distro/distro_test_common/distro_test_common.go @@ -144,7 +144,7 @@ func TestDistro_Manifest(t *testing.T, pipelinePath string, prefix string, regis imgPackageSpecSets = tt.PackageSpecSets } - manifest, _, err := imageType.Manifest(tt.ComposeRequest.Blueprint.Customizations, + manifest, _, err := imageType.Manifest(tt.ComposeRequest.Blueprint, options, repos, imgPackageSpecSets, diff --git a/internal/distro/fedora/distro_test.go b/internal/distro/fedora/distro_test.go index b6fc29546..1514ade62 100644 --- a/internal/distro/fedora/distro_test.go +++ b/internal/distro/fedora/distro_test.go @@ -426,7 +426,7 @@ func TestDistro_ManifestError(t *testing.T) { Size: imgType.Size(0), } testPackageSpecSets := distro_test_common.GetTestingImagePackageSpecSets("kernel", imgType) - _, _, err := imgType.Manifest(bp.Customizations, imgOpts, nil, testPackageSpecSets, nil, 0) + _, _, err := imgType.Manifest(&bp, imgOpts, nil, testPackageSpecSets, nil, 0) if imgTypeName == "iot-commit" || imgTypeName == "iot-container" { assert.EqualError(t, err, "kernel boot parameter customizations are not supported for ostree types") } else if imgTypeName == "iot-installer" { @@ -576,7 +576,7 @@ func TestDistro_CustomFileSystemManifestError(t *testing.T) { arch, _ := fedoraDistro.GetArch(archName) for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, nil, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, nil, nil, 0) if imgTypeName == "iot-commit" || imgTypeName == "iot-container" { assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types") } else if imgTypeName == "iot-raw-image" { @@ -607,7 +607,7 @@ func TestDistro_TestRootMountPoint(t *testing.T) { for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) testPackageSpecSets := distro_test_common.GetTestingImagePackageSpecSets("kernel", imgType) - _, _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0) if imgTypeName == "iot-commit" || imgTypeName == "iot-container" { assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types") } else if imgTypeName == "iot-raw-image" { @@ -642,7 +642,7 @@ func TestDistro_CustomFileSystemSubDirectories(t *testing.T) { for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) testPackageSpecSets := distro_test_common.GetTestingImagePackageSpecSets("kernel", imgType) - _, _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0) if strings.HasPrefix(imgTypeName, "iot-") || strings.HasPrefix(imgTypeName, "image-") { continue } else { @@ -681,7 +681,7 @@ func TestDistro_MountpointsWithArbitraryDepthAllowed(t *testing.T) { for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) testPackageSpecSets := distro_test_common.GetTestingImagePackageSpecSets("kernel", imgType) - _, _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0) if strings.HasPrefix(imgTypeName, "iot-") || strings.HasPrefix(imgTypeName, "image-") { continue } else { @@ -715,7 +715,7 @@ func TestDistro_DirtyMountpointsNotAllowed(t *testing.T) { arch, _ := fedoraDistro.GetArch(archName) for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, nil, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, nil, nil, 0) if strings.HasPrefix(imgTypeName, "iot-") || strings.HasPrefix(imgTypeName, "image-") { continue } else { @@ -745,7 +745,7 @@ func TestDistro_CustomFileSystemPatternMatching(t *testing.T) { arch, _ := fedoraDistro.GetArch(archName) for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, nil, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, nil, nil, 0) if imgTypeName == "iot-commit" || imgTypeName == "iot-container" { assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types") } else if imgTypeName == "iot-raw-image" { @@ -776,7 +776,7 @@ func TestDistro_CustomUsrPartitionNotLargeEnough(t *testing.T) { for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) testPackageSpecSets := distro_test_common.GetTestingImagePackageSpecSets("kernel", imgType) - _, _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0) if imgTypeName == "iot-commit" || imgTypeName == "iot-container" { assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types") } else if imgTypeName == "iot-raw-image" { diff --git a/internal/distro/fedora/imagetype.go b/internal/distro/fedora/imagetype.go index 25a7b9bc6..4024cb3e3 100644 --- a/internal/distro/fedora/imagetype.go +++ b/internal/distro/fedora/imagetype.go @@ -257,20 +257,13 @@ func (t *imageType) PartitionType() string { return basePartitionTable.Type } -func (t *imageType) Manifest(customizations *blueprint.Customizations, +func (t *imageType) Manifest(bp *blueprint.Blueprint, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSpecs map[string][]rpmmd.PackageSpec, containers []container.Spec, seed int64) (*manifest.Manifest, []string, error) { - bp := &blueprint.Blueprint{Name: "empty blueprint"} - err := bp.Initialize() - if err != nil { - panic("could not initialize empty blueprint: " + err.Error()) - } - bp.Customizations = customizations - // the os pipeline filters repos based on the `osPkgsKey` package set, merge the repos which // contain a payload package set into the `osPkgsKey`, so those repos are included when // building the rpm stage in the os pipeline diff --git a/internal/distro/rhel7/distro_test.go b/internal/distro/rhel7/distro_test.go index b4e1b2dc4..4da6f48dd 100644 --- a/internal/distro/rhel7/distro_test.go +++ b/internal/distro/rhel7/distro_test.go @@ -178,7 +178,7 @@ func TestDistro_ManifestError(t *testing.T) { Size: imgType.Size(0), } testPackageSpecSets := distro_test_common.GetTestingImagePackageSpecSets("kernel", imgType) - _, _, err := imgType.Manifest(bp.Customizations, imgOpts, nil, testPackageSpecSets, nil, 0) + _, _, err := imgType.Manifest(&bp, imgOpts, nil, testPackageSpecSets, nil, 0) assert.NoError(t, err) } } @@ -284,7 +284,7 @@ func TestDistro_CustomFileSystemManifestError(t *testing.T) { arch, _ := r7distro.GetArch(archName) for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, nil, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, nil, nil, 0) assert.EqualError(t, err, "The following custom mountpoints are not supported [\"/etc\"]") } } @@ -307,7 +307,7 @@ func TestDistro_TestRootMountPoint(t *testing.T) { for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) testPackageSpecSets := distro_test_common.GetTestingImagePackageSpecSets("kernel", imgType) - _, _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0) assert.NoError(t, err) } } @@ -334,7 +334,7 @@ func TestDistro_CustomFileSystemSubDirectories(t *testing.T) { for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) testPackageSpecSets := distro_test_common.GetTestingImagePackageSpecSets("kernel", imgType) - _, _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0) assert.NoError(t, err) } } @@ -369,7 +369,7 @@ func TestDistro_MountpointsWithArbitraryDepthAllowed(t *testing.T) { for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) testPackageSpecSets := distro_test_common.GetTestingImagePackageSpecSets("kernel", imgType) - _, _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0) assert.NoError(t, err) } } @@ -399,7 +399,7 @@ func TestDistro_DirtyMountpointsNotAllowed(t *testing.T) { arch, _ := r7distro.GetArch(archName) for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, nil, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, nil, nil, 0) assert.EqualError(t, err, "The following custom mountpoints are not supported [\"//\" \"/var//\" \"/var//log/audit/\"]") } } @@ -425,7 +425,7 @@ func TestDistro_CustomFileSystemPatternMatching(t *testing.T) { arch, _ := r7distro.GetArch(archName) for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, nil, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, nil, nil, 0) assert.EqualError(t, err, "The following custom mountpoints are not supported [\"/variable\" \"/variable/log/audit\"]") } } @@ -448,7 +448,7 @@ func TestDistro_CustomUsrPartitionNotLargeEnough(t *testing.T) { for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) testPackageSpecSets := distro_test_common.GetTestingImagePackageSpecSets("kernel", imgType) - _, _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0) assert.NoError(t, err) } } diff --git a/internal/distro/rhel7/imagetype.go b/internal/distro/rhel7/imagetype.go index 424966bb9..f9110ef8f 100644 --- a/internal/distro/rhel7/imagetype.go +++ b/internal/distro/rhel7/imagetype.go @@ -149,20 +149,13 @@ func (t *imageType) PartitionType() string { return basePartitionTable.Type } -func (t *imageType) Manifest(customizations *blueprint.Customizations, +func (t *imageType) Manifest(bp *blueprint.Blueprint, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSpecs map[string][]rpmmd.PackageSpec, containers []container.Spec, seed int64) (*manifest.Manifest, []string, error) { - bp := &blueprint.Blueprint{Name: "empty blueprint"} - err := bp.Initialize() - if err != nil { - panic("could not initialize empty blueprint: " + err.Error()) - } - bp.Customizations = customizations - // the os pipeline filters repos based on the `osPkgsKey` package set, merge the repos which // contain a payload package set into the `osPkgsKey`, so those repos are included when // building the rpm stage in the os pipeline diff --git a/internal/distro/rhel8/distro_test.go b/internal/distro/rhel8/distro_test.go index a1363c202..d9b9a8140 100644 --- a/internal/distro/rhel8/distro_test.go +++ b/internal/distro/rhel8/distro_test.go @@ -474,7 +474,7 @@ func TestDistro_ManifestError(t *testing.T) { Size: imgType.Size(0), } testPackageSpecSets := distro_test_common.GetTestingImagePackageSpecSets("kernel", imgType) - _, _, err := imgType.Manifest(bp.Customizations, imgOpts, nil, testPackageSpecSets, nil, 0) + _, _, err := imgType.Manifest(&bp, imgOpts, nil, testPackageSpecSets, nil, 0) if imgTypeName == "edge-commit" || imgTypeName == "edge-container" { assert.EqualError(t, err, "kernel boot parameter customizations are not supported for ostree types") } else if imgTypeName == "edge-raw-image" { @@ -657,7 +657,7 @@ func TestDistro_CustomFileSystemManifestError(t *testing.T) { arch, _ := r8distro.GetArch(archName) for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, nil, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, nil, nil, 0) if imgTypeName == "edge-commit" || imgTypeName == "edge-container" { assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types") } else if unsupported[imgTypeName] { @@ -692,7 +692,7 @@ func TestDistro_TestRootMountPoint(t *testing.T) { for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) testPackageSpecSets := distro_test_common.GetTestingImagePackageSpecSets("kernel", imgType) - _, _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0) if imgTypeName == "edge-commit" || imgTypeName == "edge-container" { assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types") } else if unsupported[imgTypeName] { @@ -733,7 +733,7 @@ func TestDistro_CustomFileSystemSubDirectories(t *testing.T) { for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) testPackageSpecSets := distro_test_common.GetTestingImagePackageSpecSets("kernel", imgType) - _, _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0) if unsupported[imgTypeName] { assert.Error(t, err) } else { @@ -780,7 +780,7 @@ func TestDistro_MountpointsWithArbitraryDepthAllowed(t *testing.T) { for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) testPackageSpecSets := distro_test_common.GetTestingImagePackageSpecSets("kernel", imgType) - _, _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0) if unsupported[imgTypeName] { assert.Error(t, err) } else { @@ -822,7 +822,7 @@ func TestDistro_DirtyMountpointsNotAllowed(t *testing.T) { arch, _ := r8distro.GetArch(archName) for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, nil, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, nil, nil, 0) if unsupported[imgTypeName] { assert.Error(t, err) } else { @@ -858,7 +858,7 @@ func TestDistro_CustomFileSystemPatternMatching(t *testing.T) { arch, _ := r8distro.GetArch(archName) for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, nil, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, nil, nil, 0) if imgTypeName == "edge-commit" || imgTypeName == "edge-container" { assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types") } else if unsupported[imgTypeName] { @@ -893,7 +893,7 @@ func TestDistro_CustomUsrPartitionNotLargeEnough(t *testing.T) { for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) testPackageSpecSets := distro_test_common.GetTestingImagePackageSpecSets("kernel", imgType) - _, _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0) if imgTypeName == "edge-commit" || imgTypeName == "edge-container" { assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types") } else if unsupported[imgTypeName] { diff --git a/internal/distro/rhel8/imagetype.go b/internal/distro/rhel8/imagetype.go index a97e289b8..7b03f15bc 100644 --- a/internal/distro/rhel8/imagetype.go +++ b/internal/distro/rhel8/imagetype.go @@ -183,20 +183,13 @@ func (t *imageType) PartitionType() string { return basePartitionTable.Type } -func (t *imageType) Manifest(customizations *blueprint.Customizations, +func (t *imageType) Manifest(bp *blueprint.Blueprint, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSpecs map[string][]rpmmd.PackageSpec, containers []container.Spec, seed int64) (*manifest.Manifest, []string, error) { - bp := &blueprint.Blueprint{Name: "empty blueprint"} - err := bp.Initialize() - if err != nil { - panic("could not initialize empty blueprint: " + err.Error()) - } - bp.Customizations = customizations - // the os pipeline filters repos based on the `osPkgsKey` package set, merge the repos which // contain a payload package set into the `osPkgsKey`, so those repos are included when // building the rpm stage in the os pipeline diff --git a/internal/distro/rhel9/distro_test.go b/internal/distro/rhel9/distro_test.go index 190e61673..85915ccab 100644 --- a/internal/distro/rhel9/distro_test.go +++ b/internal/distro/rhel9/distro_test.go @@ -457,7 +457,7 @@ func TestDistro_ManifestError(t *testing.T) { Size: imgType.Size(0), } testPackageSpecSets := distro_test_common.GetTestingImagePackageSpecSets("kernel", imgType) - _, _, err := imgType.Manifest(bp.Customizations, imgOpts, nil, testPackageSpecSets, nil, 0) + _, _, err := imgType.Manifest(&bp, imgOpts, nil, testPackageSpecSets, nil, 0) if imgTypeName == "edge-commit" || imgTypeName == "edge-container" { assert.EqualError(t, err, "kernel boot parameter customizations are not supported for ostree types") } else if imgTypeName == "edge-raw-image" { @@ -630,7 +630,7 @@ func TestDistro_CustomFileSystemManifestError(t *testing.T) { arch, _ := r9distro.GetArch(archName) for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, nil, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, nil, nil, 0) if imgTypeName == "edge-commit" || imgTypeName == "edge-container" { assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types") } else if imgTypeName == "edge-installer" || imgTypeName == "edge-simplified-installer" || imgTypeName == "edge-raw-image" { @@ -659,7 +659,7 @@ func TestDistro_TestRootMountPoint(t *testing.T) { for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) testPackageSpecSets := distro_test_common.GetTestingImagePackageSpecSets("kernel", imgType) - _, _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0) if imgTypeName == "edge-commit" || imgTypeName == "edge-container" { assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types") } else if imgTypeName == "edge-installer" || imgTypeName == "edge-simplified-installer" || imgTypeName == "edge-raw-image" { @@ -692,7 +692,7 @@ func TestDistro_CustomFileSystemSubDirectories(t *testing.T) { for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) testPackageSpecSets := distro_test_common.GetTestingImagePackageSpecSets("kernel", imgType) - _, _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0) if strings.HasPrefix(imgTypeName, "edge-") { continue } else { @@ -731,7 +731,7 @@ func TestDistro_MountpointsWithArbitraryDepthAllowed(t *testing.T) { for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) testPackageSpecSets := distro_test_common.GetTestingImagePackageSpecSets("kernel", imgType) - _, _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0) if strings.HasPrefix(imgTypeName, "edge-") { continue } else { @@ -765,7 +765,7 @@ func TestDistro_DirtyMountpointsNotAllowed(t *testing.T) { arch, _ := r9distro.GetArch(archName) for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, nil, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, nil, nil, 0) if strings.HasPrefix(imgTypeName, "edge-") { continue } else { @@ -795,7 +795,7 @@ func TestDistro_CustomFileSystemPatternMatching(t *testing.T) { arch, _ := r9distro.GetArch(archName) for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, nil, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, nil, nil, 0) if imgTypeName == "edge-commit" || imgTypeName == "edge-container" { assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types") } else if imgTypeName == "edge-installer" || imgTypeName == "edge-simplified-installer" || imgTypeName == "edge-raw-image" { @@ -824,7 +824,7 @@ func TestDistro_CustomUsrPartitionNotLargeEnough(t *testing.T) { for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) testPackageSpecSets := distro_test_common.GetTestingImagePackageSpecSets("kernel", imgType) - _, _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0) if imgTypeName == "edge-commit" || imgTypeName == "edge-container" { assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types") } else if imgTypeName == "edge-installer" || imgTypeName == "edge-simplified-installer" || imgTypeName == "edge-raw-image" { diff --git a/internal/distro/rhel9/imagetype.go b/internal/distro/rhel9/imagetype.go index 01b47a32d..c0367b0a1 100644 --- a/internal/distro/rhel9/imagetype.go +++ b/internal/distro/rhel9/imagetype.go @@ -186,20 +186,13 @@ func (t *imageType) PartitionType() string { return basePartitionTable.Type } -func (t *imageType) Manifest(customizations *blueprint.Customizations, +func (t *imageType) Manifest(bp *blueprint.Blueprint, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSpecs map[string][]rpmmd.PackageSpec, containers []container.Spec, seed int64) (*manifest.Manifest, []string, error) { - bp := &blueprint.Blueprint{Name: "empty blueprint"} - err := bp.Initialize() - if err != nil { - panic("could not initialize empty blueprint: " + err.Error()) - } - bp.Customizations = customizations - // the os pipeline filters repos based on the `osPkgsKey` package set, merge the repos which // contain a payload package set into the `osPkgsKey`, so those repos are included when // building the rpm stage in the os pipeline diff --git a/internal/distro/test_distro/distro.go b/internal/distro/test_distro/distro.go index e7fcf3e6c..b955d8529 100644 --- a/internal/distro/test_distro/distro.go +++ b/internal/distro/test_distro/distro.go @@ -242,18 +242,20 @@ 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.Manifest, []string, error) { - mountpoints := b.GetFilesystems() +func (t *TestImageType) Manifest(b *blueprint.Blueprint, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSpecSets map[string][]rpmmd.PackageSpec, containers []container.Spec, seed int64) (*manifest.Manifest, []string, error) { + if b != nil { + mountpoints := b.Customizations.GetFilesystems() - invalidMountpoints := []string{} - for _, m := range mountpoints { - if m.Mountpoint != "/" { - invalidMountpoints = append(invalidMountpoints, m.Mountpoint) + invalidMountpoints := []string{} + for _, m := range mountpoints { + if m.Mountpoint != "/" { + invalidMountpoints = append(invalidMountpoints, m.Mountpoint) + } } - } - if len(invalidMountpoints) > 0 { - return nil, nil, fmt.Errorf("The following custom mountpoints are not supported %+q", invalidMountpoints) + if len(invalidMountpoints) > 0 { + return nil, nil, fmt.Errorf("The following custom mountpoints are not supported %+q", invalidMountpoints) + } } ret := manifest.Manifest{} diff --git a/internal/store/store_test.go b/internal/store/store_test.go index 9a42fec14..d481c7d14 100644 --- a/internal/store/store_test.go +++ b/internal/store/store_test.go @@ -52,7 +52,7 @@ 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) - manifest, _, _ := suite.myImageType.Manifest(&suite.myCustomizations, suite.myImageOptions, suite.myRepoConfig, nil, nil, 0) + manifest, _, _ := suite.myImageType.Manifest(&suite.myBP, suite.myImageOptions, suite.myRepoConfig, nil, nil, 0) suite.myManifest, _ = manifest.Serialize(nil) suite.mySourceConfig = SourceConfig{ Name: "testSourceConfig", diff --git a/internal/weldr/api.go b/internal/weldr/api.go index 24a80a2a4..0b1319dea 100644 --- a/internal/weldr/api.go +++ b/internal/weldr/api.go @@ -2533,7 +2533,7 @@ func (api *API) composeHandler(writer http.ResponseWriter, request *http.Request return } - manifest, warnings, err := imageType.Manifest(bp.Customizations, + manifest, warnings, err := imageType.Manifest(bp, options, imageRepos, packageSets,