-
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.
Fix crash in containerattached when removing admin_groups or admin_us…
…ers.
- Loading branch information
1 parent
13e0b26
commit f3a5dee
Showing
2 changed files
with
132 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,24 @@ func TestAccContainerAttachedCluster_update(t *testing.T) { | |
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"location", "annotations"}, | ||
}, | ||
{ | ||
Config: testAccContainerAttachedCluster_containerAttachedCluster_removeAuthorizationUsers(context), | ||
}, | ||
{ | ||
ResourceName: "google_container_attached_cluster.primary", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"location", "annotations"}, | ||
}, | ||
{ | ||
Config: testAccContainerAttachedCluster_containerAttachedCluster_removeAuthorizationGroups(context), | ||
}, | ||
{ | ||
ResourceName: "google_container_attached_cluster.primary", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"location", "annotations"}, | ||
}, | ||
{ | ||
Config: testAccContainerAttachedCluster_containerAttachedCluster_destroy(context), | ||
}, | ||
|
@@ -155,9 +173,7 @@ resource "google_container_attached_cluster" "primary" { | |
`, context) | ||
} | ||
|
||
// Duplicate of testAccContainerAttachedCluster_containerAttachedCluster_update without lifecycle.prevent_destroy set | ||
// so the test can clean up the resource after the update. | ||
func testAccContainerAttachedCluster_containerAttachedCluster_destroy(context map[string]interface{}) string { | ||
func testAccContainerAttachedCluster_containerAttachedCluster_removeAuthorizationUsers(context map[string]interface{}) string { | ||
return acctest.Nprintf(` | ||
data "google_project" "project" { | ||
} | ||
|
@@ -178,7 +194,6 @@ resource "google_container_attached_cluster" "primary" { | |
label-two = "value-two" | ||
} | ||
authorization { | ||
admin_users = [ "[email protected]", "[email protected]"] | ||
admin_groups = [ "[email protected]"] | ||
} | ||
oidc_config { | ||
|
@@ -201,6 +216,102 @@ resource "google_container_attached_cluster" "primary" { | |
namespace = "custom-ns" | ||
} | ||
} | ||
lifecycle { | ||
prevent_destroy = true | ||
} | ||
} | ||
`, context) | ||
} | ||
|
||
func testAccContainerAttachedCluster_containerAttachedCluster_removeAuthorizationGroups(context map[string]interface{}) string { | ||
return acctest.Nprintf(` | ||
data "google_project" "project" { | ||
} | ||
data "google_container_attached_versions" "versions" { | ||
location = "us-west1" | ||
project = data.google_project.project.project_id | ||
} | ||
resource "google_container_attached_cluster" "primary" { | ||
name = "update%{random_suffix}" | ||
project = data.google_project.project.project_id | ||
location = "us-west1" | ||
description = "Test cluster updated" | ||
distribution = "aks" | ||
annotations = { | ||
label-one = "value-one" | ||
label-two = "value-two" | ||
} | ||
oidc_config { | ||
issuer_url = "https://oidc.issuer.url" | ||
jwks = base64encode("{\"keys\":[{\"use\":\"sig\",\"kty\":\"RSA\",\"kid\":\"testid\",\"alg\":\"RS256\",\"n\":\"somedata\",\"e\":\"AQAB\"}]}") | ||
} | ||
platform_version = data.google_container_attached_versions.versions.valid_versions[0] | ||
fleet { | ||
project = "projects/${data.google_project.project.number}" | ||
} | ||
monitoring_config { | ||
managed_prometheus_config {} | ||
} | ||
binary_authorization { | ||
evaluation_mode = "DISABLED" | ||
} | ||
proxy_config { | ||
kubernetes_secret { | ||
name = "new-proxy-config" | ||
namespace = "custom-ns" | ||
} | ||
} | ||
lifecycle { | ||
prevent_destroy = true | ||
} | ||
} | ||
`, context) | ||
} | ||
|
||
// Duplicate of testAccContainerAttachedCluster_containerAttachedCluster_update without lifecycle.prevent_destroy set | ||
// so the test can clean up the resource after the update. | ||
func testAccContainerAttachedCluster_containerAttachedCluster_destroy(context map[string]interface{}) string { | ||
return acctest.Nprintf(` | ||
data "google_project" "project" { | ||
} | ||
data "google_container_attached_versions" "versions" { | ||
location = "us-west1" | ||
project = data.google_project.project.project_id | ||
} | ||
resource "google_container_attached_cluster" "primary" { | ||
name = "update%{random_suffix}" | ||
project = data.google_project.project.project_id | ||
location = "us-west1" | ||
description = "Test cluster updated" | ||
distribution = "aks" | ||
annotations = { | ||
label-one = "value-one" | ||
label-two = "value-two" | ||
} | ||
oidc_config { | ||
issuer_url = "https://oidc.issuer.url" | ||
jwks = base64encode("{\"keys\":[{\"use\":\"sig\",\"kty\":\"RSA\",\"kid\":\"testid\",\"alg\":\"RS256\",\"n\":\"somedata\",\"e\":\"AQAB\"}]}") | ||
} | ||
platform_version = data.google_container_attached_versions.versions.valid_versions[0] | ||
fleet { | ||
project = "projects/${data.google_project.project.number}" | ||
} | ||
monitoring_config { | ||
managed_prometheus_config {} | ||
} | ||
binary_authorization { | ||
evaluation_mode = "DISABLED" | ||
} | ||
proxy_config { | ||
kubernetes_secret { | ||
name = "new-proxy-config" | ||
namespace = "custom-ns" | ||
} | ||
} | ||
} | ||
`, context) | ||
} |