mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-10-03 01:01:06 +00:00
allow min node counts of 0 for node pool autoscaling (#468)
This commit is contained in:
parent
5874819e21
commit
617ad7362b
@ -76,7 +76,7 @@ func resourceContainerNodePool() *schema.Resource {
|
|||||||
"min_node_count": &schema.Schema{
|
"min_node_count": &schema.Schema{
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
ValidateFunc: validation.IntAtLeast(1),
|
ValidateFunc: validation.IntAtLeast(0),
|
||||||
},
|
},
|
||||||
|
|
||||||
"max_node_count": &schema.Schema{
|
"max_node_count": &schema.Schema{
|
||||||
@ -124,9 +124,10 @@ func resourceContainerNodePoolCreate(d *schema.ResourceData, meta interface{}) e
|
|||||||
if v, ok := d.GetOk("autoscaling"); ok {
|
if v, ok := d.GetOk("autoscaling"); ok {
|
||||||
autoscaling := v.([]interface{})[0].(map[string]interface{})
|
autoscaling := v.([]interface{})[0].(map[string]interface{})
|
||||||
nodePool.Autoscaling = &container.NodePoolAutoscaling{
|
nodePool.Autoscaling = &container.NodePoolAutoscaling{
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
MinNodeCount: int64(autoscaling["min_node_count"].(int)),
|
MinNodeCount: int64(autoscaling["min_node_count"].(int)),
|
||||||
MaxNodeCount: int64(autoscaling["max_node_count"].(int)),
|
MaxNodeCount: int64(autoscaling["max_node_count"].(int)),
|
||||||
|
ForceSendFields: []string{"MinNodeCount"},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,18 +77,24 @@ func TestAccContainerNodePool_autoscaling(t *testing.T) {
|
|||||||
Config: testAccContainerNodePool_autoscaling(cluster, np),
|
Config: testAccContainerNodePool_autoscaling(cluster, np),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckContainerNodePoolMatches("google_container_node_pool.np"),
|
testAccCheckContainerNodePoolMatches("google_container_node_pool.np"),
|
||||||
|
resource.TestCheckResourceAttr("google_container_node_pool.np", "autoscaling.0.min_node_count", "1"),
|
||||||
|
resource.TestCheckResourceAttr("google_container_node_pool.np", "autoscaling.0.max_node_count", "3"),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccContainerNodePool_updateAutoscaling(cluster, np),
|
Config: testAccContainerNodePool_updateAutoscaling(cluster, np),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckContainerNodePoolMatches("google_container_node_pool.np"),
|
testAccCheckContainerNodePoolMatches("google_container_node_pool.np"),
|
||||||
|
resource.TestCheckResourceAttr("google_container_node_pool.np", "autoscaling.0.min_node_count", "0"),
|
||||||
|
resource.TestCheckResourceAttr("google_container_node_pool.np", "autoscaling.0.max_node_count", "5"),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccContainerNodePool_basic(cluster, np),
|
Config: testAccContainerNodePool_basic(cluster, np),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckContainerNodePoolMatches("google_container_node_pool.np"),
|
testAccCheckContainerNodePoolMatches("google_container_node_pool.np"),
|
||||||
|
resource.TestCheckNoResourceAttr("google_container_node_pool.np", "autoscaling.0.min_node_count"),
|
||||||
|
resource.TestCheckNoResourceAttr("google_container_node_pool.np", "autoscaling.0.max_node_count"),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -249,7 +255,7 @@ resource "google_container_node_pool" "np" {
|
|||||||
cluster = "${google_container_cluster.cluster.name}"
|
cluster = "${google_container_cluster.cluster.name}"
|
||||||
initial_node_count = 2
|
initial_node_count = 2
|
||||||
autoscaling {
|
autoscaling {
|
||||||
min_node_count = 1
|
min_node_count = 0
|
||||||
max_node_count = 5
|
max_node_count = 5
|
||||||
}
|
}
|
||||||
}`, cluster, np)
|
}`, cluster, np)
|
||||||
|
Loading…
Reference in New Issue
Block a user