Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for advanced partitioning customizations (COMPOSER-2399) #4535

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions internal/blueprint/blueprint.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,44 @@ func Convert(bp Blueprint) iblueprint.Blueprint {
}
customizations.Filesystem = ifs
}
if disk := c.Disk; disk != nil {
idisk := &iblueprint.DiskCustomization{
MinSize: disk.MinSize,
Partitions: make([]iblueprint.PartitionCustomization, len(disk.Partitions)),
}
for idx, part := range disk.Partitions {
ipart := iblueprint.PartitionCustomization{
Type: part.Type,
MinSize: part.MinSize,
BtrfsVolumeCustomization: iblueprint.BtrfsVolumeCustomization{},
VGCustomization: iblueprint.VGCustomization{
Name: part.VGCustomization.Name,
},
FilesystemTypedCustomization: iblueprint.FilesystemTypedCustomization(part.FilesystemTypedCustomization),
}

if len(part.LogicalVolumes) > 0 {
ipart.LogicalVolumes = make([]iblueprint.LVCustomization, len(part.LogicalVolumes))
for lvidx, lv := range part.LogicalVolumes {
ipart.LogicalVolumes[lvidx] = iblueprint.LVCustomization{
Name: lv.Name,
MinSize: lv.MinSize,
FilesystemTypedCustomization: iblueprint.FilesystemTypedCustomization(lv.FilesystemTypedCustomization),
}
}
}

if len(part.Subvolumes) > 0 {
ipart.Subvolumes = make([]iblueprint.BtrfsSubvolumeCustomization, len(part.Subvolumes))
for svidx, sv := range part.Subvolumes {
ipart.Subvolumes[svidx] = iblueprint.BtrfsSubvolumeCustomization(sv)
}
}

idisk.Partitions[idx] = ipart
}
customizations.Disk = idisk
}
if tz := c.Timezone; tz != nil {
itz := iblueprint.TimezoneCustomization(*tz)
customizations.Timezone = &itz
Expand Down
1 change: 1 addition & 0 deletions internal/blueprint/customizations.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type Customizations struct {
Firewall *FirewallCustomization `json:"firewall,omitempty" toml:"firewall,omitempty"`
Services *ServicesCustomization `json:"services,omitempty" toml:"services,omitempty"`
Filesystem []FilesystemCustomization `json:"filesystem,omitempty" toml:"filesystem,omitempty"`
Disk *DiskCustomization `json:"disk,omitempty" toml:"disk,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a very stupid (sorry!) question - could we simply do:

iff --git a/internal/blueprint/customizations.go b/internal/blueprint/customiza
tions.go
index 9ec43401f..5efe3eb40 100644
--- a/internal/blueprint/customizations.go
+++ b/internal/blueprint/customizations.go
@@ -5,33 +5,34 @@ import (
        "reflect"
        "strings"
 
+       "github.com/osbuild/images/pkg/blueprint"
        "github.com/osbuild/images/pkg/disk"
 )
...
-       Disk               *DiskCustomization        `json:"disk,omitempty" toml:"disk,omitempty"`
+       Disk *blueprint.DiskCustomization `json:"disk,omitempty" toml:"disk,omitempty"`
...

here (and remove disk_customizations.go in this PR)?

And then we would add a "Validate()" that simply disallows the "dc.Type" (as it seems that is the only thing we do not support compared to the images disk_blueprint)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think with the work we're doing to unify blueprints, it might be a good idea to just drop the whole copy from here and make it use the one from images directly.

InstallationDevice string `json:"installation_device,omitempty" toml:"installation_device,omitempty"`
PartitioningMode string `json:"partitioning_mode,omitempty" toml:"partitioning_mode,omitempty"`
FDO *FDOCustomization `json:"fdo,omitempty" toml:"fdo,omitempty"`
Expand Down
Loading