From 88e213dcf784dc7e74442b1b7eebc41ecd6e91c9 Mon Sep 17 00:00:00 2001 From: Smart Mekiliuwa Date: Tue, 14 Jan 2025 13:25:39 +0100 Subject: [PATCH] fixed hcp vault key caching in redis (#2215) --- internal/pkg/keys/hcpvault.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/pkg/keys/hcpvault.go b/internal/pkg/keys/hcpvault.go index 79311c84b6..a221a6108e 100644 --- a/internal/pkg/keys/hcpvault.go +++ b/internal/pkg/keys/hcpvault.go @@ -123,14 +123,14 @@ func (k *HCPVaultKeyManager) GetCurrentKeyFromCache() (string, error) { return "", ErrCredentialEncryptionFeatureUnavailable } - var currentKey string + var currentKey *string err := k.cache.Get(context.Background(), RedisCacheKey, ¤tKey) if err != nil { return "", err } - if currentKey != "" { - return currentKey, nil + if currentKey != nil && *currentKey != "" { + return *currentKey, nil } return k.GetCurrentKey() @@ -161,7 +161,7 @@ func (k *HCPVaultKeyManager) GetCurrentKey() (string, error) { return "", err } - return currentKey, k.cache.Set(context.Background(), RedisCacheKey, currentKey, -1) + return currentKey, k.cache.Set(context.Background(), RedisCacheKey, ¤tKey, -1) } } @@ -275,7 +275,7 @@ func (k *HCPVaultKeyManager) createOrUpdateSecret(newKey string) error { return parseErrorResponse(resp) } - return k.cache.Set(context.Background(), RedisCacheKey, newKey, -1) + return k.cache.Set(context.Background(), RedisCacheKey, &newKey, -1) } // deleteSecret deletes the existing secret to reset the versioning.