invoke: correctly infer version for 0.1.0-vintage plugins

Older plugins return a known error when issued the VERSION command.
Capture this error and report it as a 0.1.0 version plugin.
This commit is contained in:
Gabe Rosenhouse
2016-09-02 16:01:22 -04:00
parent 2142c076ab
commit f467134838
3 changed files with 84 additions and 2 deletions

View File

@ -65,9 +65,19 @@ func (e *PluginExec) WithoutResult(pluginPath string, netconf []byte, args CNIAr
}
func (e *PluginExec) GetVersion(pluginPath string) (version.PluginInfo, error) {
args := &Args{Command: "VERSION"}
args := &Args{
Command: "VERSION",
// set fake values required by plugins built against an older version of skel
NetNS: "/tmp/not/a/container",
IfName: "not-an-interface",
Path: "/tmp/not/a/path",
}
stdoutBytes, err := e.RawExec.ExecPlugin(pluginPath, nil, args.AsEnv())
if err != nil {
if err.Error() == "unknown CNI_COMMAND: VERSION" {
return version.PluginSupports("0.1.0"), nil
}
return nil, err
}