Skip to content

Commit

Permalink
fix: include all volume group names in the error message
Browse files Browse the repository at this point in the history
Signed-off-by: Suleyman Akbas <[email protected]>
  • Loading branch information
suleymanakbas91 committed Mar 3, 2023
1 parent d378bf2 commit 496a3e0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions api/v1alpha1/lvmcluster_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,17 +190,19 @@ func (l *LVMCluster) verifySingleDefaultDeviceClass() error {

func (l *LVMCluster) verifyPathsAreNotEmpty() error {

var deviceClassWithoutPaths []string
for _, deviceClass := range l.Spec.Storage.DeviceClasses {
if deviceClass.DeviceSelector != nil {
if len(deviceClass.DeviceSelector.Paths) == 0 {
return fmt.Errorf("path list should not be empty when DeviceSelector is specified")
}
} else {
if len(l.Spec.Storage.DeviceClasses) > 1 {
return fmt.Errorf("path list should not be empty when there are multiple deviceClasses. Please specify device path(s) under deviceSelector.paths for %s deviceClass", deviceClass.Name)
}
deviceClassWithoutPaths = append(deviceClassWithoutPaths, deviceClass.Name)
}
}
if len(l.Spec.Storage.DeviceClasses) > 1 && len(deviceClassWithoutPaths) > 0 {
return fmt.Errorf("path list should not be empty when there are multiple deviceClasses. Please specify device path(s) under deviceSelector.paths for %s deviceClass(es)", strings.Join(deviceClassWithoutPaths, `,`))
}

return nil
}
Expand Down

0 comments on commit 496a3e0

Please sign in to comment.