Skip to content

Commit

Permalink
Look up APIexports with fallback
Browse files Browse the repository at this point in the history
Signed-off-by: Nolan Brubaker <nolan@nbrubaker.com>
  • Loading branch information
nrb committed Apr 5, 2023
1 parent 67543d1 commit 1c83615
Showing 1 changed file with 1 addition and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"github.com/kcp-dev/logicalcluster/v3"

"k8s.io/apimachinery/pkg/api/equality"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/util/errors"
"k8s.io/apimachinery/pkg/util/runtime"
Expand Down Expand Up @@ -77,18 +76,7 @@ func NewController(
syncTargetLister: syncTargetInformer.Lister(),
apiExportsIndexer: apiExportInformer.Informer().GetIndexer(),
getAPIExport: func(path logicalcluster.Path, name string) (*apisv1alpha1.APIExport, error) {
// Try local informer first
export, err := indexers.ByPathAndName[*apisv1alpha1.APIExport](apisv1alpha1.Resource("apiexports"), apiExportInformer.Informer().GetIndexer(), path, name)
if err == nil {
// Quick happy path - found it locally
return export, nil
}
if !apierrors.IsNotFound(err) {
// Unrecoverable error
return nil, err
}
// Didn't find it locally - try remote
return indexers.ByPathAndName[*apisv1alpha1.APIExport](apisv1alpha1.Resource("apiexports"), globalAPIExportInformer.Informer().GetIndexer(), path, name)
return indexers.ByPathAndNameWithFallback[*apisv1alpha1.APIExport](apisv1alpha1.Resource("apiexports"), apiExportInformer.Informer().GetIndexer(), globalAPIExportInformer.Informer().GetIndexer(), path, name)
},
getAPIResourceSchema: informer.NewScopedGetterWithFallback[*apisv1alpha1.APIResourceSchema, apisv1alpha1listers.APIResourceSchemaLister](apiResourceSchemaInformer.Lister(), globalAPIResourceSchemaInformer.Lister()),
apiImportLister: apiResourceImportInformer.Lister(),
Expand Down

0 comments on commit 1c83615

Please sign in to comment.