IPAM plugin: improve error messages
Make it more clear that we failed to find an IPAM plugin. Check for a missing plugin name and issue a more helpful error.
This commit is contained in:
@ -63,10 +63,13 @@ func ExecAdd(plugin string, netconf []byte) (*Result, error) {
|
|||||||
if os.Getenv("CNI_COMMAND") != "ADD" {
|
if os.Getenv("CNI_COMMAND") != "ADD" {
|
||||||
return nil, fmt.Errorf("CNI_COMMAND is not ADD")
|
return nil, fmt.Errorf("CNI_COMMAND is not ADD")
|
||||||
}
|
}
|
||||||
|
if plugin == "" {
|
||||||
|
return nil, fmt.Errorf(`Name of IPAM plugin is missing. Specify a "type" field in the "ipam" section`)
|
||||||
|
}
|
||||||
|
|
||||||
pluginPath := Find(plugin)
|
pluginPath := Find(plugin)
|
||||||
if pluginPath == "" {
|
if pluginPath == "" {
|
||||||
return nil, fmt.Errorf("could not find %q plugin", plugin)
|
return nil, fmt.Errorf("could not find %q IPAM plugin", plugin)
|
||||||
}
|
}
|
||||||
|
|
||||||
stdout := &bytes.Buffer{}
|
stdout := &bytes.Buffer{}
|
||||||
|
Reference in New Issue
Block a user