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


Golang api.ListOptionsToSelectors函数代码示例

本文整理汇总了Golang中github.com/openshift/origin/pkg/api.ListOptionsToSelectors函数的典型用法代码示例。如果您正苦于以下问题:Golang ListOptionsToSelectors函数的具体用法?Golang ListOptionsToSelectors怎么用?Golang ListOptionsToSelectors使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ListOptionsToSelectors函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: List

func (r *REST) List(ctx kapi.Context, options *kapi.ListOptions) (runtime.Object, error) {
	imageStreams, err := r.imageStreamRegistry.ListImageStreams(ctx, options)
	if err != nil {
		return nil, err
	}

	matcher := MatchImageStreamTag(oapi.ListOptionsToSelectors(options))

	list := &api.ImageStreamTagList{}
	for _, currIS := range imageStreams.Items {
		for currTag := range currIS.Status.Tags {
			istag, err := newISTag(currTag, &currIS, nil, false)
			if err != nil {
				if kapierrors.IsNotFound(err) {
					continue
				}
				return nil, err
			}
			matches, err := matcher.Matches(istag)
			if err != nil {
				return nil, err
			}

			if matches {
				list.Items = append(list.Items, *istag)
			}
		}
	}

	return list, nil
}
开发者ID:ZenoRewn,项目名称:origin,代码行数:31,代码来源:rest.go

示例2: List

func (i *indexerToPolicyBindingLister) List(options kapi.ListOptions) (*authorizationapi.PolicyBindingList, error) {
	policyBindingList := &authorizationapi.PolicyBindingList{}
	matcher := policybindingregistry.Matcher(oapi.ListOptionsToSelectors(&options))

	if i.namespace == kapi.NamespaceAll {
		returnedList := i.Indexer.List()
		for i := range returnedList {
			policyBinding := returnedList[i].(*authorizationapi.PolicyBinding)
			if matches, err := matcher.Matches(policyBinding); err == nil && matches {
				policyBindingList.Items = append(policyBindingList.Items, *policyBinding)
			}
		}
		return policyBindingList, nil
	}

	key := &authorizationapi.PolicyBinding{ObjectMeta: kapi.ObjectMeta{Namespace: i.namespace}}
	items, err := i.Indexer.Index(cache.NamespaceIndex, key)
	if err != nil {
		return policyBindingList, err
	}

	for i := range items {
		policyBinding := items[i].(*authorizationapi.PolicyBinding)
		if matches, err := matcher.Matches(policyBinding); err == nil && matches {
			policyBindingList.Items = append(policyBindingList.Items, *policyBinding)
		}
	}
	return policyBindingList, nil
}
开发者ID:Xmagicer,项目名称:origin,代码行数:29,代码来源:policybinding.go

示例3: List

func (i *InformerToClusterPolicyLister) List(options kapi.ListOptions) (*authorizationapi.ClusterPolicyList, error) {
	clusterPolicyList := &authorizationapi.ClusterPolicyList{}
	returnedList := i.GetIndexer().List()
	matcher := clusterpolicyregistry.Matcher(oapi.ListOptionsToSelectors(&options))
	for i := range returnedList {
		clusterPolicy := returnedList[i].(*authorizationapi.ClusterPolicy)
		if matches, err := matcher.Matches(clusterPolicy); err == nil && matches {
			clusterPolicyList.Items = append(clusterPolicyList.Items, *clusterPolicy)
		}
	}
	return clusterPolicyList, nil
}
开发者ID:Xmagicer,项目名称:origin,代码行数:12,代码来源:clusterpolicy.go

示例4: List

func (i *IndexerToClusterResourceQuotaLister) List(options kapi.ListOptions) ([]*quotaapi.ClusterResourceQuota, error) {
	returnedList := i.Indexer.List()
	ret := make([]*quotaapi.ClusterResourceQuota, 0, len(returnedList))
	matcher := clusterresourcequotaregistry.Matcher(oapi.ListOptionsToSelectors(&options))

	for i := range returnedList {
		clusterResourceQuota := returnedList[i].(*quotaapi.ClusterResourceQuota)
		if matches, err := matcher.Matches(clusterResourceQuota); err == nil && matches {
			ret = append(ret, clusterResourceQuota)
		}
	}
	return ret, nil
}
开发者ID:Xmagicer,项目名称:origin,代码行数:13,代码来源:clusterresourcequota.go

示例5: List

func (i *IndexerToNamespaceLister) List(options kapi.ListOptions) ([]*kapi.Namespace, error) {
	returnedList := i.Indexer.List()
	ret := make([]*kapi.Namespace, 0, len(returnedList))
	matcher := namespace.MatchNamespace(oapi.ListOptionsToSelectors(&options))

	for i := range returnedList {
		clusterResourceQuota := returnedList[i].(*kapi.Namespace)
		if matches, err := matcher.Matches(clusterResourceQuota); err == nil && matches {
			ret = append(ret, clusterResourceQuota)
		}
	}
	return ret, nil
}
开发者ID:Xmagicer,项目名称:origin,代码行数:13,代码来源:namespace.go

示例6: List

func (c *readOnlyClusterPolicyCache) List(options *kapi.ListOptions) (*authorizationapi.ClusterPolicyList, error) {
	clusterPolicyList := &authorizationapi.ClusterPolicyList{}
	returnedList := c.indexer.List()
	matcher := clusterpolicyregistry.Matcher(api.ListOptionsToSelectors(options))
	for i := range returnedList {
		clusterPolicy, castOK := returnedList[i].(*authorizationapi.ClusterPolicy)
		if !castOK {
			return clusterPolicyList, errors.NewInvalid(authorizationapi.Kind("ClusterPolicy"), "clusterPolicy", kfield.ErrorList{})
		}
		if matches, err := matcher.Matches(clusterPolicy); err == nil && matches {
			clusterPolicyList.Items = append(clusterPolicyList.Items, *clusterPolicy)
		}
	}
	return clusterPolicyList, nil
}
开发者ID:RomainVabre,项目名称:origin,代码行数:15,代码来源:clusterpolicy.go

