vsphere/host_port_group_structure.go
func calculateComputedPolicy(policy types.HostNetworkPolicy) (map[string]string, error) {
	cpr := &schema.Resource{Schema: schemaHostNetworkPolicy()}
	cpd := cpr.Data(&terraform.InstanceState{})
	cpd.SetId("effectivepolicy")
	if err := flattenHostNetworkPolicy(cpd, &policy); err != nil {
		return nil, fmt.Errorf("error setting effective policy data: %s", err)
	}
	cpm := cpd.State().Attributes
	delete(cpm, "id")
	return cpm, nil
}
func calculateComputedPolicy(policy types.HostNetworkPolicy) (map[string]string, error) {
	cpr := &schema.Resource{Schema: schemaHostNetworkPolicy()}
	cpd := cpr.Data(&terraform.InstanceState{})
	cpd.SetId("effectivepolicy")
	if err := flattenHostNetworkPolicy(cpd, &policy); err != nil {
		return nil, fmt.Errorf("error setting effective policy data: %s", err)
	}
	cpm := cpd.State().Attributes
	delete(cpm, "id")
	return cpm, nil
}
func calculateComputedPolicy ( policy types . HostNetworkPolicy ) ( map [ string ] string , error ) { cpr := & schema . Resource { Schema : schemaHostNetworkPolicy ( ) } cpd := cpr . Data ( & terraform . InstanceState { } ) cpd . SetId ( " " ) if err := flattenHostNetworkPolicy ( cpd , & policy ) ; err != nil { return nil , fmt . Errorf ( " " , err ) } cpm := cpd . State ( ) . Attributes delete ( cpm , " " ) return cpm , nil }
// calculateComputedPolicy is a utility function to compute a map of state
// attributes for the port group's effective policy. It uses a bit of a
// roundabout way to set the attributes, but allows us to utilize our
// functional deep reading helpers to perform this task, versus having to
// re-write code.
//
// This function relies a bit on some of the lower-level utility functionality
// of helper/schema, so it may need to change in the future.
calculateComputedPolicy is a utility function to compute a map of state attributes for the port group s effective policy . It uses a bit of a roundabout way to set the attributes but allows us to utilize our functional deep reading helpers to perform this task versus having to re - write code . This function relies a bit on some of the lower - level utility functionality of helper / schema so it may need to change in the future .