rbd: unmarshal the data read from file

if are reading the kms data from the file.
than only we need to unmarshal. If we are reading
from the configmap it already returns the unmarshal
data.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna 2021-02-03 16:49:03 +05:30 committed by mergify[bot]
parent 50a720f13d
commit b370d9afb6

View File

@ -145,11 +145,11 @@ func GetKMS(tenant, kmsID string, secrets map[string]string) (EncryptionKMS, err
return nil, fmt.Errorf("failed to read kms configuration from configmap %s in namespace %s: %w", return nil, fmt.Errorf("failed to read kms configuration from configmap %s in namespace %s: %w",
namespace, name, err) namespace, name, err)
} }
} } else {
err = json.Unmarshal(content, &config)
err = json.Unmarshal(content, &config) if err != nil {
if err != nil { return nil, fmt.Errorf("failed to parse kms configuration: %w", err)
return nil, fmt.Errorf("failed to parse kms configuration: %w", err) }
} }
kmsConfig, ok := config[kmsID].(map[string]interface{}) kmsConfig, ok := config[kmsID].(map[string]interface{})