disk_size should not be required if storage is defined

This commit is contained in:
Joshua Foster 2020-03-31 11:47:09 -04:00
parent 45da4c8ee7
commit cf3c448d17
1 changed files with 8 additions and 2 deletions

View File

@ -70,8 +70,14 @@ type CreateConfig struct {
func (c *CreateConfig) Prepare() []error { func (c *CreateConfig) Prepare() []error {
var errs []error var errs []error
if c.DiskSize == 0 { if len(c.Storage) > 0 {
errs = append(errs, fmt.Errorf("'disk_size' is required")) for i, storage := range c.Storage {
if storage.DiskSize == 0 {
errs = append(errs, fmt.Errorf("storage[%d].'disk_size' is required", i))
}
}
} else if c.DiskSize == 0 {
errs = append(errs, fmt.Errorf("'disk_size' or 'storage' is required"))
} }
if c.GuestOSType == "" { if c.GuestOSType == "" {