Skip to content
This repository was archived by the owner on Apr 24, 2024. It is now read-only.

Commit 48e00a7

Browse files
committed
Only match resource schemas when APIExport name is not provided
1 parent f250f7e commit 48e00a7

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

main.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"flag"
2222
"fmt"
2323
"os"
24+
"strings"
2425

2526
"k8s.io/apimachinery/pkg/fields"
2627
"k8s.io/apimachinery/pkg/runtime"
@@ -29,12 +30,12 @@ import (
2930
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
3031
"k8s.io/client-go/rest"
3132
"k8s.io/klog/v2"
32-
"k8s.io/utils/strings/slices"
3333

34-
_ "k8s.io/client-go/plugin/pkg/client/auth"
35-
ctrl "sigs.k8s.io/controller-runtime"
3634
// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
3735
// to ensure that exec-entrypoint and run can make use of them.
36+
_ "k8s.io/client-go/plugin/pkg/client/auth"
37+
38+
ctrl "sigs.k8s.io/controller-runtime"
3839
"sigs.k8s.io/controller-runtime/pkg/client"
3940
"sigs.k8s.io/controller-runtime/pkg/healthz"
4041
"sigs.k8s.io/controller-runtime/pkg/kcp"
@@ -196,13 +197,14 @@ func restConfigForAPIExport(ctx context.Context, cfg *rest.Config, apiExportName
196197
continue
197198
}
198199

199-
if !slices.Contains(apiExport.Spec.LatestResourceSchemas, "today.widgets.data.my.domain") {
200+
setupLog.Info("APIExport event received", "name", apiExport.Name, "event", e.Type)
201+
202+
if resources := apiExport.Spec.LatestResourceSchemas; apiExportName == "" &&
203+
(len(resources) == 0 || !strings.HasSuffix(resources[0], datav1alpha1.GroupVersion.Group)) {
200204
// This is not this controller APIExport
201205
continue
202206
}
203207

204-
setupLog.Info("APIExport event received", "name", apiExport.Name, "event", e.Type)
205-
206208
if !conditions.IsTrue(apiExport, apisv1alpha1.APIExportVirtualWorkspaceURLsReady) {
207209
setupLog.Info("APIExport virtual workspace URLs are not ready", "APIExport", apiExport.Name)
208210
continue

0 commit comments

Comments
 (0)