volcano.sh/apis@v1.8.2/pkg/client/listers/bus/v1alpha1/command.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 v1alpha1 19 20 import ( 21 "k8s.io/apimachinery/pkg/api/errors" 22 "k8s.io/apimachinery/pkg/labels" 23 "k8s.io/client-go/tools/cache" 24 v1alpha1 "volcano.sh/apis/pkg/apis/bus/v1alpha1" 25 ) 26 27 // CommandLister helps list Commands. 28 // All objects returned here must be treated as read-only. 29 type CommandLister interface { 30 // List lists all Commands in the indexer. 31 // Objects returned here must be treated as read-only. 32 List(selector labels.Selector) (ret []*v1alpha1.Command, err error) 33 // Commands returns an object that can list and get Commands. 34 Commands(namespace string) CommandNamespaceLister 35 CommandListerExpansion 36 } 37 38 // commandLister implements the CommandLister interface. 39 type commandLister struct { 40 indexer cache.Indexer 41 } 42 43 // NewCommandLister returns a new CommandLister. 44 func NewCommandLister(indexer cache.Indexer) CommandLister { 45 return &commandLister{indexer: indexer} 46 } 47 48 // List lists all Commands in the indexer. 49 func (s *commandLister) List(selector labels.Selector) (ret []*v1alpha1.Command, err error) { 50 err = cache.ListAll(s.indexer, selector, func(m interface{}) { 51 ret = append(ret, m.(*v1alpha1.Command)) 52 }) 53 return ret, err 54 } 55 56 // Commands returns an object that can list and get Commands. 57 func (s *commandLister) Commands(namespace string) CommandNamespaceLister { 58 return commandNamespaceLister{indexer: s.indexer, namespace: namespace} 59 } 60 61 // CommandNamespaceLister helps list and get Commands. 62 // All objects returned here must be treated as read-only. 63 type CommandNamespaceLister interface { 64 // List lists all Commands in the indexer for a given namespace. 65 // Objects returned here must be treated as read-only. 66 List(selector labels.Selector) (ret []*v1alpha1.Command, err error) 67 // Get retrieves the Command from the indexer for a given namespace and name. 68 // Objects returned here must be treated as read-only. 69 Get(name string) (*v1alpha1.Command, error) 70 CommandNamespaceListerExpansion 71 } 72 73 // commandNamespaceLister implements the CommandNamespaceLister 74 // interface. 75 type commandNamespaceLister struct { 76 indexer cache.Indexer 77 namespace string 78 } 79 80 // List lists all Commands in the indexer for a given namespace. 81 func (s commandNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.Command, err error) { 82 err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { 83 ret = append(ret, m.(*v1alpha1.Command)) 84 }) 85 return ret, err 86 } 87 88 // Get retrieves the Command from the indexer for a given namespace and name. 89 func (s commandNamespaceLister) Get(name string) (*v1alpha1.Command, 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(v1alpha1.Resource("command"), name) 96 } 97 return obj.(*v1alpha1.Command), nil 98 }