IPAM plugin: improve error messages
authorNeil Wilson <neil@aldur.co.uk>
Mon, 7 Sep 2015 15:15:23 +0000 (15:15 +0000)
committerNeil Wilson <neil@aldur.co.uk>
Tue, 8 Sep 2015 18:08:15 +0000 (18:08 +0000)
Make it more clear that we failed to find an IPAM plugin.
Check for a missing plugin name and issue a more helpful error.

plugin/ipam.go

index 93a0d5c..8690b89 100644 (file)
@@ -63,10 +63,13 @@ func ExecAdd(plugin string, netconf []byte) (*Result, error) {
        if os.Getenv("CNI_COMMAND") != "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)
        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{}