func (c *inMemoryClient) validateChangeBatch(zone string, changes *inMemoryChange) error {
	curZone, ok := c.zones[zone]
	if !ok {
		return ErrZoneNotFound
	}
	mesh := map[string]map[string]bool{}
	for _, newEndpoint := range changes.Create {
		if c.findByType(newEndpoint.Type, curZone[newEndpoint.Name]) != nil {
			return ErrRecordAlreadyExists
		}
		if err := c.updateMesh(mesh, newEndpoint); err != nil {
			return err
		}
	}
	for _, updateEndpoint := range changes.UpdateNew {
		if c.findByType(updateEndpoint.Type, curZone[updateEndpoint.Name]) == nil {
			return ErrRecordNotFound
		}
		if err := c.updateMesh(mesh, updateEndpoint); err != nil {
			return err
		}
	}
	for _, updateOldEndpoint := range changes.UpdateOld {
		if rec := c.findByType(updateOldEndpoint.Type, curZone[updateOldEndpoint.Name]); rec == nil || rec.Target != updateOldEndpoint.Target {
			return ErrRecordNotFound
		}
	}
	for _, deleteEndpoint := range changes.Delete {
		if rec := c.findByType(deleteEndpoint.Type, curZone[deleteEndpoint.Name]); rec == nil || rec.Target != deleteEndpoint.Target {
			return ErrRecordNotFound
		}
		if err := c.updateMesh(mesh, deleteEndpoint); err != nil {
			return err
		}
	}
	return nil
}
func (c *inMemoryClient) validateChangeBatch(zone string, changes *inMemoryChange) error {
	curZone, ok := c.zones[zone]
	if !ok {
		return ErrZoneNotFound
	}
	mesh := map[string]map[string]bool{}
	for _, newEndpoint := range changes.Create {
		if c.findByType(newEndpoint.Type, curZone[newEndpoint.Name]) != nil {
			return ErrRecordAlreadyExists
		}
		if err := c.updateMesh(mesh, newEndpoint); err != nil {
			return err
		}
	}
	for _, updateEndpoint := range changes.UpdateNew {
		if c.findByType(updateEndpoint.Type, curZone[updateEndpoint.Name]) == nil {
			return ErrRecordNotFound
		}
		if err := c.updateMesh(mesh, updateEndpoint); err != nil {
			return err
		}
	}
	for _, updateOldEndpoint := range changes.UpdateOld {
		if rec := c.findByType(updateOldEndpoint.Type, curZone[updateOldEndpoint.Name]); rec == nil || rec.Target != updateOldEndpoint.Target {
			return ErrRecordNotFound
		}
	}
	for _, deleteEndpoint := range changes.Delete {
		if rec := c.findByType(deleteEndpoint.Type, curZone[deleteEndpoint.Name]); rec == nil || rec.Target != deleteEndpoint.Target {
			return ErrRecordNotFound
		}
		if err := c.updateMesh(mesh, deleteEndpoint); err != nil {
			return err
		}
	}
	return nil
}
func ( c * inMemoryClient ) validateChangeBatch ( zone string , changes * inMemoryChange ) error { curZone , ok := c . zones [ zone ] if ! ok { return ErrZoneNotFound } mesh := map [ string ] map [ string ] bool { } for _ , newEndpoint := range changes . Create { if c . findByType ( newEndpoint . Type , curZone [ newEndpoint . Name ] ) != nil { return ErrRecordAlreadyExists } if err := c . updateMesh ( mesh , newEndpoint ) ; err != nil { return err } } for _ , updateEndpoint := range changes . UpdateNew { if c . findByType ( updateEndpoint . Type , curZone [ updateEndpoint . Name ] ) == nil { return ErrRecordNotFound } if err := c . updateMesh ( mesh , updateEndpoint ) ; err != nil { return err } } for _ , updateOldEndpoint := range changes . UpdateOld { if rec := c . findByType ( updateOldEndpoint . Type , curZone [ updateOldEndpoint . Name ] ) ; rec == nil || rec . Target != updateOldEndpoint . Target { return ErrRecordNotFound } } for _ , deleteEndpoint := range changes . Delete { if rec := c . findByType ( deleteEndpoint . Type , curZone [ deleteEndpoint . Name ] ) ; rec == nil || rec . Target != deleteEndpoint . Target { return ErrRecordNotFound } if err := c . updateMesh ( mesh , deleteEndpoint ) ; err != nil { return err } } return nil }
// validateChangeBatch validates that the changes passed to InMemory DNS provider is valid
validateChangeBatch validates that the changes passed to InMemory DNS provider is valid