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