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

@ -5,7 +5,7 @@ import (
"github.com/hashicorp/terraform/helper/schema"
)
func makeAwsStringList(in []interface {}) []*string {
func makeAwsStringList(in []interface{}) []*string {
ret := make([]*string, len(in), len(in))
for i := 0; i < len(in); i++ {
ret[i] = aws.String(in[i].(string))

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
@ -51,7 +51,7 @@ func MetadataUpdate(oldMDMap map[string]interface{}, newMDMap map[string]interfa
// Reformat old metadata into a list
serverMD.Items = nil
for key, val := range curMDMap {
v := val;
v := val
serverMD.Items = append(serverMD.Items, &compute.MetadataItems{
Key: key,
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
func MetadataFormatSchema(md *compute.Metadata) (map[string]interface{}) {
func MetadataFormatSchema(md *compute.Metadata) map[string]interface{} {
newMD := make(map[string]interface{})
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 {
config := meta.(*Config)
instance, err := getInstance(config, d);
instance, err := getInstance(config, d)
if err != nil {
return err
}
@ -644,7 +644,7 @@ func resourceComputeInstanceUpdate(d *schema.ResourceData, meta interface{}) err
zone := d.Get("zone").(string)
instance, err := getInstance(config, d);
instance, err := getInstance(config, d)
if err != nil {
return err
}
@ -658,7 +658,7 @@ func resourceComputeInstanceUpdate(d *schema.ResourceData, meta interface{}) err
updateMD := func() error {
// Reload the instance in the case of a fingerprint mismatch
instance, err = getInstance(config, d);
instance, err = getInstance(config, d)
if err != nil {
return err
}

View File

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

View File

@ -83,7 +83,7 @@ func resourceStorageBucketAclCreate(d *schema.ResourceData, meta interface{}) er
if len(predefined_acl) > 0 {
if len(role_entity) > 0 {
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()
@ -99,9 +99,9 @@ func resourceStorageBucketAclCreate(d *schema.ResourceData, meta interface{}) er
return fmt.Errorf("Error updating bucket %s: %v", bucket, err)
}
return resourceStorageBucketAclRead(d, meta);
return resourceStorageBucketAclRead(d, meta)
} else if len(role_entity) > 0 {
for _, v := range(role_entity) {
for _, v := range role_entity {
pair, err := getRoleEntityPair(v.(string))
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 {
@ -135,13 +135,12 @@ func resourceStorageBucketAclCreate(d *schema.ResourceData, meta interface{}) er
return fmt.Errorf("Error updating bucket %s: %v", bucket, err)
}
return resourceStorageBucketAclRead(d, meta);
return resourceStorageBucketAclRead(d, meta)
}
return nil
}
func resourceStorageBucketAclRead(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
@ -153,7 +152,7 @@ func resourceStorageBucketAclRead(d *schema.ResourceData, meta interface{}) erro
role_entity := make([]interface{}, 0)
re_local := d.Get("role_entity").([]interface{})
re_local_map := make(map[string]string)
for _, v := range(re_local) {
for _, v := range re_local {
res, err := getRoleEntityPair(v.(string))
if err != nil {
@ -170,7 +169,7 @@ func resourceStorageBucketAclRead(d *schema.ResourceData, meta interface{}) erro
return err
}
for _, v := range(res.Items) {
for _, v := range res.Items {
log.Printf("[DEBUG]: examining re %s-%s", v.Role, v.Entity)
// We only store updates to the locally defined access controls
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_map := make(map[string]string)
for _, v := range(old_re) {
for _, v := range old_re {
res, err := getRoleEntityPair(v.(string))
if err != nil {
@ -207,7 +206,7 @@ func resourceStorageBucketAclUpdate(d *schema.ResourceData, meta interface{}) er
old_re_map[res.Entity] = res.Role
}
for _, v := range(new_re) {
for _, v := range new_re {
pair, err := getRoleEntityPair(v.(string))
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)
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") {
@ -261,7 +260,7 @@ func resourceStorageBucketAclUpdate(d *schema.ResourceData, meta interface{}) er
return fmt.Errorf("Error updating bucket %s: %v", bucket, err)
}
return resourceStorageBucketAclRead(d, meta);
return resourceStorageBucketAclRead(d, meta)
}
return nil
@ -273,7 +272,7 @@ func resourceStorageBucketAclDelete(d *schema.ResourceData, meta interface{}) er
bucket := d.Get("bucket").(string)
re_local := d.Get("role_entity").([]interface{})
for _, v := range(re_local) {
for _, v := range re_local {
res, err := getRoleEntityPair(v.(string))
if err != nil {
return err

View File

@ -2,8 +2,8 @@ package google
import (
"fmt"
"testing"
"math/rand"
"testing"
"time"
"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)
}
if (res.Role != roleEntity.Role) {
if 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)
var testGoogleStorageBucketsAclPredefined = fmt.Sprintf(`
resource "google_storage_bucket" "bucket" {
name = "%s"

View File

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

View File

@ -1,11 +1,11 @@
package google
import (
"fmt"
"testing"
"io/ioutil"
"crypto/md5"
"encoding/base64"
"fmt"
"io/ioutil"
"testing"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
@ -48,7 +48,6 @@ func testAccCheckGoogleStorageObject(bucket, object, md5 string) resource.TestCh
objectsService := storage.NewObjectsService(config.clientStorage)
getCall := objectsService.Get(bucket, object)
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)
}
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)
}

View File

@ -65,7 +65,7 @@ func resourceStorageObjectAclCreate(d *schema.ResourceData, meta interface{}) er
if len(predefined_acl) > 0 {
if len(role_entity) > 0 {
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()
@ -74,16 +74,16 @@ func resourceStorageObjectAclCreate(d *schema.ResourceData, meta interface{}) er
return fmt.Errorf("Error reading object %s: %v", bucket, err)
}
res, err = config.clientStorage.Objects.Update(bucket,object,
res, err = config.clientStorage.Objects.Update(bucket, object,
res).PredefinedAcl(predefined_acl).Do()
if err != nil {
return fmt.Errorf("Error updating object %s: %v", bucket, err)
}
return resourceStorageBucketAclRead(d, meta);
return resourceStorageBucketAclRead(d, meta)
} else if len(role_entity) > 0 {
for _, v := range(role_entity) {
for _, v := range role_entity {
pair, err := getRoleEntityPair(v.(string))
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 " +
"\"predefined_acl\" or \"role_entity\"");
"\"predefined_acl\" or \"role_entity\"")
}
func resourceStorageObjectAclRead(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
@ -121,7 +120,7 @@ func resourceStorageObjectAclRead(d *schema.ResourceData, meta interface{}) erro
role_entity := make([]interface{}, 0)
re_local := d.Get("role_entity").([]interface{})
re_local_map := make(map[string]string)
for _, v := range(re_local) {
for _, v := range re_local {
res, err := getRoleEntityPair(v.(string))
if err != nil {
@ -138,10 +137,10 @@ func resourceStorageObjectAclRead(d *schema.ResourceData, meta interface{}) erro
return err
}
for _, v := range(res.Items) {
for _, v := range res.Items {
role := ""
entity := ""
for key, val := range (v.(map[string]interface{})) {
for key, val := range v.(map[string]interface{}) {
if key == "role" {
role = val.(string)
} 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_map := make(map[string]string)
for _, v := range(old_re) {
for _, v := range old_re {
res, err := getRoleEntityPair(v.(string))
if err != nil {
@ -183,7 +182,7 @@ func resourceStorageObjectAclUpdate(d *schema.ResourceData, meta interface{}) er
old_re_map[res.Entity] = res.Role
}
for _, v := range(new_re) {
for _, v := range new_re {
pair, err := getRoleEntityPair(v.(string))
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)
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
@ -231,7 +230,7 @@ func resourceStorageObjectAclDelete(d *schema.ResourceData, meta interface{}) er
object := d.Get("object").(string)
re_local := d.Get("role_entity").([]interface{})
for _, v := range(re_local) {
for _, v := range re_local {
res, err := getRoleEntityPair(v.(string))
if err != nil {
return err

View File

@ -2,9 +2,9 @@ package google
import (
"fmt"
"testing"
"math/rand"
"io/ioutil"
"math/rand"
"testing"
"time"
"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)
}
if (res.Role != roleEntity.Role) {
if 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)
for _, g := range secgroupsToRemove.List() {
err := secgroups.RemoveServerFromGroup(computeClient, d.Id(), g.(string)).ExtractErr()
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)
}
if p.LogToFile {
if err := os.MkdirAll(logfileDir, 0755); err != nil {
return fmt.Errorf("Error creating logfile directory %s: %v", logfileDir, err)