Secrets: Implement secrets manager plugin fallback store (#54496)

* Refactor fallback to be isolated to plugin secret store

* Check for error value on replace fallback test helper

* Move ResetPlugin from test_helpers.go to plugin.go

* Add check to GetUnwrappedStoreFromCache

* Add fallback GetAll query to WithFallbackEnabled

* Add mutex lock to WithFallbackEnabled

* Add cache to fallback store

* Fix linter issues

* Fix linter issues

* Fix linter issues
This commit is contained in:
Guilherme Caulada
2022-09-02 12:39:18 -03:00
committed by GitHub
parent 6b197f3fa9
commit f4a35a4645
8 changed files with 147 additions and 90 deletions
+1 -13
View File
@@ -3,7 +3,6 @@ package kvstore
import (
"context"
"encoding/base64"
"errors"
"sync"
"time"
@@ -30,10 +29,7 @@ type cachedDecrypted struct {
value string
}
var (
b64 = base64.RawStdEncoding
errFallbackNotAllowed = errors.New("fallback not allowed for sql secret store")
)
var b64 = base64.RawStdEncoding
func NewSQLSecretsKVStore(sqlStore sqlstore.Store, secretsService secrets.Service, logger log.Logger) *SecretsKVStoreSQL {
return &SecretsKVStoreSQL{
@@ -244,14 +240,6 @@ func (kv *SecretsKVStoreSQL) GetAll(ctx context.Context) ([]Item, error) {
return items, err
}
func (kv *SecretsKVStoreSQL) Fallback() SecretsKVStore {
return nil
}
func (kv *SecretsKVStoreSQL) SetFallback(_ SecretsKVStore) error {
return errFallbackNotAllowed
}
func (kv *SecretsKVStoreSQL) getDecryptedValue(ctx context.Context, item Item) ([]byte, error) {
kv.decryptionCache.Lock()
defer kv.decryptionCache.Unlock()