forked from GoogleCloudPlatform/magic-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding labels and namespace labels to the GKEHub namespace resource (G…
…oogleCloudPlatform#8832) * Adding Terraform resources for Tenancy APIs in GKEHub * Segregating MembershipBinding and MembershipRBACRoleBinding to keep things simpler in the review * Fixing the docu URIs * Adding TF support for Tenancy API for Membership Binding * Adding dependent membership binding to the same commit chain * Making Scope un-updatable and replacing hard coded project number with the one from test env * Making Scope RRBAC updatable * Making Namespace immutable * Adding update test cases * Removing all memberships field from Scope since it is no longer supported * Removing all_memberships field for Scope from all test cases * Enhancing namespace resource with the labels fields * Adding more keys to test out the sorted comparison of keys in the map of labels * Adding more keys to test out the sorted comparison of keys in the update map
- Loading branch information
1 parent
26be40b
commit 3719625
Showing
3 changed files
with
121 additions
and
1 deletion.
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
96 changes: 96 additions & 0 deletions
96
mmv1/third_party/terraform/services/gkehub2/resource_gke_hub_namespace_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,96 @@ | ||
package gkehub2_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
|
||
"github.com/hashicorp/terraform-provider-google/google/acctest" | ||
"github.com/hashicorp/terraform-provider-google/google/envvar" | ||
) | ||
|
||
func TestAccGKEHub2Namespace_gkehubNamespaceBasicExample_update(t *testing.T) { | ||
t.Parallel() | ||
|
||
context := map[string]interface{}{ | ||
"project": envvar.GetTestProjectFromEnv(), | ||
"random_suffix": acctest.RandString(t, 10), | ||
} | ||
|
||
acctest.VcrTest(t, resource.TestCase{ | ||
PreCheck: func() { acctest.AccTestPreCheck(t) }, | ||
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccGKEHub2Namespace_gkehubNamespaceBasicExample_basic(context), | ||
}, | ||
{ | ||
ResourceName: "google_gke_hub_namespace.namespace", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"scope_namespace_id", "scope", "scope_id", "scope"}, | ||
}, | ||
{ | ||
Config: testAccGKEHub2Namespace_gkehubNamespaceBasicExample_update(context), | ||
}, | ||
{ | ||
ResourceName: "google_gke_hub_namespace.namespace", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"scope_namespace_id", "scope", "scope_id", "scope"}, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccGKEHub2Namespace_gkehubNamespaceBasicExample_basic(context map[string]interface{}) string { | ||
return acctest.Nprintf(` | ||
resource "google_gke_hub_scope" "namespace" { | ||
scope_id = "tf-test-scope%{random_suffix}" | ||
} | ||
resource "google_gke_hub_namespace" "namespace" { | ||
scope_namespace_id = "tf-test-namespace%{random_suffix}" | ||
scope_id = "tf-test-scope%{random_suffix}" | ||
scope = "${google_gke_hub_scope.namespace.name}" | ||
namespace_labels = { | ||
keyb = "valueb" | ||
keya = "valuea" | ||
keyc = "valuec" | ||
} | ||
labels = { | ||
keyb = "valueb" | ||
keya = "valuea" | ||
keyc = "valuec" | ||
} | ||
depends_on = [google_gke_hub_scope.namespace] | ||
} | ||
`, context) | ||
} | ||
|
||
func testAccGKEHub2Namespace_gkehubNamespaceBasicExample_update(context map[string]interface{}) string { | ||
return acctest.Nprintf(` | ||
resource "google_gke_hub_scope" "namespace" { | ||
scope_id = "tf-test-scope%{random_suffix}" | ||
} | ||
resource "google_gke_hub_namespace" "namespace" { | ||
scope_namespace_id = "tf-test-namespace%{random_suffix}" | ||
scope_id = "tf-test-scope%{random_suffix}" | ||
scope = "${google_gke_hub_scope.namespace.name}" | ||
namespace_labels = { | ||
updated_keyb = "updated_valueb" | ||
updated_keya = "updated_valuea" | ||
updated_keyc = "updated_valuec" | ||
} | ||
labels = { | ||
updated_keyb = "updated_valueb" | ||
updated_keya = "updated_valuea" | ||
updated_keyc = "updated_valuec" | ||
} | ||
depends_on = [google_gke_hub_scope.namespace] | ||
} | ||
`, context) | ||
} |