// gen

// Code generated by lister-gen. DO NOT EDIT.

package v1

import (
	v1 "github.com/giolekva/pcloud/core/nebula/controller/apis/nebula/v1"
	"k8s.io/apimachinery/pkg/api/errors"
	"k8s.io/apimachinery/pkg/labels"
	"k8s.io/client-go/tools/cache"
)

// NebulaCALister helps list NebulaCAs.
// All objects returned here must be treated as read-only.
type NebulaCALister interface {
	// List lists all NebulaCAs in the indexer.
	// Objects returned here must be treated as read-only.
	List(selector labels.Selector) (ret []*v1.NebulaCA, err error)
	// NebulaCAs returns an object that can list and get NebulaCAs.
	NebulaCAs(namespace string) NebulaCANamespaceLister
	NebulaCAListerExpansion
}

// nebulaCALister implements the NebulaCALister interface.
type nebulaCALister struct {
	indexer cache.Indexer
}

// NewNebulaCALister returns a new NebulaCALister.
func NewNebulaCALister(indexer cache.Indexer) NebulaCALister {
	return &nebulaCALister{indexer: indexer}
}

// List lists all NebulaCAs in the indexer.
func (s *nebulaCALister) List(selector labels.Selector) (ret []*v1.NebulaCA, err error) {
	err = cache.ListAll(s.indexer, selector, func(m interface{}) {
		ret = append(ret, m.(*v1.NebulaCA))
	})
	return ret, err
}

// NebulaCAs returns an object that can list and get NebulaCAs.
func (s *nebulaCALister) NebulaCAs(namespace string) NebulaCANamespaceLister {
	return nebulaCANamespaceLister{indexer: s.indexer, namespace: namespace}
}

// NebulaCANamespaceLister helps list and get NebulaCAs.
// All objects returned here must be treated as read-only.
type NebulaCANamespaceLister interface {
	// List lists all NebulaCAs in the indexer for a given namespace.
	// Objects returned here must be treated as read-only.
	List(selector labels.Selector) (ret []*v1.NebulaCA, err error)
	// Get retrieves the NebulaCA from the indexer for a given namespace and name.
	// Objects returned here must be treated as read-only.
	Get(name string) (*v1.NebulaCA, error)
	NebulaCANamespaceListerExpansion
}

// nebulaCANamespaceLister implements the NebulaCANamespaceLister
// interface.
type nebulaCANamespaceLister struct {
	indexer   cache.Indexer
	namespace string
}

// List lists all NebulaCAs in the indexer for a given namespace.
func (s nebulaCANamespaceLister) List(selector labels.Selector) (ret []*v1.NebulaCA, err error) {
	err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
		ret = append(ret, m.(*v1.NebulaCA))
	})
	return ret, err
}

// Get retrieves the NebulaCA from the indexer for a given namespace and name.
func (s nebulaCANamespaceLister) Get(name string) (*v1.NebulaCA, error) {
	obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
	if err != nil {
		return nil, err
	}
	if !exists {
		return nil, errors.NewNotFound(v1.Resource("nebulaca"), name)
	}
	return obj.(*v1.NebulaCA), nil
}
