Skip to content

Commit

Permalink
blueprint: add extra comments to Validate{,LayoutConstraints}
Browse files Browse the repository at this point in the history
This commit ensures that the roles of `Validate{,LayoutConstraints}`
are clearer from the code comments.

Follwup, c.f.
#1041 (comment)
  • Loading branch information
mvo5 committed Nov 25, 2024
1 parent ac1d26e commit e5dd018
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/blueprint/disk_customizations.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,10 @@ func (v *PartitionCustomization) UnmarshalTOML(data any) error {
// - Plain filesystem types are valid for the partition type
// - All non-empty properties are valid for the partition type (e.g.
// LogicalVolumes is empty when the type is "plain" or "btrfs")
//
// Note that in *addition* consumers should also call
// ValidateLayoutConstraints() to validate that the policy for disk
// customizations is met.
func (p *DiskCustomization) Validate() error {
if p == nil {
return nil
Expand Down Expand Up @@ -373,6 +377,11 @@ func validateMountpoint(path string) error {
// ValidateLayoutConstraints checks that at most one LVM Volume Group or btrfs
// volume is defined. Returns an error if both LVM and btrfs are set and if
// either has more than one element.
//
// Note that this is a *policy* validation, in theory the "disk" code
// does support the constraints but we choose not to allow them for
// now. Each consumer of "DiskCustomization" should call this
// *unless* it's very low-level and not end-user-facing.
func (p *DiskCustomization) ValidateLayoutConstraints() error {
if p == nil {
return nil
Expand Down

0 comments on commit e5dd018

Please sign in to comment.