From 9b5d40c2e314756c1f3fbe625481e035b8c8bcf2 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 20 Feb 2015 10:22:26 -0800 Subject: [PATCH] fmt --- config.go | 1 - image.go | 1 - resource_compute_address.go | 1 - resource_compute_forwarding_rule.go | 11 +++++------ resource_compute_forwarding_rule_test.go | 1 - resource_compute_instance.go | 15 ++++++--------- resource_compute_target_pool.go | 21 ++++++++++----------- 7 files changed, 21 insertions(+), 30 deletions(-) diff --git a/config.go b/config.go index 009f0009..9ae88948 100644 --- a/config.go +++ b/config.go @@ -14,7 +14,6 @@ import ( "golang.org/x/oauth2/jwt" ) - // Config is the configuration structure used to instantiate the Google // provider. type Config struct { diff --git a/image.go b/image.go index 07420228..642b74d9 100644 --- a/image.go +++ b/image.go @@ -10,7 +10,6 @@ import ( // If it is of the form name then look in the configured project and then hosted image projects. func resolveImage(c *Config, name string) (string, error) { - if strings.HasPrefix(name, "https://www.googleapis.com/compute/v1/") { return name, nil diff --git a/resource_compute_address.go b/resource_compute_address.go index 98aa838c..d67ceb19 100644 --- a/resource_compute_address.go +++ b/resource_compute_address.go @@ -32,7 +32,6 @@ func resourceComputeAddress() *schema.Resource { Type: schema.TypeString, Computed: true, }, - }, } } diff --git a/resource_compute_forwarding_rule.go b/resource_compute_forwarding_rule.go index 269ff611..e8737434 100644 --- a/resource_compute_forwarding_rule.go +++ b/resource_compute_forwarding_rule.go @@ -68,12 +68,12 @@ func resourceComputeForwardingRuleCreate(d *schema.ResourceData, meta interface{ config := meta.(*Config) frule := &compute.ForwardingRule{ - IPAddress: d.Get("ip_address").(string), - IPProtocol: d.Get("ip_protocol").(string), + IPAddress: d.Get("ip_address").(string), + IPProtocol: d.Get("ip_protocol").(string), Description: d.Get("description").(string), - Name: d.Get("name").(string), - PortRange: d.Get("port_range").(string), - Target: d.Get("target").(string), + Name: d.Get("name").(string), + PortRange: d.Get("port_range").(string), + Target: d.Get("target").(string), } log.Printf("[DEBUG] ForwardingRule insert request: %#v", frule) @@ -216,4 +216,3 @@ func resourceComputeForwardingRuleDelete(d *schema.ResourceData, meta interface{ d.SetId("") return nil } - diff --git a/resource_compute_forwarding_rule_test.go b/resource_compute_forwarding_rule_test.go index c3aa365d..ee0a0005 100644 --- a/resource_compute_forwarding_rule_test.go +++ b/resource_compute_forwarding_rule_test.go @@ -122,4 +122,3 @@ resource "google_compute_forwarding_rule" "foobar" { target = "${google_compute_target_pool.foobar-tp.self_link}" } ` - diff --git a/resource_compute_instance.go b/resource_compute_instance.go index 020f3de9..1fb79188 100644 --- a/resource_compute_instance.go +++ b/resource_compute_instance.go @@ -106,7 +106,7 @@ func resourceComputeInstance() *schema.Resource { Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "nat_ip": &schema.Schema{ - Type: schema.TypeString, + Type: schema.TypeString, Computed: true, Optional: true, }, @@ -248,7 +248,6 @@ func resourceOperationWaitZone( return nil } - func resourceComputeInstanceCreate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) @@ -308,7 +307,6 @@ func resourceComputeInstanceCreate(d *schema.ResourceData, meta interface{}) err if v, ok := d.GetOk(prefix + ".image"); ok { imageName := v.(string) - imageUrl, err := resolveImage(config, imageName) if err != nil { return fmt.Errorf( @@ -557,7 +555,6 @@ func resourceComputeInstanceRead(d *schema.ResourceData, meta interface{}) error internalIP = iface.NetworkIP } - } } @@ -654,7 +651,7 @@ func resourceComputeInstanceUpdate(d *schema.ResourceData, meta interface{}) err for i := 0; i < networkInterfacesCount; i++ { prefix := fmt.Sprintf("network_interface.%d", i) instNetworkInterface := instance.NetworkInterfaces[i] - networkName := d.Get(prefix+".name").(string) + networkName := d.Get(prefix + ".name").(string) // TODO: This sanity check is broken by #929, disabled for now (by forcing the equality) networkName = instNetworkInterface.Name @@ -663,7 +660,7 @@ func resourceComputeInstanceUpdate(d *schema.ResourceData, meta interface{}) err return fmt.Errorf("Instance networkInterface had unexpected name: %s", instNetworkInterface.Name) } - if d.HasChange(prefix+".access_config") { + if d.HasChange(prefix + ".access_config") { // TODO: This code deletes then recreates accessConfigs. This is bad because it may // leave the machine inaccessible from either ip if the creation part fails (network @@ -672,9 +669,9 @@ func resourceComputeInstanceUpdate(d *schema.ResourceData, meta interface{}) err // necessary, and also add before removing. // Delete any accessConfig that currently exists in instNetworkInterface - for _, ac := range(instNetworkInterface.AccessConfigs) { + for _, ac := range instNetworkInterface.AccessConfigs { op, err := config.clientCompute.Instances.DeleteAccessConfig( - config.Project, zone, d.Id(), networkName, ac.Name).Do(); + config.Project, zone, d.Id(), networkName, ac.Name).Do() if err != nil { return fmt.Errorf("Error deleting old access_config: %s", err) } @@ -693,7 +690,7 @@ func resourceComputeInstanceUpdate(d *schema.ResourceData, meta interface{}) err NatIP: d.Get(acPrefix + ".nat_ip").(string), } op, err := config.clientCompute.Instances.AddAccessConfig( - config.Project, zone, d.Id(), networkName, ac).Do(); + config.Project, zone, d.Id(), networkName, ac).Do() if err != nil { return fmt.Errorf("Error adding new access_config: %s", err) } diff --git a/resource_compute_target_pool.go b/resource_compute_target_pool.go index bbf09590..98935b84 100644 --- a/resource_compute_target_pool.go +++ b/resource_compute_target_pool.go @@ -72,11 +72,11 @@ func resourceComputeTargetPool() *schema.Resource { } func convertStringArr(ifaceArr []interface{}) []string { - arr := make([]string, len(ifaceArr)) - for i, v := range ifaceArr { - arr[i] = v.(string) - } - return arr + arr := make([]string, len(ifaceArr)) + for i, v := range ifaceArr { + arr[i] = v.(string) + } + return arr } func waitOp(config *Config, op *compute.Operation, @@ -151,11 +151,11 @@ func resourceComputeTargetPoolCreate(d *schema.ResourceData, meta interface{}) e // Build the parameter tpool := &compute.TargetPool{ - BackupPool: d.Get("backup_pool").(string), - Description: d.Get("description").(string), - HealthChecks: hchkUrls, - Instances: instanceUrls, - Name: d.Get("name").(string), + BackupPool: d.Get("backup_pool").(string), + Description: d.Get("description").(string), + HealthChecks: hchkUrls, + Instances: instanceUrls, + Name: d.Get("name").(string), SessionAffinity: d.Get("session_affinity").(string), } if d.Get("failover_ratio") != nil { @@ -215,7 +215,6 @@ func calcAddRemove(from []string, to []string) ([]string, []string) { return add, remove } - func resourceComputeTargetPoolUpdate(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config)