Documentation ¶
Index ¶
- Constants
- func EvaluateRemoteSecretsPlugin(ctx context.Context, mg plugins.SecretsPluginManager, cfg *setting.Cfg) error
- func GetNamespacedKVStore(kv kvstore.KVStore) *kvstore.NamespacedKVStore
- func HasPluginStarted(ctx context.Context, mg plugins.SecretsPluginManager) bool
- func IsPluginStartupErrorFatal(ctx context.Context, kvstore *kvstore.NamespacedKVStore) (bool, error)
- func NewFakeFeatureToggles(t *testing.T, returnValue bool) featuremgmt.FeatureToggles
- func NewFakeSecretsPluginManager(t *testing.T, shouldFailOnStart bool) plugins.SecretsPluginManager
- func ReplaceFallback(t *testing.T, kv SecretsKVStore, fb SecretsKVStore) error
- func ResetPlugin()
- func SetPluginStartupErrorFatal(ctx context.Context, kvstore *kvstore.NamespacedKVStore, isFatal bool) error
- func SetupFatalCrashTest(t *testing.T, shouldFailOnStart bool, isPluginErrorFatal bool, ...) (fatalCrashTestFields, error)
- func SetupTestConfig(t *testing.T) *setting.Cfg
- func StartAndReturnPlugin(mg plugins.SecretsPluginManager, ctx context.Context) (smp.SecretsManagerPlugin, error)
- type CachedKVStore
- func (kv *CachedKVStore) Del(ctx context.Context, orgId int64, namespace string, typ string) error
- func (kv *CachedKVStore) Get(ctx context.Context, orgId int64, namespace string, typ string) (string, bool, error)
- func (kv *CachedKVStore) GetAll(ctx context.Context) ([]Item, error)
- func (kv *CachedKVStore) Keys(ctx context.Context, orgId int64, namespace string, typ string) ([]Key, error)
- func (kv *CachedKVStore) Rename(ctx context.Context, orgId int64, namespace string, typ string, ...) error
- func (kv *CachedKVStore) Set(ctx context.Context, orgId int64, namespace string, typ string, value string) error
- type FakeSecretsKVStore
- func (f *FakeSecretsKVStore) Del(ctx context.Context, orgId int64, namespace string, typ string) error
- func (f *FakeSecretsKVStore) DeletionError(shouldErr bool)
- func (f *FakeSecretsKVStore) Fallback() SecretsKVStore
- func (f *FakeSecretsKVStore) Get(ctx context.Context, orgId int64, namespace string, typ string) (string, bool, error)
- func (f *FakeSecretsKVStore) GetAll(ctx context.Context) ([]Item, error)
- func (f *FakeSecretsKVStore) Keys(ctx context.Context, orgId int64, namespace string, typ string) ([]Key, error)
- func (f *FakeSecretsKVStore) Rename(ctx context.Context, orgId int64, namespace string, typ string, ...) error
- func (f *FakeSecretsKVStore) Set(ctx context.Context, orgId int64, namespace string, typ string, value string) error
- func (f *FakeSecretsKVStore) SetFallback(store SecretsKVStore) error
- type FixedKVStore
- func (kv *FixedKVStore) Del(ctx context.Context) error
- func (kv *FixedKVStore) Get(ctx context.Context) (string, bool, error)
- func (kv *FixedKVStore) Keys(ctx context.Context) ([]Key, error)
- func (kv *FixedKVStore) Rename(ctx context.Context, newNamespace string) error
- func (kv *FixedKVStore) Set(ctx context.Context, value string) error
- type Item
- type Key
- type SecretsKVStore
- type SecretsKVStorePlugin
- func (kv *SecretsKVStorePlugin) Del(ctx context.Context, orgId int64, namespace string, typ string) error
- func (kv *SecretsKVStorePlugin) Fallback() SecretsKVStore
- func (kv *SecretsKVStorePlugin) Get(ctx context.Context, orgId int64, namespace string, typ string) (string, bool, error)
- func (kv *SecretsKVStorePlugin) GetAll(ctx context.Context) ([]Item, error)
- func (kv *SecretsKVStorePlugin) Keys(ctx context.Context, orgId int64, namespace string, typ string) ([]Key, error)
- func (kv *SecretsKVStorePlugin) Rename(ctx context.Context, orgId int64, namespace string, typ string, ...) error
- func (kv *SecretsKVStorePlugin) Set(ctx context.Context, orgId int64, namespace string, typ string, value string) error
- func (kv *SecretsKVStorePlugin) WithFallbackEnabled(fn func() error) error
- type SecretsKVStoreSQL
- func (kv *SecretsKVStoreSQL) Del(ctx context.Context, orgId int64, namespace string, typ string) error
- func (kv *SecretsKVStoreSQL) Get(ctx context.Context, orgId int64, namespace string, typ string) (string, bool, error)
- func (kv *SecretsKVStoreSQL) GetAll(ctx context.Context) ([]Item, error)
- func (kv *SecretsKVStoreSQL) Keys(ctx context.Context, orgId int64, namespace string, typ string) ([]Key, error)
- func (kv *SecretsKVStoreSQL) Rename(ctx context.Context, orgId int64, namespace string, typ string, ...) error
- func (kv *SecretsKVStoreSQL) Set(ctx context.Context, orgId int64, namespace string, typ string, value string) error
Constants ¶
const ( QuitOnPluginStartupFailureKey = "quit_on_secrets_plugin_startup_failure" PluginNamespace = "secretsmanagerplugin" DataSourceSecretType = "datasource" )
const (
// Wildcard to query all organizations
AllOrganizations = -1
)
Variables ¶
This section is empty.
Functions ¶
func GetNamespacedKVStore ¶
func GetNamespacedKVStore(kv kvstore.KVStore) *kvstore.NamespacedKVStore
func HasPluginStarted ¶
func HasPluginStarted(ctx context.Context, mg plugins.SecretsPluginManager) bool
func NewFakeFeatureToggles ¶
func NewFakeFeatureToggles(t *testing.T, returnValue bool) featuremgmt.FeatureToggles
func NewFakeSecretsPluginManager ¶
func NewFakeSecretsPluginManager(t *testing.T, shouldFailOnStart bool) plugins.SecretsPluginManager
func ReplaceFallback ¶
func ReplaceFallback(t *testing.T, kv SecretsKVStore, fb SecretsKVStore) error
func ResetPlugin ¶
func ResetPlugin()
func SetupFatalCrashTest ¶
func StartAndReturnPlugin ¶
func StartAndReturnPlugin(mg plugins.SecretsPluginManager, ctx context.Context) (smp.SecretsManagerPlugin, error)
Types ¶
type CachedKVStore ¶
type CachedKVStore struct {
// contains filtered or unexported fields
}
func WithCache ¶
func WithCache(store SecretsKVStore, defaultExpiration time.Duration, cleanupInterval time.Duration) *CachedKVStore
type FakeSecretsKVStore ¶
type FakeSecretsKVStore struct {
// contains filtered or unexported fields
}
In memory kv store used for testing
func NewFakeSecretsKVStore ¶
func NewFakeSecretsKVStore() *FakeSecretsKVStore
func (*FakeSecretsKVStore) DeletionError ¶
func (f *FakeSecretsKVStore) DeletionError(shouldErr bool)
func (*FakeSecretsKVStore) Fallback ¶
func (f *FakeSecretsKVStore) Fallback() SecretsKVStore
func (*FakeSecretsKVStore) GetAll ¶
func (f *FakeSecretsKVStore) GetAll(ctx context.Context) ([]Item, error)
func (*FakeSecretsKVStore) Keys ¶
func (f *FakeSecretsKVStore) Keys(ctx context.Context, orgId int64, namespace string, typ string) ([]Key, error)
List all keys with an optional filter. If default values are provided, filter is not applied.
func (*FakeSecretsKVStore) SetFallback ¶
func (f *FakeSecretsKVStore) SetFallback(store SecretsKVStore) error
type FixedKVStore ¶
type FixedKVStore struct { OrgId int64 Namespace string Type string // contains filtered or unexported fields }
FixedKVStore is a SecretsKVStore wrapper with fixed orgId, namespace and type.
func With ¶
func With(kv SecretsKVStore, orgId int64, namespace string, typ string) *FixedKVStore
WithType returns a kvstore wrapper with fixed orgId and type.
type Item ¶
type Item struct { Id int64 OrgId *int64 Namespace *string Type *string Value string Created time.Time Updated time.Time }
Item stored in k/v store.
type SecretsKVStore ¶
type SecretsKVStore interface { Get(ctx context.Context, orgId int64, namespace string, typ string) (string, bool, error) Set(ctx context.Context, orgId int64, namespace string, typ string, value string) error Del(ctx context.Context, orgId int64, namespace string, typ string) error Keys(ctx context.Context, orgId int64, namespace string, typ string) ([]Key, error) Rename(ctx context.Context, orgId int64, namespace string, typ string, newNamespace string) error GetAll(ctx context.Context) ([]Item, error) }
SecretsKVStore is an interface for k/v store.
func GetUnwrappedStoreFromCache ¶
func GetUnwrappedStoreFromCache(kv SecretsKVStore) (SecretsKVStore, error)
func ProvideService ¶
func ProvideService( sqlStore sqlstore.Store, secretsService secrets.Service, pluginsManager plugins.SecretsPluginManager, kvstore kvstore.KVStore, features featuremgmt.FeatureToggles, cfg *setting.Cfg, ) (SecretsKVStore, error)
type SecretsKVStorePlugin ¶
SecretsKVStorePlugin provides a key/value store backed by the Grafana plugin gRPC interface
func NewFakePluginSecretsKVStore ¶
func NewFakePluginSecretsKVStore(t *testing.T, features featuremgmt.FeatureToggles, fallback SecretsKVStore) *SecretsKVStorePlugin
func NewPluginSecretsKVStore ¶
func NewPluginSecretsKVStore( secretsPlugin smp.SecretsManagerPlugin, secretsService secrets.Service, kvstore *kvstore.NamespacedKVStore, features featuremgmt.FeatureToggles, fallback SecretsKVStore, logger log.Logger, ) *SecretsKVStorePlugin
func (*SecretsKVStorePlugin) Del ¶
func (kv *SecretsKVStorePlugin) Del(ctx context.Context, orgId int64, namespace string, typ string) error
Del deletes an item from the store.
func (*SecretsKVStorePlugin) Fallback ¶
func (kv *SecretsKVStorePlugin) Fallback() SecretsKVStore
func (*SecretsKVStorePlugin) Get ¶
func (kv *SecretsKVStorePlugin) Get(ctx context.Context, orgId int64, namespace string, typ string) (string, bool, error)
Get an item from the store If it is the first time a secret has been retrieved and backwards compatibility is disabled, mark plugin startup errors fatal
func (*SecretsKVStorePlugin) GetAll ¶
func (kv *SecretsKVStorePlugin) GetAll(ctx context.Context) ([]Item, error)
func (*SecretsKVStorePlugin) Keys ¶
func (kv *SecretsKVStorePlugin) Keys(ctx context.Context, orgId int64, namespace string, typ string) ([]Key, error)
Keys get all keys for a given namespace. To query for all organizations the constant 'kvstore.AllOrganizations' can be passed as orgId.
func (*SecretsKVStorePlugin) Rename ¶
func (kv *SecretsKVStorePlugin) Rename(ctx context.Context, orgId int64, namespace string, typ string, newNamespace string) error
Rename an item in the store
func (*SecretsKVStorePlugin) Set ¶
func (kv *SecretsKVStorePlugin) Set(ctx context.Context, orgId int64, namespace string, typ string, value string) error
Set an item in the store If it is the first time a secret has been set and backwards compatibility is disabled, mark plugin startup errors fatal
func (*SecretsKVStorePlugin) WithFallbackEnabled ¶
func (kv *SecretsKVStorePlugin) WithFallbackEnabled(fn func() error) error
type SecretsKVStoreSQL ¶
type SecretsKVStoreSQL struct {
// contains filtered or unexported fields
}
SecretsKVStoreSQL provides a key/value store backed by the Grafana database
func NewFakeSQLSecretsKVStore ¶
func NewFakeSQLSecretsKVStore(t *testing.T) *SecretsKVStoreSQL
func NewSQLSecretsKVStore ¶
func (*SecretsKVStoreSQL) Del ¶
func (kv *SecretsKVStoreSQL) Del(ctx context.Context, orgId int64, namespace string, typ string) error
Del deletes an item from the store.
func (*SecretsKVStoreSQL) Get ¶
func (kv *SecretsKVStoreSQL) Get(ctx context.Context, orgId int64, namespace string, typ string) (string, bool, error)
Get an item from the store
func (*SecretsKVStoreSQL) GetAll ¶
func (kv *SecretsKVStoreSQL) GetAll(ctx context.Context) ([]Item, error)
GetAll this returns all the secrets stored in the database. This is not part of the kvstore interface as we only need it for migration from sql to plugin at this moment
func (*SecretsKVStoreSQL) Keys ¶
func (kv *SecretsKVStoreSQL) Keys(ctx context.Context, orgId int64, namespace string, typ string) ([]Key, error)
Keys get all keys for a given namespace. To query for all organizations the constant 'kvstore.AllOrganizations' can be passed as orgId.