Merge pull request #1769 from terraform-providers/paddy_1767

Fix crash when updating container cluster resource labels.
This commit is contained in:
Paddy 2018-07-13 14:21:05 -07:00 committed by GitHub
commit 8753eb0268
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 3 deletions

View File

@ -1145,10 +1145,9 @@ func resourceContainerClusterUpdate(d *schema.ResourceData, meta interface{}) er
}
if d.HasChange("resource_labels") {
resourceLabels := d.Get("resource_labels").(map[string]string)
resourceLabels := d.Get("resource_labels").(map[string]interface{})
req := &containerBeta.SetLabelsRequest{
ResourceLabels: resourceLabels,
ResourceLabels: convertStringMap(resourceLabels),
}
updateF := func() error {
name := containerClusterFullName(project, location, clusterName)

View File

@ -1183,6 +1183,32 @@ func TestAccContainerCluster_withResourceLabels(t *testing.T) {
})
}
func TestAccContainerCluster_withResourceLabelsUpdate(t *testing.T) {
t.Parallel()
clusterName := fmt.Sprintf("cluster-test-%s", acctest.RandString(10))
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckContainerClusterDestroy,
Steps: []resource.TestStep{
{
Config: testAccContainerCluster_withoutResourceLabels(clusterName),
},
{
Config: testAccContainerCluster_withResourceLabels(clusterName),
},
{
ResourceName: "google_container_cluster.with_resource_labels",
ImportStateIdPrefix: "us-central1-a/",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
func testAccCheckContainerClusterDestroy(s *terraform.State) error {
config := testAccProvider.Meta().(*Config)
@ -2254,6 +2280,16 @@ resource "google_container_cluster" "shared_vpc_cluster" {
}`, projectName, org, billingId, projectName, org, billingId, acctest.RandString(10), acctest.RandString(10), name)
}
func testAccContainerCluster_withoutResourceLabels(clusterName string) string {
return fmt.Sprintf(`
resource "google_container_cluster" "with_resource_labels" {
name = "%s"
zone = "us-central1-a"
initial_node_count = 1
}
`, clusterName)
}
func testAccContainerCluster_withResourceLabels(clusterName string) string {
return fmt.Sprintf(`
resource "google_container_cluster" "with_resource_labels" {