From 7ed5bab27d9a41be5e731f21113b8ca1b55de2d8 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 13 Dec 2024 09:54:32 +0100 Subject: [PATCH] pkg: make `seed` in `ImageType.Manifest()` random by default This commit changes the API of `ImageType.Manifest()` to take a pointer to the seed value. If no seed value is given it will automatically generate a random one. This avoid the pitfall that the consumer needs to know about properly seeding the manifests. The default use-case is to generate non-fixed seed manifests so this commit it easier. --- cmd/build/main.go | 2 +- cmd/gen-manifests/main.go | 2 +- cmd/osbuild-package-sets/main.go | 2 +- pkg/distro/distro.go | 13 +++++++++++- pkg/distro/distro_test.go | 8 ++++---- .../distro_test_common/distro_test_common.go | 14 ++++++------- pkg/distro/fedora/distro_test.go | 20 +++++++++---------- pkg/distro/fedora/imagetype.go | 3 ++- pkg/distro/rhel/imagetype.go | 3 ++- pkg/distro/rhel/rhel10/distro_test.go | 20 +++++++++---------- pkg/distro/rhel/rhel7/distro_test.go | 16 +++++++-------- pkg/distro/rhel/rhel8/distro_test.go | 18 ++++++++--------- pkg/distro/rhel/rhel9/distro_test.go | 20 +++++++++---------- pkg/distro/test_distro/distro.go | 2 +- 14 files changed, 78 insertions(+), 65 deletions(-) diff --git a/cmd/build/main.go b/cmd/build/main.go index d885f2e764..cbcff4c177 100644 --- a/cmd/build/main.go +++ b/cmd/build/main.go @@ -51,7 +51,7 @@ func makeManifest( return nil, err } - manifest, warnings, err := imgType.Manifest(&bp, options, repos, seedArg) + manifest, warnings, err := imgType.Manifest(&bp, options, repos, &seedArg) if err != nil { return nil, fmt.Errorf("[ERROR] manifest generation failed: %w", err) } diff --git a/cmd/gen-manifests/main.go b/cmd/gen-manifests/main.go index 626e1e3095..694697dd4e 100644 --- a/cmd/gen-manifests/main.go +++ b/cmd/gen-manifests/main.go @@ -208,7 +208,7 @@ func makeManifestJob( }() msgq <- fmt.Sprintf("Starting job %s", filename) - manifest, _, err := imgType.Manifest(&bp, options, repos, seedArg) + manifest, _, err := imgType.Manifest(&bp, options, repos, &seedArg) if err != nil { err = fmt.Errorf("[%s] failed: %s", filename, err) return diff --git a/cmd/osbuild-package-sets/main.go b/cmd/osbuild-package-sets/main.go index 49be4923ea..1324b863cd 100644 --- a/cmd/osbuild-package-sets/main.go +++ b/cmd/osbuild-package-sets/main.go @@ -54,7 +54,7 @@ func main() { URL: "https://example.com", // required by some image types } } - manifest, _, err := image.Manifest(&blueprint.Blueprint{}, options, nil, 0) + manifest, _, err := image.Manifest(&blueprint.Blueprint{}, options, nil, nil) if err != nil { panic(err) } diff --git a/pkg/distro/distro.go b/pkg/distro/distro.go index 741f282a96..ec88256072 100644 --- a/pkg/distro/distro.go +++ b/pkg/distro/distro.go @@ -1,6 +1,8 @@ package distro import ( + "time" + "github.com/osbuild/images/pkg/blueprint" "github.com/osbuild/images/pkg/customizations/subscription" "github.com/osbuild/images/pkg/disk" @@ -120,7 +122,9 @@ 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(bp *blueprint.Blueprint, options ImageOptions, repos []rpmmd.RepoConfig, seed int64) (*manifest.Manifest, []string, error) + // A custom seed for the rng can be specified, if nil the seed will + // be random. + Manifest(bp *blueprint.Blueprint, options ImageOptions, repos []rpmmd.RepoConfig, seed *int64) (*manifest.Manifest, []string, error) } // The ImageOptions specify options for a specific image build @@ -155,3 +159,10 @@ func ExportsFallback() []string { func PayloadPackageSets() []string { return []string{} } + +func SeedFrom(p *int64) int64 { + if p == nil { + return time.Now().UnixNano() + } + return *p +} diff --git a/pkg/distro/distro_test.go b/pkg/distro/distro_test.go index 78b8244498..dabc8699fd 100644 --- a/pkg/distro/distro_test.go +++ b/pkg/distro/distro_test.go @@ -114,7 +114,7 @@ func TestImageTypePipelineNames(t *testing.T) { repoSets[plName] = repos } - m, _, err := imageType.Manifest(&bp, options, repos, seed) + m, _, err := imageType.Manifest(&bp, options, repos, &seed) assert.NoError(err) containers := make(map[string][]container.Spec, 0) @@ -416,7 +416,7 @@ func TestPipelineRepositories(t *testing.T) { } repos := tCase.repos - manifest, _, err := imageType.Manifest(&bp, options, repos, 0) + manifest, _, err := imageType.Manifest(&bp, options, repos, nil) require.NoError(err) packageSets := manifest.GetPackageSetChains() @@ -569,7 +569,7 @@ func TestDistro_ManifestFIPSWarning(t *testing.T) { if strings.HasSuffix(imgTypeName, "simplified-installer") { bp.Customizations.InstallationDevice = "/dev/dummy" } - _, warn, err := imgType.Manifest(&bp, imgOpts, nil, 0) + _, warn, err := imgType.Manifest(&bp, imgOpts, nil, nil) if err != nil { assert.True(t, slices.Contains(noCustomizableImages, imgTypeName)) assert.Equal(t, err, fmt.Errorf(distro.NoCustomizationsAllowedError, imgTypeName)) @@ -626,7 +626,7 @@ func TestOSTreeOptionsErrorForNonOSTreeImgTypes(t *testing.T) { }, } - _, _, err = imageType.Manifest(&bp, options, nil, 0) + _, _, err = imageType.Manifest(&bp, options, nil, nil) if imageType.OSTreeRef() == "" { assert.Errorf(err, "OSTree options should not be allowed for non-OSTree image type %s/%s/%s", diff --git a/pkg/distro/distro_test_common/distro_test_common.go b/pkg/distro/distro_test_common/distro_test_common.go index a8d0a32f8f..f1c03e2ac7 100644 --- a/pkg/distro/distro_test_common/distro_test_common.go +++ b/pkg/distro/distro_test_common/distro_test_common.go @@ -37,7 +37,7 @@ func kernelCount(imgType distro.ImageType, bp blueprint.Blueprint) int { } } - manifest, _, err := imgType.Manifest(&bp, distro.ImageOptions{OSTree: ostreeOptions}, nil, 0) + manifest, _, err := imgType.Manifest(&bp, distro.ImageOptions{OSTree: ostreeOptions}, nil, nil) if err != nil { panic(err) } @@ -220,7 +220,7 @@ func TestDistro_OSTreeOptions(t *testing.T, d distro.Distro) { } options := distro.ImageOptions{OSTree: &ostreeOptions} - m, _, err := imgType.Manifest(bp, options, nil, 0) + m, _, err := imgType.Manifest(bp, options, nil, nil) assert.NoError(err) nrefs := 0 @@ -274,7 +274,7 @@ func TestDistro_OSTreeOptions(t *testing.T, d distro.Distro) { ostreeOptions.URL = "https://example.com/repo" } options := distro.ImageOptions{OSTree: &ostreeOptions} - m, _, err := imgType.Manifest(bp, options, nil, 0) + m, _, err := imgType.Manifest(bp, options, nil, nil) assert.NoError(err) nrefs := 0 @@ -320,7 +320,7 @@ func TestDistro_OSTreeOptions(t *testing.T, d distro.Distro) { URL: "https://example.com/repo", } options := distro.ImageOptions{OSTree: &ostreeOptions} - m, _, err := imgType.Manifest(bp, options, nil, 0) + m, _, err := imgType.Manifest(bp, options, nil, nil) assert.NoError(err) nrefs := 0 @@ -364,7 +364,7 @@ func TestDistro_OSTreeOptions(t *testing.T, d distro.Distro) { URL: "https://example.com/repo", } options := distro.ImageOptions{OSTree: &ostreeOptions} - m, _, err := imgType.Manifest(bp, options, nil, 0) + m, _, err := imgType.Manifest(bp, options, nil, nil) assert.NoError(err) nrefs := 0 @@ -418,7 +418,7 @@ func TestDistro_OSTreeOptions(t *testing.T, d distro.Distro) { URL: "https://example.com/repo", } options := distro.ImageOptions{OSTree: &ostreeOptions} - m, _, err := imgType.Manifest(bp, options, nil, 0) + m, _, err := imgType.Manifest(bp, options, nil, nil) assert.NoError(err) nrefs := 0 @@ -470,7 +470,7 @@ func TestDistro_OSTreeOptions(t *testing.T, d distro.Distro) { ParentRef: "test/x86_64/02", } options := distro.ImageOptions{OSTree: &ostreeOptions} - _, _, err = imgType.Manifest(bp, options, nil, 0) + _, _, err = imgType.Manifest(bp, options, nil, nil) assert.Error(err) } } diff --git a/pkg/distro/fedora/distro_test.go b/pkg/distro/fedora/distro_test.go index 0dfa58f4af..1bddc6f9e7 100644 --- a/pkg/distro/fedora/distro_test.go +++ b/pkg/distro/fedora/distro_test.go @@ -312,7 +312,7 @@ func TestImageType_BuildPackages(t *testing.T) { if assert.NoErrorf(t, err, "d.GetArch(%v) returned err = %v; expected nil", archLabel, err) { continue } - manifest, _, err := itStruct.Manifest(&blueprint.Blueprint{}, distro.ImageOptions{}, nil, 0) + manifest, _, err := itStruct.Manifest(&blueprint.Blueprint{}, distro.ImageOptions{}, nil, nil) assert.NoError(t, err) buildPkgs := manifest.GetPackageSetChains()["build"] assert.NotNil(t, buildPkgs) @@ -507,7 +507,7 @@ func TestDistro_ManifestError(t *testing.T) { imgOpts := distro.ImageOptions{ Size: imgType.Size(0), } - _, _, err := imgType.Manifest(&bp, imgOpts, nil, 0) + _, _, err := imgType.Manifest(&bp, imgOpts, nil, nil) if imgTypeName == "iot-commit" || imgTypeName == "iot-container" || imgTypeName == "iot-bootable-container" { assert.EqualError(t, err, "kernel boot parameter customizations are not supported for ostree types") } else if imgTypeName == "iot-installer" || imgTypeName == "iot-simplified-installer" { @@ -738,7 +738,7 @@ func TestDistro_CustomFileSystemManifestError(t *testing.T) { arch, _ := fedoraDistro.GetArch(archName) for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, nil) if imgTypeName == "iot-commit" || imgTypeName == "iot-container" || imgTypeName == "iot-bootable-container" { assert.EqualError(t, err, "Custom mountpoints and partitioning are not supported for ostree types") } else if imgTypeName == "iot-raw-image" || imgTypeName == "iot-qcow2-image" { @@ -772,7 +772,7 @@ func TestDistro_TestRootMountPoint(t *testing.T) { arch, _ := fedoraDistro.GetArch(archName) for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, nil) if imgTypeName == "iot-commit" || imgTypeName == "iot-container" || imgTypeName == "iot-bootable-container" { assert.EqualError(t, err, "Custom mountpoints and partitioning are not supported for ostree types") } else if imgTypeName == "iot-raw-image" || imgTypeName == "iot-qcow2-image" { @@ -810,7 +810,7 @@ func TestDistro_CustomFileSystemSubDirectories(t *testing.T) { arch, _ := fedoraDistro.GetArch(archName) for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, nil) if strings.HasPrefix(imgTypeName, "iot-") || strings.HasPrefix(imgTypeName, "image-") { continue } else if imgTypeName == "live-installer" { @@ -852,7 +852,7 @@ func TestDistro_MountpointsWithArbitraryDepthAllowed(t *testing.T) { arch, _ := fedoraDistro.GetArch(archName) for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, nil) if strings.HasPrefix(imgTypeName, "iot-") || strings.HasPrefix(imgTypeName, "image-") { continue } else if imgTypeName == "live-installer" { @@ -890,7 +890,7 @@ func TestDistro_DirtyMountpointsNotAllowed(t *testing.T) { arch, _ := fedoraDistro.GetArch(archName) for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, nil) if strings.HasPrefix(imgTypeName, "iot-") || strings.HasPrefix(imgTypeName, "image-") { continue } else if imgTypeName == "live-installer" { @@ -920,7 +920,7 @@ func TestDistro_CustomUsrPartitionNotLargeEnough(t *testing.T) { arch, _ := fedoraDistro.GetArch(archName) for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, nil) if imgTypeName == "iot-commit" || imgTypeName == "iot-container" || imgTypeName == "iot-bootable-container" { assert.EqualError(t, err, "Custom mountpoints and partitioning are not supported for ostree types") } else if imgTypeName == "iot-raw-image" || imgTypeName == "iot-qcow2-image" { @@ -965,7 +965,7 @@ func TestDistro_PartitioningConflict(t *testing.T) { arch, _ := fedoraDistro.GetArch(archName) for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, nil) if imgTypeName == "iot-commit" || imgTypeName == "iot-container" || imgTypeName == "iot-bootable-container" { assert.EqualError(t, err, "Custom mountpoints and partitioning are not supported for ostree types") } else if imgTypeName == "iot-raw-image" || imgTypeName == "iot-qcow2-image" { @@ -1063,7 +1063,7 @@ func TestDistro_DiskCustomizationRunsValidateLayoutConstraints(t *testing.T) { imgOpts := distro.ImageOptions{ Size: imgType.Size(0), } - _, _, err := imgType.Manifest(&bp, imgOpts, nil, 0) + _, _, err := imgType.Manifest(&bp, imgOpts, nil, nil) assert.EqualError(t, err, "multiple LVM volume groups are not yet supported") }) } diff --git a/pkg/distro/fedora/imagetype.go b/pkg/distro/fedora/imagetype.go index 6f2a52e032..16130a7483 100644 --- a/pkg/distro/fedora/imagetype.go +++ b/pkg/distro/fedora/imagetype.go @@ -207,7 +207,8 @@ func (t *imageType) PartitionType() disk.PartitionTableType { func (t *imageType) Manifest(bp *blueprint.Blueprint, options distro.ImageOptions, repos []rpmmd.RepoConfig, - seed int64) (*manifest.Manifest, []string, error) { + seedp *int64) (*manifest.Manifest, []string, error) { + seed := distro.SeedFrom(seedp) warnings, err := t.checkOptions(bp, options) if err != nil { diff --git a/pkg/distro/rhel/imagetype.go b/pkg/distro/rhel/imagetype.go index b01cc4553e..b92c7b8b71 100644 --- a/pkg/distro/rhel/imagetype.go +++ b/pkg/distro/rhel/imagetype.go @@ -258,7 +258,8 @@ func (t *ImageType) PartitionType() disk.PartitionTableType { func (t *ImageType) Manifest(bp *blueprint.Blueprint, options distro.ImageOptions, repos []rpmmd.RepoConfig, - seed int64) (*manifest.Manifest, []string, error) { + seedp *int64) (*manifest.Manifest, []string, error) { + seed := distro.SeedFrom(seedp) if t.Workload != nil { // For now, if an image type defines its own workload, don't allow any diff --git a/pkg/distro/rhel/rhel10/distro_test.go b/pkg/distro/rhel/rhel10/distro_test.go index c09b66a658..7534ad78f4 100644 --- a/pkg/distro/rhel/rhel10/distro_test.go +++ b/pkg/distro/rhel/rhel10/distro_test.go @@ -163,7 +163,7 @@ func TestImageType_BuildPackages(t *testing.T) { if assert.NoErrorf(t, err, "d.GetArch(%v) returned err = %v; expected nil", archLabel, err) { continue } - manifest, _, err := itStruct.Manifest(&blueprint.Blueprint{}, distro.ImageOptions{}, nil, 0) + manifest, _, err := itStruct.Manifest(&blueprint.Blueprint{}, distro.ImageOptions{}, nil, nil) assert.NoError(t, err) buildPkgs := manifest.GetPackageSetChains()["build"] assert.NotNil(t, buildPkgs) @@ -257,7 +257,7 @@ func TestDistro_ManifestError(t *testing.T) { imgOpts := distro.ImageOptions{ Size: imgType.Size(0), } - _, _, err := imgType.Manifest(&bp, imgOpts, nil, 0) + _, _, err := imgType.Manifest(&bp, imgOpts, nil, nil) assert.NoError(t, err) } } @@ -427,7 +427,7 @@ func TestDistro_CustomFileSystemManifestError(t *testing.T) { arch, _ := r10distro.GetArch(archName) for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, nil) assert.EqualError(t, err, "The following errors occurred while setting up custom mountpoints:\npath \"/etc\" is not allowed") } } @@ -449,7 +449,7 @@ func TestDistro_TestRootMountPoint(t *testing.T) { arch, _ := r10distro.GetArch(archName) for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, nil) assert.NoError(t, err) } } @@ -475,7 +475,7 @@ func TestDistro_CustomFileSystemSubDirectories(t *testing.T) { arch, _ := r10distro.GetArch(archName) for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, nil) if strings.HasPrefix(imgTypeName, "edge-") { continue } else { @@ -513,7 +513,7 @@ func TestDistro_MountpointsWithArbitraryDepthAllowed(t *testing.T) { arch, _ := r10distro.GetArch(archName) for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, nil) if strings.HasPrefix(imgTypeName, "edge-") { continue } else { @@ -547,7 +547,7 @@ func TestDistro_DirtyMountpointsNotAllowed(t *testing.T) { arch, _ := r10distro.GetArch(archName) for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, nil) assert.EqualError(t, err, "The following errors occurred while setting up custom mountpoints:\npath \"//\" must be canonical\npath \"/var//\" must be canonical\npath \"/var//log/audit/\" must be canonical") } } @@ -569,7 +569,7 @@ func TestDistro_CustomUsrPartitionNotLargeEnough(t *testing.T) { arch, _ := r10distro.GetArch(archName) for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, nil) assert.NoError(t, err) } } @@ -618,7 +618,7 @@ func TestDiskAndFilesystemCustomizationsError(t *testing.T) { for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) options := distro.ImageOptions{} - _, _, err := imgType.Manifest(&bp, options, nil, 0) + _, _, err := imgType.Manifest(&bp, options, nil, nil) if skipTest[imgTypeName] { continue } @@ -664,7 +664,7 @@ func TestNoDiskCustomizationsNoError(t *testing.T) { for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) options := distro.ImageOptions{} - _, _, err := imgType.Manifest(&bp, options, nil, 0) + _, _, err := imgType.Manifest(&bp, options, nil, nil) if skipTest[imgTypeName] { continue } diff --git a/pkg/distro/rhel/rhel7/distro_test.go b/pkg/distro/rhel/rhel7/distro_test.go index fe96b5d35c..a1e1e75d2e 100644 --- a/pkg/distro/rhel/rhel7/distro_test.go +++ b/pkg/distro/rhel/rhel7/distro_test.go @@ -125,7 +125,7 @@ func TestImageType_BuildPackages(t *testing.T) { if assert.NoErrorf(t, err, "d.GetArch(%v) returned err = %v; expected nil", archLabel, err) { continue } - manifest, _, err := itStruct.Manifest(&blueprint.Blueprint{}, distro.ImageOptions{}, nil, 0) + manifest, _, err := itStruct.Manifest(&blueprint.Blueprint{}, distro.ImageOptions{}, nil, nil) assert.NoError(t, err) buildPkgs := manifest.GetPackageSetChains()["build"] assert.NotNil(t, buildPkgs) @@ -188,7 +188,7 @@ func TestDistro_ManifestError(t *testing.T) { imgOpts := distro.ImageOptions{ Size: imgType.Size(0), } - _, _, err := imgType.Manifest(&bp, imgOpts, nil, 0) + _, _, err := imgType.Manifest(&bp, imgOpts, nil, nil) assert.NoError(t, err) } } @@ -295,7 +295,7 @@ func TestDistro_CustomFileSystemManifestError(t *testing.T) { arch, _ := r7distro.GetArch(archName) for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, nil) assert.EqualError(t, err, "The following errors occurred while setting up custom mountpoints:\npath \"/etc\" is not allowed") } } @@ -317,7 +317,7 @@ func TestDistro_TestRootMountPoint(t *testing.T) { arch, _ := r7distro.GetArch(archName) for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, nil) assert.NoError(t, err) } } @@ -343,7 +343,7 @@ func TestDistro_CustomFileSystemSubDirectories(t *testing.T) { arch, _ := r7distro.GetArch(archName) for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, nil) assert.NoError(t, err) } } @@ -377,7 +377,7 @@ func TestDistro_MountpointsWithArbitraryDepthAllowed(t *testing.T) { arch, _ := r7distro.GetArch(archName) for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, nil) assert.NoError(t, err) } } @@ -407,7 +407,7 @@ func TestDistro_DirtyMountpointsNotAllowed(t *testing.T) { arch, _ := r7distro.GetArch(archName) for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, nil) assert.EqualError(t, err, "The following errors occurred while setting up custom mountpoints:\npath \"//\" must be canonical\npath \"/var//\" must be canonical\npath \"/var//log/audit/\" must be canonical") } } @@ -429,7 +429,7 @@ func TestDistro_CustomUsrPartitionNotLargeEnough(t *testing.T) { arch, _ := r7distro.GetArch(archName) for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, nil) assert.NoError(t, err) } } diff --git a/pkg/distro/rhel/rhel8/distro_test.go b/pkg/distro/rhel/rhel8/distro_test.go index d50f2bfd0d..c2b4335e7b 100644 --- a/pkg/distro/rhel/rhel8/distro_test.go +++ b/pkg/distro/rhel/rhel8/distro_test.go @@ -293,7 +293,7 @@ func TestImageType_BuildPackages(t *testing.T) { if assert.NoErrorf(t, err, "d.GetArch(%v) returned err = %v; expected nil", archLabel, err) { continue } - manifest, _, err := itStruct.Manifest(&blueprint.Blueprint{}, distro.ImageOptions{}, nil, 0) + manifest, _, err := itStruct.Manifest(&blueprint.Blueprint{}, distro.ImageOptions{}, nil, nil) assert.NoError(t, err) buildPkgs := manifest.GetPackageSetChains()["build"] assert.NotNil(t, buildPkgs) @@ -485,7 +485,7 @@ func TestDistro_ManifestError(t *testing.T) { imgOpts := distro.ImageOptions{ Size: imgType.Size(0), } - _, _, err := imgType.Manifest(&bp, imgOpts, nil, 0) + _, _, err := imgType.Manifest(&bp, imgOpts, nil, nil) 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" { @@ -676,7 +676,7 @@ func TestDistro_CustomFileSystemManifestError(t *testing.T) { arch, _ := r8distro.GetArch(archName) for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, nil) if imgTypeName == "edge-commit" || imgTypeName == "edge-container" { assert.EqualError(t, err, "custom mountpoints are not supported for ostree types") } else if unsupported[imgTypeName] { @@ -710,7 +710,7 @@ func TestDistro_TestRootMountPoint(t *testing.T) { arch, _ := r8distro.GetArch(archName) for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, nil) if imgTypeName == "edge-commit" || imgTypeName == "edge-container" { assert.EqualError(t, err, "custom mountpoints are not supported for ostree types") } else if unsupported[imgTypeName] { @@ -750,7 +750,7 @@ func TestDistro_CustomFileSystemSubDirectories(t *testing.T) { arch, _ := r8distro.GetArch(archName) for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, nil) if unsupported[imgTypeName] { assert.Error(t, err) } else { @@ -796,7 +796,7 @@ func TestDistro_MountpointsWithArbitraryDepthAllowed(t *testing.T) { arch, _ := r8distro.GetArch(archName) for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, nil) if unsupported[imgTypeName] { assert.Error(t, err) } else { @@ -838,7 +838,7 @@ func TestDistro_DirtyMountpointsNotAllowed(t *testing.T) { arch, _ := r8distro.GetArch(archName) for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, nil) if unsupported[imgTypeName] { assert.Error(t, err) } else { @@ -870,7 +870,7 @@ func TestDistro_CustomUsrPartitionNotLargeEnough(t *testing.T) { arch, _ := r8distro.GetArch(archName) for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, nil) if imgTypeName == "edge-commit" || imgTypeName == "edge-container" { assert.EqualError(t, err, "custom mountpoints are not supported for ostree types") } else if unsupported[imgTypeName] { @@ -913,7 +913,7 @@ func TestNoDiskCustomizationsSupported(t *testing.T) { arch, _ := r8distro.GetArch(archName) for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, nil) if skipTest[imgTypeName] { continue } diff --git a/pkg/distro/rhel/rhel9/distro_test.go b/pkg/distro/rhel/rhel9/distro_test.go index 6d3d807fd0..5d2eebd29b 100644 --- a/pkg/distro/rhel/rhel9/distro_test.go +++ b/pkg/distro/rhel/rhel9/distro_test.go @@ -294,7 +294,7 @@ func TestImageType_BuildPackages(t *testing.T) { if assert.NoErrorf(t, err, "d.GetArch(%v) returned err = %v; expected nil", archLabel, err) { continue } - manifest, _, err := itStruct.Manifest(&blueprint.Blueprint{}, distro.ImageOptions{}, nil, 0) + manifest, _, err := itStruct.Manifest(&blueprint.Blueprint{}, distro.ImageOptions{}, nil, nil) assert.NoError(t, err) buildPkgs := manifest.GetPackageSetChains()["build"] assert.NotNil(t, buildPkgs) @@ -484,7 +484,7 @@ func TestDistro_ManifestError(t *testing.T) { imgOpts := distro.ImageOptions{ Size: imgType.Size(0), } - _, _, err := imgType.Manifest(&bp, imgOpts, nil, 0) + _, _, err := imgType.Manifest(&bp, imgOpts, nil, nil) 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" || imgTypeName == "edge-ami" || imgTypeName == "edge-vsphere" { @@ -669,7 +669,7 @@ func TestDistro_CustomFileSystemManifestError(t *testing.T) { arch, _ := r9distro.GetArch(archName) for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, nil) if imgTypeName == "edge-commit" || imgTypeName == "edge-container" { assert.EqualError(t, err, "custom mountpoints and partitioning are not supported for ostree types") } else if imgTypeName == "edge-installer" || imgTypeName == "edge-simplified-installer" || imgTypeName == "edge-raw-image" || imgTypeName == "edge-ami" || imgTypeName == "edge-vsphere" { @@ -697,7 +697,7 @@ func TestDistro_TestRootMountPoint(t *testing.T) { arch, _ := r9distro.GetArch(archName) for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, nil) if imgTypeName == "edge-commit" || imgTypeName == "edge-container" { assert.EqualError(t, err, "custom mountpoints and partitioning are not supported for ostree types") } else if imgTypeName == "edge-installer" || imgTypeName == "edge-simplified-installer" || imgTypeName == "edge-raw-image" || imgTypeName == "edge-ami" || imgTypeName == "edge-vsphere" { @@ -729,7 +729,7 @@ func TestDistro_CustomFileSystemSubDirectories(t *testing.T) { arch, _ := r9distro.GetArch(archName) for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, nil) if strings.HasPrefix(imgTypeName, "edge-") { continue } else { @@ -767,7 +767,7 @@ func TestDistro_MountpointsWithArbitraryDepthAllowed(t *testing.T) { arch, _ := r9distro.GetArch(archName) for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, nil) if strings.HasPrefix(imgTypeName, "edge-") { continue } else { @@ -801,7 +801,7 @@ func TestDistro_DirtyMountpointsNotAllowed(t *testing.T) { arch, _ := r9distro.GetArch(archName) for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, nil) if strings.HasPrefix(imgTypeName, "edge-") { continue } else { @@ -827,7 +827,7 @@ func TestDistro_CustomUsrPartitionNotLargeEnough(t *testing.T) { arch, _ := r9distro.GetArch(archName) for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) + _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, nil) if imgTypeName == "edge-commit" || imgTypeName == "edge-container" { assert.EqualError(t, err, "custom mountpoints and partitioning are not supported for ostree types") } else if imgTypeName == "edge-installer" || imgTypeName == "edge-simplified-installer" || imgTypeName == "edge-raw-image" || imgTypeName == "edge-ami" || imgTypeName == "edge-vsphere" { @@ -882,7 +882,7 @@ func TestDiskAndFilesystemCustomizationsError(t *testing.T) { for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) options := distro.ImageOptions{} - _, _, err := imgType.Manifest(&bp, options, nil, 0) + _, _, err := imgType.Manifest(&bp, options, nil, nil) if skipTest[imgTypeName] { continue } @@ -928,7 +928,7 @@ func TestNoDiskCustomizationsNoError(t *testing.T) { for _, imgTypeName := range arch.ListImageTypes() { imgType, _ := arch.GetImageType(imgTypeName) options := distro.ImageOptions{} - _, _, err := imgType.Manifest(&bp, options, nil, 0) + _, _, err := imgType.Manifest(&bp, options, nil, nil) if skipTest[imgTypeName] { continue } diff --git a/pkg/distro/test_distro/distro.go b/pkg/distro/test_distro/distro.go index 902ed02591..cd0aad540c 100644 --- a/pkg/distro/test_distro/distro.go +++ b/pkg/distro/test_distro/distro.go @@ -232,7 +232,7 @@ func (t *TestImageType) Exports() []string { return distro.ExportsFallback() } -func (t *TestImageType) Manifest(b *blueprint.Blueprint, options distro.ImageOptions, repos []rpmmd.RepoConfig, seed int64) (*manifest.Manifest, []string, error) { +func (t *TestImageType) Manifest(b *blueprint.Blueprint, options distro.ImageOptions, repos []rpmmd.RepoConfig, seedp *int64) (*manifest.Manifest, []string, error) { var bpPkgs []string if b != nil { mountpoints := b.Customizations.GetFilesystems()