mirror of
https://github.com/rancher/types.git
synced 2025-04-27 18:25:05 +00:00
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
This commit is contained in:
parent
11394ace11
commit
2d275102b4
@ -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"),
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user