volcano.sh/apis@v1.8.2/pkg/client/listers/scheduling/v1beta1/podgroup.go (about) 1 /* 2 Copyright 2021 The Volcano Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 // Code generated by lister-gen. DO NOT EDIT. 17 18 package v1beta1 19 20 import ( 21 "k8s.io/apimachinery/pkg/api/errors" 22 "k8s.io/apimachinery/pkg/labels" 23 "k8s.io/client-go/tools/cache" 24 v1beta1 "volcano.sh/apis/pkg/apis/scheduling/v1beta1" 25 ) 26 27 // PodGroupLister helps list PodGroups. 28 // All objects returned here must be treated as read-only. 29 type PodGroupLister interface { 30 // List lists all PodGroups in the indexer. 31 // Objects returned here must be treated as read-only. 32 List(selector labels.Selector) (ret []*v1beta1.PodGroup, err error) 33 // PodGroups returns an object that can list and get PodGroups. 34 PodGroups(namespace string) PodGroupNamespaceLister 35 PodGroupListerExpansion 36 } 37 38 // podGroupLister implements the PodGroupLister interface. 39 type podGroupLister struct { 40 indexer cache.Indexer 41 } 42 43 // NewPodGroupLister returns a new PodGroupLister. 44 func NewPodGroupLister(indexer cache.Indexer) PodGroupLister { 45 return &podGroupLister{indexer: indexer} 46 } 47 48 // List lists all PodGroups in the indexer. 49 func (s *podGroupLister) List(selector labels.Selector) (ret []*v1beta1.PodGroup, err error) { 50 err = cache.ListAll(s.indexer, selector, func(m interface{}) { 51 ret = append(ret, m.(*v1beta1.PodGroup)) 52 }) 53 return ret, err 54 } 55 56 // PodGroups returns an object that can list and get PodGroups. 57 func (s *podGroupLister) PodGroups(namespace string) PodGroupNamespaceLister { 58 return podGroupNamespaceLister{indexer: s.indexer, namespace: namespace} 59 } 60 61 // PodGroupNamespaceLister helps list and get PodGroups. 62 // All objects returned here must be treated as read-only. 63 type PodGroupNamespaceLister interface { 64 // List lists all PodGroups in the indexer for a given namespace. 65 // Objects returned here must be treated as read-only. 66 List(selector labels.Selector) (ret []*v1beta1.PodGroup, err error) 67 // Get retrieves the PodGroup from the indexer for a given namespace and name. 68 // Objects returned here must be treated as read-only. 69 Get(name string) (*v1beta1.PodGroup, error) 70 PodGroupNamespaceListerExpansion 71 } 72 73 // podGroupNamespaceLister implements the PodGroupNamespaceLister 74 // interface. 75 type podGroupNamespaceLister struct { 76 indexer cache.Indexer 77 namespace string 78 } 79 80 // List lists all PodGroups in the indexer for a given namespace. 81 func (s podGroupNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.PodGroup, err error) { 82 err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { 83 ret = append(ret, m.(*v1beta1.PodGroup)) 84 }) 85 return ret, err 86 } 87 88 // Get retrieves the PodGroup from the indexer for a given namespace and name. 89 func (s podGroupNamespaceLister) Get(name string) (*v1beta1.PodGroup, error) { 90 obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) 91 if err != nil { 92 return nil, err 93 } 94 if !exists { 95 return nil, errors.NewNotFound(v1beta1.Resource("podgroup"), name) 96 } 97 return obj.(*v1beta1.PodGroup), nil 98 }