Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow overriding the base path for a URL with custom endpoints #96

Merged
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
8 changes: 4 additions & 4 deletions google/compute_forwarding_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func expandComputeForwardingRuleBackendService(v interface{}, d TerraformResourc
return "https://www.googleapis.com/compute/v1/" + v.(string), nil
} else if strings.HasPrefix(v.(string), "regions/") || strings.HasPrefix(v.(string), "zones/") {
// For regional or zonal resources which include their region or zone, just put the project in front.
url, err := replaceVars(d, config, "https://www.googleapis.com/compute/v1/projects/{{project}}/")
url, err := replaceVars(d, config, "{{ComputeBasePath}}projects/{{project}}/")
if err != nil {
return nil, err
}
Expand All @@ -179,7 +179,7 @@ func expandComputeForwardingRuleBackendService(v interface{}, d TerraformResourc
// Anything else is assumed to be a regional resource, with a partial link that begins with the resource name.
// This isn't very likely - it's a last-ditch effort to extract something useful here. We can do a better job
// as soon as MultiResourceRefs are working since we'll know the types that this field is supposed to point to.
url, err := replaceVars(d, config, "https://www.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/")
url, err := replaceVars(d, config, "{{ComputeBasePath}}projects/{{project}}/regions/{{region}}/")
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -235,7 +235,7 @@ func expandComputeForwardingRuleTarget(v interface{}, d TerraformResourceData, c
return "https://www.googleapis.com/compute/v1/" + v.(string), nil
} else if strings.HasPrefix(v.(string), "regions/") || strings.HasPrefix(v.(string), "zones/") {
// For regional or zonal resources which include their region or zone, just put the project in front.
url, err := replaceVars(d, config, "https://www.googleapis.com/compute/v1/projects/{{project}}/")
url, err := replaceVars(d, config, "{{ComputeBasePath}}projects/{{project}}/")
if err != nil {
return nil, err
}
Expand All @@ -244,7 +244,7 @@ func expandComputeForwardingRuleTarget(v interface{}, d TerraformResourceData, c
// Anything else is assumed to be a regional resource, with a partial link that begins with the resource name.
// This isn't very likely - it's a last-ditch effort to extract something useful here. We can do a better job
// as soon as MultiResourceRefs are working since we'll know the types that this field is supposed to point to.
url, err := replaceVars(d, config, "https://www.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/")
url, err := replaceVars(d, config, "{{ComputeBasePath}}projects/{{project}}/regions/{{region}}/")
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions google/compute_target_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func expandComputeTargetInstanceInstance(v interface{}, d TerraformResourceData,
return "https://www.googleapis.com/compute/v1/" + v.(string), nil
} else if strings.HasPrefix(v.(string), "regions/") || strings.HasPrefix(v.(string), "zones/") {
// For regional or zonal resources which include their region or zone, just put the project in front.
url, err := replaceVars(d, config, "https://www.googleapis.com/compute/v1/projects/{{project}}/")
url, err := replaceVars(d, config, "{{ComputeBasePath}}projects/{{project}}/")
if err != nil {
return nil, err
}
Expand All @@ -107,7 +107,7 @@ func expandComputeTargetInstanceInstance(v interface{}, d TerraformResourceData,
// Anything else is assumed to be a regional resource, with a partial link that begins with the resource name.
// This isn't very likely - it's a last-ditch effort to extract something useful here. We can do a better job
// as soon as MultiResourceRefs are working since we'll know the types that this field is supposed to point to.
url, err := replaceVars(d, config, "https://www.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/")
url, err := replaceVars(d, config, "{{ComputeBasePath}}projects/{{project}}/regions/{{region}}/")
if err != nil {
return nil, err
}
Expand Down
Loading