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

TPG 3.0.0 changes #4680

Merged
merged 1 commit into from
Nov 13, 2019
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion google/batcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (b *RequestBatcher) stop() {
// may choose to use a key with method if needed to diff GET/read and
// POST/create)
//
// As an example, for google_project_service and google_project_services, the
// As an example, for google_project_service, the
// batcher is called to batch services.batchEnable() calls for a project
// $PROJECT. The calling code uses the template
// "serviceusage:projects/$PROJECT/services:batchEnable", which mirrors the HTTP request:
Expand Down
1 change: 1 addition & 0 deletions google/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ var defaultClientScopes = []string{
"https://www.googleapis.com/auth/cloud-platform",
"https://www.googleapis.com/auth/ndev.clouddns.readwrite",
"https://www.googleapis.com/auth/devstorage.full_control",
"https://www.googleapis.com/auth/userinfo.email",
}

func (c *Config) LoadAndValidate() error {
Expand Down
3 changes: 2 additions & 1 deletion google/data_source_compute_lb_ip_ranges_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ func TestAccDataSourceComputeLbIpRanges_basic(t *testing.T) {
}

const testAccComputeLbIpRangesConfig = `
data "google_compute_lb_ip_ranges" "some" {}
data "google_compute_lb_ip_ranges" "some" {
}
`
8 changes: 6 additions & 2 deletions google/data_source_compute_network_endpoint_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@ func dataSourceGoogleComputeNetworkEndpointGroup() *schema.Resource {
func dataSourceComputeNetworkEndpointGroupRead(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
if name, ok := d.GetOk("name"); ok {
project, err := getProject(d, config)
if err != nil {
return err
}
zone, err := getZone(d, config)
if err != nil {
return err
}
d.SetId(fmt.Sprintf("%s/%s", zone, name.(string)))
d.SetId(fmt.Sprintf("projects/%s/zones/%s/networkEndpointGroups/%s", project, zone, name.(string)))
} else if selfLink, ok := d.GetOk("self_link"); ok {
parsed, err := ParseNetworkEndpointGroupFieldValue(selfLink.(string), d, config)
if err != nil {
Expand All @@ -38,7 +42,7 @@ func dataSourceComputeNetworkEndpointGroupRead(d *schema.ResourceData, meta inte
d.Set("name", parsed.Name)
d.Set("zone", parsed.Zone)
d.Set("project", parsed.Project)
d.SetId(fmt.Sprintf("%s/%s", parsed.Zone, parsed.Name))
d.SetId(fmt.Sprintf("projects/%s/zones/%s/networkEndpointGroups/%s", parsed.Project, parsed.Zone, parsed.Name))
} else {
return errors.New("Must provide either `self_link` or `zone/name`")
}
Expand Down
33 changes: 18 additions & 15 deletions google/data_source_container_registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,26 +67,29 @@ func TestDataSourceGoogleContainerRegistryImage(t *testing.T) {

const testAccCheckGoogleContainerRegistryImage_basic = `
data "google_container_registry_image" "test" {
project = "foo"
region = "bar"
name = "baz"
project = "foo"
region = "bar"
name = "baz"
}

data "google_container_registry_image" "test2" {
project = "foo"
region = "bar"
name = "baz"
tag = "qux"
project = "foo"
region = "bar"
name = "baz"
tag = "qux"
}

data "google_container_registry_image" "test3" {
project = "foo"
region = "bar"
name = "baz"
digest = "1234"
project = "foo"
region = "bar"
name = "baz"
digest = "1234"
}

data "google_container_registry_image" "testScoped" {
project = "example.com:foo"
region = "bar"
name = "baz"
tag = "qux"
project = "example.com:foo"
region = "bar"
name = "baz"
tag = "qux"
}
`
10 changes: 7 additions & 3 deletions google/data_source_dns_managed_zone.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package google

import "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
import (
"fmt"

"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

func dataSourceDnsManagedZone() *schema.Resource {
return &schema.Resource{
Expand Down Expand Up @@ -43,13 +47,13 @@ func dataSourceDnsManagedZone() *schema.Resource {
func dataSourceDnsManagedZoneRead(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)

d.SetId(d.Get("name").(string))

project, err := getProject(d, config)
if err != nil {
return err
}

d.SetId(fmt.Sprintf("projects/%s/managedZones/%s", project, d.Get("name").(string)))

zone, err := config.clientDns.ManagedZones.Get(
project, d.Id()).Do()
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions google/data_source_dns_managed_zone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ func TestAccDataSourceDnsManagedZone_basic(t *testing.T) {
func testAccDataSourceDnsManagedZone_basic() string {
return fmt.Sprintf(`
resource "google_dns_managed_zone" "foo" {
name = "qa-zone-%s"
dns_name = "qa.tf-test.club."
description = "QA DNS zone"
name = "qa-zone-%s"
dns_name = "qa.tf-test.club."
description = "QA DNS zone"
}

data "google_dns_managed_zone" "qa" {
name = "${google_dns_managed_zone.foo.name}"
name = google_dns_managed_zone.foo.name
}
`, acctest.RandString(10))
}
7 changes: 4 additions & 3 deletions google/data_source_google_active_folder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,14 @@ func testAccDataSourceGoogleActiveFolderCheck(data_source_name string, resource_
func testAccDataSourceGoogleActiveFolderConfig(parent string, displayName string) string {
return fmt.Sprintf(`
resource "google_folder" "foobar" {
parent = "%s"
parent = "%s"
display_name = "%s"
}

data "google_active_folder" "my_folder" {
parent = "${google_folder.foobar.parent}"
display_name = "${google_folder.foobar.display_name}"
parent = google_folder.foobar.parent
display_name = google_folder.foobar.display_name
}

`, parent, displayName)
}
11 changes: 7 additions & 4 deletions google/data_source_google_billing_account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,23 @@ func testAccCheckGoogleBillingAccount_byName(name string) string {
return fmt.Sprintf(`
data "google_billing_account" "acct" {
billing_account = "%s"
}`, name)
}
`, name)
}

func testAccCheckGoogleBillingAccount_byNameClosed(name string) string {
return fmt.Sprintf(`
data "google_billing_account" "acct" {
billing_account = "%s"
open = false
}`, name)
open = false
}
`, name)
}

func testAccCheckGoogleBillingAccount_byDisplayName(name string) string {
return fmt.Sprintf(`
data "google_billing_account" "acct" {
display_name = "%s"
}`, name)
}
`, name)
}
2 changes: 1 addition & 1 deletion google/data_source_google_client_openid_userinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func dataSourceGoogleClientOpenIDUserinfoRead(d *schema.ResourceData, meta inter
// URL retrieved from https://accounts.google.com/.well-known/openid-configuration
res, err := sendRequest(config, "GET", "", "https://openidconnect.googleapis.com/v1/userinfo", nil)
if err != nil {
return fmt.Errorf("error retrieving userinfo for your provider credentials; have you enabled the 'https://www.googleapis.com/auth/userinfo.email' scope? error: %s", err)
return fmt.Errorf("error retrieving userinfo for your provider credentials. have you enabled the 'https://www.googleapis.com/auth/userinfo.email' scope? error: %s", err)
}

d.SetId(time.Now().UTC().String())
Expand Down
20 changes: 1 addition & 19 deletions google/data_source_google_client_openid_userinfo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,5 @@ func TestAccDataSourceGoogleClientOpenIDUserinfo_basic(t *testing.T) {
}

const testAccCheckGoogleClientOpenIDUserinfo_basic = `
provider "google" {
alias = "google-scoped"

# We need to add an additional scope to test this; because our tests rely on
# every env var being set, we can just add an alias with the appropriate
# scopes. This will fail if someone uses an access token instead of creds
# unless they've configured the userinfo.email scope.
scopes = [
"https://www.googleapis.com/auth/compute",
"https://www.googleapis.com/auth/cloud-platform",
"https://www.googleapis.com/auth/ndev.clouddns.readwrite",
"https://www.googleapis.com/auth/devstorage.full_control",
"https://www.googleapis.com/auth/userinfo.email",
]
}

data "google_client_openid_userinfo" "me" {
provider = "google.google-scoped"
}
data "google_client_openid_userinfo" "me" {}
`
2 changes: 1 addition & 1 deletion google/data_source_google_cloudfunctions_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func dataSourceGoogleCloudFunctionsFunctionRead(d *schema.ResourceData, meta int
Name: d.Get("name").(string),
}

d.SetId(cloudFuncId.terraformId())
d.SetId(cloudFuncId.cloudFunctionId())

err = resourceCloudFunctionsRead(d, meta)
if err != nil {
Expand Down
9 changes: 5 additions & 4 deletions google/data_source_google_cloudfunctions_function_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,24 @@ resource "google_storage_bucket" "bucket" {

resource "google_storage_bucket_object" "archive" {
name = "index.zip"
bucket = "${google_storage_bucket.bucket.name}"
bucket = google_storage_bucket.bucket.name
source = "%s"
}

resource "google_cloudfunctions_function" "function_http" {
name = "%s-http"
runtime = "nodejs8"
description = "test function"
available_memory_mb = 128
source_archive_bucket = "${google_storage_bucket.bucket.name}"
source_archive_object = "${google_storage_bucket_object.archive.name}"
source_archive_bucket = google_storage_bucket.bucket.name
source_archive_object = google_storage_bucket_object.archive.name
trigger_http = true
timeout = 61
entry_point = "helloGET"
}

data "google_cloudfunctions_function" "function_http" {
name = "${google_cloudfunctions_function.function_http.name}"
name = google_cloudfunctions_function.function_http.name
}
`, bucketName, zipFilePath, functionName)
}
3 changes: 1 addition & 2 deletions google/data_source_google_compute_address.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package google
import (
"fmt"
"regexp"
"strconv"
"strings"

"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
Expand Down Expand Up @@ -78,7 +77,7 @@ func dataSourceGoogleComputeAddressRead(d *schema.ResourceData, meta interface{}
d.Set("project", project)
d.Set("region", region)

d.SetId(strconv.FormatUint(address.Id, 10))
d.SetId(fmt.Sprintf("projects/%s/regions/%s/addresses/%s", project, region, name))
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions google/data_source_google_compute_address_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,11 @@ func testAccCheckDataSourceComputeAddressDestroy(resource_name string) resource.
func testAccDataSourceComputeAddressConfig(rsName, dsName string) string {
return fmt.Sprintf(`
resource "google_compute_address" "%s" {
name = "address-test"
name = "address-test"
}

data "google_compute_address" "%s" {
name = "${google_compute_address.%s.name}"
name = google_compute_address.%s.name
}
`, rsName, dsName, rsName)
}
11 changes: 10 additions & 1 deletion google/data_source_google_compute_backend_service.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package google

import (
"fmt"

"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

Expand All @@ -20,9 +22,16 @@ func dataSourceGoogleComputeBackendService() *schema.Resource {
}

func dataSourceComputeBackendServiceRead(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)

serviceName := d.Get("name").(string)

d.SetId(serviceName)
project, err := getProject(d, config)
if err != nil {
return err
}

d.SetId(fmt.Sprintf("projects/%s/global/backendServices/%s", project, serviceName))

return resourceComputeBackendServiceRead(d, meta)
}
4 changes: 2 additions & 2 deletions google/data_source_google_compute_backend_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func testAccDataSourceComputeBackendService_basic(serviceName, checkName string)
resource "google_compute_backend_service" "foobar" {
name = "%s"
description = "foobar backend service"
health_checks = ["${google_compute_http_health_check.zero.self_link}"]
health_checks = [google_compute_http_health_check.zero.self_link]
}

resource "google_compute_http_health_check" "zero" {
Expand All @@ -43,7 +43,7 @@ resource "google_compute_http_health_check" "zero" {
}

data "google_compute_backend_service" "baz" {
name = "${google_compute_backend_service.foobar.name}"
name = google_compute_backend_service.foobar.name
}
`, serviceName, checkName)
}
2 changes: 1 addition & 1 deletion google/data_source_google_compute_forwarding_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func dataSourceGoogleComputeForwardingRuleRead(d *schema.ResourceData, meta inte
if err != nil {
return handleNotFoundError(err, d, fmt.Sprintf("Forwarding Rule Not Found : %s", name))
}
d.SetId(frule.Name)
d.SetId(fmt.Sprintf("projects/%s/regions/%s/forwardingRules/%s", project, region, name))

d.Set("self_link", frule.SelfLink)
d.Set("description", frule.Description)
Expand Down
32 changes: 17 additions & 15 deletions google/data_source_google_compute_forwarding_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,22 @@ func testAccDataSourceGoogleForwardingRuleCheck(data_source_name string, resourc

func testAccDataSourceGoogleForwardingRuleConfig(poolName, ruleName string) string {
return fmt.Sprintf(`
resource "google_compute_target_pool" "foobar-tp" {
description = "Resource created for Terraform acceptance testing"
instances = ["us-central1-a/foo", "us-central1-b/bar"]
name = "%s"
}
resource "google_compute_forwarding_rule" "foobar-fr" {
description = "Resource created for Terraform acceptance testing"
ip_protocol = "UDP"
name = "%s"
port_range = "80-81"
target = "${google_compute_target_pool.foobar-tp.self_link}"
}
data "google_compute_forwarding_rule" "my_forwarding_rule" {
name = "${google_compute_forwarding_rule.foobar-fr.name}"
}
resource "google_compute_target_pool" "foobar-tp" {
description = "Resource created for Terraform acceptance testing"
instances = ["us-central1-a/foo", "us-central1-b/bar"]
name = "%s"
}

resource "google_compute_forwarding_rule" "foobar-fr" {
description = "Resource created for Terraform acceptance testing"
ip_protocol = "UDP"
name = "%s"
port_range = "80-81"
target = google_compute_target_pool.foobar-tp.self_link
}

data "google_compute_forwarding_rule" "my_forwarding_rule" {
name = google_compute_forwarding_rule.foobar-fr.name
}
`, poolName, ruleName)
}
4 changes: 1 addition & 3 deletions google/data_source_google_compute_global_address.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package google

import (
"fmt"
"strconv"

"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)
Expand Down Expand Up @@ -58,7 +57,6 @@ func dataSourceGoogleComputeGlobalAddressRead(d *schema.ResourceData, meta inter
d.Set("status", address.Status)
d.Set("self_link", address.SelfLink)
d.Set("project", project)

d.SetId(strconv.FormatUint(address.Id, 10))
d.SetId(fmt.Sprintf("projects/%s/global/addresses/%s", project, name))
return nil
}
Loading