Skip to content

Commit 5990a7d

Browse files
tedyuyutedz
authored andcommitted
Check namespaces match in UpdateWithEventNamespace
1 parent d8fd232 commit 5990a7d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

staging/src/k8s.io/client-go/kubernetes/typed/events/v1beta1/event_expansion.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ type EventExpansion interface {
3232
// UpdateWithEventNamespace is the same as a Update
3333
// except that it sends the request to the event.Namespace.
3434
UpdateWithEventNamespace(event *v1beta1.Event) (*v1beta1.Event, error)
35-
// PatchWithEventNamespace is the same as a Update
35+
// PatchWithEventNamespace is the same as an Update
3636
// except that it sends the request to the event.Namespace.
3737
PatchWithEventNamespace(event *v1beta1.Event, data []byte) (*v1beta1.Event, error)
3838
}
@@ -63,6 +63,9 @@ func (e *events) CreateWithEventNamespace(event *v1beta1.Event) (*v1beta1.Event,
6363
// created with the "" namespace.
6464
// Update also requires the ResourceVersion to be set in the event object.
6565
func (e *events) UpdateWithEventNamespace(event *v1beta1.Event) (*v1beta1.Event, error) {
66+
if e.ns != "" && event.Namespace != e.ns {
67+
return nil, fmt.Errorf("can't update an event with namespace '%v' in namespace '%v'", event.Namespace, e.ns)
68+
}
6669
result := &v1beta1.Event{}
6770
err := e.client.Put().
6871
NamespaceIfScoped(event.Namespace, len(event.Namespace) > 0).

0 commit comments

Comments
 (0)