Skip to content

Commit

Permalink
Immediately validate the persistent size
Browse files Browse the repository at this point in the history
... and clear the error message when necessary.

Signed-off-by: Volker Theile <[email protected]>
  • Loading branch information
votdev authored and bk201 committed Feb 19, 2024
1 parent 4be0fcf commit 885ac16
Showing 1 changed file with 29 additions and 11 deletions.
40 changes: 29 additions & 11 deletions pkg/console/install_panels.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,20 @@ func addDiskPanel(c *Console) error {
}
return true, nil
}
validatePersistentPartitionSize := func(persistentSize string) (bool, error) {
installDisk := c.config.Install.Device
dataDisk := c.config.Install.DataDisk
if dataDisk == "" || installDisk == dataDisk {
diskSize, err := util.GetDiskSizeBytes(installDisk)
if err != nil {
return false, err
}
if _, err := util.ParsePartitionSize(diskSize, persistentSize); err != nil {
return false, updateValidatorMessage(err.Error())
}
}
return true, nil
}
closeThisPage := func() {
c.CloseElements(
diskPanel,
Expand All @@ -475,17 +489,10 @@ func addDiskPanel(c *Console) error {
return err
}

installDisk := c.config.Install.Device
dataDisk := c.config.Install.DataDisk
persistentSize := c.config.Install.PersistentPartitionSize
if dataDisk == "" || installDisk == dataDisk {
diskSize, err := util.GetDiskSizeBytes(c.config.Install.Device)
if err != nil {
return err
}
if _, err := util.ParsePartitionSize(diskSize, persistentSize); err != nil {
return updateValidatorMessage(err.Error())
}
// Make sure the persistent partition size is in the correct size.
// Do NOT allow proceeding to next field.
if valid, err := validatePersistentPartitionSize(c.config.Install.PersistentPartitionSize); !valid || err != nil {
return err
}

if !diskConfirmed {
Expand Down Expand Up @@ -600,6 +607,17 @@ func addDiskPanel(c *Console) error {
if err != nil {
return err
}

// Clear previous error message.
if err := updateValidatorMessage(""); err != nil {
return err
}

// Make sure that the specified size meets the requirements.
if valid, err := validatePersistentPartitionSize(persistentSize); !valid || err != nil {
return err
}

c.config.Install.PersistentPartitionSize = persistentSize

if systemIsBIOS() {
Expand Down

0 comments on commit 885ac16

Please sign in to comment.