// Copyright 2020 the Pinniped contributors. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

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

package v1alpha1

import (
	v1alpha1 "go.pinniped.dev/generated/1.19/apis/concierge/config/v1alpha1"
	"k8s.io/apimachinery/pkg/api/errors"
	"k8s.io/apimachinery/pkg/labels"
	"k8s.io/client-go/tools/cache"
)

// CredentialIssuerLister helps list CredentialIssuers.
// All objects returned here must be treated as read-only.
type CredentialIssuerLister interface {
	// List lists all CredentialIssuers in the indexer.
	// Objects returned here must be treated as read-only.
	List(selector labels.Selector) (ret []*v1alpha1.CredentialIssuer, err error)
	// CredentialIssuers returns an object that can list and get CredentialIssuers.
	CredentialIssuers(namespace string) CredentialIssuerNamespaceLister
	CredentialIssuerListerExpansion
}

// credentialIssuerLister implements the CredentialIssuerLister interface.
type credentialIssuerLister struct {
	indexer cache.Indexer
}

// NewCredentialIssuerLister returns a new CredentialIssuerLister.
func NewCredentialIssuerLister(indexer cache.Indexer) CredentialIssuerLister {
	return &credentialIssuerLister{indexer: indexer}
}

// List lists all CredentialIssuers in the indexer.
func (s *credentialIssuerLister) List(selector labels.Selector) (ret []*v1alpha1.CredentialIssuer, err error) {
	err = cache.ListAll(s.indexer, selector, func(m interface{}) {
		ret = append(ret, m.(*v1alpha1.CredentialIssuer))
	})
	return ret, err
}

// CredentialIssuers returns an object that can list and get CredentialIssuers.
func (s *credentialIssuerLister) CredentialIssuers(namespace string) CredentialIssuerNamespaceLister {
	return credentialIssuerNamespaceLister{indexer: s.indexer, namespace: namespace}
}

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

// credentialIssuerNamespaceLister implements the CredentialIssuerNamespaceLister
// interface.
type credentialIssuerNamespaceLister struct {
	indexer   cache.Indexer
	namespace string
}

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

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