mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 20:24:09 +00:00
Check namespaces match in UpdateWithEventNamespace
This commit is contained in:
parent
d8fd232ea1
commit
5990a7d507
@ -32,7 +32,7 @@ type EventExpansion interface {
|
|||||||
// UpdateWithEventNamespace is the same as a Update
|
// UpdateWithEventNamespace is the same as a Update
|
||||||
// except that it sends the request to the event.Namespace.
|
// except that it sends the request to the event.Namespace.
|
||||||
UpdateWithEventNamespace(event *v1beta1.Event) (*v1beta1.Event, error)
|
UpdateWithEventNamespace(event *v1beta1.Event) (*v1beta1.Event, error)
|
||||||
// PatchWithEventNamespace is the same as a Update
|
// PatchWithEventNamespace is the same as an Update
|
||||||
// except that it sends the request to the event.Namespace.
|
// except that it sends the request to the event.Namespace.
|
||||||
PatchWithEventNamespace(event *v1beta1.Event, data []byte) (*v1beta1.Event, error)
|
PatchWithEventNamespace(event *v1beta1.Event, data []byte) (*v1beta1.Event, error)
|
||||||
}
|
}
|
||||||
@ -63,6 +63,9 @@ func (e *events) CreateWithEventNamespace(event *v1beta1.Event) (*v1beta1.Event,
|
|||||||
// created with the "" namespace.
|
// created with the "" namespace.
|
||||||
// Update also requires the ResourceVersion to be set in the event object.
|
// Update also requires the ResourceVersion to be set in the event object.
|
||||||
func (e *events) UpdateWithEventNamespace(event *v1beta1.Event) (*v1beta1.Event, error) {
|
func (e *events) UpdateWithEventNamespace(event *v1beta1.Event) (*v1beta1.Event, error) {
|
||||||
|
if e.ns != "" && event.Namespace != e.ns {
|
||||||
|
return nil, fmt.Errorf("can't update an event with namespace '%v' in namespace '%v'", event.Namespace, e.ns)
|
||||||
|
}
|
||||||
result := &v1beta1.Event{}
|
result := &v1beta1.Event{}
|
||||||
err := e.client.Put().
|
err := e.client.Put().
|
||||||
NamespaceIfScoped(event.Namespace, len(event.Namespace) > 0).
|
NamespaceIfScoped(event.Namespace, len(event.Namespace) > 0).
|
||||||
|
Loading…
Reference in New Issue
Block a user