mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-22 06:10:22 +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 {
|
||||
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"]
|
||||
journalPool := pv.Spec.CSI.VolumeAttributes["journalPool"]
|
||||
requestName := pv.Name
|
||||
@ -156,7 +158,7 @@ func (r ReconcilePersistentVolume) reconcilePV(obj runtime.Object) error {
|
||||
|
||||
cr, err := r.getCredentials(secretName, secretNamespace)
|
||||
if err != nil {
|
||||
util.ErrorLogMsg("failed to get credentials %s", err)
|
||||
util.ErrorLogMsg("failed to get credentials from secret %s", err)
|
||||
return err
|
||||
}
|
||||
defer cr.DeleteCredentials()
|
||||
@ -166,7 +168,6 @@ func (r ReconcilePersistentVolume) reconcilePV(obj runtime.Object) error {
|
||||
util.ErrorLogMsg("failed to regenerate journal %s", err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user