當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Selector.Empty方法代碼示例

本文整理匯總了Golang中k8s/io/kubernetes/pkg/fields.Selector.Empty方法的典型用法代碼示例。如果您正苦於以下問題:Golang Selector.Empty方法的具體用法?Golang Selector.Empty怎麽用?Golang Selector.Empty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在k8s/io/kubernetes/pkg/fields.Selector的用法示例。


在下文中一共展示了Selector.Empty方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: ListDeployments

// List obtains a list of Deployments that match selector.
func (s *storage) ListDeployments(ctx api.Context, label labels.Selector, field fields.Selector) (*experimental.DeploymentList, error) {
	if !field.Empty() {
		return nil, fmt.Errorf("field selector not supported yet")
	}
	obj, err := s.List(ctx, label, field)
	if err != nil {
		return nil, err
	}
	return obj.(*experimental.DeploymentList), err
}
開發者ID:alena1108,項目名稱:kubernetes,代碼行數:11,代碼來源:registry.go

示例2: ListJobs

func (s *storage) ListJobs(ctx api.Context, label labels.Selector, field fields.Selector) (*extensions.JobList, error) {
	if !field.Empty() {
		return nil, fmt.Errorf("field selector not supported yet")
	}
	obj, err := s.List(ctx, label, field)
	if err != nil {
		return nil, err
	}
	return obj.(*extensions.JobList), err
}
開發者ID:johnmccawley,項目名稱:origin,代碼行數:10,代碼來源:registry.go

示例3: ListControllers

// List obtains a list of ReplicationControllers that match selector.
func (s *storage) ListControllers(ctx api.Context, label labels.Selector, field fields.Selector) (*api.ReplicationControllerList, error) {
	if !field.Empty() {
		return nil, fmt.Errorf("field selector not supported yet")
	}
	obj, err := s.List(ctx, label, field)
	if err != nil {
		return nil, err
	}
	return obj.(*api.ReplicationControllerList), err
}
開發者ID:johnmccawley,項目名稱:origin,代碼行數:11,代碼來源:registry.go

示例4: MatchPod

// MatchPod returns a generic matcher for a given label and field selector.
func MatchPod(label labels.Selector, field fields.Selector) generic.Matcher {
	return &generic.SelectionPredicate{
		Label: label,
		Field: field,
		GetAttrs: func(obj runtime.Object) (labels.Set, fields.Set, error) {
			pod, ok := obj.(*api.Pod)
			if !ok {
				return nil, nil, fmt.Errorf("not a pod")
			}

			// podLabels is already sitting there ready to be used.
			// podFields is not available directly and requires allocation of a map.
			// Only bother if the fields might be useful to determining the match.
			// One common case is for a replication controller to set up a watch
			// based on labels alone; in that case we can avoid allocating the field map.
			// This is especially important in the apiserver.
			podLabels := labels.Set(pod.ObjectMeta.Labels)
			var podFields fields.Set
			if !field.Empty() && label.Matches(podLabels) {
				podFields = PodToSelectableFields(pod)
			}
			return podLabels, podFields, nil
		},
		IndexFields: []string{"spec.nodeName"},
	}
}
開發者ID:AdoHe,項目名稱:kubernetes,代碼行數:27,代碼來源:strategy.go

示例5: FieldsSelectorParam

// FieldsSelectorParam adds the given selector as a query parameter with the name paramName.
func (r *Request) FieldsSelectorParam(s fields.Selector) *Request {
	if r.err != nil {
		return r
	}
	if s == nil {
		return r
	}
	if s.Empty() {
		return r
	}
	s2, err := s.Transform(func(field, value string) (newField, newValue string, err error) {
		return fieldMappings.filterField(r.content.GroupVersion, r.resource, field, value)
	})
	if err != nil {
		r.err = err
		return r
	}
	return r.setParam(unversioned.FieldSelectorQueryParam(r.content.GroupVersion.String()), s2.String())
}
開發者ID:hyperhq,項目名稱:hypernetes,代碼行數:20,代碼來源:request.go

示例6: WatchServices

// WatchServices begins watching for new, changed, or deleted service configurations.
func (r *Registry) WatchServices(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
	version, err := storage.ParseWatchResourceVersion(resourceVersion, "service")
	if err != nil {
		return nil, err
	}
	if !label.Empty() {
		return nil, fmt.Errorf("label selectors are not supported on services")
	}
	if value, found := field.RequiresExactMatch("name"); found {
		key, err := makeServiceKey(ctx, value)
		if err != nil {
			return nil, err
		}
		// TODO: use generic.SelectionPredicate
		return r.Watch(key, version, storage.Everything)
	}
	if field.Empty() {
		return r.WatchList(makeServiceListKey(ctx), version, storage.Everything)
	}
	return nil, fmt.Errorf("only the 'name' and default (everything) field selectors are supported")
}
開發者ID:qasimali80,項目名稱:kubernetes,代碼行數:22,代碼來源:etcd.go

