@@ -39,6 +39,7 @@ import (
3939 "sigs.k8s.io/multicluster-runtime/pkg/multicluster"
4040
4141 kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache"
42+ apisv1alpha1 "github.com/kcp-dev/kcp/sdk/apis/apis/v1alpha1"
4243 "github.com/kcp-dev/logicalcluster/v3"
4344)
4445
@@ -70,13 +71,21 @@ type Options struct {
7071 // WildcardCache is the wildcard cache to use for the provider. If this is
7172 // nil, a new wildcard cache will be created for the given rest.Config.
7273 WildcardCache WildcardCache
74+
75+ // ObjectToWatch is the object type that the provider watches via a /clusters/*
76+ // wildcard endpoint to extract information about logical clusters joining and
77+ // leaving the "fleet" of (logical) clusters in kcp. If this is nil, it defaults
78+ // to [apisv1alpha1.APIBinding]. This might be useful when using this provider
79+ // against custom virtual workspaces that are not the APIExport one but share
80+ // the same endpoint semantics.
81+ ObjectToWatch client.Object
7382}
7483
7584// New creates a new kcp virtual workspace provider. The provided [rest.Config]
7685// must point to a virtual workspace apiserver base path, i.e. up to but without
7786// the '/clusters/*' suffix. This information can be extracted from the APIExport
7887// status (deprecated) or an APIExportEndpointSlice status.
79- func New (cfg * rest.Config , obj client. Object , options Options ) (* Provider , error ) {
88+ func New (cfg * rest.Config , options Options ) (* Provider , error ) {
8089 // Do the defaulting controller-runtime would do for those fields we need.
8190 if options .Scheme == nil {
8291 options .Scheme = scheme .Scheme
@@ -90,14 +99,17 @@ func New(cfg *rest.Config, obj client.Object, options Options) (*Provider, error
9099 return nil , fmt .Errorf ("failed to create wildcard cache: %w" , err )
91100 }
92101 }
102+ if options .ObjectToWatch == nil {
103+ options .ObjectToWatch = & apisv1alpha1.APIBinding {}
104+ }
93105
94106 return & Provider {
95107 config : cfg ,
96108 scheme : options .Scheme ,
97109 cache : options .WildcardCache ,
98- object : obj ,
110+ object : options . ObjectToWatch ,
99111
100- log : log .Log .WithName ("kcp-virtualworkspace -cluster-provider" ),
112+ log : log .Log .WithName ("kcp-apiexport -cluster-provider" ),
101113
102114 clusters : map [logicalcluster.Name ]cluster.Cluster {},
103115 cancelFns : map [logicalcluster.Name ]context.CancelFunc {},
0 commit comments