gofmt files from recently merged PRs

This commit is contained in:
Radek Simko 2015-10-07 13:35:06 -07:00
parent 40f09b7cbd
commit f9efede852
24 changed files with 133 additions and 140 deletions

View File

@ -23,7 +23,7 @@ func MetadataRetryWrapper(update func() error) error {
} }
} }
return fmt.Errorf("Failed to update metadata after %d retries", attempt); return fmt.Errorf("Failed to update metadata after %d retries", attempt)
} }
// Update the metadata (serverMD) according to the provided diff (oldMDMap v // Update the metadata (serverMD) according to the provided diff (oldMDMap v
@ -51,7 +51,7 @@ func MetadataUpdate(oldMDMap map[string]interface{}, newMDMap map[string]interfa
// Reformat old metadata into a list // Reformat old metadata into a list
serverMD.Items = nil serverMD.Items = nil
for key, val := range curMDMap { for key, val := range curMDMap {
v := val; v := val
serverMD.Items = append(serverMD.Items, &compute.MetadataItems{ serverMD.Items = append(serverMD.Items, &compute.MetadataItems{
Key: key, Key: key,
Value: &v, Value: &v,
@ -60,7 +60,7 @@ func MetadataUpdate(oldMDMap map[string]interface{}, newMDMap map[string]interfa
} }
// Format metadata from the server data format -> schema data format // Format metadata from the server data format -> schema data format
func MetadataFormatSchema(md *compute.Metadata) (map[string]interface{}) { func MetadataFormatSchema(md *compute.Metadata) map[string]interface{} {
newMD := make(map[string]interface{}) newMD := make(map[string]interface{})
for _, kv := range md.Items { for _, kv := range md.Items {

View File

@ -507,7 +507,7 @@ func resourceComputeInstanceCreate(d *schema.ResourceData, meta interface{}) err
func resourceComputeInstanceRead(d *schema.ResourceData, meta interface{}) error { func resourceComputeInstanceRead(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config) config := meta.(*Config)
instance, err := getInstance(config, d); instance, err := getInstance(config, d)
if err != nil { if err != nil {
return err return err
} }
@ -644,7 +644,7 @@ func resourceComputeInstanceUpdate(d *schema.ResourceData, meta interface{}) err
zone := d.Get("zone").(string) zone := d.Get("zone").(string)
instance, err := getInstance(config, d); instance, err := getInstance(config, d)
if err != nil { if err != nil {
return err return err
} }
@ -658,7 +658,7 @@ func resourceComputeInstanceUpdate(d *schema.ResourceData, meta interface{}) err
updateMD := func() error { updateMD := func() error {
// Reload the instance in the case of a fingerprint mismatch // Reload the instance in the case of a fingerprint mismatch
instance, err = getInstance(config, d); instance, err = getInstance(config, d)
if err != nil { if err != nil {
return err return err
} }

View File

@ -72,10 +72,10 @@ func resourceComputeProjectMetadataCreate(d *schema.ResourceData, meta interface
err := MetadataRetryWrapper(createMD) err := MetadataRetryWrapper(createMD)
if err != nil { if err != nil {
return err; return err
} }
return resourceComputeProjectMetadataRead(d, meta); return resourceComputeProjectMetadataRead(d, meta)
} }
func resourceComputeProjectMetadataRead(d *schema.ResourceData, meta interface{}) error { func resourceComputeProjectMetadataRead(d *schema.ResourceData, meta interface{}) error {
@ -133,10 +133,10 @@ func resourceComputeProjectMetadataUpdate(d *schema.ResourceData, meta interface
err := MetadataRetryWrapper(updateMD) err := MetadataRetryWrapper(updateMD)
if err != nil { if err != nil {
return err; return err
} }
return resourceComputeProjectMetadataRead(d, meta); return resourceComputeProjectMetadataRead(d, meta)
} }
return nil return nil

View File

@ -83,7 +83,7 @@ func resourceStorageBucketAclCreate(d *schema.ResourceData, meta interface{}) er
if len(predefined_acl) > 0 { if len(predefined_acl) > 0 {
if len(role_entity) > 0 { if len(role_entity) > 0 {
return fmt.Errorf("Error, you cannot specify both " + return fmt.Errorf("Error, you cannot specify both " +
"\"predefined_acl\" and \"role_entity\""); "\"predefined_acl\" and \"role_entity\"")
} }
res, err := config.clientStorage.Buckets.Get(bucket).Do() res, err := config.clientStorage.Buckets.Get(bucket).Do()
@ -99,9 +99,9 @@ func resourceStorageBucketAclCreate(d *schema.ResourceData, meta interface{}) er
return fmt.Errorf("Error updating bucket %s: %v", bucket, err) return fmt.Errorf("Error updating bucket %s: %v", bucket, err)
} }
return resourceStorageBucketAclRead(d, meta); return resourceStorageBucketAclRead(d, meta)
} else if len(role_entity) > 0 { } else if len(role_entity) > 0 {
for _, v := range(role_entity) { for _, v := range role_entity {
pair, err := getRoleEntityPair(v.(string)) pair, err := getRoleEntityPair(v.(string))
bucketAccessControl := &storage.BucketAccessControl{ bucketAccessControl := &storage.BucketAccessControl{
@ -118,7 +118,7 @@ func resourceStorageBucketAclCreate(d *schema.ResourceData, meta interface{}) er
} }
} }
return resourceStorageBucketAclRead(d, meta); return resourceStorageBucketAclRead(d, meta)
} }
if len(default_acl) > 0 { if len(default_acl) > 0 {
@ -135,13 +135,12 @@ func resourceStorageBucketAclCreate(d *schema.ResourceData, meta interface{}) er
return fmt.Errorf("Error updating bucket %s: %v", bucket, err) return fmt.Errorf("Error updating bucket %s: %v", bucket, err)
} }
return resourceStorageBucketAclRead(d, meta); return resourceStorageBucketAclRead(d, meta)
} }
return nil return nil
} }
func resourceStorageBucketAclRead(d *schema.ResourceData, meta interface{}) error { func resourceStorageBucketAclRead(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config) config := meta.(*Config)
@ -153,7 +152,7 @@ func resourceStorageBucketAclRead(d *schema.ResourceData, meta interface{}) erro
role_entity := make([]interface{}, 0) role_entity := make([]interface{}, 0)
re_local := d.Get("role_entity").([]interface{}) re_local := d.Get("role_entity").([]interface{})
re_local_map := make(map[string]string) re_local_map := make(map[string]string)
for _, v := range(re_local) { for _, v := range re_local {
res, err := getRoleEntityPair(v.(string)) res, err := getRoleEntityPair(v.(string))
if err != nil { if err != nil {
@ -170,7 +169,7 @@ func resourceStorageBucketAclRead(d *schema.ResourceData, meta interface{}) erro
return err return err
} }
for _, v := range(res.Items) { for _, v := range res.Items {
log.Printf("[DEBUG]: examining re %s-%s", v.Role, v.Entity) log.Printf("[DEBUG]: examining re %s-%s", v.Role, v.Entity)
// We only store updates to the locally defined access controls // We only store updates to the locally defined access controls
if _, in := re_local_map[v.Entity]; in { if _, in := re_local_map[v.Entity]; in {
@ -196,7 +195,7 @@ func resourceStorageBucketAclUpdate(d *schema.ResourceData, meta interface{}) er
old_re, new_re := o.([]interface{}), n.([]interface{}) old_re, new_re := o.([]interface{}), n.([]interface{})
old_re_map := make(map[string]string) old_re_map := make(map[string]string)
for _, v := range(old_re) { for _, v := range old_re {
res, err := getRoleEntityPair(v.(string)) res, err := getRoleEntityPair(v.(string))
if err != nil { if err != nil {
@ -207,7 +206,7 @@ func resourceStorageBucketAclUpdate(d *schema.ResourceData, meta interface{}) er
old_re_map[res.Entity] = res.Role old_re_map[res.Entity] = res.Role
} }
for _, v := range(new_re) { for _, v := range new_re {
pair, err := getRoleEntityPair(v.(string)) pair, err := getRoleEntityPair(v.(string))
bucketAccessControl := &storage.BucketAccessControl{ bucketAccessControl := &storage.BucketAccessControl{
@ -233,7 +232,7 @@ func resourceStorageBucketAclUpdate(d *schema.ResourceData, meta interface{}) er
} }
} }
for entity, _ := range(old_re_map) { for entity, _ := range old_re_map {
log.Printf("[DEBUG]: removing entity %s", entity) log.Printf("[DEBUG]: removing entity %s", entity)
err := config.clientStorage.BucketAccessControls.Delete(bucket, entity).Do() err := config.clientStorage.BucketAccessControls.Delete(bucket, entity).Do()
@ -242,7 +241,7 @@ func resourceStorageBucketAclUpdate(d *schema.ResourceData, meta interface{}) er
} }
} }
return resourceStorageBucketAclRead(d, meta); return resourceStorageBucketAclRead(d, meta)
} }
if d.HasChange("default_acl") { if d.HasChange("default_acl") {
@ -261,7 +260,7 @@ func resourceStorageBucketAclUpdate(d *schema.ResourceData, meta interface{}) er
return fmt.Errorf("Error updating bucket %s: %v", bucket, err) return fmt.Errorf("Error updating bucket %s: %v", bucket, err)
} }
return resourceStorageBucketAclRead(d, meta); return resourceStorageBucketAclRead(d, meta)
} }
return nil return nil
@ -273,7 +272,7 @@ func resourceStorageBucketAclDelete(d *schema.ResourceData, meta interface{}) er
bucket := d.Get("bucket").(string) bucket := d.Get("bucket").(string)
re_local := d.Get("role_entity").([]interface{}) re_local := d.Get("role_entity").([]interface{})
for _, v := range(re_local) { for _, v := range re_local {
res, err := getRoleEntityPair(v.(string)) res, err := getRoleEntityPair(v.(string))
if err != nil { if err != nil {
return err return err

View File

@ -2,8 +2,8 @@ package google
import ( import (
"fmt" "fmt"
"testing"
"math/rand" "math/rand"
"testing"
"time" "time"
"github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/helper/resource"
@ -146,7 +146,7 @@ func testAccCheckGoogleStorageBucketAcl(bucket, roleEntityS string) resource.Tes
return fmt.Errorf("Error retrieving contents of acl for bucket %s: %s", bucket, err) return fmt.Errorf("Error retrieving contents of acl for bucket %s: %s", bucket, err)
} }
if (res.Role != roleEntity.Role) { if res.Role != roleEntity.Role {
return fmt.Errorf("Error, Role mismatch %s != %s", res.Role, roleEntity.Role) return fmt.Errorf("Error, Role mismatch %s != %s", res.Role, roleEntity.Role)
} }
@ -218,7 +218,6 @@ resource "google_storage_bucket_acl" "acl" {
} }
`, testAclBucketName, roleEntityBasic2, roleEntityBasic3_reader) `, testAclBucketName, roleEntityBasic2, roleEntityBasic3_reader)
var testGoogleStorageBucketsAclPredefined = fmt.Sprintf(` var testGoogleStorageBucketsAclPredefined = fmt.Sprintf(`
resource "google_storage_bucket" "bucket" { resource "google_storage_bucket" "bucket" {
name = "%s" name = "%s"

View File

@ -75,7 +75,6 @@ func resourceStorageBucketObjectCreate(d *schema.ResourceData, meta interface{})
insertCall.PredefinedAcl(v.(string)) insertCall.PredefinedAcl(v.(string))
} }
_, err = insertCall.Do() _, err = insertCall.Do()
if err != nil { if err != nil {

View File

@ -1,11 +1,11 @@
package google package google
import ( import (
"fmt"
"testing"
"io/ioutil"
"crypto/md5" "crypto/md5"
"encoding/base64" "encoding/base64"
"fmt"
"io/ioutil"
"testing"
"github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform" "github.com/hashicorp/terraform/terraform"
@ -48,7 +48,6 @@ func testAccCheckGoogleStorageObject(bucket, object, md5 string) resource.TestCh
objectsService := storage.NewObjectsService(config.clientStorage) objectsService := storage.NewObjectsService(config.clientStorage)
getCall := objectsService.Get(bucket, object) getCall := objectsService.Get(bucket, object)
res, err := getCall.Do() res, err := getCall.Do()
@ -56,7 +55,7 @@ func testAccCheckGoogleStorageObject(bucket, object, md5 string) resource.TestCh
return fmt.Errorf("Error retrieving contents of object %s: %s", object, err) return fmt.Errorf("Error retrieving contents of object %s: %s", object, err)
} }
if (md5 != res.Md5Hash) { if md5 != res.Md5Hash {
return fmt.Errorf("Error contents of %s garbled, md5 hashes don't match (%s, %s)", object, md5, res.Md5Hash) return fmt.Errorf("Error contents of %s garbled, md5 hashes don't match (%s, %s)", object, md5, res.Md5Hash)
} }

View File

@ -65,7 +65,7 @@ func resourceStorageObjectAclCreate(d *schema.ResourceData, meta interface{}) er
if len(predefined_acl) > 0 { if len(predefined_acl) > 0 {
if len(role_entity) > 0 { if len(role_entity) > 0 {
return fmt.Errorf("Error, you cannot specify both " + return fmt.Errorf("Error, you cannot specify both " +
"\"predefined_acl\" and \"role_entity\""); "\"predefined_acl\" and \"role_entity\"")
} }
res, err := config.clientStorage.Objects.Get(bucket, object).Do() res, err := config.clientStorage.Objects.Get(bucket, object).Do()
@ -81,9 +81,9 @@ func resourceStorageObjectAclCreate(d *schema.ResourceData, meta interface{}) er
return fmt.Errorf("Error updating object %s: %v", bucket, err) return fmt.Errorf("Error updating object %s: %v", bucket, err)
} }
return resourceStorageBucketAclRead(d, meta); return resourceStorageBucketAclRead(d, meta)
} else if len(role_entity) > 0 { } else if len(role_entity) > 0 {
for _, v := range(role_entity) { for _, v := range role_entity {
pair, err := getRoleEntityPair(v.(string)) pair, err := getRoleEntityPair(v.(string))
objectAccessControl := &storage.ObjectAccessControl{ objectAccessControl := &storage.ObjectAccessControl{
@ -101,14 +101,13 @@ func resourceStorageObjectAclCreate(d *schema.ResourceData, meta interface{}) er
} }
} }
return resourceStorageObjectAclRead(d, meta); return resourceStorageObjectAclRead(d, meta)
} }
return fmt.Errorf("Error, you must specify either " + return fmt.Errorf("Error, you must specify either " +
"\"predefined_acl\" or \"role_entity\""); "\"predefined_acl\" or \"role_entity\"")
} }
func resourceStorageObjectAclRead(d *schema.ResourceData, meta interface{}) error { func resourceStorageObjectAclRead(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config) config := meta.(*Config)
@ -121,7 +120,7 @@ func resourceStorageObjectAclRead(d *schema.ResourceData, meta interface{}) erro
role_entity := make([]interface{}, 0) role_entity := make([]interface{}, 0)
re_local := d.Get("role_entity").([]interface{}) re_local := d.Get("role_entity").([]interface{})
re_local_map := make(map[string]string) re_local_map := make(map[string]string)
for _, v := range(re_local) { for _, v := range re_local {
res, err := getRoleEntityPair(v.(string)) res, err := getRoleEntityPair(v.(string))
if err != nil { if err != nil {
@ -138,10 +137,10 @@ func resourceStorageObjectAclRead(d *schema.ResourceData, meta interface{}) erro
return err return err
} }
for _, v := range(res.Items) { for _, v := range res.Items {
role := "" role := ""
entity := "" entity := ""
for key, val := range (v.(map[string]interface{})) { for key, val := range v.(map[string]interface{}) {
if key == "role" { if key == "role" {
role = val.(string) role = val.(string)
} else if key == "entity" { } else if key == "entity" {
@ -172,7 +171,7 @@ func resourceStorageObjectAclUpdate(d *schema.ResourceData, meta interface{}) er
old_re, new_re := o.([]interface{}), n.([]interface{}) old_re, new_re := o.([]interface{}), n.([]interface{})
old_re_map := make(map[string]string) old_re_map := make(map[string]string)
for _, v := range(old_re) { for _, v := range old_re {
res, err := getRoleEntityPair(v.(string)) res, err := getRoleEntityPair(v.(string))
if err != nil { if err != nil {
@ -183,7 +182,7 @@ func resourceStorageObjectAclUpdate(d *schema.ResourceData, meta interface{}) er
old_re_map[res.Entity] = res.Role old_re_map[res.Entity] = res.Role
} }
for _, v := range(new_re) { for _, v := range new_re {
pair, err := getRoleEntityPair(v.(string)) pair, err := getRoleEntityPair(v.(string))
objectAccessControl := &storage.ObjectAccessControl{ objectAccessControl := &storage.ObjectAccessControl{
@ -209,7 +208,7 @@ func resourceStorageObjectAclUpdate(d *schema.ResourceData, meta interface{}) er
} }
} }
for entity, _ := range(old_re_map) { for entity, _ := range old_re_map {
log.Printf("[DEBUG]: removing entity %s", entity) log.Printf("[DEBUG]: removing entity %s", entity)
err := config.clientStorage.ObjectAccessControls.Delete(bucket, object, entity).Do() err := config.clientStorage.ObjectAccessControls.Delete(bucket, object, entity).Do()
@ -218,7 +217,7 @@ func resourceStorageObjectAclUpdate(d *schema.ResourceData, meta interface{}) er
} }
} }
return resourceStorageObjectAclRead(d, meta); return resourceStorageObjectAclRead(d, meta)
} }
return nil return nil
@ -231,7 +230,7 @@ func resourceStorageObjectAclDelete(d *schema.ResourceData, meta interface{}) er
object := d.Get("object").(string) object := d.Get("object").(string)
re_local := d.Get("role_entity").([]interface{}) re_local := d.Get("role_entity").([]interface{})
for _, v := range(re_local) { for _, v := range re_local {
res, err := getRoleEntityPair(v.(string)) res, err := getRoleEntityPair(v.(string))
if err != nil { if err != nil {
return err return err

View File

@ -2,9 +2,9 @@ package google
import ( import (
"fmt" "fmt"
"testing"
"math/rand"
"io/ioutil" "io/ioutil"
"math/rand"
"testing"
"time" "time"
"github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/helper/resource"
@ -171,7 +171,7 @@ func testAccCheckGoogleStorageObjectAcl(bucket, object, roleEntityS string) reso
return fmt.Errorf("Error retrieving contents of acl for bucket %s: %s", bucket, err) return fmt.Errorf("Error retrieving contents of acl for bucket %s: %s", bucket, err)
} }
if (res.Role != roleEntity.Role) { if res.Role != roleEntity.Role {
return fmt.Errorf("Error, Role mismatch %s != %s", res.Role, roleEntity.Role) return fmt.Errorf("Error, Role mismatch %s != %s", res.Role, roleEntity.Role)
} }

View File

@ -610,7 +610,6 @@ func resourceComputeInstanceV2Update(d *schema.ResourceData, meta interface{}) e
log.Printf("[DEBUG] Security groups to remove: %v", secgroupsToRemove) log.Printf("[DEBUG] Security groups to remove: %v", secgroupsToRemove)
for _, g := range secgroupsToRemove.List() { for _, g := range secgroupsToRemove.List() {
err := secgroups.RemoveServerFromGroup(computeClient, d.Id(), g.(string)).ExtractErr() err := secgroups.RemoveServerFromGroup(computeClient, d.Id(), g.(string)).ExtractErr()
if err != nil { if err != nil {

View File

@ -326,7 +326,6 @@ func (p *Provisioner) runChefClientFunc(
cmd = fmt.Sprintf("%s -j %q -E %q", chefCmd, fb, p.Environment) cmd = fmt.Sprintf("%s -j %q -E %q", chefCmd, fb, p.Environment)
} }
if p.LogToFile { if p.LogToFile {
if err := os.MkdirAll(logfileDir, 0755); err != nil { if err := os.MkdirAll(logfileDir, 0755); err != nil {
return fmt.Errorf("Error creating logfile directory %s: %v", logfileDir, err) return fmt.Errorf("Error creating logfile directory %s: %v", logfileDir, err)