mirror of
https://github.com/kubernetes/client-go.git
synced 2025-09-13 13:52:01 +00:00
refactor(event): simplify conditional logic in event handling for both v1 and eventsv1 APIs
Signed-off-by: yshngg <yshngg@outlook.com> Kubernetes-commit: 7685612b9c24c3129e0e17a6f6874b5902de02a1
This commit is contained in:
committed by
Kubernetes Publisher
parent
81eaeec477
commit
dc29e94395
@@ -240,7 +240,7 @@ func recordEvent(ctx context.Context, sink EventSink, event *eventsv1.Event) (*e
|
||||
newEvent, err = sink.Patch(ctx, event, patch)
|
||||
}
|
||||
// Update can fail because the event may have been removed and it no longer exists.
|
||||
if !isEventSeries || (isEventSeries && util.IsKeyNotFoundError(err)) {
|
||||
if !isEventSeries || util.IsKeyNotFoundError(err) {
|
||||
// Making sure that ResourceVersion is empty on creation
|
||||
event.ResourceVersion = ""
|
||||
newEvent, err = sink.Create(ctx, event)
|
||||
|
@@ -334,7 +334,7 @@ func recordEvent(ctx context.Context, sink EventSink, event *v1.Event, patch []b
|
||||
newEvent, err = sink.Patch(event, patch)
|
||||
}
|
||||
// Update can fail because the event may have been removed and it no longer exists.
|
||||
if !updateExistingEvent || (updateExistingEvent && util.IsKeyNotFoundError(err)) {
|
||||
if !updateExistingEvent || util.IsKeyNotFoundError(err) {
|
||||
// Making sure that ResourceVersion is empty on creation
|
||||
event.ResourceVersion = ""
|
||||
newEvent, err = sink.Create(event)
|
||||
|
Reference in New Issue
Block a user