diff --git a/builtin/providers/google/import_google_project_test.go b/builtin/providers/google/import_google_project_test.go index b35c8d6bcc76..3e73e60926f7 100644 --- a/builtin/providers/google/import_google_project_test.go +++ b/builtin/providers/google/import_google_project_test.go @@ -9,7 +9,7 @@ import ( func TestAccGoogleProject_importBasic(t *testing.T) { resourceName := "google_project.acceptance" - conf := fmt.Sprintf(testAccGoogleProject_basic, projectId) + conf := testAccGoogleProject_import(projectId) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -27,3 +27,10 @@ func TestAccGoogleProject_importBasic(t *testing.T) { }, }) } + +func testAccGoogleProject_import(pid string) string { + return fmt.Sprintf(` +resource "google_project" "acceptance" { + project_id = "%s" +}`, pid) +} diff --git a/builtin/providers/google/resource_google_project.go b/builtin/providers/google/resource_google_project.go index 15ad3ed5fc78..35bce02512b4 100644 --- a/builtin/providers/google/resource_google_project.go +++ b/builtin/providers/google/resource_google_project.go @@ -444,9 +444,6 @@ func resourceServicesDelta(d *schema.ResourceData) (added, removed []string) { newMap[v.(string)] = true } - added = make([]string, 0) - removed = make([]string, 0) - // Find removed services for k, _ := range oldMap { if newMap[k] { diff --git a/builtin/providers/google/resource_google_project_test.go b/builtin/providers/google/resource_google_project_test.go index 92c2e4cac60b..055343653450 100644 --- a/builtin/providers/google/resource_google_project_test.go +++ b/builtin/providers/google/resource_google_project_test.go @@ -32,23 +32,23 @@ func multiEnvSearch(ks []string) string { } // Test that a Project resource can be created and destroyed -func TestAccGoogleProject_basic(t *testing.T) { +func TestAccGoogleProject_create(t *testing.T) { pid := "terraform-" + acctest.RandString(10) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccGoogleProjectBasic(pid, name, org), + Config: testAccGoogleProject_create(pid, name, org), Check: resource.ComposeTestCheckFunc( testAccCheckGoogleProjectExists("google_project.acceptance", pid), ), }, resource.TestStep{ - Config: testAccGoogleProjectTwoServices(pid, name, org), + Config: testAccGoogleProject_twoServices(pid, name, org), }, resource.TestStep{ - Config: testAccGoogleProjectOneService(pid, name, org), + Config: testAccGoogleProject_oneService(pid, name, org), }, }, }) @@ -65,7 +65,7 @@ func TestAccGoogleProject_iamPolicy1(t *testing.T) { Steps: []resource.TestStep{ // Create a project resource.TestStep{ - Config: testAccGoogleProjectBasic(pid, name, org), + Config: testAccGoogleProject_create(pid, name, org), Check: resource.ComposeTestCheckFunc( testAccGoogleProjectExistingPolicy(pid), ), @@ -73,7 +73,7 @@ func TestAccGoogleProject_iamPolicy1(t *testing.T) { // Second step applies an IAM policy from a data source. The application // merges policies, so we validate the expected state. resource.TestStep{ - Config: testAccGoogleProjectPolicy1(pid, name, org), + Config: testAccGoogleProject_policy1(pid, name, org), Check: resource.ComposeTestCheckFunc( testAccCheckGoogleProjectExists("google_project.acceptance", pid), testAccCheckGoogleProjectIamPolicyIsMerged("google_project.acceptance", "data.google_iam_policy.admin", pid), @@ -82,7 +82,7 @@ func TestAccGoogleProject_iamPolicy1(t *testing.T) { // Finally, remove the custom IAM policy from config and apply, then // confirm that the project is in its original state. resource.TestStep{ - Config: testAccGoogleProjectBasic(pid, name, org), + Config: testAccGoogleProject_create(pid, name, org), }, }, }) @@ -454,7 +454,7 @@ func (b Binding) Less(i, j int) bool { return b[i].Role < b[j].Role } -func testAccGoogleProjectBasic(pid, name, org string) string { +func testAccGoogleProject_create(pid, name, org string) string { return fmt.Sprintf(` resource "google_project" "acceptance" { project_id = "%s" @@ -463,7 +463,7 @@ resource "google_project" "acceptance" { }`, pid, name, org) } -func testAccGoogleProjectTwoServices(pid, name, org string) string { +func testAccGoogleProject_twoServices(pid, name, org string) string { return fmt.Sprintf(` resource "google_project" "acceptance" { project_id = "%s" @@ -473,7 +473,7 @@ resource "google_project" "acceptance" { }`, pid, name, org) } -func testAccGoogleProjectOneService(pid, name, org string) string { +func testAccGoogleProject_oneService(pid, name, org string) string { return fmt.Sprintf(` resource "google_project" "acceptance" { project_id = "%s" @@ -483,7 +483,7 @@ resource "google_project" "acceptance" { }`, pid, name, org) } -func testAccGoogleProjectPolicy1(pid, name, org string) string { +func testAccGoogleProject_policy1(pid, name, org string) string { return fmt.Sprintf(` resource "google_project" "acceptance" { project_id = "%s" diff --git a/builtin/providers/google/resourcemanager_operation.go b/builtin/providers/google/resourcemanager_operation.go index f0c0209e65b1..32c6d3435ca5 100644 --- a/builtin/providers/google/resourcemanager_operation.go +++ b/builtin/providers/google/resourcemanager_operation.go @@ -16,10 +16,7 @@ type ResourceManagerOperationWaiter struct { func (w *ResourceManagerOperationWaiter) RefreshFunc() resource.StateRefreshFunc { return func() (interface{}, string, error) { - var op *cloudresourcemanager.Operation - var err error - - op, err = w.Service.Operations.Get(w.Op.Name).Do() + op, err := w.Service.Operations.Get(w.Op.Name).Do() if err != nil { return nil, "", err diff --git a/website/source/docs/providers/google/r/google_project.html.markdown b/website/source/docs/providers/google/r/google_project.html.markdown index 523c46fcd7c2..fae34e4ce931 100644 --- a/website/source/docs/providers/google/r/google_project.html.markdown +++ b/website/source/docs/providers/google/r/google_project.html.markdown @@ -54,7 +54,7 @@ The following arguments are supported: * `org_id` - (Required) The numeric ID of the organization this project belongs to. Changing this forces a new project to be created. -* `name` - (Optional) The display name of the project. +* `name` - (Required) The display name of the project. * `services` - (Optional) The services/APIs that are enabled for this project. For a list of available services, run `gcloud beta service-management list`