@@ -27,6 +27,7 @@ import (
2727 "k8s.io/component-base/logs"
2828 logsv1 "k8s.io/component-base/logs/api/v1"
2929
30+ providerkcp "github.com/kube-bind/kube-bind/backend/provider/kcp/options"
3031 kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2"
3132)
3233
@@ -36,14 +37,15 @@ type Options struct {
3637 Cookie * Cookie
3738 Serve * Serve
3839
40+ ProviderKcp * providerkcp.Options
41+
3942 ExtraOptions
4043}
4144
4245type ExtraOptions struct {
4346 KubeConfig string
4447
45- Provider string
46- ServerURL string
48+ Provider string
4749
4850 NamespacePrefix string
4951 PrettyName string
@@ -73,6 +75,9 @@ type completedOptions struct {
7375 Cookie * Cookie
7476 Serve * Serve
7577
78+ // Provider specific options
79+ ProviderKcp * providerkcp.CompletedOptions
80+
7681 ExtraOptions
7782}
7883
@@ -85,23 +90,24 @@ func NewOptions() *Options {
8590 logs := logs .NewOptions ()
8691 logs .Verbosity = logsv1 .VerbosityLevel (2 )
8792
88- return & Options {
89- Logs : logs ,
90- OIDC : NewOIDC (),
91- Cookie : NewCookie (),
92- Serve : NewServe (),
93+ opts := & Options {
94+ Logs : logs ,
95+ OIDC : NewOIDC (),
96+ Cookie : NewCookie (),
97+ Serve : NewServe (),
98+ ProviderKcp : providerkcp .NewOptions (),
9399
94100 ExtraOptions : ExtraOptions {
95101 Provider : "kubernetes" ,
96102 NamespacePrefix : "cluster" ,
97103 PrettyName : "Backend" ,
98104 ConsumerScope : string (kubebindv1alpha2 .NamespacedScope ),
99105 ClusterScopedIsolation : string (kubebindv1alpha2 .IsolationPrefixed ),
100- ServerURL : "" ,
101106 SchemaSource : CustomResourceDefinitionSource .String (),
102107 Frontend : "embedded" , // Not used, but indicates to use embedded frontend using SPA.
103108 },
104109 }
110+ return opts
105111}
106112
107113var providerAliases = map [string ]string {
@@ -135,6 +141,7 @@ func (options *Options) AddFlags(fs *pflag.FlagSet) {
135141 options .OIDC .AddFlags (fs )
136142 options .Cookie .AddFlags (fs )
137143 options .Serve .AddFlags (fs )
144+ options .ProviderKcp .AddFlags (fs )
138145
139146 fs .StringVar (& options .KubeConfig , "kubeconfig" , options .KubeConfig , "path to a kubeconfig. Only required if out-of-cluster" )
140147 fs .StringVar (& options .NamespacePrefix , "namespace-prefix" , options .NamespacePrefix , "The prefix to use for cluster namespaces" )
@@ -160,8 +167,6 @@ func (options *Options) AddFlags(fs *pflag.FlagSet) {
160167 values ),
161168 )
162169
163- fs .StringVar (& options .ServerURL , "server-url" , options .ServerURL , "The URL of the backend server. If not specified, it will be derived from the kubeconfig or service account's hosts." )
164-
165170 fs .StringVar (& options .TestingAutoSelect , "testing-auto-select" , options .TestingAutoSelect , "<resource>.<group> that is automatically selected on th bind screen for testing" )
166171 fs .MarkHidden ("testing-auto-select" ) //nolint:errcheck
167172}
@@ -209,15 +214,24 @@ func (options *Options) Complete() (*CompletedOptions, error) {
209214 }
210215 options .ExternalCA = ca
211216 }
212- return & CompletedOptions {
217+ co := & CompletedOptions {
213218 completedOptions : & completedOptions {
214219 Logs : options .Logs ,
215220 OIDC : options .OIDC ,
216221 Cookie : options .Cookie ,
217222 Serve : options .Serve ,
218223 ExtraOptions : options .ExtraOptions ,
219224 },
220- }, nil
225+ }
226+
227+ if options .Provider == "kcp" {
228+ opts , err := options .ProviderKcp .Complete ()
229+ if err != nil {
230+ return nil , err
231+ }
232+ co .completedOptions .ProviderKcp = opts
233+ }
234+ return co , nil
221235}
222236
223237func (options * CompletedOptions ) Validate () error {
0 commit comments