mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-10-01 16:21:06 +00:00
Merge pull request #1769 from terraform-providers/paddy_1767
Fix crash when updating container cluster resource labels.
This commit is contained in:
commit
8753eb0268
@ -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)
|
||||
|
@ -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" {
|
||||
|
Loading…
Reference in New Issue
Block a user