|
|
|
@ -41,6 +41,7 @@ func (s *PluginSecretMigrationService) Migrate(ctx context.Context) error { |
|
|
|
|
// Check if we should migrate to plugin - default false
|
|
|
|
|
if s.cfg.SectionWithEnvOverrides("secrets").Key("migrate_to_plugin").MustBool(false) && |
|
|
|
|
s.remoteCheck.ShouldUseRemoteSecretsPlugin() { |
|
|
|
|
s.logger.Debug("starting migration of unified secrets to the plugin") |
|
|
|
|
// we need to instantiate the secretsKVStore as this is not on wire, and in this scenario,
|
|
|
|
|
// the secrets store would be the plugin.
|
|
|
|
|
secretsSql := &secretsKVStoreSQL{ |
|
|
|
@ -63,6 +64,7 @@ func (s *PluginSecretMigrationService) Migrate(ctx context.Context) error { |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
s.logger.Debug("migrated unified secrets to plugin", "number of secrets", len(allSec)) |
|
|
|
|
// as no err was returned, when we delete all the secrets from the sql store
|
|
|
|
|
for _, sec := range allSec { |
|
|
|
|
err = secretsSql.Del(ctx, *sec.OrgId, *sec.Namespace, *sec.Type) |
|
|
|
@ -70,6 +72,7 @@ func (s *PluginSecretMigrationService) Migrate(ctx context.Context) error { |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
s.logger.Debug("deleted unified secrets after migration", "number of secrets", len(allSec)) |
|
|
|
|
} |
|
|
|
|
return nil |
|
|
|
|
} |
|
|
|
|