-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
152 additions
and
9 deletions.
There are no files selected for viewing
Submodule terraform
updated
from 6124c2 to c3764b
Submodule terraform-beta
updated
from f05c53 to 896d3d
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
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
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
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
110 changes: 110 additions & 0 deletions
110
provider/terraform/tests/resource_storage_default_object_access_control_test.go
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 |
---|---|---|
@@ -0,0 +1,110 @@ | ||
package google | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform/helper/resource" | ||
"github.com/hashicorp/terraform/terraform" | ||
) | ||
|
||
func TestAccStorageDefaultObjectAccessControl_basic(t *testing.T) { | ||
t.Parallel() | ||
|
||
bucketName := testBucketName() | ||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { | ||
if errObjectAcl != nil { | ||
panic(errObjectAcl) | ||
} | ||
testAccPreCheck(t) | ||
}, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccStorageDefaultObjectAccessControlDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testGoogleStorageDefaultObjectAccessControlBasic(bucketName, "READER", "allUsers"), | ||
}, | ||
{ | ||
ResourceName: "google_storage_default_object_access_control.default", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestAccStorageDefaultObjectAccessControl_update(t *testing.T) { | ||
t.Parallel() | ||
|
||
bucketName := testBucketName() | ||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { | ||
if errObjectAcl != nil { | ||
panic(errObjectAcl) | ||
} | ||
testAccPreCheck(t) | ||
}, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccStorageDefaultObjectAccessControlDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testGoogleStorageDefaultObjectAccessControlBasic(bucketName, "READER", "allUsers"), | ||
}, | ||
{ | ||
ResourceName: "google_storage_default_object_access_control.default", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
}, | ||
{ | ||
Config: testGoogleStorageDefaultObjectAccessControlBasic(bucketName, "OWNER", "allUsers"), | ||
}, | ||
{ | ||
ResourceName: "google_storage_default_object_access_control.default", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccStorageDefaultObjectAccessControlDestroy(s *terraform.State) error { | ||
config := testAccProvider.Meta().(*Config) | ||
|
||
for _, rs := range s.RootModule().Resources { | ||
if rs.Type != "google_storage_bucket_acl" { | ||
continue | ||
} | ||
|
||
bucket := rs.Primary.Attributes["bucket"] | ||
entity := rs.Primary.Attributes["entity"] | ||
|
||
rePairs, err := config.clientStorage.DefaultObjectAccessControls.List(bucket).Do() | ||
if err != nil { | ||
return fmt.Errorf("Can't list role entity acl for bucket %s", bucket) | ||
} | ||
|
||
for _, v := range rePairs.Items { | ||
if v.Entity == entity { | ||
return fmt.Errorf("found entity %s as role entity acl entry in bucket %s", entity, bucket) | ||
} | ||
} | ||
|
||
} | ||
|
||
return nil | ||
} | ||
|
||
func testGoogleStorageDefaultObjectAccessControlBasic(bucketName, role, entity string) string { | ||
return fmt.Sprintf(` | ||
resource "google_storage_bucket" "bucket" { | ||
name = "%s" | ||
} | ||
resource "google_storage_default_object_access_control" "default" { | ||
bucket = "${google_storage_bucket.bucket.name}" | ||
role = "%s" | ||
entity = "%s" | ||
} | ||
`, bucketName, role, entity) | ||
} |
File renamed without changes.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
9 changes: 9 additions & 0 deletions
9
templates/terraform/examples/storage_default_object_access_control_public.tf.erb
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
resource "google_storage_default_object_access_control" "<%= ctx[:primary_resource_id] %>" { | ||
bucket = "${google_storage_bucket.bucket.name}" | ||
role = "READER" | ||
entity = "allUsers" | ||
} | ||
|
||
resource "google_storage_bucket" "bucket" { | ||
name = "<%= ctx[:vars]['bucket_name'] %>" | ||
} |
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