mirror of
https://github.com/kubernetes/client-go.git
synced 2025-06-25 06:31:35 +00:00
GIT-110335: address namespace defaulting for events
Kubernetes-commit: 85e74aa3122114ac7e82c3044f387d03661063e4
This commit is contained in:
parent
c6bd30b9ec
commit
e2ef40870b
@ -17,7 +17,7 @@ limitations under the License.
|
|||||||
package fake
|
package fake
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/fields"
|
"k8s.io/apimachinery/pkg/fields"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
@ -26,9 +26,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (c *FakeEvents) CreateWithEventNamespace(event *v1.Event) (*v1.Event, error) {
|
func (c *FakeEvents) CreateWithEventNamespace(event *v1.Event) (*v1.Event, error) {
|
||||||
action := core.NewRootCreateAction(eventsResource, event)
|
var action core.CreateActionImpl
|
||||||
if c.ns != "" {
|
if c.ns != "" {
|
||||||
action = core.NewCreateAction(eventsResource, c.ns, event)
|
action = core.NewCreateAction(eventsResource, c.ns, event)
|
||||||
|
} else {
|
||||||
|
action = core.NewCreateAction(eventsResource, event.GetNamespace(), event)
|
||||||
}
|
}
|
||||||
obj, err := c.Fake.Invokes(action, event)
|
obj, err := c.Fake.Invokes(action, event)
|
||||||
if obj == nil {
|
if obj == nil {
|
||||||
@ -40,9 +42,11 @@ func (c *FakeEvents) CreateWithEventNamespace(event *v1.Event) (*v1.Event, error
|
|||||||
|
|
||||||
// Update replaces an existing event. Returns the copy of the event the server returns, or an error.
|
// Update replaces an existing event. Returns the copy of the event the server returns, or an error.
|
||||||
func (c *FakeEvents) UpdateWithEventNamespace(event *v1.Event) (*v1.Event, error) {
|
func (c *FakeEvents) UpdateWithEventNamespace(event *v1.Event) (*v1.Event, error) {
|
||||||
action := core.NewRootUpdateAction(eventsResource, event)
|
var action core.UpdateActionImpl
|
||||||
if c.ns != "" {
|
if c.ns != "" {
|
||||||
action = core.NewUpdateAction(eventsResource, c.ns, event)
|
action = core.NewUpdateAction(eventsResource, c.ns, event)
|
||||||
|
} else {
|
||||||
|
action = core.NewUpdateAction(eventsResource, event.GetNamespace(), event)
|
||||||
}
|
}
|
||||||
obj, err := c.Fake.Invokes(action, event)
|
obj, err := c.Fake.Invokes(action, event)
|
||||||
if obj == nil {
|
if obj == nil {
|
||||||
@ -57,9 +61,11 @@ func (c *FakeEvents) UpdateWithEventNamespace(event *v1.Event) (*v1.Event, error
|
|||||||
func (c *FakeEvents) PatchWithEventNamespace(event *v1.Event, data []byte) (*v1.Event, error) {
|
func (c *FakeEvents) PatchWithEventNamespace(event *v1.Event, data []byte) (*v1.Event, error) {
|
||||||
// TODO: Should be configurable to support additional patch strategies.
|
// TODO: Should be configurable to support additional patch strategies.
|
||||||
pt := types.StrategicMergePatchType
|
pt := types.StrategicMergePatchType
|
||||||
action := core.NewRootPatchAction(eventsResource, event.Name, pt, data)
|
var action core.PatchActionImpl
|
||||||
if c.ns != "" {
|
if c.ns != "" {
|
||||||
action = core.NewPatchAction(eventsResource, c.ns, event.Name, pt, data)
|
action = core.NewPatchAction(eventsResource, c.ns, event.Name, pt, data)
|
||||||
|
} else {
|
||||||
|
action = core.NewPatchAction(eventsResource, event.GetNamespace(), event.Name, pt, data)
|
||||||
}
|
}
|
||||||
obj, err := c.Fake.Invokes(action, event)
|
obj, err := c.Fake.Invokes(action, event)
|
||||||
if obj == nil {
|
if obj == nil {
|
||||||
@ -71,9 +77,11 @@ func (c *FakeEvents) PatchWithEventNamespace(event *v1.Event, data []byte) (*v1.
|
|||||||
|
|
||||||
// Search returns a list of events matching the specified object.
|
// Search returns a list of events matching the specified object.
|
||||||
func (c *FakeEvents) Search(scheme *runtime.Scheme, objOrRef runtime.Object) (*v1.EventList, error) {
|
func (c *FakeEvents) Search(scheme *runtime.Scheme, objOrRef runtime.Object) (*v1.EventList, error) {
|
||||||
action := core.NewRootListAction(eventsResource, eventsKind, metav1.ListOptions{})
|
var action core.ListActionImpl
|
||||||
if c.ns != "" {
|
if c.ns != "" {
|
||||||
action = core.NewListAction(eventsResource, eventsKind, c.ns, metav1.ListOptions{})
|
action = core.NewListAction(eventsResource, eventsKind, c.ns, metav1.ListOptions{})
|
||||||
|
} else {
|
||||||
|
action = core.NewListAction(eventsResource, eventsKind, v1.NamespaceDefault, metav1.ListOptions{})
|
||||||
}
|
}
|
||||||
obj, err := c.Fake.Invokes(action, &v1.EventList{})
|
obj, err := c.Fake.Invokes(action, &v1.EventList{})
|
||||||
if obj == nil {
|
if obj == nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user