// Returns the appropriate field selector based on the API version being used to communicate with the server. // The returned field selector can be used with List and Watch to filter desired events. func (e *events) GetFieldSelector(involvedObjectName, involvedObjectNamespace, involvedObjectKind, involvedObjectUID *string) fields.Selector { apiVersion := e.client.APIVersion() field := fields.Set{} if involvedObjectName != nil { field[getInvolvedObjectNameFieldLabel(apiVersion)] = *involvedObjectName } if involvedObjectNamespace != nil { field["involvedObject.namespace"] = *involvedObjectNamespace } if involvedObjectKind != nil { field["involvedObject.kind"] = *involvedObjectKind } if involvedObjectUID != nil { field["involvedObject.uid"] = *involvedObjectUID } return field.AsSelector() }
// Search finds events about the specified object. The namespace of the // object must match this event's client namespace unless the event client // was made with the "" namespace. func (e *events) Search(objOrRef runtime.Object) (*api.EventList, error) { ref, err := api.GetReference(objOrRef) if err != nil { return nil, err } if e.namespace != "" && ref.Namespace != e.namespace { return nil, fmt.Errorf("won't be able to find any events of namespace '%v' in namespace '%v'", ref.Namespace, e.namespace) } fields := fields.Set{} if ref.Kind != "" { fields["involvedObject.kind"] = ref.Kind } if ref.Namespace != "" { fields["involvedObject.namespace"] = ref.Namespace } if ref.Name != "" { fields["involvedObject.name"] = ref.Name } if ref.UID != "" { fields["involvedObject.uid"] = string(ref.UID) } return e.List(labels.Everything(), fields.AsSelector()) }