From 5a47db4d94d0957fd8b69f9c41af89b3e78fb70f Mon Sep 17 00:00:00 2001 From: The Magician Date: Tue, 30 Oct 2018 12:36:19 -0700 Subject: [PATCH] Remove beta generated resource maps from GA provider. (#2350) /cc @rileykarson --- google/filestore_operation.go | 70 +----- ...ource_binaryauthorization_attestor_test.go | 181 +------------- ...esource_binaryauthorization_policy_test.go | 225 +----------------- .../resource_containeranalysis_note_test.go | 101 +------- google/resource_filestore_instance_test.go | 148 +----------- 5 files changed, 5 insertions(+), 720 deletions(-) diff --git a/google/filestore_operation.go b/google/filestore_operation.go index 05ce0592..93cfad7a 100644 --- a/google/filestore_operation.go +++ b/google/filestore_operation.go @@ -1,71 +1,3 @@ package google -import ( - "fmt" - "log" - "time" - - "github.com/hashicorp/terraform/helper/resource" - file "google.golang.org/api/file/v1beta1" -) - -type FilestoreOperationWaiter struct { - Service *file.ProjectsLocationsService - Op *file.Operation -} - -func (w *FilestoreOperationWaiter) RefreshFunc() resource.StateRefreshFunc { - return func() (interface{}, string, error) { - op, err := w.Service.Operations.Get(w.Op.Name).Do() - - if err != nil { - return nil, "", err - } - - log.Printf("[DEBUG] Got %v while polling for operation %s's 'done' status", op.Done, w.Op.Name) - - return op, fmt.Sprint(op.Done), nil - } -} - -func (w *FilestoreOperationWaiter) Conf() *resource.StateChangeConf { - return &resource.StateChangeConf{ - Pending: []string{"false"}, - Target: []string{"true"}, - Refresh: w.RefreshFunc(), - } -} - -func filestoreOperationWait(service *file.Service, op *file.Operation, project, activity string) error { - return filestoreOperationWaitTime(service, op, project, activity, 4) -} - -func filestoreOperationWaitTime(service *file.Service, op *file.Operation, project, activity string, timeoutMin int) error { - if op.Done { - if op.Error != nil { - return fmt.Errorf("Error code %v, message: %s", op.Error.Code, op.Error.Message) - } - return nil - } - - w := &FilestoreOperationWaiter{ - Service: service.Projects.Locations, - Op: op, - } - - state := w.Conf() - state.Delay = 10 * time.Second - state.Timeout = time.Duration(timeoutMin) * time.Minute - state.MinTimeout = 2 * time.Second - opRaw, err := state.WaitForState() - if err != nil { - return fmt.Errorf("Error waiting for %s: %s", activity, err) - } - - op = opRaw.(*file.Operation) - if op.Error != nil { - return fmt.Errorf("Error code %v, message: %s", op.Error.Code, op.Error.Message) - } - - return nil -} +// Magic Modules doesn't let us remove files - blank out beta-only common-compile files for now. diff --git a/google/resource_binaryauthorization_attestor_test.go b/google/resource_binaryauthorization_attestor_test.go index 01cbde01..93cfad7a 100644 --- a/google/resource_binaryauthorization_attestor_test.go +++ b/google/resource_binaryauthorization_attestor_test.go @@ -1,182 +1,3 @@ package google -import ( - "fmt" - "testing" - - "github.com/hashicorp/terraform/helper/acctest" - "github.com/hashicorp/terraform/helper/resource" - "github.com/hashicorp/terraform/terraform" -) - -func TestAccBinaryAuthorizationAttestor_basic(t *testing.T) { - t.Parallel() - - name := acctest.RandString(10) - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckBinaryAuthorizationAttestorDestroy, - Steps: []resource.TestStep{ - { - Config: testAccBinaryAuthorizationAttestorBasic(name), - }, - { - ResourceName: "google_binary_authorization_attestor.attestor", - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - -func TestAccBinaryAuthorizationAttestor_full(t *testing.T) { - t.Parallel() - - name := acctest.RandString(10) - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckBinaryAuthorizationAttestorDestroy, - Steps: []resource.TestStep{ - { - Config: testAccBinaryAuthorizationAttestorFull(name), - }, - { - ResourceName: "google_binary_authorization_attestor.attestor", - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - -func TestAccBinaryAuthorizationAttestor_update(t *testing.T) { - t.Parallel() - - name := acctest.RandString(10) - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckBinaryAuthorizationAttestorDestroy, - Steps: []resource.TestStep{ - resource.TestStep{ - Config: testAccBinaryAuthorizationAttestorBasic(name), - }, - { - ResourceName: "google_binary_authorization_attestor.attestor", - ImportState: true, - ImportStateVerify: true, - }, - { - Config: testAccBinaryAuthorizationAttestorFull(name), - }, - { - ResourceName: "google_binary_authorization_attestor.attestor", - ImportState: true, - ImportStateVerify: true, - }, - { - Config: testAccBinaryAuthorizationAttestorBasic(name), - }, - { - ResourceName: "google_binary_authorization_attestor.attestor", - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - -func testAccCheckBinaryAuthorizationAttestorDestroy(s *terraform.State) error { - config := testAccProvider.Meta().(*Config) - - for _, rs := range s.RootModule().Resources { - if rs.Type != "google_binary_authorization_attestor" { - continue - } - - project, err := getTestProject(rs.Primary, config) - if err != nil { - return err - } - - name := rs.Primary.Attributes["name"] - - url := fmt.Sprintf("https://binaryauthorization.googleapis.com/v1beta1/projects/%s/attestors/%s", project, name) - _, err = sendRequest(config, "GET", url, nil) - - if err == nil { - return fmt.Errorf("Error, attestor %s still exists", name) - } - } - - return nil -} - -func testAccBinaryAuthorizationAttestorBasic(name string) string { - return fmt.Sprintf(` -resource "google_container_analysis_note" "note" { - name = "tf-test-%s" - attestation_authority { - hint { - human_readable_name = "My Attestor" - } - } -} - -resource "google_binary_authorization_attestor" "attestor" { - name = "tf-test-%s" - attestation_authority_note { - note_reference = "${google_container_analysis_note.note.name}" - } -} -`, name, name) -} - -func testAccBinaryAuthorizationAttestorFull(name string) string { - return fmt.Sprintf(` -resource "google_container_analysis_note" "note" { - name = "tf-test-%s" - attestation_authority { - hint { - human_readable_name = "My Attestor" - } - } -} - -resource "google_binary_authorization_attestor" "attestor" { - name = "tf-test-%s" - description = "my description" - attestation_authority_note { - note_reference = "${google_container_analysis_note.note.name}" - public_keys { - ascii_armored_pgp_public_key = <