-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove beta generated resource maps from GA provider. (#2350)
<!-- This change is generated by MagicModules. --> /cc @rileykarson
- Loading branch information
1 parent
0c7bc33
commit 081847c
Showing
5 changed files
with
5 additions
and
720 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 = <<EOF | ||
%s | ||
EOF | ||
comment = "this key has a comment" | ||
} | ||
} | ||
} | ||
`, name, name, armoredPubKey) | ||
} | ||
|
||
// Generated key using instructions from | ||
// https://cloud.google.com/binary-authorization/docs/creating-attestors#generate_pgp_key_pairs. | ||
// This key has no real meaning and was generated in order to have a valid key | ||
// for testing. | ||
const armoredPubKey = `mQENBFtP0doBCADF+joTiXWKVuP8kJt3fgpBSjT9h8ezMfKA4aXZctYLx5wslWQl | ||
bB7Iu2ezkECNzoEeU7WxUe8a61pMCh9cisS9H5mB2K2uM4Jnf8tgFeXn3akJDVo0 | ||
oR1IC+Dp9mXbRSK3MAvKkOwWlG99sx3uEdvmeBRHBOO+grchLx24EThXFOyP9Fk6 | ||
V39j6xMjw4aggLD15B4V0v9JqBDdJiIYFzszZDL6pJwZrzcP0z8JO4rTZd+f64bD | ||
Mpj52j/pQfA8lZHOaAgb1OrthLdMrBAjoDjArV4Ek7vSbrcgYWcI6BhsQrFoxKdX | ||
83TZKai55ZCfCLIskwUIzA1NLVwyzCS+fSN/ABEBAAG0KCJUZXN0IEF0dGVzdG9y | ||
IiA8ZGFuYWhvZmZtYW5AZ29vZ2xlLmNvbT6JAU4EEwEIADgWIQRfWkqHt6hpTA1L | ||
uY060eeM4dc66AUCW0/R2gIbLwULCQgHAgYVCgkICwIEFgIDAQIeAQIXgAAKCRA6 | ||
0eeM4dc66HdpCAC4ot3b0OyxPb0Ip+WT2U0PbpTBPJklesuwpIrM4Lh0N+1nVRLC | ||
51WSmVbM8BiAFhLbN9LpdHhds1kUrHF7+wWAjdR8sqAj9otc6HGRM/3qfa2qgh+U | ||
WTEk/3us/rYSi7T7TkMuutRMIa1IkR13uKiW56csEMnbOQpn9rDqwIr5R8nlZP5h | ||
MAU9vdm1DIv567meMqTaVZgR3w7bck2P49AO8lO5ERFpVkErtu/98y+rUy9d789l | ||
+OPuS1NGnxI1YKsNaWJF4uJVuvQuZ1twrhCbGNtVorO2U12+cEq+YtUxj7kmdOC1 | ||
qoIRW6y0+UlAc+MbqfL0ziHDOAmcqz1GnROg | ||
=6Bvm` | ||
// Magic Modules doesn't let us remove files - blank out beta-only common-compile files for now. |
Oops, something went wrong.