Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,7 @@ func mountDatastores(mountsToAdd []interface{}, d *schema.ResourceData, config *
req["ignoreColocation"] = v.(bool)
}

// Construct the URL directly using d.Id() for the resource name
//mountUrl := fmt.Sprintf("%s%s:mountDatastore", config.VmwareengineBasePath, d.Id())
mountUrl, err := tpgresource.ReplaceVars(d, config, "{{"{{"}}VmwareengineBasePath{{"}}"}}{{"{{"}}parent{{"}}"}}/clusters/{{"{{"}}name{{"}}"}}:mountDatastore")
mountUrl, err := tpgresource.ReplaceVars(d, config, transport_tpg.BaseUrl(Product, config) + "{{"{{"}}parent{{"}}"}}/clusters/{{"{{"}}name{{"}}"}}:mountDatastore")
if err != nil {
return err
}
Expand Down Expand Up @@ -136,8 +134,7 @@ func unmountDatastores(mountsToRemove []interface{}, d *schema.ResourceData, con
return fmt.Errorf("no datastore found in the unmount request : %#v", mountMap)
}

//unmountUrl := fmt.Sprintf("%s%s:unmountDatastore", config.VmwareengineBasePath, d.Id())
unmountUrl, err := tpgresource.ReplaceVars(d, config, "{{"{{"}}VmwareengineBasePath{{"}}"}}{{"{{"}}parent{{"}}"}}/clusters/{{"{{"}}name{{"}}"}}:unmountDatastore")
unmountUrl, err := tpgresource.ReplaceVars(d, config, transport_tpg.BaseUrl(Product, config) + "{{"{{"}}parent{{"}}"}}/clusters/{{"{{"}}name{{"}}"}}:unmountDatastore")
if err != nil {
return err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ if bp, err := tpgresource.GetBillingProject(d, config); err == nil {
// ==================== Build Restore URL & Execute Request ====================
// Construct the restore URL using base path and url params
url := fmt.Sprintf("%sprojects/%s/locations/%s/backupVaults/%s/dataSources/%s/backups/%s:restore",
config.BackupDRBasePath,
transport_tpg.BaseUrl(Product, config),
project,
d.Get("location").(string),
d.Get("backup_vault_id").(string),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Handle desired state after queue creation
if v, ok := d.GetOk("desired_state"); ok && v.(string) == "PAUSED" {
pauseUrl := fmt.Sprintf("%s%s:pause", config.CloudTasksBasePath, id)
pauseUrl := fmt.Sprintf("%s%s:pause", transport_tpg.BaseUrl(Product, config), id)

_, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Config: config,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ It's used to populate the "serviceAgents" field from the API response.

log.Printf("[DEBUG] {{ .Name }}PostCreate: Attempting to get operation %s", opName)

getOpURL := config.WorkloadIdentityBasePath + opName
getOpURL := transport_tpg.BaseUrl(Product, config) + opName
opRes, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Config: config,
Method: "GET",
Expand Down
6 changes: 3 additions & 3 deletions mmv1/templates/terraform/pre_delete/detach_disk.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ if d.Get("create_snapshot_before_destroy").(bool) {
snapshotObj["snapshotEncryptionKey"] = snapshotEncryptionKey
}

snapshotUrl := fmt.Sprintf("%sprojects/%s/global/snapshots", config.ComputeBasePath, project)
snapshotUrl := fmt.Sprintf("%sprojects/%s/global/snapshots", transport_tpg.BaseUrl(Product, config), project)

res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Config: config,
Expand Down Expand Up @@ -89,7 +89,7 @@ if v, ok := readRes["users"].([]interface{}); ok {
}

// Get instance details using REST API
instanceUrl, err := tpgresource.ReplaceVars(d, config, fmt.Sprintf("%sprojects/%s/zones/%s/instances/%s", config.ComputeBasePath, instanceProject, instanceZone, instanceName))
instanceUrl, err := tpgresource.ReplaceVars(d, config, fmt.Sprintf("%sprojects/%s/zones/%s/instances/%s", transport_tpg.BaseUrl(Product, config), instanceProject, instanceZone, instanceName))
if err != nil {
return err
}
Expand Down Expand Up @@ -127,7 +127,7 @@ if v, ok := readRes["users"].([]interface{}); ok {

for _, call := range detachCalls {
detachUrl := fmt.Sprintf("%sprojects/%s/zones/%s/instances/%s/detachDisk?deviceName=%s",
config.ComputeBasePath, call.project, call.zone, call.instance, call.deviceName)
transport_tpg.BaseUrl(Product, config), call.project, call.zone, call.instance, call.deviceName)

res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Config: config,
Expand Down
61 changes: 32 additions & 29 deletions mmv1/third_party/terraform/acctest/bootstrap_test_utils.go.tmpl

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func DataSourceArtifactRegistryFileRead(d *schema.ResourceData, meta interface{}
fileID := d.Get("file_id").(string)
outputPath := d.Get("output_path").(string)

resourceURL := buildFileResourceURL(config.ArtifactRegistryBasePath, project, location, repoID, fileID)
resourceURL := buildFileResourceURL(transport_tpg.BaseUrl(Product, config), project, location, repoID, fileID)
timeout := d.Timeout(schema.TimeoutRead)

metaResp, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (

"github.com/hashicorp/terraform-provider-google/google/acctest"
"github.com/hashicorp/terraform-provider-google/google/envvar"
"github.com/hashicorp/terraform-provider-google/google/services/artifactregistry"
transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport"
)

const testFileContents = "hello-artifact-registry\n"
Expand Down Expand Up @@ -101,7 +103,7 @@ func uploadGenericArtifact(t *testing.T, project, location, repoID, pkg, version
// inserts "upload/" before the version segment, e.g.:
// https://artifactregistry.googleapis.com/v1/ →
// https://artifactregistry.googleapis.com/upload/v1/
uploadBase := strings.Replace(config.ArtifactRegistryBasePath, "v1/", "upload/v1/", 1)
uploadBase := strings.Replace(transport_tpg.BaseUrl(artifactregistry.Product, config), "v1/", "upload/v1/", 1)
uploadURL := fmt.Sprintf(
"%sprojects/%s/locations/%s/repositories/%s/genericArtifacts:create?alt=json&uploadType=multipart",
uploadBase, project, location, repoID,
Expand Down
2 changes: 1 addition & 1 deletion mmv1/third_party/terraform/services/bigquery/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

func NewClient(c *transport_tpg.Config, userAgent string) *bigquery.Service {
bigQueryClientBasePath := c.BigQueryBasePath
bigQueryClientBasePath := transport_tpg.BaseUrl(Product, c)
log.Printf("[INFO] Instantiating Google Cloud BigQuery client for path %s", bigQueryClientBasePath)
wrappedBigQueryClient := transport_tpg.ClientWithAdditionalRetries(c.Client, transport_tpg.IamMemberMissing)
clientBigQuery, err := bigquery.NewService(c.Context, option.WithHTTPClient(wrappedBigQueryClient))
Expand Down
2 changes: 1 addition & 1 deletion mmv1/third_party/terraform/services/cloudbilling/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

func NewClient(c *transport_tpg.Config, userAgent string) *cloudbilling.APIService {
cloudBillingClientBasePath := transport_tpg.RemoveBasePathVersion(c.CloudBillingBasePath)
cloudBillingClientBasePath := transport_tpg.RemoveBasePathVersion(transport_tpg.BaseUrl(Product, c))
log.Printf("[INFO] Instantiating Google Cloud Billing client for path %s", cloudBillingClientBasePath)
clientBilling, err := cloudbilling.NewService(c.Context, option.WithHTTPClient(c.Client))
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

func NewClient(c *transport_tpg.Config, userAgent string) *cloudfunctions.Service {
cloudFunctionsClientBasePath := transport_tpg.RemoveBasePathVersion(c.CloudFunctionsBasePath)
cloudFunctionsClientBasePath := transport_tpg.RemoveBasePathVersion(transport_tpg.BaseUrl(Product, c))
log.Printf("[INFO] Instantiating Google Cloud CloudFunctions Client for path %s", cloudFunctionsClientBasePath)
clientCloudFunctions, err := cloudfunctions.NewService(c.Context, option.WithHTTPClient(c.Client))
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

func NewClient(c *transport_tpg.Config, userAgent string) *cloudidentity.Service {
cloudidentityClientBasePath := transport_tpg.RemoveBasePathVersion(c.CloudIdentityBasePath)
cloudidentityClientBasePath := transport_tpg.RemoveBasePathVersion(transport_tpg.BaseUrl(Product, c))
log.Printf("[INFO] Instantiating Google Cloud CloudIdentity client for path %s", cloudidentityClientBasePath)
clientCloudIdentity, err := cloudidentity.NewService(c.Context, option.WithHTTPClient(c.Client))
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion mmv1/third_party/terraform/services/cloudrunv2/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

func NewClient(c *transport_tpg.Config, userAgent string) *runadminv2.Service {
runAdminV2ClientBasePath := transport_tpg.RemoveBasePathVersion(transport_tpg.RemoveBasePathVersion(c.CloudRunV2BasePath))
runAdminV2ClientBasePath := transport_tpg.RemoveBasePathVersion(transport_tpg.RemoveBasePathVersion(transport_tpg.BaseUrl(Product, c)))
log.Printf("[INFO] Instantiating Google Cloud Run Admin v2 client for path %s", runAdminV2ClientBasePath)
clientRunAdminV2, err := runadminv2.NewService(c.Context, option.WithHTTPClient(c.Client))
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/hashicorp/terraform-provider-google/google/acctest"
"github.com/hashicorp/terraform-provider-google/google/envvar"
"github.com/hashicorp/terraform-provider-google/google/services/compute"
transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport"

"github.com/hashicorp/terraform-plugin-testing/helper/resource"
Expand Down Expand Up @@ -182,7 +183,7 @@ func testAccComputeInstanceGroup_destroyProducer(t *testing.T) func(s *terraform
continue
}
url := fmt.Sprintf("%sprojects/%s/zones/%s/instanceGroups/%s",
config.ComputeBasePath, config.Project, rs.Primary.Attributes["zone"], rs.Primary.Attributes["name"])
transport_tpg.BaseUrl(compute.Product, config), config.Project, rs.Primary.Attributes["zone"], rs.Primary.Attributes["name"])
_, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Config: config,
Method: "GET",
Expand Down Expand Up @@ -213,7 +214,7 @@ func testAccComputeInstanceGroup_exists(t *testing.T, n string, instanceGroup *m
config := acctest.GoogleProviderConfig(t)

url := fmt.Sprintf("%sprojects/%s/zones/%s/instanceGroups/%s",
config.ComputeBasePath, config.Project, rs.Primary.Attributes["zone"], rs.Primary.Attributes["name"])
transport_tpg.BaseUrl(compute.Product, config), config.Project, rs.Primary.Attributes["zone"], rs.Primary.Attributes["name"])
found, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Config: config,
Method: "GET",
Expand Down Expand Up @@ -245,7 +246,7 @@ func testAccComputeInstanceGroup_updated(t *testing.T, n string, size int64, ins
config := acctest.GoogleProviderConfig(t)

url := fmt.Sprintf("%sprojects/%s/zones/%s/instanceGroups/%s",
config.ComputeBasePath, config.Project, rs.Primary.Attributes["zone"], rs.Primary.Attributes["name"])
transport_tpg.BaseUrl(compute.Product, config), config.Project, rs.Primary.Attributes["zone"], rs.Primary.Attributes["name"])
instanceGroupRes, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Config: config,
Method: "GET",
Expand Down Expand Up @@ -283,7 +284,7 @@ func testAccComputeInstanceGroup_named_ports(t *testing.T, n string, np map[stri
config := acctest.GoogleProviderConfig(t)

url := fmt.Sprintf("%sprojects/%s/zones/%s/instanceGroups/%s",
config.ComputeBasePath, config.Project, rs.Primary.Attributes["zone"], rs.Primary.Attributes["name"])
transport_tpg.BaseUrl(compute.Product, config), config.Project, rs.Primary.Attributes["zone"], rs.Primary.Attributes["name"])
instanceGroupRes, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Config: config,
Method: "GET",
Expand Down Expand Up @@ -339,7 +340,7 @@ func testAccComputeInstanceGroup_hasCorrectNetwork(t *testing.T, nInstanceGroup
Method: "GET",
Project: config.Project,
RawURL: fmt.Sprintf("%sprojects/%s/zones/%s/instanceGroups/%s",
config.ComputeBasePath, config.Project, rsInstanceGroup.Primary.Attributes["zone"], rsInstanceGroup.Primary.Attributes["name"]),
transport_tpg.BaseUrl(compute.Product, config), config.Project, rsInstanceGroup.Primary.Attributes["zone"], rsInstanceGroup.Primary.Attributes["name"]),
UserAgent: config.UserAgent,
})
if err != nil {
Expand All @@ -358,7 +359,7 @@ func testAccComputeInstanceGroup_hasCorrectNetwork(t *testing.T, nInstanceGroup
Method: "GET",
Project: config.Project,
RawURL: fmt.Sprintf("%sprojects/%s/global/networks/%s",
config.ComputeBasePath, config.Project, rsNetwork.Primary.Attributes["name"]),
transport_tpg.BaseUrl(compute.Product, config), config.Project, rsNetwork.Primary.Attributes["name"]),
UserAgent: config.UserAgent,
})
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion mmv1/third_party/terraform/services/iambeta/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

func NewClient(c *transport_tpg.Config, userAgent string) *iam.Service {
iamClientBasePath := transport_tpg.RemoveBasePathVersion(c.IAMBetaBasePath)
iamClientBasePath := transport_tpg.RemoveBasePathVersion(transport_tpg.BaseUrl(Product, c))
log.Printf("[INFO] Instantiating Google Cloud IAM client for path %s", iamClientBasePath)
clientIAM, err := iam.NewService(c.Context, option.WithHTTPClient(c.Client))
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

func NewClient(c *transport_tpg.Config, userAgent string) *iamcredentials.Service {
iamCredentialsClientBasePath := transport_tpg.RemoveBasePathVersion(c.IamCredentialsBasePath)
iamCredentialsClientBasePath := transport_tpg.RemoveBasePathVersion(transport_tpg.BaseUrl(Product, c))
log.Printf("[INFO] Instantiating Google Cloud IAMCredentials client for path %s", iamCredentialsClientBasePath)
clientIamCredentials, err := iamcredentials.NewService(c.Context, option.WithHTTPClient(c.Client))
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion mmv1/third_party/terraform/services/serviceusage/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

func NewClient(c *transport_tpg.Config, userAgent string) *serviceusage.Service {
serviceUsageClientBasePath := transport_tpg.RemoveBasePathVersion(c.ServiceUsageBasePath)
serviceUsageClientBasePath := transport_tpg.RemoveBasePathVersion(transport_tpg.BaseUrl(Product, c))
log.Printf("[INFO] Instantiating Google Cloud Service Usage client for path %s", serviceUsageClientBasePath)
clientServiceUsage, err := serviceusage.NewService(c.Context, option.WithHTTPClient(c.Client))
if err != nil {
Expand Down
Loading