Skip to content

Commit d504436

Browse files
authored
Merge pull request #1068 from songjiaxun/master
Fix the "gcloud services enable" logic
2 parents 1201eb1 + 5d6e3c7 commit d504436

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

test/k8s-integration/cluster.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"os"
88
"os/exec"
99
"path/filepath"
10+
"regexp"
1011
"strconv"
1112
"strings"
1213

@@ -161,13 +162,16 @@ func setImageTypeEnvs(imageType string) error {
161162

162163
func clusterUpGKE(gceZone, gceRegion string, numNodes int, numWindowsNodes int, imageType string, useManagedDriver bool) error {
163164
// Enable the GKE service API
165+
var gkeServiceName string
164166
gkeURL := os.Getenv("CLOUDSDK_API_ENDPOINT_OVERRIDES_CONTAINER")
165167
if gkeURL == "" {
166-
gkeURL = "container.googleapis.com"
168+
gkeServiceName = "container.googleapis.com"
169+
} else {
170+
gkeServiceName = regexp.MustCompile("https://(.+)/").FindStringSubmatch(gkeURL)[1]
167171
}
168-
_, err := exec.Command("gcloud", "services", "enable", gkeURL).CombinedOutput()
172+
_, err := exec.Command("gcloud", "services", "enable", gkeServiceName).CombinedOutput()
169173
if err != nil {
170-
return fmt.Errorf("failed to enable GKE service API %q: %v", gkeURL, err)
174+
return fmt.Errorf("failed to enable GKE service API %q: %v", gkeServiceName, err)
171175
}
172176

173177
locationArg, locationVal, err := gkeLocationArgs(gceZone, gceRegion)

0 commit comments

Comments
 (0)