本文整理匯總了Golang中k8s/io/kubernetes/pkg/fields.Set類的典型用法代碼示例。如果您正苦於以下問題:Golang Set類的具體用法?Golang Set怎麽用?Golang Set使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Set類的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()
}