Secrets: Make the Migrator extensible (#67307)
* [Chore] Remove setting provider from secret service Co-authored-by: Tania B <yalyna.ts@gmail.com> Co-authored-by: Joan López de la Franca Beltran <joanjan14@gmail.com> * Add a ShouldBeRedacted func Co-authored-by: Tania B <yalyna.ts@gmail.com> Co-authored-by: Joan López de la Franca Beltran <joanjan14@gmail.com> * Secrets: Make Migrator extensible Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com> Co-authored-by: Tania B <yalyna.ts@gmail.com> * Alerting: Fix tests after refactor Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com> Co-authored-by: Tania B <yalyna.ts@gmail.com> * Remove commented code no longer used * Fix Wire bindings Co-authored-by: Tania B <yalyna.ts@gmail.com> * Add constructors to secrets * Linting * Undo undesired change --------- Co-authored-by: gamab <gabi.mabs@gmail.com> Co-authored-by: Tania B <yalyna.ts@gmail.com> Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
This commit is contained in:
co-authored by
Tania B
Joan López de la Franca Beltran
Gabriel MABILLE
gamab
parent
a50afe67d3
commit
cc65b4d46a
@@ -9,23 +9,23 @@ import (
|
||||
)
|
||||
|
||||
type grafanaProvider struct {
|
||||
settings setting.Provider
|
||||
cfg *setting.Cfg
|
||||
encryption encryption.Internal
|
||||
}
|
||||
|
||||
func New(settings setting.Provider, encryption encryption.Internal) secrets.Provider {
|
||||
func New(cfg *setting.Cfg, encryption encryption.Internal) secrets.Provider {
|
||||
return grafanaProvider{
|
||||
settings: settings,
|
||||
cfg: cfg,
|
||||
encryption: encryption,
|
||||
}
|
||||
}
|
||||
|
||||
func (p grafanaProvider) Encrypt(ctx context.Context, blob []byte) ([]byte, error) {
|
||||
key := p.settings.KeyValue("security", "secret_key").Value()
|
||||
key := p.cfg.SectionWithEnvOverrides("security").Key("secret_key").Value()
|
||||
return p.encryption.Encrypt(ctx, blob, key)
|
||||
}
|
||||
|
||||
func (p grafanaProvider) Decrypt(ctx context.Context, blob []byte) ([]byte, error) {
|
||||
key := p.settings.KeyValue("security", "secret_key").Value()
|
||||
key := p.cfg.SectionWithEnvOverrides("security").Key("secret_key").Value()
|
||||
return p.encryption.Decrypt(ctx, blob, key)
|
||||
}
|
||||
|
||||
@@ -11,20 +11,20 @@ import (
|
||||
|
||||
type Service struct {
|
||||
enc encryption.Internal
|
||||
settings setting.Provider
|
||||
cfg *setting.Cfg
|
||||
features featuremgmt.FeatureToggles
|
||||
}
|
||||
|
||||
func ProvideService(enc encryption.Internal, settings setting.Provider, features featuremgmt.FeatureToggles) Service {
|
||||
func ProvideService(enc encryption.Internal, cfg *setting.Cfg, features featuremgmt.FeatureToggles) Service {
|
||||
return Service{
|
||||
enc: enc,
|
||||
settings: settings,
|
||||
cfg: cfg,
|
||||
features: features,
|
||||
}
|
||||
}
|
||||
|
||||
func (s Service) Provide() (map[secrets.ProviderID]secrets.Provider, error) {
|
||||
return map[secrets.ProviderID]secrets.Provider{
|
||||
kmsproviders.Default: grafana.New(s.settings, s.enc),
|
||||
kmsproviders.Default: grafana.New(s.cfg, s.enc),
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user