From 2d275102b46ee04b46fec7faf0fc978b2edfb426 Mon Sep 17 00:00:00 2001 From: Yuki Nishiwaki Date: Tue, 31 Jul 2018 21:40:45 +0900 Subject: [PATCH] Check data is nil before executing mapping in os_info This os_info mapper is used for v1.NodeStatus but there is some case that mapper is evaluated when v1.NodeStatus is nil. For example, when the user try to create v3.Node by calling API(POST /v3/nodes). So we should check data is nil or not before executing mapper in order to prevent from trying to use data(nil) as map inside OSInfo.FromInternal --- mapper/os_info.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mapper/os_info.go b/mapper/os_info.go index 7e53c633..fd998f14 100644 --- a/mapper/os_info.go +++ b/mapper/os_info.go @@ -12,6 +12,9 @@ type OSInfo struct { } func (o OSInfo) FromInternal(data map[string]interface{}) { + if data == nil { + return + } cpuInfo := map[string]interface{}{ "count": values.GetValueN(data, "capacity", "cpu"), }