@@ -90,7 +90,7 @@ type Environment struct {
90
90
// UseExisting indicates that this environments should use an
91
91
// existing kubeconfig, instead of trying to stand up a new control plane.
92
92
// This is useful in cases that need aggregated API servers and the like.
93
- UseExistingCluster bool
93
+ UseExistingCluster * bool
94
94
95
95
// ControlPlaneStartTimeout is the maximum duration each controlplane component
96
96
// may take to start. It defaults to the KUBEBUILDER_CONTROLPLANE_START_TIMEOUT
@@ -113,7 +113,7 @@ type Environment struct {
113
113
114
114
// Stop stops a running server
115
115
func (te * Environment ) Stop () error {
116
- if te .UseExistingCluster {
116
+ if te .useExistingCluster () {
117
117
return nil
118
118
}
119
119
return te .ControlPlane .Stop ()
@@ -130,11 +130,7 @@ func (te Environment) getAPIServerFlags() []string {
130
130
131
131
// Start starts a local Kubernetes server and updates te.ApiserverPort with the port it is listening on
132
132
func (te * Environment ) Start () (* rest.Config , error ) {
133
- if ! te .UseExistingCluster {
134
- // Check USE_EXISTING_CLUSTER env then
135
- te .UseExistingCluster = strings .ToLower (os .Getenv (envUseExistingCluster )) == "true"
136
- }
137
- if te .UseExistingCluster {
133
+ if te .useExistingCluster () {
138
134
log .V (1 ).Info ("using existing cluster" )
139
135
if te .Config == nil {
140
136
// we want to allow people to pass in their own config, so
@@ -256,3 +252,10 @@ func (te *Environment) defaultTimeouts() error {
256
252
}
257
253
return nil
258
254
}
255
+
256
+ func (te * Environment ) useExistingCluster () bool {
257
+ if te .UseExistingCluster == nil {
258
+ return strings .ToLower (os .Getenv (envUseExistingCluster )) == "true"
259
+ }
260
+ return * te .UseExistingCluster == true
261
+ }
0 commit comments