Skip to content

Commit

Permalink
add 'projects/' suffix if this library is used with an older version …
Browse files Browse the repository at this point in the history
…of the google api library

Signed-off-by: Paco Xu <paco.xu@daocloud.io>
  • Loading branch information
pacoxu committed Aug 9, 2021
1 parent 2d3323d commit 768d69a
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions staging/src/k8s.io/legacy-cloud-providers/gce/gce.go
Expand Up @@ -435,9 +435,15 @@ func CreateGCECloud(config *CloudConfig) (*Cloud, error) {
serviceAlpha.UserAgent = userAgent

if config.APIEndpoint != "" {
service.BasePath = config.APIEndpoint
serviceBeta.BasePath = strings.Replace(config.APIEndpoint, "v1", "beta", -1)
serviceAlpha.BasePath = strings.Replace(config.APIEndpoint, "v1", "alpha", -1)
if strings.HasSuffix(service.BasePath, "/projects/") {
service.BasePath = getProjectsBasePath(config.APIEndpoint)
serviceBeta.BasePath = getProjectsBasePath(strings.Replace(config.APIEndpoint, "v1", "beta", -1))
serviceAlpha.BasePath = getProjectsBasePath(strings.Replace(config.APIEndpoint, "v1", "alpha", -1))
} else {
service.BasePath = config.APIEndpoint
serviceBeta.BasePath = strings.Replace(config.APIEndpoint, "v1", "beta", -1)
serviceAlpha.BasePath = strings.Replace(config.APIEndpoint, "v1", "alpha", -1)
}
}

containerService, err := container.NewService(context.Background(), option.WithTokenSource(config.TokenSource))
Expand Down

0 comments on commit 768d69a

Please sign in to comment.