provider/google: Fix project metadata sshkeys from showing up

This commit is contained in:
Lars Wander 2016-01-05 11:37:52 -05:00
parent 5c6304ed57
commit a006a6a399
4 changed files with 6 additions and 10 deletions

View File

@ -60,11 +60,13 @@ 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(curMDMap map[string]interface{}, md *compute.Metadata) map[string]interface{} {
newMD := make(map[string]interface{})
for _, kv := range md.Items {
newMD[kv.Key] = *kv.Value
if _, ok := curMDMap[kv.Key]; ok {
newMD[kv.Key] = *kv.Value
}
}
return newMD

View File

@ -562,7 +562,7 @@ func resourceComputeInstanceRead(d *schema.ResourceData, meta interface{}) error
// Synch metadata
md := instance.Metadata
_md := MetadataFormatSchema(md)
_md := MetadataFormatSchema(d.Get("metadata").(map[string]interface{}), md)
delete(_md, "startup-script")
if script, scriptExists := d.GetOk("metadata_startup_script"); scriptExists {

View File

@ -90,7 +90,7 @@ func resourceComputeProjectMetadataRead(d *schema.ResourceData, meta interface{}
md := project.CommonInstanceMetadata
if err = d.Set("metadata", MetadataFormatSchema(md)); err != nil {
if err = d.Set("metadata", MetadataFormatSchema(d.Get("metadata").(map[string]interface{}), md)); err != nil {
return fmt.Errorf("Error setting metadata: %s", err)
}

View File

@ -13,8 +13,6 @@ import (
func TestAccComputeProjectMetadata_basic(t *testing.T) {
var project compute.Project
t.Skip("See https://github.com/hashicorp/terraform/issues/4504")
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
@ -38,8 +36,6 @@ func TestAccComputeProjectMetadata_basic(t *testing.T) {
func TestAccComputeProjectMetadata_modify_1(t *testing.T) {
var project compute.Project
t.Skip("See https://github.com/hashicorp/terraform/issues/4504")
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
@ -76,8 +72,6 @@ func TestAccComputeProjectMetadata_modify_1(t *testing.T) {
func TestAccComputeProjectMetadata_modify_2(t *testing.T) {
var project compute.Project
t.Skip("See https://github.com/hashicorp/terraform/issues/4504")
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,