rbd: add unit test for ParseEncryptionOpts

Signed-off-by: riya-singhal31 <rsinghal@redhat.com>
This commit is contained in:
riya-singhal31
2023-05-25 18:01:30 +05:30
committed by mergify[bot]
parent e92edd09ef
commit b5e68c810e
3 changed files with 108 additions and 4 deletions

View File

@ -20,8 +20,8 @@ import (
"context"
"errors"
"fmt"
"strings"
"strconv"
"strings"
kmsapi "github.com/ceph/ceph-csi/internal/kms"
"github.com/ceph/ceph-csi/internal/util"
@ -341,8 +341,14 @@ func ParseEncryptionOpts(
encrypted, kmsID string
)
encrypted, ok = volOptions["encrypted"]
val, _ := strconv.ParseBool(encrypted)
if !ok || !val{
if !ok {
return "", util.EncryptionTypeNone, nil
}
ok, err = strconv.ParseBool(encrypted)
if err != nil {
return "", util.EncryptionTypeInvalid, err
}
if !ok {
return "", util.EncryptionTypeNone, nil
}
kmsID, err = util.FetchEncryptionKMSID(encrypted, volOptions["encryptionKMSID"])