Merge pull request #9141 from dmcgowan/config-migration

Add support for plugin config migration
This commit is contained in:
Akihiro Suda
2023-10-05 10:51:34 -07:00
committed by GitHub
5 changed files with 177 additions and 19 deletions

View File

@@ -203,6 +203,19 @@ func New(ctx context.Context, config *srvconfig.Config) (*Server, error) {
required[r] = struct{}{}
}
// Run migration for each configuration version
// Run each plugin migration for each version to ensure that migration logic is simple and
// focused on upgrading from one version at a time.
for v := config.Version; v < srvconfig.CurrentConfigVersion; v++ {
for _, p := range plugins {
if p.ConfigMigration != nil {
if err := p.ConfigMigration(ctx, v, config.Plugins); err != nil {
return nil, err
}
}
}
}
for _, p := range plugins {
id := p.URI()
log.G(ctx).WithField("type", p.Type).Infof("loading plugin %q...", id)