// Copyright 2020-2024 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.28/apis/supervisor/idp/v1alpha1"
	"k8s.io/apimachinery/pkg/api/errors"
	"k8s.io/apimachinery/pkg/labels"
	"k8s.io/client-go/tools/cache"
)

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

// gitHubIdentityProviderLister implements the GitHubIdentityProviderLister interface.
type gitHubIdentityProviderLister struct {
	indexer cache.Indexer
}

// NewGitHubIdentityProviderLister returns a new GitHubIdentityProviderLister.
func NewGitHubIdentityProviderLister(indexer cache.Indexer) GitHubIdentityProviderLister {
	return &gitHubIdentityProviderLister{indexer: indexer}
}

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

// GitHubIdentityProviders returns an object that can list and get GitHubIdentityProviders.
func (s *gitHubIdentityProviderLister) GitHubIdentityProviders(namespace string) GitHubIdentityProviderNamespaceLister {
	return gitHubIdentityProviderNamespaceLister{indexer: s.indexer, namespace: namespace}
}

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

// gitHubIdentityProviderNamespaceLister implements the GitHubIdentityProviderNamespaceLister
// interface.
type gitHubIdentityProviderNamespaceLister struct {
	indexer   cache.Indexer
	namespace string
}

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

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