Check events against nil

Signed-off-by: Ted Yu <yuzhihong@gmail.com>
This commit is contained in:
Ted Yu 2020-05-22 13:35:25 -07:00
parent 4c9571d909
commit df57a68b47

View File

@ -97,13 +97,15 @@ func (s *v2v3Store) mkV2Events(wr clientv3.WatchResponse) (evs []*v2store.Event)
key = ev key = ev
} }
} }
v2ev := &v2store.Event{ if act != nil && act.Kv != nil && key != nil {
Action: string(act.Kv.Value), v2ev := &v2store.Event{
Node: s.mkV2Node(key.Kv), Action: string(act.Kv.Value),
PrevNode: s.mkV2Node(key.PrevKv), Node: s.mkV2Node(key.Kv),
EtcdIndex: mkV2Rev(wr.Header.Revision), PrevNode: s.mkV2Node(key.PrevKv),
EtcdIndex: mkV2Rev(wr.Header.Revision),
}
evs = append(evs, v2ev)
} }
evs = append(evs, v2ev)
} }
return evs return evs
} }