From b5db5d3075b5e65bfa9bcb72ffd9a39218f3b9f8 Mon Sep 17 00:00:00 2001 From: Neil Wilson Date: Mon, 7 Sep 2015 15:15:23 +0000 Subject: [PATCH] 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. --- plugin/ipam.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugin/ipam.go b/plugin/ipam.go index 93a0d5c9..8690b895 100644 --- a/plugin/ipam.go +++ b/plugin/ipam.go @@ -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{}