Better error message when plugin cannot be found
This commit is contained in:
@ -17,6 +17,7 @@ package ipam
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/appc/cni/pkg/invoke"
|
||||
"github.com/appc/cni/pkg/ip"
|
||||
@ -29,14 +30,30 @@ 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.ExecPluginWithResult(invoke.Find(plugin), netconf, invoke.ArgsFromEnv())
|
||||
|
||||
paths := strings.Split(os.Getenv("CNI_PATH"), ":")
|
||||
|
||||
pluginPath, err := invoke.FindInPath(plugin, paths)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return invoke.ExecPluginWithResult(pluginPath, netconf, invoke.ArgsFromEnv())
|
||||
}
|
||||
|
||||
func ExecDel(plugin string, netconf []byte) error {
|
||||
if os.Getenv("CNI_COMMAND") != "DEL" {
|
||||
return fmt.Errorf("CNI_COMMAND is not DEL")
|
||||
}
|
||||
return invoke.ExecPluginWithoutResult(invoke.Find(plugin), netconf, invoke.ArgsFromEnv())
|
||||
|
||||
paths := strings.Split(os.Getenv("CNI_PATH"), ":")
|
||||
|
||||
pluginPath, err := invoke.FindInPath(plugin, paths)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return invoke.ExecPluginWithoutResult(pluginPath, netconf, invoke.ArgsFromEnv())
|
||||
}
|
||||
|
||||
// ConfigureIface takes the result of IPAM plugin and
|
||||
|
Reference in New Issue
Block a user