Skip to content

Commit 5a71e2a

Browse files
authored
Merge pull request #52 from FourFifthsCode/kubeconfig-provider-schema
✨ Add Scheme as option when configuring kubeconfig provider clusters
2 parents 4550ac5 + 84d0d70 commit 5a71e2a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

providers/kubeconfig/provider.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ import (
2929

3030
corev1 "k8s.io/api/core/v1"
3131
apierrors "k8s.io/apimachinery/pkg/api/errors"
32+
"k8s.io/apimachinery/pkg/runtime"
33+
"k8s.io/client-go/kubernetes/scheme"
3234
"k8s.io/client-go/tools/clientcmd"
3335

3436
ctrl "sigs.k8s.io/controller-runtime"
@@ -61,6 +63,9 @@ func New(opts Options) *Provider {
6163
if opts.KubeconfigSecretKey == "" {
6264
opts.KubeconfigSecretKey = DefaultKubeconfigSecretKey
6365
}
66+
if opts.Scheme == nil {
67+
opts.Scheme = scheme.Scheme
68+
}
6469

6570
return &Provider{
6671
opts: opts,
@@ -77,6 +82,8 @@ type Options struct {
7782
KubeconfigSecretLabel string
7883
// KubeconfigSecretKey is the key in the secret data that contains the kubeconfig.
7984
KubeconfigSecretKey string
85+
// Scheme is the scheme to use for the clusters.
86+
Scheme *runtime.Scheme
8087
}
8188

8289
type index struct {
@@ -254,7 +261,9 @@ func (p *Provider) createAndEngageCluster(ctx context.Context, clusterName strin
254261

255262
// Create a new cluster
256263
log.Info("Creating new cluster from kubeconfig")
257-
cl, err := cluster.New(restConfig)
264+
cl, err := cluster.New(restConfig, func(o *cluster.Options) {
265+
o.Scheme = p.opts.Scheme
266+
})
258267
if err != nil {
259268
return fmt.Errorf("failed to create cluster: %w", err)
260269
}

0 commit comments

Comments
 (0)