示例7: List

// List retrieves a list of Projects that match label.
func (s *REST) List(ctx kapi.Context, options *kapi.ListOptions) (runtime.Object, error) {
	user, ok := kapi.UserFrom(ctx)
	if !ok {
		return nil, kerrors.NewForbidden(projectapi.Resource("project"), "", fmt.Errorf("unable to list projects without a user on the context"))
	}
	namespaceList, err := s.lister.List(user)
	if err != nil {
		return nil, err
	}
	m := nsregistry.MatchNamespace(oapi.ListOptionsToSelectors(options))
	list, err := filterList(namespaceList, m, nil)
	if err != nil {
		return nil, err
	}
	return convertNamespaceList(list.(*kapi.NamespaceList)), nil
}
开发者ID:asiainfoLDP,项目名称:datafactory,代码行数:17,代码来源:proxy.go

示例8: List

func (m *VirtualStorage) List(ctx kapi.Context, options *kapi.ListOptions) (runtime.Object, error) {
	policyList, err := m.PolicyStorage.ListPolicies(ctx, options)
	if err != nil {
		return nil, err
	}

	labelSelector, fieldSelector := oapi.ListOptionsToSelectors(options)

	roleList := &authorizationapi.RoleList{}
	for _, policy := range policyList.Items {
		for _, role := range policy.Roles {
			if labelSelector.Matches(labels.Set(role.Labels)) &&
				fieldSelector.Matches(authorizationapi.RoleToSelectableFields(role)) {
				roleList.Items = append(roleList.Items, *role)
			}
		}
	}

	return roleList, nil
}
开发者ID:Xmagicer,项目名称:origin,代码行数:20,代码来源:virtual_storage.go

示例9: List

func (m *VirtualStorage) List(ctx kapi.Context, options *unversioned.ListOptions) (runtime.Object, error) {
	policyBindingList, err := m.BindingRegistry.ListPolicyBindings(ctx, options)
	if err != nil {
		return nil, err
	}

	labelSelector, fieldSelector := oapi.ListOptionsToSelectors(options)

	roleBindingList := &authorizationapi.RoleBindingList{}
	for _, policyBinding := range policyBindingList.Items {
		for _, roleBinding := range policyBinding.RoleBindings {
			if labelSelector.Matches(labels.Set(roleBinding.Labels)) &&
				fieldSelector.Matches(authorizationapi.RoleBindingToSelectableFields(roleBinding)) {
				roleBindingList.Items = append(roleBindingList.Items, *roleBinding)
			}
		}
	}

	return roleBindingList, nil
}
开发者ID:erinboyd,项目名称:origin,代码行数:20,代码来源:virtual_storage.go

示例10: List

func (r *AppliedClusterResourceQuotaREST) List(ctx kapi.Context, options *kapi.ListOptions) (runtime.Object, error) {
	namespace, ok := kapi.NamespaceFrom(ctx)
	if !ok {
		return nil, kapierrors.NewBadRequest("namespace is required")
	}

	// TODO max resource version?  watch?
	list := &quotaapi.AppliedClusterResourceQuotaList{}
	matcher := clusterresourcequotaregistry.Matcher(oapi.ListOptionsToSelectors(options))
	quotaNames, _ := r.quotaMapper.GetClusterQuotasFor(namespace)

	for _, name := range quotaNames {
		quota, err := r.quotaLister.Get(name)
		if err != nil {
			continue
		}
		if matches, err := matcher.Matches(quota); err != nil || !matches {
			continue
		}
		list.Items = append(list.Items, *quotaapi.ConvertClusterResourceQuotaToAppliedClusterResourceQuota(quota))
	}

	return list, nil
}
开发者ID:juanluisvaladas,项目名称:origin,代码行数:24,代码来源:filter.go

示例11: List

func (c *readOnlyPolicyBindingCache) List(options *unversioned.ListOptions, namespace string) (*authorizationapi.PolicyBindingList, error) {
	var returnedList []interface{}
	if namespace == kapi.NamespaceAll {
		returnedList = c.indexer.List()
	} else {
		items, err := c.indexer.Index("namespace", &authorizationapi.PolicyBinding{ObjectMeta: kapi.ObjectMeta{Namespace: namespace}})
		returnedList = items
		if err != nil {
			return &authorizationapi.PolicyBindingList{}, errors.NewInvalid("PolicyBindingList", "policyBindingList", kfield.ErrorList{kfield.Invalid(kfield.NewPath("policyBindingList"), nil, err.Error())})
		}
	}
	policyBindingList := &authorizationapi.PolicyBindingList{}
	matcher := bindingregistry.Matcher(api.ListOptionsToSelectors(options))
	for i := range returnedList {
		policyBinding, castOK := returnedList[i].(*authorizationapi.PolicyBinding)
		if !castOK {
			return policyBindingList, errors.NewInvalid("PolicyBindingList", "policyBindingList", kfield.ErrorList{})
		}
		if matches, err := matcher.Matches(policyBinding); err == nil && matches {
			policyBindingList.Items = append(policyBindingList.Items, *policyBinding)
		}
	}
	return policyBindingList, nil
}
开发者ID:erinboyd,项目名称:origin,代码行数:24,代码来源:policybinding.go


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