diff --git a/pkg/distro/generic/images.go b/pkg/distro/generic/images.go index edc7c8b2f1..d7daf9e0f5 100644 --- a/pkg/distro/generic/images.go +++ b/pkg/distro/generic/images.go @@ -447,8 +447,7 @@ func diskImage(t *imageType, containers []container.SourceSpec, rng *rand.Rand) (image.ImageKind, error) { - img := image.NewDiskImage() - img.Platform = t.platform + img := image.NewDiskImage(t.platform, t.Filename()) var err error img.OSCustomizations, err = osCustomizations(t, packageSets[osPkgsKey], options, containers, bp) @@ -470,8 +469,6 @@ func diskImage(t *imageType, } img.PartitionTable = pt - img.Filename = t.Filename() - img.VPCForceSize = t.ImageTypeYAML.DiskImageVPCForceSize if img.OSCustomizations.NoBLS { @@ -494,9 +491,7 @@ func tarImage(t *imageType, payloadRepos []rpmmd.RepoConfig, containers []container.SourceSpec, rng *rand.Rand) (image.ImageKind, error) { - img := image.NewArchive() - - img.Platform = t.platform + img := image.NewArchive(t.platform, t.Filename()) var err error img.OSCustomizations, err = osCustomizations(t, packageSets[osPkgsKey], options, containers, bp) @@ -511,8 +506,6 @@ func tarImage(t *imageType, img.Compression = t.ImageTypeYAML.Compression img.OSVersion = d.OsVersion() - img.Filename = t.Filename() - return img, nil } @@ -523,9 +516,7 @@ func containerImage(t *imageType, payloadRepos []rpmmd.RepoConfig, containers []container.SourceSpec, rng *rand.Rand) (image.ImageKind, error) { - img := image.NewBaseContainer() - - img.Platform = t.platform + img := image.NewBaseContainer(t.platform, t.Filename()) var err error img.OSCustomizations, err = osCustomizations(t, packageSets[osPkgsKey], options, containers, bp) @@ -535,8 +526,6 @@ func containerImage(t *imageType, img.OSCustomizations.PayloadRepos = payloadRepos img.Environment = &t.ImageTypeYAML.Environment - img.Filename = t.Filename() - return img, nil } @@ -548,9 +537,8 @@ func liveInstallerImage(t *imageType, containers []container.SourceSpec, rng *rand.Rand) (image.ImageKind, error) { - img := image.NewAnacondaLiveInstaller() + img := image.NewAnacondaLiveInstaller(t.platform, t.Filename()) - img.Platform = t.platform img.ExtraBasePackages = packageSets[installerPkgsKey] d := t.arch.distro @@ -566,8 +554,6 @@ func liveInstallerImage(t *imageType, return nil, err } - img.Filename = t.Filename() - imgConfig := t.getDefaultImageConfig() if locale := imgConfig.Locale; locale != nil { img.Locale = *locale @@ -592,7 +578,7 @@ func imageInstallerImage(t *imageType, customizations := bp.Customizations - img := image.NewAnacondaTarInstaller() + img := image.NewAnacondaTarInstaller(t.platform, t.Filename()) var err error img.OSCustomizations, err = osCustomizations(t, packageSets[osPkgsKey], options, containers, bp) @@ -609,8 +595,6 @@ func imageInstallerImage(t *imageType, img.Kickstart.Keyboard = img.OSCustomizations.Keyboard img.Kickstart.Timezone = &img.OSCustomizations.Timezone - img.Platform = t.platform - img.ExtraBasePackages = packageSets[installerPkgsKey] img.InstallerCustomizations, err = installerCustomizations(t, bp.Customizations) @@ -645,8 +629,6 @@ func imageInstallerImage(t *imageType, return nil, err } - img.Filename = t.Filename() - img.RootfsCompression = "xz" // This also triggers using the bcj filter return img, nil @@ -661,12 +643,10 @@ func iotCommitImage(t *imageType, rng *rand.Rand) (image.ImageKind, error) { parentCommit, commitRef := makeOSTreeParentCommit(options.OSTree, t.OSTreeRef()) - img := image.NewOSTreeArchive(commitRef) + img := image.NewOSTreeArchive(t.platform, t.Filename(), commitRef) d := t.arch.distro - img.Platform = t.platform - var err error img.OSCustomizations, err = osCustomizations(t, packageSets[osPkgsKey], options, containers, bp) if err != nil { @@ -683,7 +663,6 @@ func iotCommitImage(t *imageType, img.Environment = &t.ImageTypeYAML.Environment img.OSTreeParent = parentCommit img.OSVersion = d.OsVersion() - img.Filename = t.Filename() return img, nil } @@ -697,12 +676,10 @@ func bootableContainerImage(t *imageType, rng *rand.Rand) (image.ImageKind, error) { parentCommit, commitRef := makeOSTreeParentCommit(options.OSTree, t.OSTreeRef()) - img := image.NewOSTreeArchive(commitRef) + img := image.NewOSTreeArchive(t.platform, t.Filename(), commitRef) d := t.arch.distro - img.Platform = t.platform - var err error img.OSCustomizations, err = osCustomizations(t, packageSets[osPkgsKey], options, containers, bp) if err != nil { @@ -713,7 +690,6 @@ func bootableContainerImage(t *imageType, img.Environment = &t.ImageTypeYAML.Environment img.OSTreeParent = parentCommit img.OSVersion = d.OsVersion() - img.Filename = t.Filename() img.InstallWeakDeps = false img.BootContainer = true id, err := distro.ParseID(d.Name()) @@ -737,9 +713,8 @@ func iotContainerImage(t *imageType, rng *rand.Rand) (image.ImageKind, error) { parentCommit, commitRef := makeOSTreeParentCommit(options.OSTree, t.OSTreeRef()) - img := image.NewOSTreeContainer(commitRef) + img := image.NewOSTreeContainer(t.platform, t.Filename(), commitRef) d := t.arch.distro - img.Platform = t.platform var err error img.OSCustomizations, err = osCustomizations(t, packageSets[osPkgsKey], options, containers, bp) @@ -759,7 +734,6 @@ func iotContainerImage(t *imageType, img.OSTreeParent = parentCommit img.OSVersion = d.OsVersion() img.ExtraContainerPackages = packageSets[containerPkgsKey] - img.Filename = t.Filename() return img, nil } @@ -779,10 +753,9 @@ func iotInstallerImage(t *imageType, return nil, fmt.Errorf("%s: %s", t.Name(), err.Error()) } - img := image.NewAnacondaOSTreeInstaller(commit) + img := image.NewAnacondaOSTreeInstaller(t.platform, t.Filename(), commit) customizations := bp.Customizations - img.Platform = t.platform img.ExtraBasePackages = packageSets[installerPkgsKey] img.Kickstart, err = kickstart.New(customizations) if err != nil { @@ -822,8 +795,6 @@ func iotInstallerImage(t *imageType, return nil, err } - img.Filename = t.Filename() - img.RootfsCompression = "xz" // This also triggers using the bcj filter imgConfig := t.getDefaultImageConfig() if locale := imgConfig.Locale; locale != nil { @@ -845,7 +816,7 @@ func iotImage(t *imageType, if err != nil { return nil, fmt.Errorf("%s: %s", t.Name(), err.Error()) } - img := image.NewOSTreeDiskImageFromCommit(commit) + img := image.NewOSTreeDiskImageFromCommit(t.platform, t.Filename(), commit) customizations := bp.Customizations deploymentConfig, err := ostreeDeploymentCustomizations(t, customizations) @@ -855,8 +826,6 @@ func iotImage(t *imageType, img.OSTreeDeploymentCustomizations = deploymentConfig img.OSCustomizations.PayloadRepos = payloadRepos - img.Platform = t.platform - img.Remote = ostree.Remote{ Name: t.ImageTypeYAML.OSTree.RemoteName, } @@ -875,7 +844,6 @@ func iotImage(t *imageType, } img.PartitionTable = pt - img.Filename = t.Filename() img.Compression = t.ImageTypeYAML.Compression return img, nil @@ -893,7 +861,7 @@ func iotSimplifiedInstallerImage(t *imageType, if err != nil { return nil, fmt.Errorf("%s: %s", t.Name(), err.Error()) } - rawImg := image.NewOSTreeDiskImageFromCommit(commit) + rawImg := image.NewOSTreeDiskImageFromCommit(t.platform, t.Filename(), commit) customizations := bp.Customizations deploymentConfig, err := ostreeDeploymentCustomizations(t, customizations) @@ -902,7 +870,6 @@ func iotSimplifiedInstallerImage(t *imageType, } rawImg.OSTreeDeploymentCustomizations = deploymentConfig - rawImg.Platform = t.platform rawImg.OSCustomizations.PayloadRepos = payloadRepos rawImg.Remote = ostree.Remote{ Name: t.OSTree.RemoteName, @@ -920,12 +887,9 @@ func iotSimplifiedInstallerImage(t *imageType, } rawImg.PartitionTable = pt - rawImg.Filename = t.Filename() - - img := image.NewOSTreeSimplifiedInstaller(rawImg, customizations.InstallationDevice) + // XXX: can we take platform/filename in NewOSTreeSimplifiedInstaller from rawImg instead? + img := image.NewOSTreeSimplifiedInstaller(t.platform, t.Filename(), rawImg, customizations.InstallationDevice) img.ExtraBasePackages = packageSets[installerPkgsKey] - img.Platform = t.platform - img.Filename = t.Filename() if bpFDO := customizations.GetFDO(); bpFDO != nil { img.FDO = fdo.FromBP(*bpFDO) } @@ -975,13 +939,12 @@ func netinstImage(t *imageType, customizations := bp.Customizations - img := image.NewAnacondaNetInstaller() + img := image.NewAnacondaNetInstaller(t.platform, t.Filename()) language, _ := customizations.GetPrimaryLocale() if language != nil { img.Language = *language } - img.Platform = t.platform img.ExtraBasePackages = packageSets[installerPkgsKey] var err error @@ -1005,8 +968,6 @@ func netinstImage(t *imageType, return nil, err } - img.Filename = t.Filename() - img.RootfsCompression = "xz" // This also triggers using the bcj filter return img, nil diff --git a/pkg/image/anaconda_container_installer.go b/pkg/image/anaconda_container_installer.go index 8e8ea60620..c3e9e7a48d 100644 --- a/pkg/image/anaconda_container_installer.go +++ b/pkg/image/anaconda_container_installer.go @@ -20,7 +20,7 @@ import ( type AnacondaContainerInstaller struct { Base - Platform platform.Platform + InstallerCustomizations manifest.InstallerCustomizations ExtraBasePackages rpmmd.PackageSet @@ -37,8 +37,6 @@ type AnacondaContainerInstaller struct { ContainerSource container.SourceSpec ContainerRemoveSignatures bool - Filename string - Kickstart *kickstart.Options // Locale for the installer. This should be set to the same locale as the @@ -49,9 +47,9 @@ type AnacondaContainerInstaller struct { InstallRootfsType disk.FSType } -func NewAnacondaContainerInstaller(container container.SourceSpec, ref string) *AnacondaContainerInstaller { +func NewAnacondaContainerInstaller(platform platform.Platform, filename string, container container.SourceSpec, ref string) *AnacondaContainerInstaller { return &AnacondaContainerInstaller{ - Base: NewBase("container-installer"), + Base: NewBase("container-installer", platform, filename), ContainerSource: container, Ref: ref, } @@ -67,7 +65,7 @@ func (img *AnacondaContainerInstaller) InstantiateManifest(m *manifest.Manifest, anacondaPipeline := manifest.NewAnacondaInstaller( manifest.AnacondaInstallerTypePayload, buildPipeline, - img.Platform, + img.platform, repos, "kernel", img.Product, @@ -79,7 +77,7 @@ func (img *AnacondaContainerInstaller) InstantiateManifest(m *manifest.Manifest, anacondaPipeline.ExcludePackages = img.ExtraBasePackages.Exclude anacondaPipeline.ExtraRepos = img.ExtraBasePackages.Repositories anacondaPipeline.Variant = img.Variant - anacondaPipeline.Biosdevname = (img.Platform.GetArch() == arch.ARCH_X86_64) + anacondaPipeline.Biosdevname = (img.platform.GetArch() == arch.ARCH_X86_64) anacondaPipeline.Checkpoint() anacondaPipeline.InstallerCustomizations = img.InstallerCustomizations @@ -101,8 +99,8 @@ func (img *AnacondaContainerInstaller) InstantiateManifest(m *manifest.Manifest, } bootTreePipeline := manifest.NewEFIBootTree(buildPipeline, img.Product, img.OSVersion) - bootTreePipeline.Platform = img.Platform - bootTreePipeline.UEFIVendor = img.Platform.GetUEFIVendor() + bootTreePipeline.Platform = img.platform + bootTreePipeline.UEFIVendor = img.platform.GetUEFIVendor() bootTreePipeline.ISOLabel = img.ISOLabel if img.Kickstart == nil { @@ -138,7 +136,7 @@ func (img *AnacondaContainerInstaller) InstantiateManifest(m *manifest.Manifest, isoTreePipeline.InstallRootfsType = img.InstallRootfsType isoPipeline := manifest.NewISO(buildPipeline, isoTreePipeline, img.ISOLabel) - isoPipeline.SetFilename(img.Filename) + isoPipeline.SetFilename(img.filename) isoPipeline.ISOBoot = img.InstallerCustomizations.ISOBoot artifact := isoPipeline.Export() diff --git a/pkg/image/anaconda_live_installer.go b/pkg/image/anaconda_live_installer.go index 8cf15a14c0..1fe65cae3b 100644 --- a/pkg/image/anaconda_live_installer.go +++ b/pkg/image/anaconda_live_installer.go @@ -16,7 +16,6 @@ import ( type AnacondaLiveInstaller struct { Base - Platform platform.Platform InstallerCustomizations manifest.InstallerCustomizations Environment environment.Environment @@ -31,8 +30,6 @@ type AnacondaLiveInstaller struct { Release string Preview bool - Filename string - // Locale for the installer. This should be set to the same locale as the // ISO OS payload, if known. Locale string @@ -41,9 +38,9 @@ type AnacondaLiveInstaller struct { AdditionalDrivers []string } -func NewAnacondaLiveInstaller() *AnacondaLiveInstaller { +func NewAnacondaLiveInstaller(platform platform.Platform, filename string) *AnacondaLiveInstaller { return &AnacondaLiveInstaller{ - Base: NewBase("live-installer"), + Base: NewBase("live-installer", platform, filename), } } @@ -57,7 +54,7 @@ func (img *AnacondaLiveInstaller) InstantiateManifest(m *manifest.Manifest, livePipeline := manifest.NewAnacondaInstaller( manifest.AnacondaInstallerTypeLive, buildPipeline, - img.Platform, + img.platform, repos, "kernel", img.Product, @@ -69,7 +66,7 @@ func (img *AnacondaLiveInstaller) InstantiateManifest(m *manifest.Manifest, livePipeline.ExcludePackages = img.ExtraBasePackages.Exclude livePipeline.Variant = img.Variant - livePipeline.Biosdevname = (img.Platform.GetArch() == arch.ARCH_X86_64) + livePipeline.Biosdevname = (img.platform.GetArch() == arch.ARCH_X86_64) livePipeline.Locale = img.Locale livePipeline.InstallerCustomizations = img.InstallerCustomizations @@ -87,8 +84,8 @@ func (img *AnacondaLiveInstaller) InstantiateManifest(m *manifest.Manifest, } bootTreePipeline := manifest.NewEFIBootTree(buildPipeline, img.Product, img.OSVersion) - bootTreePipeline.Platform = img.Platform - bootTreePipeline.UEFIVendor = img.Platform.GetUEFIVendor() + bootTreePipeline.Platform = img.platform + bootTreePipeline.UEFIVendor = img.platform.GetUEFIVendor() bootTreePipeline.ISOLabel = img.ISOLabel bootTreePipeline.DefaultMenu = img.InstallerCustomizations.DefaultMenu @@ -114,7 +111,7 @@ func (img *AnacondaLiveInstaller) InstantiateManifest(m *manifest.Manifest, isoTreePipeline.RootfsType = img.InstallerCustomizations.ISORootfsType isoPipeline := manifest.NewISO(buildPipeline, isoTreePipeline, img.ISOLabel) - isoPipeline.SetFilename(img.Filename) + isoPipeline.SetFilename(img.filename) isoPipeline.ISOBoot = img.InstallerCustomizations.ISOBoot artifact := isoPipeline.Export() diff --git a/pkg/image/anaconda_net_installer.go b/pkg/image/anaconda_net_installer.go index 79325cbfe2..f88d57095a 100644 --- a/pkg/image/anaconda_net_installer.go +++ b/pkg/image/anaconda_net_installer.go @@ -17,7 +17,6 @@ import ( type AnacondaNetInstaller struct { Base - Platform platform.Platform InstallerCustomizations manifest.InstallerCustomizations Environment environment.Environment @@ -32,13 +31,12 @@ type AnacondaNetInstaller struct { Release string Preview bool - Filename string Language string } -func NewAnacondaNetInstaller() *AnacondaNetInstaller { +func NewAnacondaNetInstaller(platform platform.Platform, filename string) *AnacondaNetInstaller { return &AnacondaNetInstaller{ - Base: NewBase("netinst"), + Base: NewBase("netinst", platform, filename), } } @@ -53,7 +51,7 @@ func (img *AnacondaNetInstaller) InstantiateManifest(m *manifest.Manifest, anacondaPipeline := manifest.NewAnacondaInstaller( installerType, buildPipeline, - img.Platform, + img.platform, repos, "kernel", img.Product, @@ -65,7 +63,7 @@ func (img *AnacondaNetInstaller) InstantiateManifest(m *manifest.Manifest, anacondaPipeline.ExcludePackages = img.ExtraBasePackages.Exclude anacondaPipeline.ExtraRepos = img.ExtraBasePackages.Repositories anacondaPipeline.Variant = img.Variant - anacondaPipeline.Biosdevname = (img.Platform.GetArch() == arch.ARCH_X86_64) + anacondaPipeline.Biosdevname = (img.platform.GetArch() == arch.ARCH_X86_64) anacondaPipeline.InstallerCustomizations = img.InstallerCustomizations @@ -89,8 +87,8 @@ func (img *AnacondaNetInstaller) InstantiateManifest(m *manifest.Manifest, } bootTreePipeline := manifest.NewEFIBootTree(buildPipeline, img.Product, img.OSVersion) - bootTreePipeline.Platform = img.Platform - bootTreePipeline.UEFIVendor = img.Platform.GetUEFIVendor() + bootTreePipeline.Platform = img.platform + bootTreePipeline.UEFIVendor = img.platform.GetUEFIVendor() bootTreePipeline.ISOLabel = img.ISOLabel bootTreePipeline.DefaultMenu = img.InstallerCustomizations.DefaultMenu @@ -117,7 +115,7 @@ func (img *AnacondaNetInstaller) InstantiateManifest(m *manifest.Manifest, isoTreePipeline.ISOBoot = img.InstallerCustomizations.ISOBoot isoPipeline := manifest.NewISO(buildPipeline, isoTreePipeline, img.ISOLabel) - isoPipeline.SetFilename(img.Filename) + isoPipeline.SetFilename(img.filename) isoPipeline.ISOBoot = img.InstallerCustomizations.ISOBoot artifact := isoPipeline.Export() diff --git a/pkg/image/anaconda_ostree_installer.go b/pkg/image/anaconda_ostree_installer.go index c2f91aec6d..d93ce42fa6 100644 --- a/pkg/image/anaconda_ostree_installer.go +++ b/pkg/image/anaconda_ostree_installer.go @@ -20,7 +20,6 @@ import ( type AnacondaOSTreeInstaller struct { Base - Platform platform.Platform InstallerCustomizations manifest.InstallerCustomizations ExtraBasePackages rpmmd.PackageSet @@ -40,16 +39,14 @@ type AnacondaOSTreeInstaller struct { Commit ostree.SourceSpec - Filename string - // Locale for the installer. This should be set to the same locale as the // ISO OS payload, if known. Locale string } -func NewAnacondaOSTreeInstaller(commit ostree.SourceSpec) *AnacondaOSTreeInstaller { +func NewAnacondaOSTreeInstaller(platform platform.Platform, filename string, commit ostree.SourceSpec) *AnacondaOSTreeInstaller { return &AnacondaOSTreeInstaller{ - Base: NewBase("ostree-installer"), + Base: NewBase("ostree-installer", platform, filename), Commit: commit, } } @@ -64,7 +61,7 @@ func (img *AnacondaOSTreeInstaller) InstantiateManifest(m *manifest.Manifest, anacondaPipeline := manifest.NewAnacondaInstaller( manifest.AnacondaInstallerTypePayload, buildPipeline, - img.Platform, + img.platform, repos, "kernel", img.Product, @@ -81,7 +78,7 @@ func (img *AnacondaOSTreeInstaller) InstantiateManifest(m *manifest.Manifest, } } anacondaPipeline.Variant = img.Variant - anacondaPipeline.Biosdevname = (img.Platform.GetArch() == arch.ARCH_X86_64) + anacondaPipeline.Biosdevname = (img.platform.GetArch() == arch.ARCH_X86_64) anacondaPipeline.Checkpoint() anacondaPipeline.InstallerCustomizations = img.InstallerCustomizations @@ -104,8 +101,8 @@ func (img *AnacondaOSTreeInstaller) InstantiateManifest(m *manifest.Manifest, } bootTreePipeline := manifest.NewEFIBootTree(buildPipeline, img.Product, img.OSVersion) - bootTreePipeline.Platform = img.Platform - bootTreePipeline.UEFIVendor = img.Platform.GetUEFIVendor() + bootTreePipeline.Platform = img.platform + bootTreePipeline.UEFIVendor = img.platform.GetUEFIVendor() bootTreePipeline.ISOLabel = img.ISOLabel bootTreePipeline.DefaultMenu = img.InstallerCustomizations.DefaultMenu @@ -143,7 +140,7 @@ func (img *AnacondaOSTreeInstaller) InstantiateManifest(m *manifest.Manifest, isoTreePipeline.SubscriptionPipeline = subscriptionPipeline isoPipeline := manifest.NewISO(buildPipeline, isoTreePipeline, img.ISOLabel) - isoPipeline.SetFilename(img.Filename) + isoPipeline.SetFilename(img.filename) isoPipeline.ISOBoot = img.InstallerCustomizations.ISOBoot artifact := isoPipeline.Export() diff --git a/pkg/image/anaconda_tar_installer.go b/pkg/image/anaconda_tar_installer.go index 9c9bafb5e4..02e18ccecf 100644 --- a/pkg/image/anaconda_tar_installer.go +++ b/pkg/image/anaconda_tar_installer.go @@ -38,7 +38,6 @@ func efiBootPartitionTable(rng *rand.Rand) *disk.PartitionTable { type AnacondaTarInstaller struct { Base - Platform platform.Platform OSCustomizations manifest.OSCustomizations InstallerCustomizations manifest.InstallerCustomizations Environment environment.Environment @@ -55,13 +54,11 @@ type AnacondaTarInstaller struct { OSVersion string Release string Preview bool - - Filename string } -func NewAnacondaTarInstaller() *AnacondaTarInstaller { +func NewAnacondaTarInstaller(platform platform.Platform, filename string) *AnacondaTarInstaller { return &AnacondaTarInstaller{ - Base: NewBase("image-installer"), + Base: NewBase("image-installer", platform, filename), } } @@ -83,7 +80,7 @@ func (img *AnacondaTarInstaller) InstantiateManifest(m *manifest.Manifest, anacondaPipeline := manifest.NewAnacondaInstaller( manifest.AnacondaInstallerTypePayload, buildPipeline, - img.Platform, + img.platform, repos, "kernel", img.Product, @@ -101,7 +98,7 @@ func (img *AnacondaTarInstaller) InstantiateManifest(m *manifest.Manifest, } } anacondaPipeline.Variant = img.Variant - anacondaPipeline.Biosdevname = (img.Platform.GetArch() == arch.ARCH_X86_64) + anacondaPipeline.Biosdevname = (img.platform.GetArch() == arch.ARCH_X86_64) anacondaPipeline.InstallerCustomizations = img.InstallerCustomizations @@ -127,8 +124,8 @@ func (img *AnacondaTarInstaller) InstantiateManifest(m *manifest.Manifest, } bootTreePipeline := manifest.NewEFIBootTree(buildPipeline, img.Product, img.OSVersion) - bootTreePipeline.Platform = img.Platform - bootTreePipeline.UEFIVendor = img.Platform.GetUEFIVendor() + bootTreePipeline.Platform = img.platform + bootTreePipeline.UEFIVendor = img.platform.GetUEFIVendor() bootTreePipeline.ISOLabel = img.ISOLabel bootTreePipeline.DefaultMenu = img.InstallerCustomizations.DefaultMenu @@ -144,7 +141,7 @@ func (img *AnacondaTarInstaller) InstantiateManifest(m *manifest.Manifest, kernelOpts = append(kernelOpts, img.OSCustomizations.KernelOptionsAppend...) bootTreePipeline.KernelOpts = kernelOpts - osPipeline := manifest.NewOS(buildPipeline, img.Platform, repos) + osPipeline := manifest.NewOS(buildPipeline, img.platform, repos) osPipeline.OSCustomizations = img.OSCustomizations osPipeline.Environment = img.Environment @@ -169,7 +166,7 @@ func (img *AnacondaTarInstaller) InstantiateManifest(m *manifest.Manifest, isoTreePipeline.ISOBoot = img.InstallerCustomizations.ISOBoot isoPipeline := manifest.NewISO(buildPipeline, isoTreePipeline, img.ISOLabel) - isoPipeline.SetFilename(img.Filename) + isoPipeline.SetFilename(img.filename) isoPipeline.ISOBoot = img.InstallerCustomizations.ISOBoot artifact := isoPipeline.Export() diff --git a/pkg/image/archive.go b/pkg/image/archive.go index 246f210e8d..8581e28bc9 100644 --- a/pkg/image/archive.go +++ b/pkg/image/archive.go @@ -13,18 +13,16 @@ import ( type Archive struct { Base - Platform platform.Platform OSCustomizations manifest.OSCustomizations Environment environment.Environment - Filename string Compression string OSVersion string } -func NewArchive() *Archive { +func NewArchive(platform platform.Platform, filename string) *Archive { return &Archive{ - Base: NewBase("archive"), + Base: NewBase("archive", platform, filename), } } @@ -35,7 +33,7 @@ func (img *Archive) InstantiateManifest(m *manifest.Manifest, buildPipeline := addBuildBootstrapPipelines(m, runner, repos, nil) buildPipeline.Checkpoint() - osPipeline := manifest.NewOS(buildPipeline, img.Platform, repos) + osPipeline := manifest.NewOS(buildPipeline, img.platform, repos) osPipeline.OSCustomizations = img.OSCustomizations osPipeline.Environment = img.Environment osPipeline.OSVersion = img.OSVersion @@ -43,7 +41,7 @@ func (img *Archive) InstantiateManifest(m *manifest.Manifest, tarPipeline := manifest.NewTar(buildPipeline, osPipeline, "archive") compressionPipeline := GetCompressionPipeline(img.Compression, buildPipeline, tarPipeline) - compressionPipeline.SetFilename(img.Filename) + compressionPipeline.SetFilename(img.filename) return compressionPipeline.Export(), nil } diff --git a/pkg/image/bootc_disk.go b/pkg/image/bootc_disk.go index 1225360aba..e349df843c 100644 --- a/pkg/image/bootc_disk.go +++ b/pkg/image/bootc_disk.go @@ -16,11 +16,8 @@ import ( type BootcDiskImage struct { Base - Platform platform.Platform PartitionTable *disk.PartitionTable - Filename string - ContainerSource *container.SourceSpec BuildContainerSource *container.SourceSpec @@ -28,9 +25,9 @@ type BootcDiskImage struct { OSCustomizations manifest.OSCustomizations } -func NewBootcDiskImage(container container.SourceSpec, buildContainer container.SourceSpec) *BootcDiskImage { +func NewBootcDiskImage(platform platform.Platform, filename string, container container.SourceSpec, buildContainer container.SourceSpec) *BootcDiskImage { return &BootcDiskImage{ - Base: NewBase("bootc-raw-image"), + Base: NewBase("bootc-raw-image", platform, filename), ContainerSource: &container, BuildContainerSource: &buildContainer, } @@ -99,7 +96,7 @@ func (img *BootcDiskImage) InstantiateManifestFromContainers(m *manifest.Manifes // this is signified by passing nil to the below pipelines. var hostPipeline manifest.Build - rawImage := manifest.NewRawBootcImage(buildPipeline, containers, img.Platform) + rawImage := manifest.NewRawBootcImage(buildPipeline, containers, img.platform) rawImage.PartitionTable = img.PartitionTable rawImage.Users = img.OSCustomizations.Users rawImage.Groups = img.OSCustomizations.Groups @@ -112,11 +109,11 @@ func (img *BootcDiskImage) InstantiateManifestFromContainers(m *manifest.Manifes // In BIB, we export multiple images from the same pipeline so we use the // filename as the basename for each export and set the extensions based on // each file format. - fileBasename := img.Filename + fileBasename := img.filename rawImage.SetFilename(fmt.Sprintf("%s.raw", fileBasename)) qcow2Pipeline := manifest.NewQCOW2(hostPipeline, rawImage) - qcow2Pipeline.Compat = img.Platform.GetQCOW2Compat() + qcow2Pipeline.Compat = img.platform.GetQCOW2Compat() qcow2Pipeline.SetFilename(fmt.Sprintf("%s.qcow2", fileBasename)) vmdkPipeline := manifest.NewVMDK(hostPipeline, rawImage) diff --git a/pkg/image/bootc_disk_legacy.go b/pkg/image/bootc_disk_legacy.go index 7a974981f5..617ca22220 100644 --- a/pkg/image/bootc_disk_legacy.go +++ b/pkg/image/bootc_disk_legacy.go @@ -37,12 +37,12 @@ func (img *BootcLegacyDiskImage) InstantiateManifestFromContainers(m *manifest.M // XXX: hardcoded for now ref := "ostree/1/1/0" ostreeImg := &OSTreeDiskImage{ - Base: NewBase("bootc-raw-image"), + Base: NewBase("bootc-raw-image", img.bootcImg.platform, img.bootcImg.filename), ContainerSource: img.bootcImg.ContainerSource, Ref: ref, OSName: "default", } - ostreeImg.Platform = img.bootcImg.Platform + ostreeImg.platform = img.bootcImg.platform ostreeImg.PartitionTable = img.bootcImg.PartitionTable ostreeImg.OSTreeDeploymentCustomizations.KernelOptionsAppend = img.bootcImg.OSCustomizations.KernelOptionsAppend ostreeImg.OSTreeDeploymentCustomizations.Users = img.bootcImg.OSCustomizations.Users @@ -57,7 +57,7 @@ func (img *BootcLegacyDiskImage) InstantiateManifestFromContainers(m *manifest.M opts := &baseRawOstreeImageOpts{useBootupd: true} - fileBasename := img.bootcImg.Filename + fileBasename := img.bootcImg.filename // In BIB, we export multiple images from the same pipeline so we use the // filename as the basename for each export and set the extensions based on @@ -66,7 +66,7 @@ func (img *BootcLegacyDiskImage) InstantiateManifestFromContainers(m *manifest.M baseImage.SetFilename(fmt.Sprintf("%s.raw", fileBasename)) qcow2Pipeline := manifest.NewQCOW2(hostPipeline, baseImage) - qcow2Pipeline.Compat = ostreeImg.Platform.GetQCOW2Compat() + qcow2Pipeline.Compat = ostreeImg.platform.GetQCOW2Compat() qcow2Pipeline.SetFilename(fmt.Sprintf("%s.qcow2", fileBasename)) vmdkPipeline := manifest.NewVMDK(hostPipeline, baseImage) diff --git a/pkg/image/bootc_disk_test.go b/pkg/image/bootc_disk_test.go index 41a5b4af78..3c7e497fea 100644 --- a/pkg/image/bootc_disk_test.go +++ b/pkg/image/bootc_disk_test.go @@ -26,7 +26,7 @@ func TestBootcDiskImageNew(t *testing.T) { Name: "name", } - img := image.NewBootcDiskImage(containerSource, containerSource) + img := image.NewBootcDiskImage(testPlatform, "filename", containerSource, containerSource) require.NotNil(t, img) assert.Equal(t, img.Base.Name(), "bootc-raw-image") } @@ -74,10 +74,8 @@ func makeBootcDiskImageOsbuildManifest(t *testing.T, opts *bootcDiskImageTestOpt } containers := []container.SourceSpec{containerSource} - img := image.NewBootcDiskImage(containerSource, containerSource) - img.Filename = "fake-disk" + img := image.NewBootcDiskImage(makeFakePlatform(opts), "fake-disk", containerSource, containerSource) require.NotNil(t, img) - img.Platform = makeFakePlatform(opts) img.PartitionTable = testdisk.MakeFakePartitionTable("/", "/boot", "/boot/efi") img.OSCustomizations.KernelOptionsAppend = opts.KernelOptionsAppend img.OSCustomizations.Users = opts.Users diff --git a/pkg/image/container.go b/pkg/image/container.go index f169d9337d..0959a5c2b7 100644 --- a/pkg/image/container.go +++ b/pkg/image/container.go @@ -13,15 +13,13 @@ import ( type BaseContainer struct { Base - Platform platform.Platform OSCustomizations manifest.OSCustomizations Environment environment.Environment - Filename string } -func NewBaseContainer() *BaseContainer { +func NewBaseContainer(platform platform.Platform, filename string) *BaseContainer { return &BaseContainer{ - Base: NewBase("base-container"), + Base: NewBase("base-container", platform, filename), } } @@ -32,12 +30,12 @@ func (img *BaseContainer) InstantiateManifest(m *manifest.Manifest, buildPipeline := addBuildBootstrapPipelines(m, runner, repos, nil) buildPipeline.Checkpoint() - osPipeline := manifest.NewOS(buildPipeline, img.Platform, repos) + osPipeline := manifest.NewOS(buildPipeline, img.platform, repos) osPipeline.OSCustomizations = img.OSCustomizations osPipeline.Environment = img.Environment ociPipeline := manifest.NewOCIContainer(buildPipeline, osPipeline) - ociPipeline.SetFilename(img.Filename) + ociPipeline.SetFilename(img.filename) artifact := ociPipeline.Export() return artifact, nil diff --git a/pkg/image/disk.go b/pkg/image/disk.go index 6d302b00f7..f402b2927b 100644 --- a/pkg/image/disk.go +++ b/pkg/image/disk.go @@ -18,11 +18,10 @@ import ( type DiskImage struct { Base - Platform platform.Platform + PartitionTable *disk.PartitionTable OSCustomizations manifest.OSCustomizations Environment environment.Environment - Filename string Compression string // Control the VPC subformat use of force_size @@ -35,9 +34,9 @@ type DiskImage struct { OSNick string } -func NewDiskImage() *DiskImage { +func NewDiskImage(platform platform.Platform, filename string) *DiskImage { return &DiskImage{ - Base: NewBase("disk"), + Base: NewBase("disk", platform, filename), PartTool: osbuild.PTSfdisk, } } @@ -50,7 +49,7 @@ func (img *DiskImage) InstantiateManifest(m *manifest.Manifest, buildPipeline := addBuildBootstrapPipelines(m, runner, repos, nil) buildPipeline.Checkpoint() - osPipeline := manifest.NewOS(buildPipeline, img.Platform, repos) + osPipeline := manifest.NewOS(buildPipeline, img.platform, repos) osPipeline.PartitionTable = img.PartitionTable osPipeline.OSCustomizations = img.OSCustomizations osPipeline.Environment = img.Environment @@ -62,16 +61,16 @@ func (img *DiskImage) InstantiateManifest(m *manifest.Manifest, rawImagePipeline.PartTool = img.PartTool var imagePipeline manifest.FilePipeline - switch img.Platform.GetImageFormat() { + switch img.platform.GetImageFormat() { case platform.FORMAT_RAW: imagePipeline = rawImagePipeline case platform.FORMAT_QCOW2: qcow2Pipeline := manifest.NewQCOW2(buildPipeline, rawImagePipeline) - qcow2Pipeline.Compat = img.Platform.GetQCOW2Compat() + qcow2Pipeline.Compat = img.platform.GetQCOW2Compat() imagePipeline = qcow2Pipeline case platform.FORMAT_VAGRANT_LIBVIRT: qcow2Pipeline := manifest.NewQCOW2(buildPipeline, rawImagePipeline) - qcow2Pipeline.Compat = img.Platform.GetQCOW2Compat() + qcow2Pipeline.Compat = img.platform.GetQCOW2Compat() vagrantPipeline := manifest.NewVagrant(buildPipeline, qcow2Pipeline, osbuild.VagrantProviderLibvirt, rng) @@ -87,7 +86,7 @@ func (img *DiskImage) InstantiateManifest(m *manifest.Manifest, tarPipeline := manifest.NewTar(buildPipeline, vagrantPipeline, "archive") tarPipeline.Format = osbuild.TarArchiveFormatUstar - tarPipeline.SetFilename(img.Filename) + tarPipeline.SetFilename(img.filename) imagePipeline = tarPipeline case platform.FORMAT_VHD: @@ -101,8 +100,8 @@ func (img *DiskImage) InstantiateManifest(m *manifest.Manifest, ovfPipeline := manifest.NewOVF(buildPipeline, vmdkPipeline) tarPipeline := manifest.NewTar(buildPipeline, ovfPipeline, "archive") tarPipeline.Format = osbuild.TarArchiveFormatUstar - tarPipeline.SetFilename(img.Filename) - extLess := strings.TrimSuffix(img.Filename, filepath.Ext(img.Filename)) + tarPipeline.SetFilename(img.filename) + extLess := strings.TrimSuffix(img.filename, filepath.Ext(img.filename)) // The .ovf descriptor needs to be the first file in the archive tarPipeline.Paths = []string{ fmt.Sprintf("%s.ovf", extLess), @@ -121,7 +120,7 @@ func (img *DiskImage) InstantiateManifest(m *manifest.Manifest, } compressionPipeline := GetCompressionPipeline(img.Compression, buildPipeline, imagePipeline) - compressionPipeline.SetFilename(img.Filename) + compressionPipeline.SetFilename(img.filename) return compressionPipeline.Export(), nil } diff --git a/pkg/image/image.go b/pkg/image/image.go index 88c6752ec0..eb1f558f32 100644 --- a/pkg/image/image.go +++ b/pkg/image/image.go @@ -6,6 +6,7 @@ import ( "github.com/osbuild/images/pkg/artifact" "github.com/osbuild/images/pkg/manifest" + "github.com/osbuild/images/pkg/platform" "github.com/osbuild/images/pkg/rpmmd" "github.com/osbuild/images/pkg/runner" ) @@ -16,16 +17,20 @@ type ImageKind interface { } type Base struct { - name string + name string + platform platform.Platform + filename string } func (img Base) Name() string { return img.name } -func NewBase(name string) Base { +func NewBase(name string, platform platform.Platform, filename string) Base { return Base{ - name: name, + name: name, + platform: platform, + filename: filename, } } diff --git a/pkg/image/installer_image_test.go b/pkg/image/installer_image_test.go index 787a8a0967..c653016dfe 100644 --- a/pkg/image/installer_image_test.go +++ b/pkg/image/installer_image_test.go @@ -87,26 +87,24 @@ const ( ) func TestContainerInstallerUnsetKSOptions(t *testing.T) { - img := image.NewAnacondaContainerInstaller(container.SourceSpec{}, "") + img := image.NewAnacondaContainerInstaller(testPlatform, "filename", container.SourceSpec{}, "") assert.NotNil(t, img) img.Product = product img.OSVersion = osversion img.ISOLabel = isolabel - img.Platform = testPlatform mfs := instantiateAndSerialize(t, img, mockPackageSets(), mockContainerSpecs(), nil) assert.Contains(t, mfs, fmt.Sprintf(`"inst.ks=hd:LABEL=%s:/osbuild.ks"`, isolabel)) } func TestContainerInstallerUnsetKSPath(t *testing.T) { - img := image.NewAnacondaContainerInstaller(container.SourceSpec{}, "") + img := image.NewAnacondaContainerInstaller(testPlatform, "filename", container.SourceSpec{}, "") assert.NotNil(t, img) img.Product = product img.OSVersion = osversion img.ISOLabel = isolabel - img.Platform = testPlatform // set empty kickstart options (no path) img.Kickstart = &kickstart.Options{} @@ -115,13 +113,12 @@ func TestContainerInstallerUnsetKSPath(t *testing.T) { } func TestContainerInstallerSetKSPath(t *testing.T) { - img := image.NewAnacondaContainerInstaller(container.SourceSpec{}, "") + img := image.NewAnacondaContainerInstaller(testPlatform, "filename", container.SourceSpec{}, "") assert.NotNil(t, img) img.Product = product img.OSVersion = osversion img.ISOLabel = isolabel - img.Platform = testPlatform img.Kickstart = &kickstart.Options{ Path: "/test.ks", } @@ -132,13 +129,12 @@ func TestContainerInstallerSetKSPath(t *testing.T) { } func TestContainerInstallerExt4Rootfs(t *testing.T) { - img := image.NewAnacondaContainerInstaller(container.SourceSpec{}, "") + img := image.NewAnacondaContainerInstaller(testPlatform, "filename", container.SourceSpec{}, "") assert.NotNil(t, img) img.Product = product img.OSVersion = osversion img.ISOLabel = isolabel - img.Platform = testPlatform mfs := instantiateAndSerialize(t, img, mockPackageSets(), mockContainerSpecs(), nil) @@ -148,14 +144,13 @@ func TestContainerInstallerExt4Rootfs(t *testing.T) { } func TestContainerInstallerSquashfsRootfs(t *testing.T) { - img := image.NewAnacondaContainerInstaller(container.SourceSpec{}, "") + img := image.NewAnacondaContainerInstaller(testPlatform, "filename", container.SourceSpec{}, "") assert.NotNil(t, img) img.Product = product img.OSVersion = osversion img.ISOLabel = isolabel img.InstallerCustomizations.ISORootfsType = manifest.SquashfsRootfs - img.Platform = testPlatform mfs := instantiateAndSerialize(t, img, mockPackageSets(), mockContainerSpecs(), nil) @@ -165,13 +160,12 @@ func TestContainerInstallerSquashfsRootfs(t *testing.T) { } func TestOSTreeInstallerUnsetKSPath(t *testing.T) { - img := image.NewAnacondaOSTreeInstaller(ostree.SourceSpec{}) + img := image.NewAnacondaOSTreeInstaller(testPlatform, "filename", ostree.SourceSpec{}) assert.NotNil(t, img) img.Product = product img.OSVersion = osversion img.ISOLabel = isolabel - img.Platform = testPlatform img.Kickstart = &kickstart.Options{ // the ostree options must be non-nil OSTree: &kickstart.OSTree{}, @@ -182,13 +176,12 @@ func TestOSTreeInstallerUnsetKSPath(t *testing.T) { } func TestOSTreeInstallerSetKSPath(t *testing.T) { - img := image.NewAnacondaOSTreeInstaller(ostree.SourceSpec{}) + img := image.NewAnacondaOSTreeInstaller(testPlatform, "filename", ostree.SourceSpec{}) assert.NotNil(t, img) img.Product = product img.OSVersion = osversion img.ISOLabel = isolabel - img.Platform = testPlatform img.Kickstart = &kickstart.Options{ // the ostree options must be non-nil OSTree: &kickstart.OSTree{}, @@ -201,13 +194,12 @@ func TestOSTreeInstallerSetKSPath(t *testing.T) { } func TestOSTreeInstallerExt4Rootfs(t *testing.T) { - img := image.NewAnacondaOSTreeInstaller(ostree.SourceSpec{}) + img := image.NewAnacondaOSTreeInstaller(testPlatform, "filename", ostree.SourceSpec{}) assert.NotNil(t, img) img.Product = product img.OSVersion = osversion img.ISOLabel = isolabel - img.Platform = testPlatform img.Kickstart = &kickstart.Options{ // the ostree options must be non-nil OSTree: &kickstart.OSTree{}, @@ -221,14 +213,13 @@ func TestOSTreeInstallerExt4Rootfs(t *testing.T) { } func TestOSTreeInstallerSquashfsRootfs(t *testing.T) { - img := image.NewAnacondaOSTreeInstaller(ostree.SourceSpec{}) + img := image.NewAnacondaOSTreeInstaller(testPlatform, "filename", ostree.SourceSpec{}) assert.NotNil(t, img) img.Product = product img.OSVersion = osversion img.ISOLabel = isolabel img.InstallerCustomizations.ISORootfsType = manifest.SquashfsRootfs - img.Platform = testPlatform img.Kickstart = &kickstart.Options{ // the ostree options must be non-nil OSTree: &kickstart.OSTree{}, @@ -242,13 +233,12 @@ func TestOSTreeInstallerSquashfsRootfs(t *testing.T) { } func TestTarInstallerUnsetKSOptions(t *testing.T) { - img := image.NewAnacondaTarInstaller() + img := image.NewAnacondaTarInstaller(testPlatform, "filename") assert.NotNil(t, img) img.Product = product img.OSVersion = osversion img.ISOLabel = isolabel - img.Platform = testPlatform mfs := instantiateAndSerialize(t, img, mockPackageSets(), nil, nil) @@ -257,13 +247,12 @@ func TestTarInstallerUnsetKSOptions(t *testing.T) { } func TestTarInstallerUnsetKSPath(t *testing.T) { - img := image.NewAnacondaTarInstaller() + img := image.NewAnacondaTarInstaller(testPlatform, "filename") assert.NotNil(t, img) img.Product = product img.OSVersion = osversion img.ISOLabel = isolabel - img.Platform = testPlatform img.Kickstart = &kickstart.Options{} mfs := instantiateAndSerialize(t, img, mockPackageSets(), nil, nil) @@ -273,13 +262,12 @@ func TestTarInstallerUnsetKSPath(t *testing.T) { } func TestTarInstallerSetKSPath(t *testing.T) { - img := image.NewAnacondaTarInstaller() + img := image.NewAnacondaTarInstaller(testPlatform, "filename") assert.NotNil(t, img) img.Product = product img.OSVersion = osversion img.ISOLabel = isolabel - img.Platform = testPlatform img.Kickstart = &kickstart.Options{ Path: "/test.ks", } @@ -292,13 +280,12 @@ func TestTarInstallerSetKSPath(t *testing.T) { } func TestTarInstallerExt4Rootfs(t *testing.T) { - img := image.NewAnacondaTarInstaller() + img := image.NewAnacondaTarInstaller(testPlatform, "filename") assert.NotNil(t, img) img.Product = product img.OSVersion = osversion img.ISOLabel = isolabel - img.Platform = testPlatform mfs := instantiateAndSerialize(t, img, mockPackageSets(), nil, nil) // Confirm that it includes the rootfs-image pipeline that makes the ext4 rootfs @@ -307,14 +294,13 @@ func TestTarInstallerExt4Rootfs(t *testing.T) { } func TestTarInstallerSquashfsRootfs(t *testing.T) { - img := image.NewAnacondaTarInstaller() + img := image.NewAnacondaTarInstaller(testPlatform, "filename") assert.NotNil(t, img) img.Product = product img.OSVersion = osversion img.ISOLabel = isolabel img.InstallerCustomizations.ISORootfsType = manifest.SquashfsRootfs - img.Platform = testPlatform mfs := instantiateAndSerialize(t, img, mockPackageSets(), nil, nil) // Confirm that it does not include rootfs-image pipeline @@ -323,13 +309,12 @@ func TestTarInstallerSquashfsRootfs(t *testing.T) { } func TestLiveInstallerExt4Rootfs(t *testing.T) { - img := image.NewAnacondaLiveInstaller() + img := image.NewAnacondaLiveInstaller(testPlatform, "filename") assert.NotNil(t, img) img.Product = product img.OSVersion = osversion img.ISOLabel = isolabel - img.Platform = testPlatform mfs := instantiateAndSerialize(t, img, mockPackageSets(), nil, nil) // Confirm that it includes the rootfs-image pipeline that makes the ext4 rootfs @@ -338,14 +323,13 @@ func TestLiveInstallerExt4Rootfs(t *testing.T) { } func TestLiveInstallerSquashfsRootfs(t *testing.T) { - img := image.NewAnacondaLiveInstaller() + img := image.NewAnacondaLiveInstaller(testPlatform, "filename") assert.NotNil(t, img) img.Product = product img.OSVersion = osversion img.ISOLabel = isolabel img.InstallerCustomizations.ISORootfsType = manifest.SquashfsRootfs - img.Platform = testPlatform mfs := instantiateAndSerialize(t, img, mockPackageSets(), nil, nil) // Confirm that it does not include rootfs-image pipeline @@ -379,8 +363,7 @@ func instantiateAndSerialize(t *testing.T, img image.ImageKind, depsolved map[st func TestContainerInstallerPanics(t *testing.T) { assert := assert.New(t) - img := image.NewAnacondaContainerInstaller(container.SourceSpec{}, "") - img.Platform = testPlatform + img := image.NewAnacondaContainerInstaller(testPlatform, "filename", container.SourceSpec{}, "") assert.PanicsWithError("org.osbuild.grub2.iso: product.name option is required", func() { instantiateAndSerialize(t, img, mockPackageSets(), mockContainerSpecs(), nil) }) img.Product = product assert.PanicsWithError("org.osbuild.grub2.iso: product.version option is required", func() { instantiateAndSerialize(t, img, mockPackageSets(), mockContainerSpecs(), nil) }) @@ -390,8 +373,7 @@ func TestContainerInstallerPanics(t *testing.T) { func TestOSTreeInstallerPanics(t *testing.T) { assert := assert.New(t) - img := image.NewAnacondaOSTreeInstaller(ostree.SourceSpec{}) - img.Platform = testPlatform + img := image.NewAnacondaOSTreeInstaller(testPlatform, "filename", ostree.SourceSpec{}) img.Kickstart = &kickstart.Options{ // the ostree options must be non-nil OSTree: &kickstart.OSTree{}, @@ -411,8 +393,7 @@ func TestOSTreeInstallerPanics(t *testing.T) { func TestTarInstallerPanics(t *testing.T) { assert := assert.New(t) - img := image.NewAnacondaTarInstaller() - img.Platform = testPlatform + img := image.NewAnacondaTarInstaller(testPlatform, "filename") assert.PanicsWithError("org.osbuild.grub2.iso: product.name option is required", func() { instantiateAndSerialize(t, img, mockPackageSets(), nil, nil) }) @@ -493,7 +474,7 @@ func TestContainerInstallerModules(t *testing.T) { // Remove this when we drop support for RHEL 8. for _, legacy := range []bool{true, false} { t.Run(name, func(t *testing.T) { - img := image.NewAnacondaContainerInstaller(container.SourceSpec{}, "") + img := image.NewAnacondaContainerInstaller(testPlatform, "filename", container.SourceSpec{}, "") img.Product = product img.OSVersion = osversion img.ISOLabel = isolabel @@ -503,7 +484,6 @@ func TestContainerInstallerModules(t *testing.T) { img.InstallerCustomizations.DisabledAnacondaModules = tc.disable assert.NotNil(t, img) - img.Platform = testPlatform mfs := instantiateAndSerialize(t, img, mockPackageSets(), mockContainerSpecs(), nil) modules := findAnacondaStageModules(t, manifest.OSBuildManifest(mfs), legacy) assert.NotNil(t, modules) @@ -520,7 +500,7 @@ func TestOSTreeInstallerModules(t *testing.T) { // Remove this when we drop support for RHEL 8. for _, legacy := range []bool{true, false} { t.Run(name, func(t *testing.T) { - img := image.NewAnacondaOSTreeInstaller(ostree.SourceSpec{}) + img := image.NewAnacondaOSTreeInstaller(testPlatform, "filename", ostree.SourceSpec{}) img.Product = product img.OSVersion = osversion img.ISOLabel = isolabel @@ -534,7 +514,6 @@ func TestOSTreeInstallerModules(t *testing.T) { img.InstallerCustomizations.DisabledAnacondaModules = tc.disable assert.NotNil(t, img) - img.Platform = testPlatform mfs := instantiateAndSerialize(t, img, mockPackageSets(), nil, mockOSTreeCommitSpecs()) modules := findAnacondaStageModules(t, manifest.OSBuildManifest(mfs), legacy) assert.NotNil(t, modules) @@ -551,7 +530,7 @@ func TestTarInstallerModules(t *testing.T) { // Remove this when we drop support for RHEL 8. for _, legacy := range []bool{true, false} { t.Run(name, func(t *testing.T) { - img := image.NewAnacondaTarInstaller() + img := image.NewAnacondaTarInstaller(testPlatform, "filename") img.Product = product img.OSVersion = osversion img.ISOLabel = isolabel @@ -561,7 +540,6 @@ func TestTarInstallerModules(t *testing.T) { img.InstallerCustomizations.DisabledAnacondaModules = tc.disable assert.NotNil(t, img) - img.Platform = testPlatform mfs := instantiateAndSerialize(t, img, mockPackageSets(), nil, nil) modules := findAnacondaStageModules(t, manifest.OSBuildManifest(mfs), legacy) assert.NotNil(t, modules) @@ -593,13 +571,12 @@ func TestInstallerLocales(t *testing.T) { for input, expected := range locales { { // Container - img := image.NewAnacondaContainerInstaller(container.SourceSpec{}, "") + img := image.NewAnacondaContainerInstaller(testPlatform, "filename", container.SourceSpec{}, "") assert.NotNil(t, img) img.Product = product img.OSVersion = osversion img.ISOLabel = isolabel - img.Platform = testPlatform img.Locale = input mfs := instantiateAndSerialize(t, img, mockPackageSets(), mockContainerSpecs(), nil) @@ -609,13 +586,12 @@ func TestInstallerLocales(t *testing.T) { } { // OSTree - img := image.NewAnacondaOSTreeInstaller(ostree.SourceSpec{}) + img := image.NewAnacondaOSTreeInstaller(testPlatform, "filename", ostree.SourceSpec{}) assert.NotNil(t, img) img.Product = product img.OSVersion = osversion img.ISOLabel = isolabel - img.Platform = testPlatform img.Kickstart = &kickstart.Options{ // the ostree options must be non-nil OSTree: &kickstart.OSTree{}, @@ -629,13 +605,12 @@ func TestInstallerLocales(t *testing.T) { } { // Tar - img := image.NewAnacondaTarInstaller() + img := image.NewAnacondaTarInstaller(testPlatform, "filename") assert.NotNil(t, img) img.Product = product img.OSVersion = osversion img.ISOLabel = isolabel - img.Platform = testPlatform img.OSCustomizations.Language = input mfs := instantiateAndSerialize(t, img, mockPackageSets(), nil, nil) @@ -645,13 +620,12 @@ func TestInstallerLocales(t *testing.T) { } { // Net - img := image.NewAnacondaNetInstaller() + img := image.NewAnacondaNetInstaller(testPlatform, "filename") assert.NotNil(t, img) img.Product = product img.OSVersion = osversion img.ISOLabel = isolabel - img.Platform = testPlatform img.Language = input mfs := instantiateAndSerialize(t, img, mockPackageSets(), nil, nil) @@ -661,13 +635,12 @@ func TestInstallerLocales(t *testing.T) { } { // Live - img := image.NewAnacondaLiveInstaller() + img := image.NewAnacondaLiveInstaller(testPlatform, "filename") assert.NotNil(t, img) img.Product = product img.OSVersion = osversion img.ISOLabel = isolabel - img.Platform = testPlatform img.Locale = input mfs := instantiateAndSerialize(t, img, mockPackageSets(), nil, nil) @@ -729,7 +702,7 @@ func findGrub2IsoStageOptions(t *testing.T, mf manifest.OSBuildManifest, pipelin } func TestContainerInstallerDracut(t *testing.T) { - img := image.NewAnacondaContainerInstaller(container.SourceSpec{}, "") + img := image.NewAnacondaContainerInstaller(testPlatform, "filename", container.SourceSpec{}, "") img.Product = product img.OSVersion = osversion img.ISOLabel = isolabel @@ -741,7 +714,6 @@ func TestContainerInstallerDracut(t *testing.T) { img.InstallerCustomizations.AdditionalDrivers = testDrivers assert.NotNil(t, img) - img.Platform = testPlatform mfs := instantiateAndSerialize(t, img, mockPackageSets(), mockContainerSpecs(), nil) modules, addModules, drivers, addDrivers := findDracutStageOptions(t, manifest.OSBuildManifest(mfs), "anaconda-tree") assert.Nil(t, modules) @@ -754,7 +726,7 @@ func TestContainerInstallerDracut(t *testing.T) { } func TestOSTreeInstallerDracut(t *testing.T) { - img := image.NewAnacondaOSTreeInstaller(ostree.SourceSpec{}) + img := image.NewAnacondaOSTreeInstaller(testPlatform, "filename", ostree.SourceSpec{}) img.Product = product img.OSVersion = osversion img.ISOLabel = isolabel @@ -770,7 +742,6 @@ func TestOSTreeInstallerDracut(t *testing.T) { img.InstallerCustomizations.AdditionalDrivers = testDrivers assert.NotNil(t, img) - img.Platform = testPlatform mfs := instantiateAndSerialize(t, img, mockPackageSets(), nil, mockOSTreeCommitSpecs()) modules, addModules, drivers, addDrivers := findDracutStageOptions(t, manifest.OSBuildManifest(mfs), "anaconda-tree") assert.Nil(t, modules) @@ -783,7 +754,7 @@ func TestOSTreeInstallerDracut(t *testing.T) { } func TestTarInstallerDracut(t *testing.T) { - img := image.NewAnacondaTarInstaller() + img := image.NewAnacondaTarInstaller(testPlatform, "filename") img.Product = product img.OSVersion = osversion img.ISOLabel = isolabel @@ -795,7 +766,6 @@ func TestTarInstallerDracut(t *testing.T) { img.InstallerCustomizations.AdditionalDrivers = testDrivers assert.NotNil(t, img) - img.Platform = testPlatform mfs := instantiateAndSerialize(t, img, mockPackageSets(), nil, nil) modules, addModules, drivers, addDrivers := findDracutStageOptions(t, manifest.OSBuildManifest(mfs), "anaconda-tree") assert.Nil(t, modules) @@ -808,7 +778,7 @@ func TestTarInstallerDracut(t *testing.T) { } func TestTarInstallerKernelOpts(t *testing.T) { - img := image.NewAnacondaTarInstaller() + img := image.NewAnacondaTarInstaller(testPlatform, "filename") img.Product = product img.OSVersion = osversion img.ISOLabel = isolabel @@ -818,7 +788,6 @@ func TestTarInstallerKernelOpts(t *testing.T) { img.InstallerCustomizations.AdditionalKernelOpts = testOpts assert.NotNil(t, img) - img.Platform = testPlatform mfs := instantiateAndSerialize(t, img, mockPackageSets(), nil, nil) opts := findGrub2IsoStageOptions(t, manifest.OSBuildManifest(mfs), "efiboot-tree") @@ -828,13 +797,12 @@ func TestTarInstallerKernelOpts(t *testing.T) { } func TestNetInstallerExt4Rootfs(t *testing.T) { - img := image.NewAnacondaNetInstaller() + img := image.NewAnacondaNetInstaller(testPlatform, "filename") assert.NotNil(t, img) img.Product = product img.OSVersion = osversion img.ISOLabel = isolabel - img.Platform = testPlatform mfs := instantiateAndSerialize(t, img, mockPackageSets(), nil, nil) // Confirm that it includes the rootfs-image pipeline that makes the ext4 rootfs @@ -843,14 +811,13 @@ func TestNetInstallerExt4Rootfs(t *testing.T) { } func TestNetInstallerSquashfsRootfs(t *testing.T) { - img := image.NewAnacondaNetInstaller() + img := image.NewAnacondaNetInstaller(testPlatform, "filename") assert.NotNil(t, img) img.Product = product img.OSVersion = osversion img.ISOLabel = isolabel img.InstallerCustomizations.ISORootfsType = manifest.SquashfsRootfs - img.Platform = testPlatform mfs := instantiateAndSerialize(t, img, mockPackageSets(), nil, nil) // Confirm that it does not include rootfs-image pipeline @@ -859,7 +826,7 @@ func TestNetInstallerSquashfsRootfs(t *testing.T) { } func TestNetInstallerDracut(t *testing.T) { - img := image.NewAnacondaNetInstaller() + img := image.NewAnacondaNetInstaller(testPlatform, "filename") img.Product = product img.OSVersion = osversion img.ISOLabel = isolabel @@ -870,7 +837,6 @@ func TestNetInstallerDracut(t *testing.T) { img.InstallerCustomizations.AdditionalDrivers = testDrivers assert.NotNil(t, img) - img.Platform = testPlatform mfs := instantiateAndSerialize(t, img, mockPackageSets(), nil, nil) modules, addModules, drivers, addDrivers := findDracutStageOptions(t, manifest.OSBuildManifest(mfs), "anaconda-tree") assert.Nil(t, modules) diff --git a/pkg/image/ostree_archive.go b/pkg/image/ostree_archive.go index 154a8bf83b..4ef37fc684 100644 --- a/pkg/image/ostree_archive.go +++ b/pkg/image/ostree_archive.go @@ -15,7 +15,6 @@ import ( type OSTreeArchive struct { Base - Platform platform.Platform OSCustomizations manifest.OSCustomizations Environment environment.Environment @@ -27,7 +26,6 @@ type OSTreeArchive struct { OSTreeRef string OSVersion string - Filename string InstallWeakDeps bool @@ -39,9 +37,9 @@ type OSTreeArchive struct { BootcConfig *bootc.Config } -func NewOSTreeArchive(ref string) *OSTreeArchive { +func NewOSTreeArchive(platform platform.Platform, filename string, ref string) *OSTreeArchive { return &OSTreeArchive{ - Base: NewBase("ostree-archive"), + Base: NewBase("ostree-archive", platform, filename), OSTreeRef: ref, InstallWeakDeps: true, } @@ -54,7 +52,7 @@ func (img *OSTreeArchive) InstantiateManifest(m *manifest.Manifest, buildPipeline := addBuildBootstrapPipelines(m, runner, repos, nil) buildPipeline.Checkpoint() - osPipeline := manifest.NewOS(buildPipeline, img.Platform, repos) + osPipeline := manifest.NewOS(buildPipeline, img.platform, repos) osPipeline.OSCustomizations = img.OSCustomizations osPipeline.Environment = img.Environment osPipeline.OSTreeParent = img.OSTreeParent @@ -69,11 +67,11 @@ func (img *OSTreeArchive) InstantiateManifest(m *manifest.Manifest, osPipeline.Bootupd = true osPipeline.BootcConfig = img.BootcConfig encapsulatePipeline := manifest.NewOSTreeEncapsulate(buildPipeline, ostreeCommitPipeline, "ostree-encapsulate") - encapsulatePipeline.SetFilename(img.Filename) + encapsulatePipeline.SetFilename(img.filename) artifact = encapsulatePipeline.Export() } else { tarPipeline := manifest.NewTar(buildPipeline, ostreeCommitPipeline, "commit-archive") - tarPipeline.SetFilename(img.Filename) + tarPipeline.SetFilename(img.filename) artifact = tarPipeline.Export() } diff --git a/pkg/image/ostree_container.go b/pkg/image/ostree_container.go index 9cfc307167..6bedf12a11 100644 --- a/pkg/image/ostree_container.go +++ b/pkg/image/ostree_container.go @@ -14,7 +14,6 @@ import ( type OSTreeContainer struct { Base - Platform platform.Platform OSCustomizations manifest.OSCustomizations Environment environment.Environment @@ -28,12 +27,12 @@ type OSTreeContainer struct { OSVersion string ExtraContainerPackages rpmmd.PackageSet // FIXME: this is never read ContainerLanguage string - Filename string } -func NewOSTreeContainer(ref string) *OSTreeContainer { +func NewOSTreeContainer(platform platform.Platform, filename string, ref string) *OSTreeContainer { return &OSTreeContainer{ - Base: NewBase("ostree-container"), + Base: NewBase("ostree-container", platform, filename), + OSTreeRef: ref, } } @@ -45,7 +44,7 @@ func (img *OSTreeContainer) InstantiateManifest(m *manifest.Manifest, buildPipeline := addBuildBootstrapPipelines(m, runner, repos, nil) buildPipeline.Checkpoint() - osPipeline := manifest.NewOS(buildPipeline, img.Platform, repos) + osPipeline := manifest.NewOS(buildPipeline, img.platform, repos) osPipeline.OSCustomizations = img.OSCustomizations osPipeline.Environment = img.Environment osPipeline.OSTreeRef = img.OSTreeRef @@ -59,7 +58,7 @@ func (img *OSTreeContainer) InstantiateManifest(m *manifest.Manifest, serverPipeline := manifest.NewOSTreeCommitServer( buildPipeline, - img.Platform, + img.platform, repos, commitPipeline, nginxConfigPath, @@ -70,7 +69,7 @@ func (img *OSTreeContainer) InstantiateManifest(m *manifest.Manifest, containerPipeline := manifest.NewOCIContainer(buildPipeline, serverPipeline) containerPipeline.Cmd = []string{"nginx", "-c", nginxConfigPath} containerPipeline.ExposedPorts = []string{listenPort} - containerPipeline.SetFilename(img.Filename) + containerPipeline.SetFilename(img.filename) artifact := containerPipeline.Export() return artifact, nil diff --git a/pkg/image/ostree_disk.go b/pkg/image/ostree_disk.go index f60e264467..b1d00147e6 100644 --- a/pkg/image/ostree_disk.go +++ b/pkg/image/ostree_disk.go @@ -16,8 +16,6 @@ import ( type OSTreeDiskImage struct { Base - - Platform platform.Platform OSCustomizations manifest.OSCustomizations PartitionTable *disk.PartitionTable @@ -30,8 +28,6 @@ type OSTreeDiskImage struct { OSName string Ref string - Filename string - Compression string // Container buildable tweaks the buildroot to be container friendly, @@ -39,16 +35,16 @@ type OSTreeDiskImage struct { ContainerBuildable bool } -func NewOSTreeDiskImageFromCommit(commit ostree.SourceSpec) *OSTreeDiskImage { +func NewOSTreeDiskImageFromCommit(platform platform.Platform, filename string, commit ostree.SourceSpec) *OSTreeDiskImage { return &OSTreeDiskImage{ - Base: NewBase("ostree-raw-image"), + Base: NewBase("ostree-raw-image", platform, filename), CommitSource: &commit, } } -func NewOSTreeDiskImageFromContainer(container container.SourceSpec, ref string) *OSTreeDiskImage { +func NewOSTreeDiskImageFromContainer(platform platform.Platform, filename string, container container.SourceSpec, ref string) *OSTreeDiskImage { return &OSTreeDiskImage{ - Base: NewBase("ostree-raw-image"), + Base: NewBase("ostree-raw-image", platform, filename), ContainerSource: &container, Ref: ref, } @@ -66,9 +62,9 @@ func baseRawOstreeImage(img *OSTreeDiskImage, buildPipeline manifest.Build, opts var osPipeline *manifest.OSTreeDeployment switch { case img.CommitSource != nil: - osPipeline = manifest.NewOSTreeCommitDeployment(buildPipeline, img.CommitSource, img.OSName, img.Platform) + osPipeline = manifest.NewOSTreeCommitDeployment(buildPipeline, img.CommitSource, img.OSName, img.platform) case img.ContainerSource != nil: - osPipeline = manifest.NewOSTreeContainerDeployment(buildPipeline, img.ContainerSource, img.Ref, img.OSName, img.Platform) + osPipeline = manifest.NewOSTreeContainerDeployment(buildPipeline, img.ContainerSource, img.Ref, img.OSName, img.platform) default: panic("no content source defined for ostree image") } @@ -82,7 +78,7 @@ func baseRawOstreeImage(img *OSTreeDiskImage, buildPipeline manifest.Build, opts osPipeline.EnabledServices = img.OSCustomizations.EnabledServices osPipeline.DisabledServices = img.OSCustomizations.DisabledServices - return manifest.NewRawOStreeImage(buildPipeline, osPipeline, img.Platform) + return manifest.NewRawOStreeImage(buildPipeline, osPipeline, img.platform) } // replaced in testing @@ -96,7 +92,7 @@ func (img *OSTreeDiskImage) InstantiateManifest(m *manifest.Manifest, buildPipeline.Checkpoint() // don't support compressing non-raw images - imgFormat := img.Platform.GetImageFormat() + imgFormat := img.platform.GetImageFormat() if imgFormat == platform.FORMAT_UNSET { // treat unset as raw for this check imgFormat = platform.FORMAT_RAW @@ -106,19 +102,19 @@ func (img *OSTreeDiskImage) InstantiateManifest(m *manifest.Manifest, } baseImage := baseRawOstreeImage(img, buildPipeline, nil) - switch img.Platform.GetImageFormat() { + switch img.platform.GetImageFormat() { case platform.FORMAT_VMDK: vmdkPipeline := manifest.NewVMDK(buildPipeline, baseImage) - vmdkPipeline.SetFilename(img.Filename) + vmdkPipeline.SetFilename(img.filename) return vmdkPipeline.Export(), nil case platform.FORMAT_QCOW2: qcow2Pipeline := manifest.NewQCOW2(buildPipeline, baseImage) - qcow2Pipeline.Compat = img.Platform.GetQCOW2Compat() - qcow2Pipeline.SetFilename(img.Filename) + qcow2Pipeline.Compat = img.platform.GetQCOW2Compat() + qcow2Pipeline.SetFilename(img.filename) return qcow2Pipeline.Export(), nil default: compressionPipeline := GetCompressionPipeline(img.Compression, buildPipeline, baseImage) - compressionPipeline.SetFilename(img.Filename) + compressionPipeline.SetFilename(img.filename) return compressionPipeline.Export(), nil } diff --git a/pkg/image/ostree_disk_test.go b/pkg/image/ostree_disk_test.go index 188e308dba..799cbe9cbf 100644 --- a/pkg/image/ostree_disk_test.go +++ b/pkg/image/ostree_disk_test.go @@ -6,11 +6,9 @@ import ( "github.com/stretchr/testify/require" - "github.com/osbuild/images/pkg/arch" "github.com/osbuild/images/pkg/container" "github.com/osbuild/images/pkg/image" "github.com/osbuild/images/pkg/manifest" - "github.com/osbuild/images/pkg/platform" "github.com/osbuild/images/pkg/rpmmd" "github.com/osbuild/images/pkg/runner" ) @@ -38,15 +36,8 @@ func TestOSTreeDiskImageManifestSetsContainerBuildable(t *testing.T) { buildOpts = nil mf := manifest.New() - img := image.NewOSTreeDiskImageFromContainer(containerSource, ref) + img := image.NewOSTreeDiskImageFromContainer(testPlatform, "filename", containerSource, ref) require.NotNil(t, img) - img.Platform = &platform.Data{ - ImageFormat: platform.FORMAT_QCOW2, - - Arch: arch.ARCH_X86_64, - BIOSPlatform: "i386-pc", - UEFIVendor: "fedora", - } img.OSName = "osname" img.ContainerBuildable = containerBuildable diff --git a/pkg/image/ostree_simplified_installer.go b/pkg/image/ostree_simplified_installer.go index 66886459f3..03599f4d49 100644 --- a/pkg/image/ostree_simplified_installer.go +++ b/pkg/image/ostree_simplified_installer.go @@ -21,7 +21,6 @@ type OSTreeSimplifiedInstaller struct { // Raw image that will be created and embedded rawImage *OSTreeDiskImage - Platform platform.Platform OSCustomizations manifest.OSCustomizations Environment environment.Environment @@ -46,8 +45,6 @@ type OSTreeSimplifiedInstaller struct { installDevice string - Filename string - FDO *fdo.Options // Ignition firstboot configuration options @@ -60,9 +57,9 @@ type OSTreeSimplifiedInstaller struct { AdditionalDrivers []string } -func NewOSTreeSimplifiedInstaller(rawImage *OSTreeDiskImage, installDevice string) *OSTreeSimplifiedInstaller { +func NewOSTreeSimplifiedInstaller(platform platform.Platform, filename string, rawImage *OSTreeDiskImage, installDevice string) *OSTreeSimplifiedInstaller { return &OSTreeSimplifiedInstaller{ - Base: NewBase("ostree-simplified-installer"), + Base: NewBase("ostree-simplified-installer", platform, filename), rawImage: rawImage, installDevice: installDevice, } @@ -83,7 +80,7 @@ func (img *OSTreeSimplifiedInstaller) InstantiateManifest(m *manifest.Manifest, coiPipeline := manifest.NewCoreOSInstaller( buildPipeline, - img.Platform, + img.platform, repos, "kernel", img.Product, @@ -94,7 +91,7 @@ func (img *OSTreeSimplifiedInstaller) InstantiateManifest(m *manifest.Manifest, coiPipeline.ExtraRepos = img.ExtraBasePackages.Repositories coiPipeline.FDO = img.FDO coiPipeline.Ignition = img.IgnitionEmbedded - coiPipeline.Biosdevname = (img.Platform.GetArch() == arch.ARCH_X86_64) + coiPipeline.Biosdevname = (img.platform.GetArch() == arch.ARCH_X86_64) coiPipeline.Variant = img.Variant coiPipeline.AdditionalDracutModules = img.AdditionalDracutModules coiPipeline.AdditionalDrivers = img.AdditionalDrivers @@ -105,12 +102,12 @@ func (img *OSTreeSimplifiedInstaller) InstantiateManifest(m *manifest.Manifest, isoLabel = img.ISOLabel } else { // TODO: replace isoLabelTmpl with more high-level properties - isoLabel = fmt.Sprintf(img.ISOLabelTmpl, img.Platform.GetArch()) + isoLabel = fmt.Sprintf(img.ISOLabelTmpl, img.platform.GetArch()) } bootTreePipeline := manifest.NewEFIBootTree(buildPipeline, img.Product, img.OSVersion) - bootTreePipeline.Platform = img.Platform - bootTreePipeline.UEFIVendor = img.Platform.GetUEFIVendor() + bootTreePipeline.Platform = img.platform + bootTreePipeline.UEFIVendor = img.platform.GetUEFIVendor() bootTreePipeline.ISOLabel = isoLabel // kernel options for EFI boot tree grub stage @@ -143,7 +140,7 @@ func (img *OSTreeSimplifiedInstaller) InstantiateManifest(m *manifest.Manifest, bootTreePipeline.KernelOpts = kernelOpts // enable ISOLinux on x86_64 only - isoLinuxEnabled := img.Platform.GetArch() == arch.ARCH_X86_64 + isoLinuxEnabled := img.platform.GetArch() == arch.ARCH_X86_64 isoTreePipeline := manifest.NewCoreOSISOTree(buildPipeline, compressedImage, coiPipeline, bootTreePipeline) isoTreePipeline.KernelOpts = kernelOpts @@ -153,7 +150,7 @@ func (img *OSTreeSimplifiedInstaller) InstantiateManifest(m *manifest.Manifest, isoTreePipeline.ISOLinux = isoLinuxEnabled isoPipeline := manifest.NewISO(buildPipeline, isoTreePipeline, isoLabel) - isoPipeline.SetFilename(img.Filename) + isoPipeline.SetFilename(img.filename) if isoLinuxEnabled { isoPipeline.ISOBoot = manifest.SyslinuxISOBoot } diff --git a/pkg/image/ostree_simplified_installer_test.go b/pkg/image/ostree_simplified_installer_test.go index 3ce02346de..312f6b566b 100644 --- a/pkg/image/ostree_simplified_installer_test.go +++ b/pkg/image/ostree_simplified_installer_test.go @@ -3,21 +3,22 @@ package image_test import ( "testing" + "github.com/stretchr/testify/assert" + "github.com/osbuild/images/internal/testdisk" "github.com/osbuild/images/pkg/arch" "github.com/osbuild/images/pkg/image" "github.com/osbuild/images/pkg/manifest" "github.com/osbuild/images/pkg/ostree" "github.com/osbuild/images/pkg/platform" - "github.com/stretchr/testify/assert" ) func TestSimplifiedInstallerDracut(t *testing.T) { commit := ostree.SourceSpec{} - ostreeDiskImage := image.NewOSTreeDiskImageFromCommit(commit) + platform := &platform.Data{Arch: arch.ARCH_X86_64} + ostreeDiskImage := image.NewOSTreeDiskImageFromCommit(platform, "filename", commit) ostreeDiskImage.PartitionTable = testdisk.MakeFakePartitionTable("/") - ostreeDiskImage.Platform = &platform.Data{Arch: arch.ARCH_X86_64} - img := image.NewOSTreeSimplifiedInstaller(ostreeDiskImage, "") + img := image.NewOSTreeSimplifiedInstaller(testPlatform, "filename", ostreeDiskImage, "") img.Product = product img.OSVersion = osversion img.ISOLabel = isolabel @@ -41,7 +42,6 @@ func TestSimplifiedInstallerDracut(t *testing.T) { packageSets["coi-tree"] = packageSets["os"] assert.NotNil(t, img) - img.Platform = testPlatform mfs := instantiateAndSerialize(t, img, packageSets, nil, commitSpec) modules, addModules, drivers, addDrivers := findDracutStageOptions(t, manifest.OSBuildManifest(mfs), "coi-tree") assert.NotNil(t, modules)