Skip to content

Commit

Permalink
omit /projects from compute basepath (#5092) (#9834)
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Aug 17, 2021
1 parent 4725a55 commit 99e9711
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .changelog/5092.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
compute: fixed instances where compute resource calls would have their urls appended with a redundant `/projects` after the host
```
10 changes: 4 additions & 6 deletions google/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -507,29 +507,27 @@ func (c *Config) getTokenSource(clientScopes []string, initialCredentialsOnly bo
// of those "projects" as well. You can find out if this is required by looking at
// the basePath value in the client library file.
func (c *Config) NewComputeClient(userAgent string) *compute.Service {
computeClientBasePath := c.ComputeBasePath + "projects/"
log.Printf("[INFO] Instantiating GCE client for path %s", computeClientBasePath)
log.Printf("[INFO] Instantiating GCE client for path %s", c.ComputeBasePath)
clientCompute, err := compute.NewService(c.context, option.WithHTTPClient(c.client))
if err != nil {
log.Printf("[WARN] Error creating client compute: %s", err)
return nil
}
clientCompute.UserAgent = userAgent
clientCompute.BasePath = computeClientBasePath
clientCompute.BasePath = c.ComputeBasePath

return clientCompute
}

func (c *Config) NewComputeBetaClient(userAgent string) *computeBeta.Service {
computeBetaClientBasePath := c.ComputeBetaBasePath + "projects/"
log.Printf("[INFO] Instantiating GCE Beta client for path %s", computeBetaClientBasePath)
log.Printf("[INFO] Instantiating GCE Beta client for path %s", c.ComputeBetaBasePath)
clientComputeBeta, err := computeBeta.NewService(c.context, option.WithHTTPClient(c.client))
if err != nil {
log.Printf("[WARN] Error creating client compute beta: %s", err)
return nil
}
clientComputeBeta.UserAgent = userAgent
clientComputeBeta.BasePath = computeBetaClientBasePath
clientComputeBeta.BasePath = c.ComputeBetaBasePath

return clientComputeBeta
}
Expand Down

0 comments on commit 99e9711

Please sign in to comment.