Update go-toml to v2
Updates host file parsing to use new v2 method rather than the removed toml.Tree. Signed-off-by: Derek McGowan <derek@mcg.dev>
This commit is contained in:
@@ -18,7 +18,6 @@ package command
|
||||
|
||||
import (
|
||||
gocontext "context"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
@@ -28,28 +27,12 @@ import (
|
||||
"github.com/containerd/containerd/services/server"
|
||||
srvconfig "github.com/containerd/containerd/services/server/config"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"github.com/pelletier/go-toml"
|
||||
"github.com/pelletier/go-toml/v2"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
// Config is a wrapper of server config for printing out.
|
||||
type Config struct {
|
||||
*srvconfig.Config
|
||||
// Plugins overrides `Plugins map[string]toml.Tree` in server config.
|
||||
Plugins map[string]interface{} `toml:"plugins"`
|
||||
}
|
||||
|
||||
// WriteTo marshals the config to the provided writer
|
||||
func (c *Config) WriteTo(w io.Writer) (int64, error) {
|
||||
return 0, toml.NewEncoder(w).Encode(c)
|
||||
}
|
||||
|
||||
func outputConfig(cfg *srvconfig.Config) error {
|
||||
config := &Config{
|
||||
Config: cfg,
|
||||
}
|
||||
|
||||
plugins, err := server.LoadPlugins(gocontext.Background(), config.Config)
|
||||
func outputConfig(config *srvconfig.Config) error {
|
||||
plugins, err := server.LoadPlugins(gocontext.Background(), config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -83,13 +66,9 @@ func outputConfig(cfg *srvconfig.Config) error {
|
||||
// when a config without a version is loaded from disk and has no version
|
||||
// set, we assume it's a v1 config. But when generating new configs via
|
||||
// this command, generate the v2 config
|
||||
config.Config.Version = 2
|
||||
config.Version = 2
|
||||
|
||||
// remove overridden Plugins type to avoid duplication in output
|
||||
config.Config.Plugins = nil
|
||||
|
||||
_, err = config.WriteTo(os.Stdout)
|
||||
return err
|
||||
return toml.NewEncoder(os.Stdout).Encode(config)
|
||||
}
|
||||
|
||||
func defaultConfig() *srvconfig.Config {
|
||||
|
||||
Reference in New Issue
Block a user