distro: define PartitionType method on ImageType
This is needed so that we can do different things depending on the given layout; this will be used in tests for now only. Only GPT allows for arbitrary number of partitions and once we assert this in code we will need to adjust the tests accordingly. NB: This method might be removed again in the future, once generic LVM support is added everywhere and the ability to differentiate between MBR and GPT layouts is not needed anymore.
This commit is contained in:
parent
c64e3149aa
commit
2ee3fd31a1
10 changed files with 66 additions and 0 deletions
|
|
@ -97,6 +97,10 @@ type ImageType interface {
|
||||||
// is 0 the default value for the format will be returned.
|
// is 0 the default value for the format will be returned.
|
||||||
Size(size uint64) uint64
|
Size(size uint64) uint64
|
||||||
|
|
||||||
|
// Returns the corresponding partion type ("gpt", "dos") or "" the image type
|
||||||
|
// has no partition table. Only support for RHEL 8.5+
|
||||||
|
PartitionType() string
|
||||||
|
|
||||||
// Returns the sets of packages to include and exclude when building the image.
|
// Returns the sets of packages to include and exclude when building the image.
|
||||||
// Indexed by a string label. How each set is labeled and used depends on the
|
// Indexed by a string label. How each set is labeled and used depends on the
|
||||||
// image type.
|
// image type.
|
||||||
|
|
|
||||||
|
|
@ -192,6 +192,10 @@ func (t *imageType) Size(size uint64) uint64 {
|
||||||
return size
|
return size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *imageType) PartitionType() string {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
func (t *imageType) Packages(bp blueprint.Blueprint) ([]string, []string) {
|
func (t *imageType) Packages(bp blueprint.Blueprint) ([]string, []string) {
|
||||||
packages := append(t.packages, bp.GetPackages()...)
|
packages := append(t.packages, bp.GetPackages()...)
|
||||||
timezone, _ := bp.Customizations.GetTimezoneSettings()
|
timezone, _ := bp.Customizations.GetTimezoneSettings()
|
||||||
|
|
|
||||||
|
|
@ -184,6 +184,10 @@ func (t *imageType) Size(size uint64) uint64 {
|
||||||
return size
|
return size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *imageType) PartitionType() string {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
func (t *imageType) Packages(bp blueprint.Blueprint) ([]string, []string) {
|
func (t *imageType) Packages(bp blueprint.Blueprint) ([]string, []string) {
|
||||||
packages := append(t.packages, bp.GetPackages()...)
|
packages := append(t.packages, bp.GetPackages()...)
|
||||||
timezone, _ := bp.Customizations.GetTimezoneSettings()
|
timezone, _ := bp.Customizations.GetTimezoneSettings()
|
||||||
|
|
|
||||||
|
|
@ -215,6 +215,10 @@ func (t *imageType) Size(size uint64) uint64 {
|
||||||
return size
|
return size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *imageType) PartitionType() string {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
func (t *imageType) Packages(bp blueprint.Blueprint) ([]string, []string) {
|
func (t *imageType) Packages(bp blueprint.Blueprint) ([]string, []string) {
|
||||||
packages := append(t.packages, bp.GetPackages()...)
|
packages := append(t.packages, bp.GetPackages()...)
|
||||||
timezone, _ := bp.Customizations.GetTimezoneSettings()
|
timezone, _ := bp.Customizations.GetTimezoneSettings()
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,10 @@ func (t *imageTypeS2) Size(size uint64) uint64 {
|
||||||
return size
|
return size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *imageTypeS2) PartitionType() string {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
func (t *imageTypeS2) Packages(bp blueprint.Blueprint) ([]string, []string) {
|
func (t *imageTypeS2) Packages(bp blueprint.Blueprint) ([]string, []string) {
|
||||||
packages := append(t.packageSets["packages"].Include, bp.GetPackages()...)
|
packages := append(t.packageSets["packages"].Include, bp.GetPackages()...)
|
||||||
timezone, _ := bp.Customizations.GetTimezoneSettings()
|
timezone, _ := bp.Customizations.GetTimezoneSettings()
|
||||||
|
|
|
||||||
|
|
@ -327,6 +327,16 @@ func (t *imageType) getPartitionTable(
|
||||||
return disk.CreatePartitionTable(mountpoints, imageSize, &basePartitionTable, rng)
|
return disk.CreatePartitionTable(mountpoints, imageSize, &basePartitionTable, rng)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *imageType) PartitionType() string {
|
||||||
|
archName := t.arch.Name()
|
||||||
|
basePartitionTable, exists := t.basePartitionTables[archName]
|
||||||
|
if !exists {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
return basePartitionTable.Type
|
||||||
|
}
|
||||||
|
|
||||||
// local type for ostree commit metadata used to define commit sources
|
// local type for ostree commit metadata used to define commit sources
|
||||||
type ostreeCommit struct {
|
type ostreeCommit struct {
|
||||||
Checksum string
|
Checksum string
|
||||||
|
|
|
||||||
|
|
@ -404,6 +404,17 @@ func (t *imageType) getDefaultImageConfig() *distro.ImageConfig {
|
||||||
imageConfig = &distro.ImageConfig{}
|
imageConfig = &distro.ImageConfig{}
|
||||||
}
|
}
|
||||||
return imageConfig.InheritFrom(t.arch.distro.getDefaultImageConfig())
|
return imageConfig.InheritFrom(t.arch.distro.getDefaultImageConfig())
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *imageType) PartitionType() string {
|
||||||
|
archName := t.arch.Name()
|
||||||
|
basePartitionTable, exists := t.basePartitionTables[archName]
|
||||||
|
if !exists {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
return basePartitionTable.Type
|
||||||
}
|
}
|
||||||
|
|
||||||
// local type for ostree commit metadata used to define commit sources
|
// local type for ostree commit metadata used to define commit sources
|
||||||
|
|
|
||||||
|
|
@ -392,6 +392,17 @@ func (t *imageType) getDefaultImageConfig() *distro.ImageConfig {
|
||||||
imageConfig = &distro.ImageConfig{}
|
imageConfig = &distro.ImageConfig{}
|
||||||
}
|
}
|
||||||
return imageConfig.InheritFrom(t.arch.distro.getDefaultImageConfig())
|
return imageConfig.InheritFrom(t.arch.distro.getDefaultImageConfig())
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *imageType) PartitionType() string {
|
||||||
|
archName := t.arch.Name()
|
||||||
|
basePartitionTable, exists := t.basePartitionTables[archName]
|
||||||
|
if !exists {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
return basePartitionTable.Type
|
||||||
}
|
}
|
||||||
|
|
||||||
// local type for ostree commit metadata used to define commit sources
|
// local type for ostree commit metadata used to define commit sources
|
||||||
|
|
|
||||||
|
|
@ -362,6 +362,16 @@ func (t *imageType) getPartitionTable(
|
||||||
return disk.CreatePartitionTable(mountpoints, imageSize, &basePartitionTable, rng)
|
return disk.CreatePartitionTable(mountpoints, imageSize, &basePartitionTable, rng)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *imageType) PartitionType() string {
|
||||||
|
archName := t.arch.Name()
|
||||||
|
basePartitionTable, exists := t.basePartitionTables[archName]
|
||||||
|
if !exists {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
return basePartitionTable.Type
|
||||||
|
}
|
||||||
|
|
||||||
// local type for ostree commit metadata used to define commit sources
|
// local type for ostree commit metadata used to define commit sources
|
||||||
type ostreeCommit struct {
|
type ostreeCommit struct {
|
||||||
Checksum string
|
Checksum string
|
||||||
|
|
|
||||||
|
|
@ -167,6 +167,10 @@ func (t *TestImageType) Size(size uint64) uint64 {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *TestImageType) PartitionType() string {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
func (t *TestImageType) Packages(bp blueprint.Blueprint) ([]string, []string) {
|
func (t *TestImageType) Packages(bp blueprint.Blueprint) ([]string, []string) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue