util: Add EncryptionTypeNone and unit tests

Add type none to distinguish disabled encryption (positive result)
from invalid configuration (negative result).

Signed-off-by: Marcel Lauhoff <marcel.lauhoff@suse.com>
This commit is contained in:
Marcel Lauhoff
2022-09-06 18:44:00 +02:00
committed by mergify[bot]
parent f89076b1d7
commit 2abfafdf3f
3 changed files with 62 additions and 11 deletions

View File

@ -383,11 +383,13 @@ func (conn *Connection) CheckReservation(ctx context.Context,
}
}
if encryptionType != util.EncryptionTypeInvalid {
if encryptionType != util.EncryptionTypeNone {
if savedImageAttributes.EncryptionType != encryptionType {
return nil, fmt.Errorf("internal state inconsistent, omap encryption type"+
" mismatch, request KMS (%s) volume UUID (%s) volume omap KMS (%d)",
kmsConfig, objUUID, savedImageAttributes.EncryptionType)
" mismatch, request type %q(%d) volume UUID (%s) volume omap encryption type %q (%d)",
util.EncryptionTypeString(encryptionType), encryptionType,
objUUID, util.EncryptionTypeString(savedImageAttributes.EncryptionType),
savedImageAttributes.EncryptionType)
}
}