Merge pull request #72205 from losipiuk/lo/env-gke-api-endpoint

Use CLOUDSDK_API_ENDPOINT_OVERRIDES_CONTAINER for GKE Api endpoint
pull/564/head
Kubernetes Prow Robot 2018-12-20 03:11:44 -08:00 committed by GitHub
commit cdeb8c108f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 2 deletions

View File

@ -68,7 +68,6 @@ const (
makeSchedulableDelay = 20 * time.Second makeSchedulableDelay = 20 * time.Second
freshStatusLimit = 20 * time.Second freshStatusLimit = 20 * time.Second
gkeEndpoint = "https://test-container.sandbox.googleapis.com"
gkeUpdateTimeout = 15 * time.Minute gkeUpdateTimeout = 15 * time.Minute
gkeNodepoolNameKey = "cloud.google.com/gke-nodepool" gkeNodepoolNameKey = "cloud.google.com/gke-nodepool"
@ -1035,13 +1034,24 @@ func runDrainTest(f *framework.Framework, migSizes map[string]int, namespace str
verifyFunction(increasedSize) verifyFunction(increasedSize)
} }
func getGkeApiEndpoint() string {
gkeApiEndpoint := os.Getenv("CLOUDSDK_API_ENDPOINT_OVERRIDES_CONTAINER")
if gkeApiEndpoint == "" {
gkeApiEndpoint = "https://test-container.sandbox.googleapis.com"
}
if strings.HasSuffix(gkeApiEndpoint, "/") {
gkeApiEndpoint = gkeApiEndpoint[:len(gkeApiEndpoint)-1]
}
return gkeApiEndpoint
}
func getGKEURL(apiVersion string, suffix string) string { func getGKEURL(apiVersion string, suffix string) string {
out, err := execCmd("gcloud", "auth", "print-access-token").Output() out, err := execCmd("gcloud", "auth", "print-access-token").Output()
framework.ExpectNoError(err) framework.ExpectNoError(err)
token := strings.Replace(string(out), "\n", "", -1) token := strings.Replace(string(out), "\n", "", -1)
return fmt.Sprintf("%s/%s/%s?access_token=%s", return fmt.Sprintf("%s/%s/%s?access_token=%s",
gkeEndpoint, getGkeApiEndpoint(),
apiVersion, apiVersion,
suffix, suffix,
token) token)