cleanup: add a helper function storeImageID

added a helper function storeImageID to reduce
code duplication.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna
2020-12-04 14:06:05 +05:30
committed by mergify[bot]
parent b2fb43b335
commit 43fde0a30a
3 changed files with 19 additions and 29 deletions

View File

@ -752,14 +752,8 @@ func genVolFromVolID(ctx context.Context, volumeID string, cr *util.Credentials,
}
if rbdVol.ImageID == "" {
err = rbdVol.getImageID()
err = rbdVol.storeImageID(ctx, j)
if err != nil {
util.ErrorLog(ctx, "failed to get image id %s: %v", rbdVol, err)
return rbdVol, err
}
err = j.StoreImageID(ctx, rbdVol.JournalPool, rbdVol.ReservedID, rbdVol.ImageID)
if err != nil {
util.ErrorLog(ctx, "failed to store volume id %s: %v", rbdVol, err)
return rbdVol, err
}
}