-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bring forwards/backwards compatible 0.12 syntax to HEAD (#408)
<!-- This change is generated by MagicModules. --> /cc @rileykarson
- Loading branch information
1 parent
7e71b70
commit 3c953a2
Showing
15 changed files
with
139 additions
and
173 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
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
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,7 +1,6 @@ | ||
package google | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"reflect" | ||
"testing" | ||
|
@@ -19,37 +18,6 @@ func TestAccFolderIamPolicy_basic(t *testing.T) { | |
org := getTestOrgFromEnv(t) | ||
parent := "organizations/" + org | ||
|
||
policy := &resourceManagerV2Beta1.Policy{ | ||
Bindings: []*resourceManagerV2Beta1.Binding{ | ||
{ | ||
Role: "roles/viewer", | ||
Members: []string{ | ||
"user:[email protected]", | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckGoogleFolderIamPolicyDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccFolderIamPolicy_basic(folderDisplayName, parent, policy), | ||
Check: testAccCheckGoogleFolderIamPolicy("google_folder_iam_policy.test", policy), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestAccFolderIamPolicy_update(t *testing.T) { | ||
t.Parallel() | ||
|
||
folderDisplayName := "tf-test-" + acctest.RandString(10) | ||
org := getTestOrgFromEnv(t) | ||
parent := "organizations/" + org | ||
|
||
policy1 := &resourceManagerV2Beta1.Policy{ | ||
Bindings: []*resourceManagerV2Beta1.Binding{ | ||
{ | ||
|
@@ -83,11 +51,11 @@ func TestAccFolderIamPolicy_update(t *testing.T) { | |
CheckDestroy: testAccCheckGoogleFolderIamPolicyDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccFolderIamPolicy_basic(folderDisplayName, parent, policy1), | ||
Config: testAccFolderIamPolicy_basic(folderDisplayName, parent, "roles/viewer", "user:[email protected]"), | ||
Check: testAccCheckGoogleFolderIamPolicy("google_folder_iam_policy.test", policy1), | ||
}, | ||
{ | ||
Config: testAccFolderIamPolicy_basic(folderDisplayName, parent, policy2), | ||
Config: testAccFolderIamPolicy_basic2(folderDisplayName, parent, "roles/editor", "user:[email protected]", "roles/viewer", "user:[email protected]"), | ||
Check: testAccCheckGoogleFolderIamPolicy("google_folder_iam_policy.test", policy2), | ||
}, | ||
}, | ||
|
@@ -162,31 +130,49 @@ func testAccFolderExistingPolicy(org, fname string) resource.TestCheckFunc { | |
} | ||
} | ||
|
||
func testAccFolderIamPolicy_basic(folder, parent string, policy *resourceManagerV2Beta1.Policy) string { | ||
var bindingBuffer bytes.Buffer | ||
func testAccFolderIamPolicy_basic(folder, parent, role, member string) string { | ||
return fmt.Sprintf(` | ||
resource "google_folder" "permissiontest" { | ||
display_name = "%s" | ||
parent = "%s" | ||
} | ||
for _, binding := range policy.Bindings { | ||
bindingBuffer.WriteString("binding {\n") | ||
bindingBuffer.WriteString(fmt.Sprintf("role = \"%s\"\n", binding.Role)) | ||
bindingBuffer.WriteString(fmt.Sprintf("members = [\n")) | ||
for _, member := range binding.Members { | ||
bindingBuffer.WriteString(fmt.Sprintf("\"%s\",\n", member)) | ||
} | ||
bindingBuffer.WriteString("]}\n") | ||
} | ||
data "google_iam_policy" "test" { | ||
binding { | ||
role = "%s" | ||
members = ["%s"] | ||
} | ||
} | ||
resource "google_folder_iam_policy" "test" { | ||
folder = "${google_folder.permissiontest.name}" | ||
policy_data = "${data.google_iam_policy.test.policy_data}" | ||
} | ||
`, folder, parent, role, member) | ||
} | ||
|
||
func testAccFolderIamPolicy_basic2(folder, parent, role, member, role2, member2 string) string { | ||
return fmt.Sprintf(` | ||
resource "google_folder" "permissiontest" { | ||
display_name = "%s" | ||
parent = "%s" | ||
} | ||
data "google_iam_policy" "test" { | ||
%s | ||
binding { | ||
role = "%s" | ||
members = ["%s"] | ||
} | ||
binding { | ||
role = "%s" | ||
members = ["%s"] | ||
} | ||
} | ||
resource "google_folder_iam_policy" "test" { | ||
folder = "${google_folder.permissiontest.name}" | ||
policy_data = "${data.google_iam_policy.test.policy_data}" | ||
} | ||
`, folder, parent, bindingBuffer.String()) | ||
`, folder, parent, role, member, role2, member2) | ||
} |
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 |
---|---|---|
|
@@ -380,31 +380,25 @@ data "google_iam_policy" "admin" { | |
} | ||
audit_config { | ||
service = "cloudkms.googleapis.com" | ||
audit_log_configs = [ | ||
{ | ||
log_type = "DATA_READ" | ||
exempted_members = [ | ||
"user:[email protected]", | ||
] | ||
}, | ||
{ | ||
log_type = "DATA_WRITE" | ||
} | ||
] | ||
audit_log_configs { | ||
log_type = "DATA_READ" | ||
exempted_members = ["user:[email protected]"] | ||
} | ||
audit_log_configs { | ||
log_type = "DATA_WRITE" | ||
} | ||
} | ||
audit_config { | ||
service = "cloudsql.googleapis.com" | ||
audit_log_configs = [ | ||
{ | ||
log_type = "DATA_READ" | ||
exempted_members = [ | ||
"user:[email protected]", | ||
] | ||
}, | ||
{ | ||
log_type = "DATA_WRITE" | ||
} | ||
] | ||
audit_log_configs { | ||
log_type = "DATA_READ" | ||
exempted_members = ["user:[email protected]"] | ||
} | ||
audit_log_configs { | ||
log_type = "DATA_WRITE" | ||
} | ||
} | ||
} | ||
`, pid, name, org) | ||
|
@@ -476,31 +470,25 @@ data "google_iam_policy" "expanded" { | |
} | ||
audit_config { | ||
service = "cloudkms.googleapis.com" | ||
audit_log_configs = [ | ||
{ | ||
log_type = "DATA_READ" | ||
exempted_members = [ | ||
"user:[email protected]", | ||
] | ||
}, | ||
{ | ||
log_type = "DATA_WRITE" | ||
} | ||
] | ||
audit_log_configs { | ||
log_type = "DATA_READ" | ||
exempted_members = ["user:[email protected]"] | ||
} | ||
audit_log_configs { | ||
log_type = "DATA_WRITE" | ||
} | ||
} | ||
audit_config { | ||
service = "cloudkms.googleapis.com" | ||
audit_log_configs = [ | ||
{ | ||
log_type = "DATA_READ" | ||
exempted_members = [ | ||
"user:[email protected]", | ||
] | ||
}, | ||
{ | ||
log_type = "ADMIN_READ" | ||
} | ||
] | ||
audit_log_configs { | ||
log_type = "DATA_READ" | ||
exempted_members = ["user:[email protected]"] | ||
} | ||
audit_log_configs { | ||
log_type = "DATA_WRITE" | ||
} | ||
} | ||
}`, pid, name, org) | ||
} |
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
Oops, something went wrong.