@@ -29,8 +29,7 @@ import (
29
29
30
30
corev1 "k8s.io/api/core/v1"
31
31
apierrors "k8s.io/apimachinery/pkg/api/errors"
32
- "k8s.io/apimachinery/pkg/runtime"
33
- "k8s.io/client-go/kubernetes/scheme"
32
+ "k8s.io/client-go/rest"
34
33
"k8s.io/client-go/tools/clientcmd"
35
34
36
35
ctrl "sigs.k8s.io/controller-runtime"
@@ -63,9 +62,6 @@ func New(opts Options) *Provider {
63
62
if opts .KubeconfigSecretKey == "" {
64
63
opts .KubeconfigSecretKey = DefaultKubeconfigSecretKey
65
64
}
66
- if opts .Scheme == nil {
67
- opts .Scheme = scheme .Scheme
68
- }
69
65
70
66
return & Provider {
71
67
opts : opts ,
@@ -82,8 +78,10 @@ type Options struct {
82
78
KubeconfigSecretLabel string
83
79
// KubeconfigSecretKey is the key in the secret data that contains the kubeconfig.
84
80
KubeconfigSecretKey string
85
- // Scheme is the scheme to use for the clusters.
86
- Scheme * runtime.Scheme
81
+ // ClusterOptions is the list of options to pass to the cluster object.
82
+ ClusterOptions []cluster.Option
83
+ // RESTOptions is the list of options to pass to the rest client.
84
+ RESTOptions []func (cfg * rest.Config ) error
87
85
}
88
86
89
87
type index struct {
@@ -259,11 +257,16 @@ func (p *Provider) createAndEngageCluster(ctx context.Context, clusterName strin
259
257
return fmt .Errorf ("failed to parse kubeconfig: %w" , err )
260
258
}
261
259
260
+ // Apply REST options
261
+ for _ , opt := range p .opts .RESTOptions {
262
+ if err := opt (restConfig ); err != nil {
263
+ return fmt .Errorf ("failed to apply REST option: %w" , err )
264
+ }
265
+ }
266
+
262
267
// Create a new cluster
263
268
log .Info ("Creating new cluster from kubeconfig" )
264
- cl , err := cluster .New (restConfig , func (o * cluster.Options ) {
265
- o .Scheme = p .opts .Scheme
266
- })
269
+ cl , err := cluster .New (restConfig , p .opts .ClusterOptions ... )
267
270
if err != nil {
268
271
return fmt .Errorf ("failed to create cluster: %w" , err )
269
272
}
0 commit comments