Skip to content

Commit

Permalink
fix: prevent panic in validate config if machine.install is missing
Browse files Browse the repository at this point in the history
Fixes #3382

Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
(cherry picked from commit 4b3580a)
  • Loading branch information
smira committed Mar 30, 2021
1 parent a8cf70c commit be14916
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pkg/machinery/config/types/v1alpha1/v1alpha1_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ func (c *Config) Validate(mode config.RuntimeMode) error {
if mode.RequiresInstall() {
if c.MachineConfig.MachineInstall == nil {
result = multierror.Append(result, fmt.Errorf("install instructions are required in %q mode", mode))
}

if c.MachineConfig.MachineInstall.InstallDisk == "" {
result = multierror.Append(result, fmt.Errorf("an install disk is required in %q mode", mode))
}
} else {
if c.MachineConfig.MachineInstall.InstallDisk == "" {
result = multierror.Append(result, fmt.Errorf("an install disk is required in %q mode", mode))
}

if _, err := os.Stat(c.MachineConfig.MachineInstall.InstallDisk); os.IsNotExist(err) {
result = multierror.Append(result, fmt.Errorf("specified install disk does not exist: %q", c.MachineConfig.MachineInstall.InstallDisk))
if _, err := os.Stat(c.MachineConfig.MachineInstall.InstallDisk); os.IsNotExist(err) {
result = multierror.Append(result, fmt.Errorf("specified install disk does not exist: %q", c.MachineConfig.MachineInstall.InstallDisk))
}
}
}

Expand Down

0 comments on commit be14916

Please sign in to comment.