Merge pull request #4512 from lwander/b-gcp-fix-sshkey-metadata
provider/google: Fix project metadata sshkeys from showing up
This commit is contained in:
commit
3f697d5b12
|
@ -60,11 +60,13 @@ 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(curMDMap map[string]interface{}, 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 {
|
||||||
newMD[kv.Key] = *kv.Value
|
if _, ok := curMDMap[kv.Key]; ok {
|
||||||
|
newMD[kv.Key] = *kv.Value
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return newMD
|
return newMD
|
||||||
|
|
|
@ -562,7 +562,7 @@ func resourceComputeInstanceRead(d *schema.ResourceData, meta interface{}) error
|
||||||
// Synch metadata
|
// Synch metadata
|
||||||
md := instance.Metadata
|
md := instance.Metadata
|
||||||
|
|
||||||
_md := MetadataFormatSchema(md)
|
_md := MetadataFormatSchema(d.Get("metadata").(map[string]interface{}), md)
|
||||||
delete(_md, "startup-script")
|
delete(_md, "startup-script")
|
||||||
|
|
||||||
if script, scriptExists := d.GetOk("metadata_startup_script"); scriptExists {
|
if script, scriptExists := d.GetOk("metadata_startup_script"); scriptExists {
|
||||||
|
|
|
@ -90,7 +90,7 @@ func resourceComputeProjectMetadataRead(d *schema.ResourceData, meta interface{}
|
||||||
|
|
||||||
md := project.CommonInstanceMetadata
|
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)
|
return fmt.Errorf("Error setting metadata: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,6 @@ import (
|
||||||
func TestAccComputeProjectMetadata_basic(t *testing.T) {
|
func TestAccComputeProjectMetadata_basic(t *testing.T) {
|
||||||
var project compute.Project
|
var project compute.Project
|
||||||
|
|
||||||
t.Skip("See https://github.com/hashicorp/terraform/issues/4504")
|
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
Providers: testAccProviders,
|
Providers: testAccProviders,
|
||||||
|
@ -38,8 +36,6 @@ func TestAccComputeProjectMetadata_basic(t *testing.T) {
|
||||||
func TestAccComputeProjectMetadata_modify_1(t *testing.T) {
|
func TestAccComputeProjectMetadata_modify_1(t *testing.T) {
|
||||||
var project compute.Project
|
var project compute.Project
|
||||||
|
|
||||||
t.Skip("See https://github.com/hashicorp/terraform/issues/4504")
|
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
Providers: testAccProviders,
|
Providers: testAccProviders,
|
||||||
|
@ -76,8 +72,6 @@ func TestAccComputeProjectMetadata_modify_1(t *testing.T) {
|
||||||
func TestAccComputeProjectMetadata_modify_2(t *testing.T) {
|
func TestAccComputeProjectMetadata_modify_2(t *testing.T) {
|
||||||
var project compute.Project
|
var project compute.Project
|
||||||
|
|
||||||
t.Skip("See https://github.com/hashicorp/terraform/issues/4504")
|
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
Providers: testAccProviders,
|
Providers: testAccProviders,
|
||||||
|
|
Loading…
Reference in New Issue