From eb9925d88cb2aa1dae87074c9b5fe10b6f07afac Mon Sep 17 00:00:00 2001 From: Derek McGowan Date: Fri, 29 Dec 2023 11:36:08 -0800 Subject: [PATCH] Update config migrations to decode using the plugin type Ensure migration picks up defaults and correct ordering from the plugin configuration. Ensures that the migration matches the behavior of the default output and how the configuration will be loaded. Signed-off-by: Derek McGowan --- cmd/containerd/command/config.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/cmd/containerd/command/config.go b/cmd/containerd/command/config.go index 0e08f5afa..84e418e95 100644 --- a/cmd/containerd/command/config.go +++ b/cmd/containerd/command/config.go @@ -123,6 +123,28 @@ var configCommand = cli.Command{ } } + plugins, err := server.LoadPlugins(ctx, config) + if err != nil { + return err + } + if len(plugins) != 0 { + if config.Plugins == nil { + config.Plugins = make(map[string]interface{}) + } + for _, p := range plugins { + if p.Config == nil { + continue + } + + pc, err := config.Decode(ctx, p.URI(), p.Config) + if err != nil { + return err + } + + config.Plugins[p.URI()] = pc + } + } + config.Version = srvconfig.CurrentConfigVersion return toml.NewEncoder(os.Stdout).SetIndentTables(true).Encode(config)