bug fix: exec of DEL cmd caused JSON decode error

When plugin is executed with a DEL command, it does not
print result to stdout unless there is an error. Therefore
it stdout bytes should not be passed to json.Unmarshal.
This commit is contained in:
Eugene Yakubovich
2015-09-18 10:30:10 -07:00
parent cc918a1aea
commit 9ea56937d4
3 changed files with 26 additions and 16 deletions

View File

@ -29,15 +29,14 @@ func ExecAdd(plugin string, netconf []byte) (*types.Result, error) {
if os.Getenv("CNI_COMMAND") != "ADD" {
return nil, fmt.Errorf("CNI_COMMAND is not ADD")
}
return invoke.ExecPlugin(invoke.Find(plugin), netconf, invoke.ArgsFromEnv())
return invoke.ExecPluginWithResult(invoke.Find(plugin), netconf, invoke.ArgsFromEnv())
}
func ExecDel(plugin string, netconf []byte) error {
if os.Getenv("CNI_COMMAND") != "DEL" {
return fmt.Errorf("CNI_COMMAND is not DEL")
}
_, err := invoke.ExecPlugin(invoke.Find(plugin), netconf, invoke.ArgsFromEnv())
return err
return invoke.ExecPluginWithoutResult(invoke.Find(plugin), netconf, invoke.ArgsFromEnv())
}
// ConfigureIface takes the result of IPAM plugin and