Revert "Added support for updating a cloud storage object using source field (#362)" (#787)

This reverts commit 5ba87f3d9e.
This commit is contained in:
Vincent Roseberry 2017-11-24 11:10:58 -08:00 committed by GitHub
parent 5ba87f3d9e
commit 40c20047b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 0 additions and 66 deletions

View File

@ -2,11 +2,8 @@ package google
import (
"bytes"
"crypto/md5"
"encoding/base64"
"fmt"
"io"
"io/ioutil"
"log"
"os"
@ -95,9 +92,6 @@ func resourceStorageBucketObject() *schema.Resource {
Optional: true,
ForceNew: true,
ConflictsWith: []string{"content"},
StateFunc: func(src interface{}) string {
return fileNameWithMd5(src.(string))
},
},
"storage_class": &schema.Schema{
@ -114,20 +108,6 @@ func objectGetId(object *storage.Object) string {
return object.Bucket + "-" + object.Name
}
func fileNameWithMd5(filename string) string {
data, err := ioutil.ReadFile(filename)
if err != nil {
log.Printf("[WARN] Failed to read source file %s. Will not compute md5 to store in state", filename)
return filename
}
h := md5.New()
h.Write(data)
md5 := base64.StdEncoding.EncodeToString(h.Sum(nil))
return filename + ":" + md5
}
func resourceStorageBucketObjectCreate(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)

View File

@ -5,7 +5,6 @@ import (
"encoding/base64"
"fmt"
"io/ioutil"
"os"
"testing"
"github.com/hashicorp/terraform/helper/resource"
@ -47,51 +46,6 @@ func TestAccGoogleStorageObject_basic(t *testing.T) {
})
}
func TestAccGoogleStorageObject_recreate(t *testing.T) {
t.Parallel()
bucketName := testBucketName()
writeFile := func(name string, data []byte) string {
h := md5.New()
h.Write(data)
data_md5 := base64.StdEncoding.EncodeToString(h.Sum(nil))
ioutil.WriteFile(name, data, 0644)
return data_md5
}
data_md5 := writeFile(tf.Name(), []byte("data data data"))
updated_data_md5 := writeFile(tf.Name()+".update", []byte("datum"))
resource.Test(t, resource.TestCase{
PreCheck: func() {
if err != nil {
panic(err)
}
testAccPreCheck(t)
},
Providers: testAccProviders,
CheckDestroy: testAccGoogleStorageObjectDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testGoogleStorageBucketsObjectBasic(bucketName),
Check: testAccCheckGoogleStorageObject(bucketName, objectName, data_md5),
},
resource.TestStep{
PreConfig: func() {
updateName := tf.Name() + ".update"
err := os.Rename(updateName, tf.Name())
if err != nil {
t.Errorf("Failed to rename %s to %s", updateName, tf.Name())
}
},
Config: testGoogleStorageBucketsObjectBasic(bucketName),
Check: testAccCheckGoogleStorageObject(bucketName, objectName, updated_data_md5),
},
},
})
}
func TestAccGoogleStorageObject_content(t *testing.T) {
t.Parallel()