Skip to content

Commit 31d8c66

Browse files
committed
✨ Allow setting "UseExistingCluster" via environment
1 parent 13ee2bc commit 31d8c66

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pkg/envtest/server.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"fmt"
2121
"os"
2222
"path/filepath"
23+
"strings"
2324
"time"
2425

2526
apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
@@ -34,6 +35,7 @@ var log = logf.RuntimeLog.WithName("test-env")
3435

3536
// Default binary path for test framework
3637
const (
38+
envUseExistingCluster = "USE_EXISTING_CLUSTER"
3739
envKubeAPIServerBin = "TEST_ASSET_KUBE_APISERVER"
3840
envEtcdBin = "TEST_ASSET_ETCD"
3941
envKubectlBin = "TEST_ASSET_KUBECTL"
@@ -122,6 +124,10 @@ func (te Environment) getAPIServerFlags() []string {
122124

123125
// Start starts a local Kubernetes server and updates te.ApiserverPort with the port it is listening on
124126
func (te *Environment) Start() (*rest.Config, error) {
127+
if !te.UseExistingCluster {
128+
// Check USE_EXISTING_CLUSTER env then
129+
te.UseExistingCluster = strings.ToLower(os.Getenv(envUseExistingCluster)) == "true"
130+
}
125131
if te.UseExistingCluster {
126132
log.V(1).Info("using existing cluster")
127133
if te.Config == nil {

0 commit comments

Comments
 (0)