Skip to content

Commit

Permalink
Use copystructure to copy the map
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyriakos Oikonomakos authored and koikonom committed Jan 29, 2021
1 parent 78eb8b2 commit 9d5570c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions vsphere/virtual_machine_config_structure.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"log"
"reflect"

"github.com/mitchellh/copystructure"

"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
Expand Down Expand Up @@ -628,9 +630,11 @@ func expandVAppConfig(d *schema.ResourceData, client *govmomi.Client) (*types.Vm
if newVApps != nil && len(newVApps) > 0 && newVApps[0] != nil {
newVApp := newVApps[0].(map[string]interface{})
if props, ok := newVApp["properties"].(map[string]interface{}); ok {
for k, v := range props {
newMap[k] = v
propsCopy, err := copystructure.Copy(props)
if err != nil {
return nil, fmt.Errorf("while extracting vapp properties into a new map: %s", err)
}
newMap = propsCopy.(map[string]interface{})
}
}

Expand Down

0 comments on commit 9d5570c

Please # to comment.