Merge pull request #78482 from tedyu/evt-expansion

Check namespaces match in UpdateWithEventNamespace
This commit is contained in:
Kubernetes Prow Robot 2019-05-30 04:55:14 -07:00 committed by GitHub
commit b3981a2f9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -32,7 +32,7 @@ type EventExpansion interface {
// UpdateWithEventNamespace is the same as a Update
// except that it sends the request to the event.Namespace.
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.
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.
// Update also requires the ResourceVersion to be set in the event object.
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{}
err := e.client.Put().
NamespaceIfScoped(event.Namespace, len(event.Namespace) > 0).