distro: use storage unit constants from the common package
Don't redefine the storage unit multiples in each distro, but use the constants defined in the `common` package. This will make it easier to split related image type definitions into separate files.
This commit is contained in:
parent
ff28b0f5d3
commit
4b25fa73bc
5 changed files with 41 additions and 52 deletions
|
|
@ -24,7 +24,6 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
GigaByte = 1024 * 1024 * 1024
|
||||
// package set names
|
||||
|
||||
// main/common os image package set name
|
||||
|
|
@ -140,7 +139,7 @@ var (
|
|||
defaultImageConfig: &distro.ImageConfig{
|
||||
Locale: common.StringToPtr("en_US.UTF-8"),
|
||||
},
|
||||
defaultSize: 10 * GigaByte,
|
||||
defaultSize: 10 * common.GibiByte,
|
||||
rpmOstree: true,
|
||||
bootable: true,
|
||||
image: iotRawImage,
|
||||
|
|
@ -168,7 +167,7 @@ var (
|
|||
},
|
||||
kernelOptions: defaultKernelOptions,
|
||||
bootable: true,
|
||||
defaultSize: 2 * GigaByte,
|
||||
defaultSize: 2 * common.GibiByte,
|
||||
image: liveImage,
|
||||
buildPipelines: []string{"build"},
|
||||
payloadPipelines: []string{"os", "image", "qcow2"},
|
||||
|
|
@ -196,7 +195,7 @@ var (
|
|||
},
|
||||
kernelOptions: defaultKernelOptions,
|
||||
bootable: true,
|
||||
defaultSize: 2 * GigaByte,
|
||||
defaultSize: 2 * common.GibiByte,
|
||||
image: liveImage,
|
||||
buildPipelines: []string{"build"},
|
||||
payloadPipelines: []string{"os", "image", "vpc"},
|
||||
|
|
@ -223,7 +222,7 @@ var (
|
|||
},
|
||||
kernelOptions: defaultKernelOptions,
|
||||
bootable: true,
|
||||
defaultSize: 2 * GigaByte,
|
||||
defaultSize: 2 * common.GibiByte,
|
||||
image: liveImage,
|
||||
buildPipelines: []string{"build"},
|
||||
payloadPipelines: []string{"os", "image", "vmdk"},
|
||||
|
|
@ -249,7 +248,7 @@ var (
|
|||
},
|
||||
kernelOptions: defaultKernelOptions,
|
||||
bootable: true,
|
||||
defaultSize: 2 * GigaByte,
|
||||
defaultSize: 2 * common.GibiByte,
|
||||
image: liveImage,
|
||||
buildPipelines: []string{"build"},
|
||||
payloadPipelines: []string{"os", "image", "qcow2"},
|
||||
|
|
@ -272,7 +271,7 @@ var (
|
|||
defaultImageConfig: defaultEc2ImageConfig,
|
||||
kernelOptions: defaultKernelOptions,
|
||||
bootable: true,
|
||||
defaultSize: 6 * GigaByte,
|
||||
defaultSize: 6 * common.GibiByte,
|
||||
image: liveImage,
|
||||
buildPipelines: []string{"build"},
|
||||
payloadPipelines: []string{"os", "image"},
|
||||
|
|
@ -501,10 +500,9 @@ func (t *imageType) OSTreeRef() string {
|
|||
}
|
||||
|
||||
func (t *imageType) Size(size uint64) uint64 {
|
||||
const MegaByte = 1024 * 1024
|
||||
// Microsoft Azure requires vhd images to be rounded up to the nearest MB
|
||||
if t.name == "vhd" && size%MegaByte != 0 {
|
||||
size = (size/MegaByte + 1) * MegaByte
|
||||
if t.name == "vhd" && size%common.MebiByte != 0 {
|
||||
size = (size/common.MebiByte + 1) * common.MebiByte
|
||||
}
|
||||
if size == 0 {
|
||||
size = t.defaultSize
|
||||
|
|
|
|||
|
|
@ -5,9 +5,6 @@ import (
|
|||
"github.com/osbuild/osbuild-composer/internal/distro"
|
||||
)
|
||||
|
||||
// shared constants
|
||||
const GigaByte = 1024 * 1024 * 1024
|
||||
|
||||
// ////////// Partition table //////////
|
||||
|
||||
var defaultBasePartitionTables = distro.BasePartitionTableMap{
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ var qcow2ImgType = imageType{
|
|||
},
|
||||
},
|
||||
bootable: true,
|
||||
defaultSize: 10 * GigaByte,
|
||||
defaultSize: 10 * common.GibiByte,
|
||||
pipelines: qcow2Pipelines,
|
||||
buildPipelines: []string{"build"},
|
||||
payloadPipelines: []string{"os", "image", "qcow2"},
|
||||
|
|
|
|||
|
|
@ -340,10 +340,9 @@ func (t *imageType) OSTreeRef() string {
|
|||
}
|
||||
|
||||
func (t *imageType) Size(size uint64) uint64 {
|
||||
const MegaByte = 1024 * 1024
|
||||
// Microsoft Azure requires vhd images to be rounded up to the nearest MB
|
||||
if t.name == "vhd" && size%MegaByte != 0 {
|
||||
size = (size/MegaByte + 1) * MegaByte
|
||||
if t.name == "vhd" && size%common.MebiByte != 0 {
|
||||
size = (size/common.MebiByte + 1) * common.MebiByte
|
||||
}
|
||||
if size == 0 {
|
||||
size = t.defaultSize
|
||||
|
|
@ -709,8 +708,6 @@ func NewCentosHostDistro(name, modulePlatformID, ostreeRef string) distro.Distro
|
|||
}
|
||||
|
||||
func newDistro(distroName string) distro.Distro {
|
||||
const GigaByte = 1024 * 1024 * 1024
|
||||
|
||||
rd := distroMap[distroName]
|
||||
|
||||
// Architecture definitions
|
||||
|
|
@ -824,7 +821,7 @@ func newDistro(distroName string) distro.Distro {
|
|||
packageSets: map[string]packageSetFunc{
|
||||
buildPkgsKey: edgeRawImageBuildPackageSet,
|
||||
},
|
||||
defaultSize: 10 * GigaByte,
|
||||
defaultSize: 10 * common.GibiByte,
|
||||
rpmOstree: true,
|
||||
bootable: true,
|
||||
bootISO: false,
|
||||
|
|
@ -885,7 +882,7 @@ func newDistro(distroName string) distro.Distro {
|
|||
defaultImageConfig: &distro.ImageConfig{
|
||||
EnabledServices: edgeServices,
|
||||
},
|
||||
defaultSize: 10 * GigaByte,
|
||||
defaultSize: 10 * common.GibiByte,
|
||||
rpmOstree: true,
|
||||
bootable: true,
|
||||
bootISO: true,
|
||||
|
|
@ -924,7 +921,7 @@ func newDistro(distroName string) distro.Distro {
|
|||
},
|
||||
},
|
||||
bootable: true,
|
||||
defaultSize: 10 * GigaByte,
|
||||
defaultSize: 10 * common.GibiByte,
|
||||
pipelines: qcow2Pipelines,
|
||||
buildPipelines: []string{"build"},
|
||||
payloadPipelines: []string{"os", "image", "qcow2"},
|
||||
|
|
@ -952,7 +949,7 @@ func newDistro(distroName string) distro.Distro {
|
|||
},
|
||||
kernelOptions: "ro biosdevname=0 rootdelay=300 console=ttyS0 earlyprintk=ttyS0 net.ifnames=0",
|
||||
bootable: true,
|
||||
defaultSize: 4 * GigaByte,
|
||||
defaultSize: 4 * common.GibiByte,
|
||||
pipelines: vhdPipelines(false),
|
||||
buildPipelines: []string{"build"},
|
||||
payloadPipelines: []string{"os", "image", "vpc"},
|
||||
|
|
@ -1174,7 +1171,7 @@ func newDistro(distroName string) distro.Distro {
|
|||
},
|
||||
kernelOptions: "ro net.ifnames=0",
|
||||
bootable: true,
|
||||
defaultSize: 4 * GigaByte,
|
||||
defaultSize: 4 * common.GibiByte,
|
||||
pipelines: vmdkPipelines,
|
||||
buildPipelines: []string{"build"},
|
||||
payloadPipelines: []string{"os", "image", "vmdk"},
|
||||
|
|
@ -1195,7 +1192,7 @@ func newDistro(distroName string) distro.Distro {
|
|||
},
|
||||
kernelOptions: "ro net.ifnames=0",
|
||||
bootable: true,
|
||||
defaultSize: 4 * GigaByte,
|
||||
defaultSize: 4 * common.GibiByte,
|
||||
pipelines: openstackPipelines,
|
||||
buildPipelines: []string{"build"},
|
||||
payloadPipelines: []string{"os", "image", "qcow2"},
|
||||
|
|
@ -1409,7 +1406,7 @@ func newDistro(distroName string) distro.Distro {
|
|||
kernelOptions: "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295 crashkernel=auto",
|
||||
bootable: true,
|
||||
bootType: distro.LegacyBootType,
|
||||
defaultSize: 10 * GigaByte,
|
||||
defaultSize: 10 * common.GibiByte,
|
||||
pipelines: ec2Pipelines,
|
||||
buildPipelines: []string{"build"},
|
||||
payloadPipelines: []string{"os", "image"},
|
||||
|
|
@ -1431,7 +1428,7 @@ func newDistro(distroName string) distro.Distro {
|
|||
defaultImageConfig: defaultAMIImageConfig,
|
||||
kernelOptions: "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295 iommu.strict=0 crashkernel=auto",
|
||||
bootable: true,
|
||||
defaultSize: 10 * GigaByte,
|
||||
defaultSize: 10 * common.GibiByte,
|
||||
pipelines: ec2Pipelines,
|
||||
buildPipelines: []string{"build"},
|
||||
payloadPipelines: []string{"os", "image"},
|
||||
|
|
@ -1454,7 +1451,7 @@ func newDistro(distroName string) distro.Distro {
|
|||
kernelOptions: "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295 crashkernel=auto",
|
||||
bootable: true,
|
||||
bootType: distro.LegacyBootType,
|
||||
defaultSize: 10 * GigaByte,
|
||||
defaultSize: 10 * common.GibiByte,
|
||||
pipelines: rhelEc2Pipelines,
|
||||
buildPipelines: []string{"build"},
|
||||
payloadPipelines: []string{"os", "image", "archive"},
|
||||
|
|
@ -1476,7 +1473,7 @@ func newDistro(distroName string) distro.Distro {
|
|||
defaultImageConfig: defaultEc2ImageConfig,
|
||||
kernelOptions: "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295 iommu.strict=0 crashkernel=auto",
|
||||
bootable: true,
|
||||
defaultSize: 10 * GigaByte,
|
||||
defaultSize: 10 * common.GibiByte,
|
||||
pipelines: rhelEc2Pipelines,
|
||||
buildPipelines: []string{"build"},
|
||||
payloadPipelines: []string{"os", "image", "archive"},
|
||||
|
|
@ -1499,7 +1496,7 @@ func newDistro(distroName string) distro.Distro {
|
|||
kernelOptions: "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295 crashkernel=auto",
|
||||
bootable: true,
|
||||
bootType: distro.LegacyBootType,
|
||||
defaultSize: 10 * GigaByte,
|
||||
defaultSize: 10 * common.GibiByte,
|
||||
pipelines: rhelEc2Pipelines,
|
||||
buildPipelines: []string{"build"},
|
||||
payloadPipelines: []string{"os", "image", "archive"},
|
||||
|
|
@ -1633,7 +1630,7 @@ func newDistro(distroName string) distro.Distro {
|
|||
kernelOptions: "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295 crashkernel=auto processor.max_cstate=1 intel_idle.max_cstate=1",
|
||||
bootable: true,
|
||||
bootType: distro.LegacyBootType,
|
||||
defaultSize: 10 * GigaByte,
|
||||
defaultSize: 10 * common.GibiByte,
|
||||
pipelines: rhelEc2Pipelines,
|
||||
buildPipelines: []string{"build"},
|
||||
payloadPipelines: []string{"os", "image", "archive"},
|
||||
|
|
@ -1786,7 +1783,7 @@ func newDistro(distroName string) distro.Distro {
|
|||
kernelOptions: "net.ifnames=0 biosdevname=0 scsi_mod.use_blk_mq=Y crashkernel=auto console=ttyS0,38400n8d",
|
||||
bootable: true,
|
||||
bootType: distro.UEFIBootType,
|
||||
defaultSize: 20 * GigaByte,
|
||||
defaultSize: 20 * common.GibiByte,
|
||||
pipelines: gcePipelines,
|
||||
buildPipelines: []string{"build"},
|
||||
payloadPipelines: []string{"os", "image", "archive"},
|
||||
|
|
@ -1834,7 +1831,7 @@ func newDistro(distroName string) distro.Distro {
|
|||
kernelOptions: "net.ifnames=0 biosdevname=0 scsi_mod.use_blk_mq=Y crashkernel=auto console=ttyS0,38400n8d",
|
||||
bootable: true,
|
||||
bootType: distro.UEFIBootType,
|
||||
defaultSize: 20 * GigaByte,
|
||||
defaultSize: 20 * common.GibiByte,
|
||||
pipelines: gcePipelines,
|
||||
buildPipelines: []string{"build"},
|
||||
payloadPipelines: []string{"os", "image", "archive"},
|
||||
|
|
|
|||
|
|
@ -306,10 +306,9 @@ func (t *imageType) OSTreeRef() string {
|
|||
}
|
||||
|
||||
func (t *imageType) Size(size uint64) uint64 {
|
||||
const MegaByte = 1024 * 1024
|
||||
// Microsoft Azure requires vhd images to be rounded up to the nearest MB
|
||||
if t.name == "vhd" && size%MegaByte != 0 {
|
||||
size = (size/MegaByte + 1) * MegaByte
|
||||
if t.name == "vhd" && size%common.MebiByte != 0 {
|
||||
size = (size/common.MebiByte + 1) * common.MebiByte
|
||||
}
|
||||
if size == 0 {
|
||||
size = t.defaultSize
|
||||
|
|
@ -649,8 +648,6 @@ func NewCentosHostDistro(name, modulePlatformID, ostreeRef string) distro.Distro
|
|||
}
|
||||
|
||||
func newDistro(distroName string) distro.Distro {
|
||||
const GigaByte = 1024 * 1024 * 1024
|
||||
|
||||
rd := distroMap[distroName]
|
||||
|
||||
// Architecture definitions
|
||||
|
|
@ -747,7 +744,7 @@ func newDistro(distroName string) distro.Distro {
|
|||
defaultImageConfig: &distro.ImageConfig{
|
||||
Locale: common.StringToPtr("en_US.UTF-8"),
|
||||
},
|
||||
defaultSize: 10 * GigaByte,
|
||||
defaultSize: 10 * common.GibiByte,
|
||||
rpmOstree: true,
|
||||
bootable: true,
|
||||
bootISO: false,
|
||||
|
|
@ -809,7 +806,7 @@ func newDistro(distroName string) distro.Distro {
|
|||
defaultImageConfig: &distro.ImageConfig{
|
||||
EnabledServices: edgeServices,
|
||||
},
|
||||
defaultSize: 10 * GigaByte,
|
||||
defaultSize: 10 * common.GibiByte,
|
||||
rpmOstree: true,
|
||||
bootable: true,
|
||||
bootISO: true,
|
||||
|
|
@ -848,7 +845,7 @@ func newDistro(distroName string) distro.Distro {
|
|||
},
|
||||
},
|
||||
bootable: true,
|
||||
defaultSize: 10 * GigaByte,
|
||||
defaultSize: 10 * common.GibiByte,
|
||||
pipelines: qcow2Pipelines,
|
||||
buildPipelines: []string{"build"},
|
||||
payloadPipelines: []string{"os", "image", "qcow2"},
|
||||
|
|
@ -877,7 +874,7 @@ func newDistro(distroName string) distro.Distro {
|
|||
},
|
||||
kernelOptions: "ro biosdevname=0 rootdelay=300 console=ttyS0 earlyprintk=ttyS0 net.ifnames=0",
|
||||
bootable: true,
|
||||
defaultSize: 4 * GigaByte,
|
||||
defaultSize: 4 * common.GibiByte,
|
||||
pipelines: vhdPipelines(false),
|
||||
buildPipelines: []string{"build"},
|
||||
payloadPipelines: []string{"os", "image", "vpc"},
|
||||
|
|
@ -1086,7 +1083,7 @@ func newDistro(distroName string) distro.Distro {
|
|||
},
|
||||
kernelOptions: "ro net.ifnames=0",
|
||||
bootable: true,
|
||||
defaultSize: 4 * GigaByte,
|
||||
defaultSize: 4 * common.GibiByte,
|
||||
pipelines: vmdkPipelines,
|
||||
buildPipelines: []string{"build"},
|
||||
payloadPipelines: []string{"os", "image", "vmdk"},
|
||||
|
|
@ -1110,7 +1107,7 @@ func newDistro(distroName string) distro.Distro {
|
|||
},
|
||||
kernelOptions: "ro net.ifnames=0",
|
||||
bootable: true,
|
||||
defaultSize: 4 * GigaByte,
|
||||
defaultSize: 4 * common.GibiByte,
|
||||
pipelines: openstackPipelines,
|
||||
buildPipelines: []string{"build"},
|
||||
payloadPipelines: []string{"os", "image", "qcow2"},
|
||||
|
|
@ -1326,7 +1323,7 @@ func newDistro(distroName string) distro.Distro {
|
|||
kernelOptions: "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295",
|
||||
bootable: true,
|
||||
bootType: distro.LegacyBootType,
|
||||
defaultSize: 10 * GigaByte,
|
||||
defaultSize: 10 * common.GibiByte,
|
||||
pipelines: ec2Pipelines,
|
||||
buildPipelines: []string{"build"},
|
||||
payloadPipelines: []string{"os", "image"},
|
||||
|
|
@ -1348,7 +1345,7 @@ func newDistro(distroName string) distro.Distro {
|
|||
defaultImageConfig: defaultAMIImageConfig,
|
||||
kernelOptions: "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295 iommu.strict=0",
|
||||
bootable: true,
|
||||
defaultSize: 10 * GigaByte,
|
||||
defaultSize: 10 * common.GibiByte,
|
||||
pipelines: ec2Pipelines,
|
||||
buildPipelines: []string{"build"},
|
||||
payloadPipelines: []string{"os", "image"},
|
||||
|
|
@ -1371,7 +1368,7 @@ func newDistro(distroName string) distro.Distro {
|
|||
kernelOptions: "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295",
|
||||
bootable: true,
|
||||
bootType: distro.LegacyBootType,
|
||||
defaultSize: 10 * GigaByte,
|
||||
defaultSize: 10 * common.GibiByte,
|
||||
pipelines: rhelEc2Pipelines,
|
||||
buildPipelines: []string{"build"},
|
||||
payloadPipelines: []string{"os", "image", "archive"},
|
||||
|
|
@ -1393,7 +1390,7 @@ func newDistro(distroName string) distro.Distro {
|
|||
defaultImageConfig: defaultEc2ImageConfig,
|
||||
kernelOptions: "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295 iommu.strict=0",
|
||||
bootable: true,
|
||||
defaultSize: 10 * GigaByte,
|
||||
defaultSize: 10 * common.GibiByte,
|
||||
pipelines: rhelEc2Pipelines,
|
||||
buildPipelines: []string{"build"},
|
||||
payloadPipelines: []string{"os", "image", "archive"},
|
||||
|
|
@ -1416,7 +1413,7 @@ func newDistro(distroName string) distro.Distro {
|
|||
kernelOptions: "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295",
|
||||
bootable: true,
|
||||
bootType: distro.LegacyBootType,
|
||||
defaultSize: 10 * GigaByte,
|
||||
defaultSize: 10 * common.GibiByte,
|
||||
pipelines: rhelEc2Pipelines,
|
||||
buildPipelines: []string{"build"},
|
||||
payloadPipelines: []string{"os", "image", "archive"},
|
||||
|
|
@ -1550,7 +1547,7 @@ func newDistro(distroName string) distro.Distro {
|
|||
kernelOptions: "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295 processor.max_cstate=1 intel_idle.max_cstate=1",
|
||||
bootable: true,
|
||||
bootType: distro.LegacyBootType,
|
||||
defaultSize: 10 * GigaByte,
|
||||
defaultSize: 10 * common.GibiByte,
|
||||
pipelines: rhelEc2Pipelines,
|
||||
buildPipelines: []string{"build"},
|
||||
payloadPipelines: []string{"os", "image", "archive"},
|
||||
|
|
@ -1691,7 +1688,7 @@ func newDistro(distroName string) distro.Distro {
|
|||
kernelOptions: "net.ifnames=0 biosdevname=0 scsi_mod.use_blk_mq=Y console=ttyS0,38400n8d",
|
||||
bootable: true,
|
||||
bootType: distro.UEFIBootType,
|
||||
defaultSize: 20 * GigaByte,
|
||||
defaultSize: 20 * common.GibiByte,
|
||||
pipelines: gcePipelines,
|
||||
buildPipelines: []string{"build"},
|
||||
payloadPipelines: []string{"os", "image", "archive"},
|
||||
|
|
@ -1739,7 +1736,7 @@ func newDistro(distroName string) distro.Distro {
|
|||
kernelOptions: "net.ifnames=0 biosdevname=0 scsi_mod.use_blk_mq=Y console=ttyS0,38400n8d",
|
||||
bootable: true,
|
||||
bootType: distro.UEFIBootType,
|
||||
defaultSize: 20 * GigaByte,
|
||||
defaultSize: 20 * common.GibiByte,
|
||||
pipelines: gcePipelines,
|
||||
buildPipelines: []string{"build"},
|
||||
payloadPipelines: []string{"os", "image", "archive"},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue