本文整理汇总了Golang中k8s/io/kubernetes/pkg/fields.Set.AsSelector方法的典型用法代码示例。如果您正苦于以下问题:Golang Set.AsSelector方法的具体用法?Golang Set.AsSelector怎么用?Golang Set.AsSelector使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类k8s/io/kubernetes/pkg/fields.Set
的用法示例。
在下文中一共展示了Set.AsSelector方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: NewUnidlingController
func NewUnidlingController(scaleNS kextclient.ScalesGetter, endptsNS kclient.EndpointsGetter, evtNS kclient.EventsGetter, dcNamespacer deployclient.DeploymentConfigsGetter, rcNamespacer kclient.ReplicationControllersGetter, resyncPeriod time.Duration) *UnidlingController {
fieldSet := fields.Set{}
fieldSet["reason"] = unidlingapi.NeedPodsReason
fieldSelector := fieldSet.AsSelector()
unidlingController := &UnidlingController{
scaleNamespacer: scaleNS,
endpointsNamespacer: endptsNS,
queue: workqueue.NewRateLimitingQueue(workqueue.DefaultControllerRateLimiter()),
lastFiredCache: &lastFiredCache{
items: make(map[types.NamespacedName]time.Time),
},
dcNamespacer: dcNamespacer,
rcNamespacer: rcNamespacer,
}
_, controller := framework.NewInformer(
&cache.ListWatch{
// No need to list -- we only care about new events
ListFunc: func(options kapi.ListOptions) (runtime.Object, error) {
return &kapi.EventList{}, nil
},
WatchFunc: func(options kapi.ListOptions) (watch.Interface, error) {
options.FieldSelector = fieldSelector
return evtNS.Events(kapi.NamespaceAll).Watch(options)
},
},
&kapi.Event{},
resyncPeriod,
framework.ResourceEventHandlerFuncs{
AddFunc: func(obj interface{}) {
event := obj.(*kapi.Event)
unidlingController.enqueueEvent(event)
},
UpdateFunc: func(oldObj interface{}, newObj interface{}) {
// retrigger on new last-seen times
event := newObj.(*kapi.Event)
unidlingController.enqueueEvent(event)
},
DeleteFunc: func(obj interface{}) {
// this is just to clean up our cache of the last seen times
event := obj.(*kapi.Event)
unidlingController.clearEventFromCache(event)
},
},
)
unidlingController.controller = controller
return unidlingController
}
示例2: GetFieldSelector
// 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().String()
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()
}