本文整理汇总了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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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 := "aapi.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
}
示例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
}