Skip to content

Commit 9d835b2

Browse files
omit /projects from compute basepath (#5092) (#3532)
Signed-off-by: Modular Magician <[email protected]>
1 parent 96688c6 commit 9d835b2

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

.changelog/5092.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
compute: fixed instances where compute resource calls would have their urls appended with a redundant `/projects` after the host
3+
```

google-beta/config.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -536,29 +536,27 @@ func (c *Config) getTokenSource(clientScopes []string, initialCredentialsOnly bo
536536
// of those "projects" as well. You can find out if this is required by looking at
537537
// the basePath value in the client library file.
538538
func (c *Config) NewComputeClient(userAgent string) *compute.Service {
539-
computeClientBasePath := c.ComputeBasePath + "projects/"
540-
log.Printf("[INFO] Instantiating GCE client for path %s", computeClientBasePath)
539+
log.Printf("[INFO] Instantiating GCE client for path %s", c.ComputeBasePath)
541540
clientCompute, err := compute.NewService(c.context, option.WithHTTPClient(c.client))
542541
if err != nil {
543542
log.Printf("[WARN] Error creating client compute: %s", err)
544543
return nil
545544
}
546545
clientCompute.UserAgent = userAgent
547-
clientCompute.BasePath = computeClientBasePath
546+
clientCompute.BasePath = c.ComputeBasePath
548547

549548
return clientCompute
550549
}
551550

552551
func (c *Config) NewComputeBetaClient(userAgent string) *computeBeta.Service {
553-
computeBetaClientBasePath := c.ComputeBetaBasePath + "projects/"
554-
log.Printf("[INFO] Instantiating GCE Beta client for path %s", computeBetaClientBasePath)
552+
log.Printf("[INFO] Instantiating GCE Beta client for path %s", c.ComputeBetaBasePath)
555553
clientComputeBeta, err := computeBeta.NewService(c.context, option.WithHTTPClient(c.client))
556554
if err != nil {
557555
log.Printf("[WARN] Error creating client compute beta: %s", err)
558556
return nil
559557
}
560558
clientComputeBeta.UserAgent = userAgent
561-
clientComputeBeta.BasePath = computeBetaClientBasePath
559+
clientComputeBeta.BasePath = c.ComputeBetaBasePath
562560

563561
return clientComputeBeta
564562
}

google-beta/resource_gke_hub_feature_membership_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"fmt"
66
"testing"
77

8-
"github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl"
8+
dcl "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl"
99
gkehub "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/gkehub/beta"
1010
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
1111
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"

0 commit comments

Comments
 (0)