From 39b5f90b18c9a862342477505518ac79345683c3 Mon Sep 17 00:00:00 2001 From: yanxuean Date: Thu, 7 Sep 2017 15:55:48 +0800 Subject: [PATCH] Improve server.LoadConfig function Cann't use the new created config in server.LoadConfig When arg v is nil fix #1483 Signed-off-by: yanxuean --- server/config.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/config.go b/server/config.go index 02659b669..40b8cbc3c 100644 --- a/server/config.go +++ b/server/config.go @@ -5,6 +5,8 @@ import ( "io" "github.com/BurntSushi/toml" + "github.com/containerd/containerd/errdefs" + "github.com/pkg/errors" ) // Config provides containerd configuration data for the server @@ -69,7 +71,7 @@ func (c *Config) WriteTo(w io.Writer) (int64, error) { // LoadConfig loads the containerd server config from the provided path func LoadConfig(path string, v *Config) error { if v == nil { - v = &Config{} + return errors.Wrapf(errdefs.ErrInvalidArgument, "argument v must not be nil") } md, err := toml.DecodeFile(path, v) if err != nil {