provider/google: Fix project metadata sshkeys from showing up
This commit is contained in:
parent
5c6304ed57
commit
a006a6a399
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue