From 1003822e53265326f3edde1c74ac2714fe8b4855 Mon Sep 17 00:00:00 2001 From: Tang Le Date: Thu, 2 Mar 2017 10:25:19 +0800 Subject: [PATCH] Check n.IPAM before use it in LoadIPAMConfig function Signed-off-by: Tang Le --- plugins/ipam/host-local/backend/allocator/config.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/ipam/host-local/backend/allocator/config.go b/plugins/ipam/host-local/backend/allocator/config.go index d261d0f0..8c004489 100644 --- a/plugins/ipam/host-local/backend/allocator/config.go +++ b/plugins/ipam/host-local/backend/allocator/config.go @@ -54,6 +54,10 @@ func LoadIPAMConfig(bytes []byte, args string) (*IPAMConfig, string, error) { return nil, "", err } + if n.IPAM == nil { + return nil, "", fmt.Errorf("IPAM config missing 'ipam' key") + } + if args != "" { n.IPAM.Args = &IPAMArgs{} err := types.LoadArgs(args, n.IPAM.Args) @@ -62,10 +66,6 @@ func LoadIPAMConfig(bytes []byte, args string) (*IPAMConfig, string, error) { } } - if n.IPAM == nil { - return nil, "", fmt.Errorf("IPAM config missing 'ipam' key") - } - // Copy net name into IPAM so not to drag Net struct around n.IPAM.Name = n.Name