Skip to content

Commit b08f0ab

Browse files
authored
Merge pull request kubernetes-sigs#10832 from chrischdi/test-clusterproxy-restconfigmodifier
🌱 test: add restConfigModifier Option to clusterProxy
2 parents 1544568 + 31f2938 commit b08f0ab

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

test/framework/cluster_proxy.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,15 @@ func WithMachineLogCollector(logCollector ClusterLogCollector) Option {
141141
}
142142
}
143143

144+
// WithRESTConfigModifier allows to modify the rest config in GetRESTConfig.
145+
// Using this function it is possible to create ClusterProxy that can work with workload clusters hosted in places
146+
// not directly accessible from the machine where we run the E2E tests, e.g. inside kind.
147+
func WithRESTConfigModifier(f func(*rest.Config)) Option {
148+
return func(c *clusterProxy) {
149+
c.restConfigModifier = f
150+
}
151+
}
152+
144153
// clusterProxy provides a base implementation of the ClusterProxy interface.
145154
type clusterProxy struct {
146155
name string
@@ -150,6 +159,8 @@ type clusterProxy struct {
150159
logCollector ClusterLogCollector
151160
cache cache.Cache
152161
onceCache sync.Once
162+
163+
restConfigModifier func(*rest.Config)
153164
}
154165

155166
// NewClusterProxy returns a clusterProxy given a KubeconfigPath and the scheme defining the types hosted in the cluster.
@@ -321,6 +332,11 @@ func (p *clusterProxy) GetRESTConfig() *rest.Config {
321332
Expect(err).ToNot(HaveOccurred(), "Failed to get ClientConfig from %q", p.kubeconfigPath)
322333

323334
restConfig.UserAgent = "cluster-api-e2e"
335+
336+
if p.restConfigModifier != nil {
337+
p.restConfigModifier(restConfig)
338+
}
339+
324340
return restConfig
325341
}
326342

0 commit comments

Comments
 (0)