当前位置: 首页>>代码示例>>Golang>>正文


Golang Set.AsSelector方法代码示例

本文整理汇总了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
}
开发者ID:abhgupta,项目名称:origin,代码行数:52,代码来源:controller.go

示例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()
}
开发者ID:Clarifai,项目名称:kubernetes,代码行数:19,代码来源:event_expansion.go


注:本文中的k8s/io/kubernetes/pkg/fields.Set.AsSelector方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。