Add migrate subcommand to config command

Allows applying migration to existing configurations

Signed-off-by: Derek McGowan <derek@mcg.dev>
This commit is contained in:
Derek McGowan 2023-09-25 15:15:19 -07:00
parent 0320ad1843
commit 62f273d508
No known key found for this signature in database
GPG Key ID: F58C5D0A4405ACDB

View File

@ -33,12 +33,14 @@ import (
) )
func outputConfig(ctx gocontext.Context, config *srvconfig.Config) error { func outputConfig(ctx gocontext.Context, config *srvconfig.Config) error {
plugins, err := server.LoadPlugins(gocontext.Background(), config) plugins, err := server.LoadPlugins(ctx, config)
if err != nil { if err != nil {
return err return err
} }
if len(plugins) != 0 { if len(plugins) != 0 {
config.Plugins = make(map[string]interface{}) if config.Plugins == nil {
config.Plugins = make(map[string]interface{})
}
for _, p := range plugins { for _, p := range plugins {
if p.Config == nil { if p.Config == nil {
continue continue
@ -69,7 +71,7 @@ func outputConfig(ctx gocontext.Context, config *srvconfig.Config) error {
// this command, generate the max configuration version // this command, generate the max configuration version
config.Version = srvconfig.CurrentConfigVersion config.Version = srvconfig.CurrentConfigVersion
return toml.NewEncoder(os.Stdout).Encode(config) return toml.NewEncoder(os.Stdout).SetIndentTables(true).Encode(config)
} }
func defaultConfig() *srvconfig.Config { func defaultConfig() *srvconfig.Config {