Add config migration and bump config version

Allows plugins to migrate from older configurations

Signed-off-by: Derek McGowan <derek@mcg.dev>
This commit is contained in:
Derek McGowan
2023-09-25 14:42:17 -07:00
parent bcd658c76c
commit f58158e2d3
4 changed files with 152 additions and 16 deletions

View File

@@ -202,6 +202,16 @@ func New(ctx context.Context, config *srvconfig.Config) (*Server, error) {
required[r] = struct{}{}
}
if config.Version < srvconfig.CurrentConfigVersion {
for _, p := range plugins {
if p.ConfigMigration != nil {
if err := p.ConfigMigration(ctx, config.Version, 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)