mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-22 14:20:19 +00:00
cleanup: refactor deeply nested if statements in persistentvolume.go
Refactored deeply nested if statement in persistentvolume.go to reduce cognitive complexity. Signed-off-by: Rakshith R <rar@redhat.com>
This commit is contained in:
parent
7d105143fc
commit
0f7b653b4e
@ -129,7 +129,9 @@ func (r ReconcilePersistentVolume) reconcilePV(obj runtime.Object) error {
|
|||||||
if !ok {
|
if !ok {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if pv.Spec.CSI != nil && pv.Spec.CSI.Driver == r.config.DriverName {
|
if pv.Spec.CSI == nil || pv.Spec.CSI.Driver != r.config.DriverName {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
pool := pv.Spec.CSI.VolumeAttributes["pool"]
|
pool := pv.Spec.CSI.VolumeAttributes["pool"]
|
||||||
journalPool := pv.Spec.CSI.VolumeAttributes["journalPool"]
|
journalPool := pv.Spec.CSI.VolumeAttributes["journalPool"]
|
||||||
requestName := pv.Name
|
requestName := pv.Name
|
||||||
@ -156,7 +158,7 @@ func (r ReconcilePersistentVolume) reconcilePV(obj runtime.Object) error {
|
|||||||
|
|
||||||
cr, err := r.getCredentials(secretName, secretNamespace)
|
cr, err := r.getCredentials(secretName, secretNamespace)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
util.ErrorLogMsg("failed to get credentials %s", err)
|
util.ErrorLogMsg("failed to get credentials from secret %s", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer cr.DeleteCredentials()
|
defer cr.DeleteCredentials()
|
||||||
@ -166,7 +168,6 @@ func (r ReconcilePersistentVolume) reconcilePV(obj runtime.Object) error {
|
|||||||
util.ErrorLogMsg("failed to regenerate journal %s", err)
|
util.ErrorLogMsg("failed to regenerate journal %s", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user