mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-07-01 07:42:40 +00:00
Regional cluster update support for additional zones (#1359)
This commit is contained in:
parent
c25a5b1c81
commit
039e82cf6d
|
@ -1007,7 +1007,10 @@ func resourceContainerClusterUpdate(d *schema.ResourceData, meta interface{}) er
|
|||
// Since we can't add & remove zones in the same request, first add all the
|
||||
// zones, then remove the ones we aren't using anymore.
|
||||
azSet := azSetOld.Union(azSetNew)
|
||||
azSet.Add(location)
|
||||
|
||||
if isZone(location) {
|
||||
azSet.Add(location)
|
||||
}
|
||||
|
||||
req := &container.UpdateClusterRequest{
|
||||
Update: &container.ClusterUpdate{
|
||||
|
@ -1021,7 +1024,9 @@ func resourceContainerClusterUpdate(d *schema.ResourceData, meta interface{}) er
|
|||
return err
|
||||
}
|
||||
|
||||
azSetNew.Add(location)
|
||||
if isZone(location) {
|
||||
azSetNew.Add(location)
|
||||
}
|
||||
if !azSet.Equal(azSetNew) {
|
||||
req = &container.UpdateClusterRequest{
|
||||
Update: &container.ClusterUpdate{
|
||||
|
|
|
@ -304,6 +304,38 @@ func TestAccContainerCluster_withAdditionalZones(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestAccContainerCluster_regionalWithAdditionalZones(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_regionalAdditionalZones(clusterName),
|
||||
},
|
||||
{
|
||||
ResourceName: "google_container_cluster.with_additional_zones",
|
||||
ImportStateIdPrefix: "us-central1/",
|
||||
ImportState: true,
|
||||
ImportStateVerify: true,
|
||||
},
|
||||
{
|
||||
Config: testAccContainerCluster_regionalUpdateAdditionalZones(clusterName),
|
||||
},
|
||||
{
|
||||
ResourceName: "google_container_cluster.with_additional_zones",
|
||||
ImportStateIdPrefix: "us-central1/",
|
||||
ImportState: true,
|
||||
ImportStateVerify: true,
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestAccContainerCluster_withKubernetesAlpha(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
@ -1369,6 +1401,34 @@ resource "google_container_cluster" "with_additional_zones" {
|
|||
}`, clusterName)
|
||||
}
|
||||
|
||||
func testAccContainerCluster_regionalAdditionalZones(clusterName string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_container_cluster" "with_additional_zones" {
|
||||
name = "%s"
|
||||
region = "us-central1"
|
||||
initial_node_count = 1
|
||||
|
||||
additional_zones = [
|
||||
"us-central1-f",
|
||||
"us-central1-c",
|
||||
]
|
||||
}`, clusterName)
|
||||
}
|
||||
|
||||
func testAccContainerCluster_regionalUpdateAdditionalZones(clusterName string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_container_cluster" "with_additional_zones" {
|
||||
name = "%s"
|
||||
region = "us-central1"
|
||||
initial_node_count = 1
|
||||
|
||||
additional_zones = [
|
||||
"us-central1-f",
|
||||
"us-central1-b",
|
||||
]
|
||||
}`, clusterName)
|
||||
}
|
||||
|
||||
func testAccContainerCluster_withKubernetesAlpha(clusterName string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_container_cluster" "with_kubernetes_alpha" {
|
||||
|
|
Loading…
Reference in New Issue
Block a user