diff --git a/cmd/gen-manifests/main.go b/cmd/gen-manifests/main.go index 099bad22e..6a97b477d 100644 --- a/cmd/gen-manifests/main.go +++ b/cmd/gen-manifests/main.go @@ -128,7 +128,7 @@ func makeManifestJob(name string, imgType distro.ImageType, cr composeRequest, d // use default OSTreeRef for image type options.OSTree.Ref = imgType.OSTreeRef() } - manifest, err := imgType.Manifest(cr.Blueprint.Customizations, options, repos, packageSpecs, seedArg) + manifest, err := imgType.Manifest(cr.Blueprint.Customizations, options, repos, packageSpecs, nil, seedArg) if err != nil { return fmt.Errorf("[%s] failed: %s", filename, err) } diff --git a/cmd/osbuild-pipeline/main.go b/cmd/osbuild-pipeline/main.go index e81658ee2..e8ffeb4d8 100644 --- a/cmd/osbuild-pipeline/main.go +++ b/cmd/osbuild-pipeline/main.go @@ -186,6 +186,7 @@ func main() { options, repos, depsolvedSets, + nil, seedArg) if err != nil { panic(err.Error()) diff --git a/cmd/osbuild-store-dump/main.go b/cmd/osbuild-store-dump/main.go index aa72729b0..239058598 100644 --- a/cmd/osbuild-store-dump/main.go +++ b/cmd/osbuild-store-dump/main.go @@ -29,7 +29,7 @@ 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, 0) + manifest, err := t.Manifest(bp.Customizations, 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 fbe4f8c58..b2ddba870 100644 --- a/internal/cloudapi/v2/server.go +++ b/internal/cloudapi/v2/server.go @@ -307,7 +307,7 @@ func generateManifest(ctx context.Context, workers *worker.Server, depsolveJobID return } - manifest, err := imageType.Manifest(b, options, repos, depsolveResults.PackageSpecs, seed) + manifest, err := imageType.Manifest(b, options, repos, depsolveResults.PackageSpecs, nil, seed) if err != nil { reason := "Error generating manifest" jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorManifestGeneration, reason) diff --git a/internal/distro/distro.go b/internal/distro/distro.go index 1a43a2660..4d629450a 100644 --- a/internal/distro/distro.go +++ b/internal/distro/distro.go @@ -7,6 +7,7 @@ import ( "strings" "github.com/osbuild/osbuild-composer/internal/blueprint" + "github.com/osbuild/osbuild-composer/internal/container" "github.com/osbuild/osbuild-composer/internal/disk" "github.com/osbuild/osbuild-composer/internal/ostree" "github.com/osbuild/osbuild-composer/internal/rpmmd" @@ -122,7 +123,7 @@ type ImageType interface { // to build an image, given output format with all packages and customizations // specified in the given blueprint. 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, seed int64) (Manifest, error) + Manifest(b *blueprint.Customizations, options ImageOptions, repos []rpmmd.RepoConfig, packageSpecSets map[string][]rpmmd.PackageSpec, containers []container.Spec, seed int64) (Manifest, error) } // The ImageOptions specify options for a specific image build diff --git a/internal/distro/distro_test_common/distro_test_common.go b/internal/distro/distro_test_common/distro_test_common.go index a99b547da..c7872eeb0 100644 --- a/internal/distro/distro_test_common/distro_test_common.go +++ b/internal/distro/distro_test_common/distro_test_common.go @@ -125,6 +125,7 @@ func TestDistro_Manifest(t *testing.T, pipelinePath string, prefix string, regis }, repos, imgPackageSpecSets, + nil, RandomTestSeed) if (err == nil && tt.Manifest == nil) || (err != nil && tt.Manifest != nil) { diff --git a/internal/distro/fedora/distro.go b/internal/distro/fedora/distro.go index 332243c06..5ee0a0368 100644 --- a/internal/distro/fedora/distro.go +++ b/internal/distro/fedora/distro.go @@ -8,6 +8,7 @@ import ( "strings" "github.com/osbuild/osbuild-composer/internal/blueprint" + "github.com/osbuild/osbuild-composer/internal/container" "github.com/osbuild/osbuild-composer/internal/disk" "github.com/osbuild/osbuild-composer/internal/distro" "github.com/osbuild/osbuild-composer/internal/environment" @@ -532,7 +533,7 @@ func (t *imageType) PackageSets(bp blueprint.Blueprint, options distro.ImageOpti } // create a manifest object and instantiate it with the computed packageSetChains - manifest, err := t.initializeManifest(&bp, options, globalRepos, packageSets, 0) + manifest, err := t.initializeManifest(&bp, options, globalRepos, packageSets, nil, 0) if err != nil { // TODO: handle manifest initialization errors more gracefully, we // refuse to initialize manifests with invalid config. @@ -605,9 +606,10 @@ func (t *imageType) initializeManifest(bp *blueprint.Blueprint, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSets map[string]rpmmd.PackageSet, + containers []container.Spec, seed int64) (*manifest.Manifest, error) { - if err := t.checkOptions(bp.Customizations, options); err != nil { + if err := t.checkOptions(bp.Customizations, options, containers); err != nil { return nil, err } @@ -642,6 +644,7 @@ func (t *imageType) Manifest(customizations *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSets map[string][]rpmmd.PackageSpec, + containers []container.Spec, seed int64) (distro.Manifest, error) { bp := &blueprint.Blueprint{} @@ -651,7 +654,7 @@ func (t *imageType) Manifest(customizations *blueprint.Customizations, } bp.Customizations = customizations - manifest, err := t.initializeManifest(bp, options, repos, nil, seed) + manifest, err := t.initializeManifest(bp, options, repos, nil, containers, seed) if err != nil { return distro.Manifest{}, err } @@ -660,7 +663,12 @@ func (t *imageType) Manifest(customizations *blueprint.Customizations, } // checkOptions checks the validity and compatibility of options and customizations for the image type. -func (t *imageType) checkOptions(customizations *blueprint.Customizations, options distro.ImageOptions) error { +func (t *imageType) checkOptions(customizations *blueprint.Customizations, options distro.ImageOptions, containers []container.Spec) error { + + if len(containers) > 0 { + return fmt.Errorf("embedding containers is not supported for %s on %s", t.name, t.arch.distro.name) + } + if t.bootISO && t.rpmOstree { if options.OSTree.Parent == "" { return fmt.Errorf("boot ISO image type %q requires specifying a URL from which to retrieve the OSTree commit", t.name) diff --git a/internal/distro/fedora/distro_test.go b/internal/distro/fedora/distro_test.go index 5a2c61ee1..4dca8ae4f 100644 --- a/internal/distro/fedora/distro_test.go +++ b/internal/distro/fedora/distro_test.go @@ -404,7 +404,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, 0) + _, err := imgType.Manifest(bp.Customizations, imgOpts, nil, testPackageSpecSets, nil, 0) if imgTypeName == "fedora-iot-commit" || imgTypeName == "fedora-iot-container" { assert.EqualError(t, err, "kernel boot parameter customizations are not supported for ostree types") } else if imgTypeName == "fedora-iot-installer" { @@ -538,7 +538,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, 0) + _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, nil, nil, 0) if imgTypeName == "fedora-iot-commit" || imgTypeName == "fedora-iot-container" { assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types") } else if imgTypeName == "fedora-iot-installer" { @@ -567,7 +567,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, 0) + _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0) if imgTypeName == "fedora-iot-commit" || imgTypeName == "fedora-iot-container" { assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types") } else if imgTypeName == "fedora-iot-installer" { @@ -600,7 +600,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, 0) + _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0) if strings.HasPrefix(imgTypeName, "fedora-iot-") { continue } else { @@ -639,7 +639,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, 0) + _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0) if strings.HasPrefix(imgTypeName, "fedora-iot-") { continue } else { @@ -673,7 +673,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, 0) + _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, nil, nil, 0) if strings.HasPrefix(imgTypeName, "fedora-iot-") { continue } else { @@ -703,7 +703,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, 0) + _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, nil, nil, 0) if imgTypeName == "fedora-iot-commit" || imgTypeName == "fedora-iot-container" { assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types") } else if imgTypeName == "fedora-iot-installer" { @@ -732,7 +732,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, 0) + _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0) if imgTypeName == "fedora-iot-commit" || imgTypeName == "fedora-iot-container" { assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types") } else if imgTypeName == "fedora-iot-installer" { diff --git a/internal/distro/rhel7/distro.go b/internal/distro/rhel7/distro.go index 73097cb02..4f0f61b79 100644 --- a/internal/distro/rhel7/distro.go +++ b/internal/distro/rhel7/distro.go @@ -9,6 +9,7 @@ import ( "strings" "github.com/osbuild/osbuild-composer/internal/blueprint" + "github.com/osbuild/osbuild-composer/internal/container" "github.com/osbuild/osbuild-composer/internal/disk" "github.com/osbuild/osbuild-composer/internal/distro" "github.com/osbuild/osbuild-composer/internal/osbuild" @@ -395,9 +396,10 @@ func (t *imageType) Manifest(customizations *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSpecSets map[string][]rpmmd.PackageSpec, + containers []container.Spec, seed int64) (distro.Manifest, error) { - if err := t.checkOptions(customizations, options); err != nil { + if err := t.checkOptions(customizations, options, containers); err != nil { return distro.Manifest{}, err } @@ -427,7 +429,11 @@ func (t *imageType) Manifest(customizations *blueprint.Customizations, } // checkOptions checks the validity and compatibility of options and customizations for the image type. -func (t *imageType) checkOptions(customizations *blueprint.Customizations, options distro.ImageOptions) error { +func (t *imageType) checkOptions(customizations *blueprint.Customizations, options distro.ImageOptions, containers []container.Spec) error { + + if len(containers) > 0 { + return fmt.Errorf("embedding containers is not supported for %s on %s", t.name, t.arch.distro.name) + } mountpoints := customizations.GetFilesystems() diff --git a/internal/distro/rhel7/distro_test.go b/internal/distro/rhel7/distro_test.go index 27722608b..b727f941a 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, 0) + _, err := imgType.Manifest(bp.Customizations, 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, 0) + _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, nil, nil, 0) assert.EqualError(t, err, "The following custom mountpoints are not supported [\"/boot\"]") } } @@ -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, 0) + _, err := imgType.Manifest(bp.Customizations, 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, 0) + _, err := imgType.Manifest(bp.Customizations, 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, 0) + _, err := imgType.Manifest(bp.Customizations, 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, 0) + _, err := imgType.Manifest(bp.Customizations, 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, 0) + _, err := imgType.Manifest(bp.Customizations, 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, 0) + _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0) assert.NoError(t, err) } } diff --git a/internal/distro/rhel8/distro.go b/internal/distro/rhel8/distro.go index 346c77252..b3d530068 100644 --- a/internal/distro/rhel8/distro.go +++ b/internal/distro/rhel8/distro.go @@ -10,6 +10,7 @@ import ( "github.com/osbuild/osbuild-composer/internal/blueprint" "github.com/osbuild/osbuild-composer/internal/common" + "github.com/osbuild/osbuild-composer/internal/container" "github.com/osbuild/osbuild-composer/internal/disk" "github.com/osbuild/osbuild-composer/internal/distro" "github.com/osbuild/osbuild-composer/internal/osbuild" @@ -512,9 +513,10 @@ func (t *imageType) Manifest(customizations *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSpecSets map[string][]rpmmd.PackageSpec, + containers []container.Spec, seed int64) (distro.Manifest, error) { - if err := t.checkOptions(customizations, options); err != nil { + if err := t.checkOptions(customizations, options, containers); err != nil { return distro.Manifest{}, err } @@ -558,7 +560,12 @@ func (t *imageType) Manifest(customizations *blueprint.Customizations, } // checkOptions checks the validity and compatibility of options and customizations for the image type. -func (t *imageType) checkOptions(customizations *blueprint.Customizations, options distro.ImageOptions) error { +func (t *imageType) checkOptions(customizations *blueprint.Customizations, options distro.ImageOptions, containers []container.Spec) error { + + if len(containers) > 0 { + return fmt.Errorf("embedding containers is not supported for %s on %s", t.name, t.arch.distro.name) + } + if t.bootISO && t.rpmOstree { if options.OSTree.Parent == "" { return fmt.Errorf("boot ISO image type %q requires specifying a URL from which to retrieve the OSTree commit", t.name) diff --git a/internal/distro/rhel8/distro_test.go b/internal/distro/rhel8/distro_test.go index f83299fa8..ac7827ad9 100644 --- a/internal/distro/rhel8/distro_test.go +++ b/internal/distro/rhel8/distro_test.go @@ -453,7 +453,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, 0) + _, err := imgType.Manifest(bp.Customizations, 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" { @@ -623,7 +623,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, 0) + _, err := imgType.Manifest(bp.Customizations, 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" { @@ -652,7 +652,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, 0) + _, err := imgType.Manifest(bp.Customizations, 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" { @@ -685,7 +685,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, 0) + _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0) if strings.HasPrefix(imgTypeName, "edge-") { continue } else { @@ -724,7 +724,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, 0) + _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0) if strings.HasPrefix(imgTypeName, "edge-") { continue } else { @@ -758,7 +758,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, 0) + _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, nil, nil, 0) if strings.HasPrefix(imgTypeName, "edge-") { continue } else { @@ -788,7 +788,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, 0) + _, err := imgType.Manifest(bp.Customizations, 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" { @@ -817,7 +817,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, 0) + _, err := imgType.Manifest(bp.Customizations, 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/rhel90/distro.go b/internal/distro/rhel90/distro.go index 4fea0b44c..290d61504 100644 --- a/internal/distro/rhel90/distro.go +++ b/internal/distro/rhel90/distro.go @@ -10,6 +10,7 @@ import ( "github.com/osbuild/osbuild-composer/internal/blueprint" "github.com/osbuild/osbuild-composer/internal/common" + "github.com/osbuild/osbuild-composer/internal/container" "github.com/osbuild/osbuild-composer/internal/disk" "github.com/osbuild/osbuild-composer/internal/distro" "github.com/osbuild/osbuild-composer/internal/osbuild" @@ -446,9 +447,10 @@ func (t *imageType) Manifest(customizations *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSpecSets map[string][]rpmmd.PackageSpec, + containers []container.Spec, seed int64) (distro.Manifest, error) { - if err := t.checkOptions(customizations, options); err != nil { + if err := t.checkOptions(customizations, options, containers); err != nil { return distro.Manifest{}, err } @@ -492,7 +494,12 @@ func (t *imageType) Manifest(customizations *blueprint.Customizations, } // checkOptions checks the validity and compatibility of options and customizations for the image type. -func (t *imageType) checkOptions(customizations *blueprint.Customizations, options distro.ImageOptions) error { +func (t *imageType) checkOptions(customizations *blueprint.Customizations, options distro.ImageOptions, containers []container.Spec) error { + + if len(containers) > 0 { + return fmt.Errorf("embedding containers is not supported for %s on %s", t.name, t.arch.distro.name) + } + if t.bootISO && t.rpmOstree { if options.OSTree.Parent == "" { return fmt.Errorf("boot ISO image type %q requires specifying a URL from which to retrieve the OSTree commit", t.name) diff --git a/internal/distro/rhel90/distro_test.go b/internal/distro/rhel90/distro_test.go index c32ec5283..c1b586469 100644 --- a/internal/distro/rhel90/distro_test.go +++ b/internal/distro/rhel90/distro_test.go @@ -445,7 +445,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, 0) + _, err := imgType.Manifest(bp.Customizations, 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" { @@ -615,7 +615,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, 0) + _, err := imgType.Manifest(bp.Customizations, 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" { @@ -644,7 +644,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, 0) + _, err := imgType.Manifest(bp.Customizations, 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" { @@ -677,7 +677,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, 0) + _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0) if strings.HasPrefix(imgTypeName, "edge-") { continue } else { @@ -716,7 +716,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, 0) + _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, testPackageSpecSets, nil, 0) if strings.HasPrefix(imgTypeName, "edge-") { continue } else { @@ -750,7 +750,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, 0) + _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, nil, nil, 0) if strings.HasPrefix(imgTypeName, "edge-") { continue } else { @@ -780,7 +780,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, 0) + _, err := imgType.Manifest(bp.Customizations, 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" { @@ -809,7 +809,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, 0) + _, err := imgType.Manifest(bp.Customizations, 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/test_distro/distro.go b/internal/distro/test_distro/distro.go index 1d97ecdb7..6b1bedb3e 100644 --- a/internal/distro/test_distro/distro.go +++ b/internal/distro/test_distro/distro.go @@ -7,6 +7,7 @@ import ( "sort" "github.com/osbuild/osbuild-composer/internal/blueprint" + "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/rpmmd" @@ -233,7 +234,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, seed int64) (distro.Manifest, error) { +func (t *TestImageType) Manifest(b *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSpecSets map[string][]rpmmd.PackageSpec, containers []container.Spec, seed int64) (distro.Manifest, error) { mountpoints := b.GetFilesystems() invalidMountpoints := []string{} diff --git a/internal/store/fixtures.go b/internal/store/fixtures.go index 72da7be3e..dff422659 100644 --- a/internal/store/fixtures.go +++ b/internal/store/fixtures.go @@ -50,7 +50,7 @@ func FixtureBase() *Store { if err != nil { panic(fmt.Sprintf("failed to get image type %s for a test distro architecture: %v", test_distro.TestImageTypeName, err)) } - manifest, err := imgType.Manifest(nil, distro.ImageOptions{}, nil, nil, 0) + manifest, err := imgType.Manifest(nil, distro.ImageOptions{}, nil, nil, nil, 0) if err != nil { panic(fmt.Sprintf("failed to create a manifest: %v", err)) } @@ -185,7 +185,7 @@ func FixtureFinished() *Store { if err != nil { panic(fmt.Sprintf("failed to get image type %s for a test distro architecture: %v", test_distro.TestImageTypeName, err)) } - manifest, err := imgType.Manifest(nil, distro.ImageOptions{}, nil, nil, 0) + manifest, err := imgType.Manifest(nil, distro.ImageOptions{}, nil, nil, nil, 0) if err != nil { panic(fmt.Sprintf("failed to create a manifest: %v", err)) } diff --git a/internal/store/store_test.go b/internal/store/store_test.go index 00c4e43ea..8736551ce 100644 --- a/internal/store/store_test.go +++ b/internal/store/store_test.go @@ -50,7 +50,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) - suite.myManifest, _ = suite.myImageType.Manifest(&suite.myCustomizations, suite.myImageOptions, suite.myRepoConfig, nil, 0) + suite.myManifest, _ = suite.myImageType.Manifest(&suite.myCustomizations, suite.myImageOptions, suite.myRepoConfig, nil, nil, 0) suite.mySourceConfig = SourceConfig{ Name: "testSourceConfig", } diff --git a/internal/weldr/api.go b/internal/weldr/api.go index 36d8d0de0..6058e0168 100644 --- a/internal/weldr/api.go +++ b/internal/weldr/api.go @@ -2337,6 +2337,7 @@ func (api *API) composeHandler(writer http.ResponseWriter, request *http.Request options, imageRepos, packageSets, + nil, seed) if err != nil { errors := responseError{ diff --git a/internal/weldr/api_test.go b/internal/weldr/api_test.go index 4067ade94..f3a925b4e 100644 --- a/internal/weldr/api_test.go +++ b/internal/weldr/api_test.go @@ -669,7 +669,7 @@ func TestCompose(t *testing.T) { require.NoError(t, err) imgType, err := arch.GetImageType(test_distro.TestImageTypeName) require.NoError(t, err) - manifest, err := imgType.Manifest(nil, distro.ImageOptions{}, nil, nil, 0) + manifest, err := imgType.Manifest(nil, distro.ImageOptions{}, nil, nil, nil, 0) require.NoError(t, err) expectedComposeLocal := &store.Compose{ @@ -775,7 +775,7 @@ func TestCompose(t *testing.T) { require.NoError(t, err) imgType2, err := arch2.GetImageType(test_distro.TestImageTypeName) require.NoError(t, err) - manifest2, err := imgType.Manifest(nil, distro.ImageOptions{}, nil, nil, 0) + manifest2, err := imgType.Manifest(nil, distro.ImageOptions{}, nil, nil, nil, 0) require.NoError(t, err) expectedComposeGoodDistro := &store.Compose{ @@ -1717,7 +1717,7 @@ func TestComposePOST_ImageTypeDenylist(t *testing.T) { require.NoError(t, err) imgType2, err := arch.GetImageType(test_distro.TestImageType2Name) require.NoError(t, err) - manifest, err := imgType.Manifest(nil, distro.ImageOptions{}, nil, nil, 0) + manifest, err := imgType.Manifest(nil, distro.ImageOptions{}, nil, nil, nil, 0) require.NoError(t, err) expectedComposeLocal := &store.Compose{ diff --git a/internal/weldr/compose_test.go b/internal/weldr/compose_test.go index d90ca4076..8f74031fb 100644 --- a/internal/weldr/compose_test.go +++ b/internal/weldr/compose_test.go @@ -32,7 +32,7 @@ func TestComposeStatusFromLegacyError(t *testing.T) { if err != nil { t.Fatalf("error getting image type from arch: %v", err) } - manifest, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, nil, 0) + manifest, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, nil, nil, 0) if err != nil { t.Fatalf("error creating osbuild manifest: %v", err) } @@ -81,7 +81,7 @@ func TestComposeStatusFromJobError(t *testing.T) { if err != nil { t.Fatalf("error getting image type from arch: %v", err) } - manifest, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, nil, 0) + manifest, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, nil, nil, 0) if err != nil { t.Fatalf("error creating osbuild manifest: %v", err) } diff --git a/internal/worker/server_test.go b/internal/worker/server_test.go index 6f59defca..c4ff8b584 100644 --- a/internal/worker/server_test.go +++ b/internal/worker/server_test.go @@ -127,7 +127,7 @@ func TestCreate(t *testing.T) { if err != nil { t.Fatalf("error getting image type from arch: %v", err) } - manifest, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, nil, 0) + manifest, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, nil, nil, 0) if err != nil { t.Fatalf("error creating osbuild manifest: %v", err) } @@ -152,7 +152,7 @@ func TestCancel(t *testing.T) { if err != nil { t.Fatalf("error getting image type from arch: %v", err) } - manifest, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, nil, 0) + manifest, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, nil, nil, 0) if err != nil { t.Fatalf("error creating osbuild manifest: %v", err) } @@ -189,7 +189,7 @@ func TestUpdate(t *testing.T) { if err != nil { t.Fatalf("error getting image type from arch: %v", err) } - manifest, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, nil, 0) + manifest, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, nil, nil, 0) if err != nil { t.Fatalf("error creating osbuild manifest: %v", err) } @@ -219,7 +219,7 @@ func TestArgs(t *testing.T) { require.NoError(t, err) imageType, err := arch.GetImageType(test_distro.TestImageTypeName) require.NoError(t, err) - manifest, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, nil, 0) + 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) @@ -265,7 +265,7 @@ func TestUpload(t *testing.T) { if err != nil { t.Fatalf("error getting image type from arch: %v", err) } - manifest, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, nil, 0) + manifest, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, nil, nil, 0) if err != nil { t.Fatalf("error creating osbuild manifest: %v", err) } @@ -295,7 +295,7 @@ func TestUploadNotAcceptingArtifacts(t *testing.T) { if err != nil { t.Fatalf("error getting image type from arch: %v", err) } - manifest, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, nil, 0) + manifest, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, nil, nil, 0) if err != nil { t.Fatalf("error creating osbuild manifest: %v", err) } @@ -325,7 +325,7 @@ func TestUploadAlteredBasePath(t *testing.T) { if err != nil { t.Fatalf("error getting image type from arch: %v", err) } - manifest, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, nil, 0) + manifest, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, nil, nil, 0) if err != nil { t.Fatalf("error creating osbuild manifest: %v", err) }