util: move GetID() from EncryptionKMS to VolumeEncryption

There is no need for each EncryptionKMS to implement the same GetID()
function. We have a VolumeEncryption type that is more suitable for
keeping track of the KMS-ID that was used to get the configuration of
the KMS.

This does not change any metadata that is stored anywhere.

Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
Niels de Vos
2021-03-19 16:21:48 +01:00
committed by mergify[bot]
parent 9317e2afb4
commit eea97ca014
10 changed files with 38 additions and 46 deletions

View File

@ -208,7 +208,7 @@ func (ri *rbdImage) configureEncryption(kmsID string, credentials map[string]str
return err
}
ri.encryption, err = util.NewVolumeEncryption(kms)
ri.encryption, err = util.NewVolumeEncryption(kmsID, kms)
// if the KMS can not store the DEK itself, we'll store it in the
// metadata of the RBD image itself

View File

@ -234,7 +234,7 @@ func (rv *rbdVolume) Exists(ctx context.Context, parentVol *rbdVolume) (bool, er
kmsID := ""
if rv.isEncrypted() {
kmsID = rv.encryption.KMS.GetID()
kmsID = rv.encryption.GetID()
}
j, err := volJournal.Connect(rv.Monitors, rv.RadosNamespace, rv.conn.Creds)
@ -411,7 +411,7 @@ func reserveVol(ctx context.Context, rbdVol *rbdVolume, rbdSnap *rbdSnapshot, cr
kmsID := ""
if rbdVol.isEncrypted() {
kmsID = rbdVol.encryption.KMS.GetID()
kmsID = rbdVol.encryption.GetID()
}
j, err := volJournal.Connect(rbdVol.Monitors, rbdVol.RadosNamespace, cr)