mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
do not initialize copy's slice if nil in original
This commit is contained in:
@@ -1531,9 +1531,7 @@ func TestClientEndpoint_GetNode(t *testing.T) {
|
||||
node.StatusUpdatedAt = resp2.Node.StatusUpdatedAt
|
||||
node.SecretID = ""
|
||||
node.Events = resp2.Node.Events
|
||||
if !reflect.DeepEqual(node, resp2.Node) {
|
||||
t.Fatalf("bad: %#v \n %#v", node, resp2.Node)
|
||||
}
|
||||
require.Equal(t, node, resp2.Node)
|
||||
|
||||
// assert that the node register event was set correctly
|
||||
if len(resp2.Node.Events) != 1 {
|
||||
|
||||
@@ -3064,8 +3064,10 @@ type NodeCpuResources struct {
|
||||
|
||||
func (n NodeCpuResources) Copy() NodeCpuResources {
|
||||
newN := n
|
||||
newN.ReservableCpuCores = make([]uint16, len(n.ReservableCpuCores))
|
||||
copy(newN.ReservableCpuCores, n.ReservableCpuCores)
|
||||
if n.ReservableCpuCores != nil {
|
||||
newN.ReservableCpuCores = make([]uint16, len(n.ReservableCpuCores))
|
||||
copy(newN.ReservableCpuCores, n.ReservableCpuCores)
|
||||
}
|
||||
|
||||
return newN
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user