示例7: WatchRoutes

// WatchRoutes begins watching for new, changed, or deleted route configurations.
func (registry *Etcd) WatchRoutes(ctx kapi.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
	if !label.Empty() {
		return nil, fmt.Errorf("label selectors are not supported on routes yet")
	}

	version, err := storage.ParseWatchResourceVersion(resourceVersion, "pod")
	if err != nil {
		return nil, err
	}

	if value, found := field.RequiresExactMatch("ID"); found {
		key, err := makeRouteKey(ctx, value)
		if err != nil {
			return nil, err
		}
		return registry.Watch(key, version, storage.Everything)
	}

	if field.Empty() {
		key := kubeetcd.MakeEtcdListKey(ctx, RoutePath)
		return registry.WatchList(key, version, storage.Everything)
	}
	return nil, fmt.Errorf("only the 'ID' and default (everything) field selectors are supported")
}
開發者ID:Tlacenka,項目名稱:origin,代碼行數:25,代碼來源:etcd.go

示例8: MatchEndpoints

// MatchEndpoints returns a generic matcher for a given label and field selector.
func MatchEndpoints(label labels.Selector, field fields.Selector) pkgstorage.SelectionPredicate {
	return pkgstorage.SelectionPredicate{
		Label: label,
		Field: field,
		GetAttrs: func(obj runtime.Object) (labels.Set, fields.Set, error) {
			endpoints, ok := obj.(*api.Endpoints)
			if !ok {
				return nil, nil, fmt.Errorf("invalid object type %#v", obj)
			}

			// Compute fields only if field selectors is non-empty
			// (otherwise those won't be used).
			// Those are generally also not needed if label selector does
			// not match labels, but additional computation of it is expensive.
			var endpointsFields fields.Set
			if !field.Empty() {
				endpointsFields = EndpointsToSelectableFields(endpoints)
			}
			return endpoints.Labels, endpointsFields, nil
		},
	}
}
開發者ID:eljefedelrodeodeljefe,項目名稱:kubernetes,代碼行數:23,代碼來源:strategy.go

示例9: MatchNode

// MatchNode returns a generic matcher for a given label and field selector.
func MatchNode(label labels.Selector, field fields.Selector) pkgstorage.SelectionPredicate {
	return pkgstorage.SelectionPredicate{
		Label: label,
		Field: field,
		GetAttrs: func(obj runtime.Object) (labels.Set, fields.Set, error) {
			nodeObj, ok := obj.(*api.Node)
			if !ok {
				return nil, nil, fmt.Errorf("not a node")
			}

			// Compute fields only if field selectors is non-empty
			// (otherwise those won't be used).
			// Those are generally also not needed if label selector does
			// not match labels, but additional computation of it is expensive.
			var nodeFields fields.Set
			if !field.Empty() {
				nodeFields = NodeToSelectableFields(nodeObj)
			}
			return labels.Set(nodeObj.ObjectMeta.Labels), nodeFields, nil
		},
		IndexFields: []string{"metadata.name"},
	}
}
開發者ID:Q-Lee,項目名稱:kubernetes,代碼行數:24,代碼來源:strategy.go

示例10: MatchPod

// MatchPod returns a generic matcher for a given label and field selector.
func MatchPod(label labels.Selector, field fields.Selector) storage.SelectionPredicate {
	return storage.SelectionPredicate{
		Label: label,
		Field: field,
		GetAttrs: func(obj runtime.Object) (labels.Set, fields.Set, error) {
			pod, ok := obj.(*api.Pod)
			if !ok {
				return nil, nil, fmt.Errorf("not a pod")
			}

			// Compute fields only if field selectors is non-empty
			// (otherwise those won't be used).
			// Those are generally also not needed if label selector does
			// not match labels, but additional computation of it is expensive.
			var podFields fields.Set
			if !field.Empty() {
				podFields = PodToSelectableFields(pod)
			}
			return labels.Set(pod.ObjectMeta.Labels), podFields, nil
		},
		IndexFields: []string{"spec.nodeName"},
	}
}
開發者ID:eljefedelrodeodeljefe,項目名稱:kubernetes,代碼行數:24,代碼來源:strategy.go

示例11: Watch

// Watch begins watching for new, changed, or deleted images.
func (r *REST) Watch(ctx kapi.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
	if !field.Empty() {
		return nil, errors.New("field selectors are not supported on images")
	}
	return r.store.WatchPredicate(ctx, image.MatchImage(label, field), resourceVersion)
}
開發者ID:ncantor,項目名稱:origin,代碼行數:7,代碼來源:etcd.go


注:本文中的k8s/io/kubernetes/pkg/fields.Selector.Empty方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。