Switch all our tests to version 2
Also warn when someone uses version 1 Signed-off-by: Davanum Srinivas <davanum@gmail.com>
This commit is contained in:
@@ -23,6 +23,7 @@ import (
|
||||
"github.com/imdario/mergo"
|
||||
"github.com/pelletier/go-toml"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/containerd/plugin"
|
||||
@@ -94,8 +95,9 @@ func (c *Config) GetVersion() int {
|
||||
|
||||
// ValidateV2 validates the config for a v2 file
|
||||
func (c *Config) ValidateV2() error {
|
||||
if c.GetVersion() != 2 {
|
||||
return nil
|
||||
version := c.GetVersion()
|
||||
if version < 2 {
|
||||
logrus.Warnf("deprecated version : `%d`, please switch to version `2`", version)
|
||||
}
|
||||
for _, p := range c.DisabledPlugins {
|
||||
if len(strings.Split(p, ".")) < 4 {
|
||||
@@ -258,7 +260,11 @@ func LoadConfig(path string, out *Config) error {
|
||||
out.Imports = append(out.Imports, path)
|
||||
}
|
||||
|
||||
return out.ValidateV2()
|
||||
err := out.ValidateV2()
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to load TOML from %s", path)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// loadConfigFile decodes a TOML file at the given path
|
||||
|
@@ -185,8 +185,8 @@ imports = ["data1.toml", "data2.toml"]
|
||||
|
||||
func TestDecodePlugin(t *testing.T) {
|
||||
data := `
|
||||
version = 1
|
||||
[plugins.linux]
|
||||
version = 2
|
||||
[plugins."io.containerd.runtime.v1.linux"]
|
||||
shim_debug = true
|
||||
`
|
||||
|
||||
@@ -203,7 +203,7 @@ version = 1
|
||||
assert.NilError(t, err)
|
||||
|
||||
pluginConfig := map[string]interface{}{}
|
||||
_, err = out.Decode(&plugin.Registration{ID: "linux", Config: &pluginConfig})
|
||||
_, err = out.Decode(&plugin.Registration{Type: "io.containerd.runtime.v1", ID: "linux", Config: &pluginConfig})
|
||||
assert.NilError(t, err)
|
||||
assert.Equal(t, true, pluginConfig["shim_debug"])
|
||||
}
|
||||
|
Reference in New Issue
Block a user