Updated variable names and docs.

This commit is contained in:
Riley Karson 2017-06-16 15:39:44 -07:00
parent 78b0879c6d
commit 3f26ea6425
3 changed files with 9 additions and 9 deletions

View File

@ -132,7 +132,7 @@ func resourceComputeInstanceGroupManagerCreate(d *schema.ResourceData, meta inte
return err
}
var targetSize int64 = 0
targetSize := int64(0)
if v, ok := d.GetOk("target_size"); ok {
targetSize = int64(v.(int))
}
@ -143,6 +143,7 @@ func resourceComputeInstanceGroupManagerCreate(d *schema.ResourceData, meta inte
BaseInstanceName: d.Get("base_instance_name").(string),
InstanceTemplate: d.Get("instance_template").(string),
TargetSize: targetSize,
// Force send TargetSize to allow a value of 0.
ForceSendFields: []string{"TargetSize"},
}
@ -381,11 +382,10 @@ func resourceComputeInstanceGroupManagerUpdate(d *schema.ResourceData, meta inte
d.SetPartial("named_port")
}
// We won't ever see changes if target_size is unset
if d.HasChange("target_size") {
target_size := int64(d.Get("target_size").(int))
targetSize := int64(d.Get("target_size").(int))
op, err := config.clientCompute.InstanceGroupManagers.Resize(
project, d.Get("zone").(string), d.Id(), target_size).Do()
project, d.Get("zone").(string), d.Id(), targetSize).Do()
if err != nil {
return fmt.Errorf("Error updating InstanceGroupManager: %s", err)
}

View File

@ -42,8 +42,8 @@ func TestAccInstanceGroupManager_basic(t *testing.T) {
func TestAccInstanceGroupManager_targetSizeZero(t *testing.T) {
var manager compute.InstanceGroupManager
template := fmt.Sprintf("igm-test-%s", acctest.RandString(10))
igm := fmt.Sprintf("igm-test-%s", acctest.RandString(10))
templateName := fmt.Sprintf("igm-test-%s", acctest.RandString(10))
igmName := fmt.Sprintf("igm-test-%s", acctest.RandString(10))
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
@ -51,7 +51,7 @@ func TestAccInstanceGroupManager_targetSizeZero(t *testing.T) {
CheckDestroy: testAccCheckInstanceGroupManagerDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccInstanceGroupManager_targetSizeZero(template, igm),
Config: testAccInstanceGroupManager_targetSizeZero(templateName, igmName),
Check: resource.ComposeTestCheckFunc(
testAccCheckInstanceGroupManagerExists(
"google_compute_instance_group_manager.igm-basic", &manager),

View File

@ -74,9 +74,9 @@ The following arguments are supported:
restart all of the instances at once. In the future, as the GCE API matures
we will support `"ROLLING_UPDATE"` as well.
* `target_size` - (Optional, Default `0`) The target number of running instances for this managed
* `target_size` - (Optional) The target number of running instances for this managed
instance group. This value should always be explicitly set unless this resource is attached to
an autoscaler, in which case it should never be set.
an autoscaler, in which case it should never be set. Defaults to `0`.
* `target_pools` - (Optional) The full URL of all target pools to which new
instances in the group are added. Updating the target pools attribute does