vsphere/virtual_machine_config_structure.go
func flattenExtraConfig(d *schema.ResourceData, opts []types.BaseOptionValue) error {
	if len(opts) < 1 {
		// No opts to read is a no-op
		return nil
	}
	ec := make(map[string]interface{})
	for _, v := range opts {
		ov := v.GetOptionValue()
		for k := range d.Get("extra_config").(map[string]interface{}) {
			if ov.Key == k {
				ec[ov.Key] = ov.Value
			}
		}
	}
	return d.Set("extra_config", ec)
}
func flattenExtraConfig(d *schema.ResourceData, opts []types.BaseOptionValue) error {
	if len(opts) < 1 {
		// No opts to read is a no-op
		return nil
	}
	ec := make(map[string]interface{})
	for _, v := range opts {
		ov := v.GetOptionValue()
		for k := range d.Get("extra_config").(map[string]interface{}) {
			if ov.Key == k {
				ec[ov.Key] = ov.Value
			}
		}
	}
	return d.Set("extra_config", ec)
}
func flattenExtraConfig ( d * schema . ResourceData , opts [ ] types . BaseOptionValue ) error { if len ( opts ) < 1 { // No opts to read is a no-op return nil } ec := make ( map [ string ] interface { } ) for _ , v := range opts { ov := v . GetOptionValue ( ) for k := range d . Get ( " " ) . ( map [ string ] interface { } ) { if ov . Key == k { ec [ ov . Key ] = ov . Value } } } return d . Set ( " " , ec ) }
// flattenExtraConfig reads in the extraConfig from a running virtual machine
// and *only* sets the keys in extra_config that we know about. This is to
// prevent Terraform from interfering with values that are maintained
// out-of-band by vSphere which could lead to spurious diffs and unstable
// operation.  Note the side-effect here is that Terraform cannot track manual
// drift that is not a part of normal vSphere operation. Removing keys that
// have been in configuration through at least one successful apply though are
// safe, as removing them will add a nil value for that key in the next
// chnageset, properly effecting its removal.
flattenExtraConfig reads in the extraConfig from a running virtual machine and * only * sets the keys in extra_config that we know about . This is to prevent Terraform from interfering with values that are maintained out - of - band by vSphere which could lead to spurious diffs and unstable operation . Note the side - effect here is that Terraform cannot track manual drift that is not a part of normal vSphere operation . Removing keys that have been in configuration through at least one successful apply though are safe as removing them will add a nil value for that key in the next chnageset properly effecting its removal .