Skip to content

Commit b71b466

Browse files
committed
Update kind provider to support receiving options, remove prefix filter on cluster names.
The filter removal was not replaced with any other method to decide if a cluster should be engaged or not. This was due to reading the following PR comment which indicates it may be best for the manager to be making the engagement decision: kubernetes-sigs/controller-runtime#2746 (comment)
1 parent b3a1d5c commit b71b466

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

examples/kind/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func main() {
4444
entryLog := ctrllog.Log.WithName("entrypoint")
4545
ctx := signals.SetupSignalHandler()
4646

47-
provider := kind.New()
47+
provider := kind.New(kind.Options{})
4848
mgr, err := mcmanager.New(ctrl.GetConfigOrDie(), provider, manager.Options{})
4949
if err != nil {
5050
entryLog.Error(err, "unable to create manager")

providers/kind/provider.go

+13-9
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package kind
1919
import (
2020
"context"
2121
"fmt"
22-
"strings"
2322
"sync"
2423
"time"
2524

@@ -40,13 +39,22 @@ import (
4039

4140
var _ multicluster.Provider = &Provider{}
4241

42+
// Options are the options for the kind cluster Provider.
43+
type Options struct {
44+
// ClusterOptions are the options passed to the cluster constructor.
45+
ClusterOptions []cluster.Option
46+
}
47+
4348
// New creates a new kind cluster Provider.
44-
func New() *Provider {
45-
return &Provider{
49+
func New(opts Options) *Provider {
50+
p := &Provider{
51+
opts: opts,
4652
log: log.Log.WithName("kind-cluster-provider"),
4753
clusters: map[string]cluster.Cluster{},
4854
cancelFns: map[string]context.CancelFunc{},
4955
}
56+
57+
return p
5058
}
5159

5260
type index struct {
@@ -57,7 +65,7 @@ type index struct {
5765

5866
// Provider is a cluster Provider that works with a local Kind instance.
5967
type Provider struct {
60-
opts []cluster.Option
68+
opts Options
6169
log logr.Logger
6270
lock sync.RWMutex
6371
clusters map[string]cluster.Cluster
@@ -98,10 +106,6 @@ func (p *Provider) Run(ctx context.Context, mgr mcmanager.Manager) error {
98106
for _, clusterName := range list {
99107
log := p.log.WithValues("cluster", clusterName)
100108

101-
// skip?
102-
if !strings.HasPrefix(clusterName, "fleet-") {
103-
continue
104-
}
105109
p.lock.RLock()
106110
if _, ok := p.clusters[clusterName]; ok {
107111
p.lock.RUnlock()
@@ -120,7 +124,7 @@ func (p *Provider) Run(ctx context.Context, mgr mcmanager.Manager) error {
120124
p.log.Info("failed to create rest config", "error", err)
121125
return false, nil // keep going
122126
}
123-
cl, err := cluster.New(cfg, p.opts...)
127+
cl, err := cluster.New(cfg, p.opts.ClusterOptions...)
124128
if err != nil {
125129
p.log.Info("failed to create cluster", "error", err)
126130
return false, nil // keep going

0 commit comments

Comments
 (0)