vsphere/internal/vmworkflow/virtual_machine_customize_subresource.go
func ValidateCustomizationSpec(d *schema.ResourceDiff, family string) error {
	// Validate that the proper section exists for OS family suboptions.
	linuxExists := len(d.Get(cKeyPrefix+"."+"linux_options").([]interface{})) > 0
	windowsExists := len(d.Get(cKeyPrefix+"."+"windows_options").([]interface{})) > 0
	sysprepExists := d.Get(cKeyPrefix+"."+"windows_sysprep_text").(string) != ""
	switch {
	case family == string(types.VirtualMachineGuestOsFamilyLinuxGuest) && !linuxExists:
		return errors.New("linux_options must exist in VM customization options for Linux operating systems")
	case family == string(types.VirtualMachineGuestOsFamilyWindowsGuest) && !windowsExists && !sysprepExists:
		return errors.New("one of windows_options or windows_sysprep_text must exist in VM customization options for Windows operating systems")
	}
	return nil
}
func ValidateCustomizationSpec(d *schema.ResourceDiff, family string) error {
	// Validate that the proper section exists for OS family suboptions.
	linuxExists := len(d.Get(cKeyPrefix+"."+"linux_options").([]interface{})) > 0
	windowsExists := len(d.Get(cKeyPrefix+"."+"windows_options").([]interface{})) > 0
	sysprepExists := d.Get(cKeyPrefix+"."+"windows_sysprep_text").(string) != ""
	switch {
	case family == string(types.VirtualMachineGuestOsFamilyLinuxGuest) && !linuxExists:
		return errors.New("linux_options must exist in VM customization options for Linux operating systems")
	case family == string(types.VirtualMachineGuestOsFamilyWindowsGuest) && !windowsExists && !sysprepExists:
		return errors.New("one of windows_options or windows_sysprep_text must exist in VM customization options for Windows operating systems")
	}
	return nil
}
// ValidateCustomizationSpec checks the validity of the supplied customization
// spec. It should be called during diff customization to veto invalid configs.