Skip to content

Commit

Permalink
fixed hcp vault key caching in redis (#2215)
Browse files Browse the repository at this point in the history
  • Loading branch information
mekilis authored Jan 14, 2025
1 parent d39644c commit 88e213d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions internal/pkg/keys/hcpvault.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, &currentKey)
if err != nil {
return "", err
}

if currentKey != "" {
return currentKey, nil
if currentKey != nil && *currentKey != "" {
return *currentKey, nil
}

return k.GetCurrentKey()
Expand Down Expand Up @@ -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, &currentKey, -1)
}
}

Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 88e213d

Please sign in to comment.