mirror of
				https://github.com/StackExchange/dnscontrol.git
				synced 2024-05-11 05:55:12 +00:00 
			
		
		
		
	BUG: Some DNS zones are downloaded twice (#2120)
Signed-off-by: Amelia Aronsohn <squirrel@wearing.black> Co-authored-by: Tom Limoncelli <tal@whatexit.org> Co-authored-by: Grégoire Henry <hnrgrgr@users.noreply.github.com> Co-authored-by: Amelia Aronsohn <squirrel@wearing.black> Co-authored-by: Kai Schwarz <kschwarz@hexonet.net> Co-authored-by: Asif Nawaz <asif.nawaz@centralnic.com> Co-authored-by: imlonghao <git@imlonghao.com> Co-authored-by: Will Power <1619102+willpower232@users.noreply.github.com>
This commit is contained in:
		| @@ -88,22 +88,13 @@ func (c *exoscaleProvider) GetNameservers(domain string) ([]*models.Nameserver, | ||||
| } | ||||
|  | ||||
| // GetZoneRecords gets the records of a zone and returns them in RecordConfig format. | ||||
| func (c *exoscaleProvider) GetZoneRecords(domain string) (models.Records, error) { | ||||
| 	return nil, fmt.Errorf("not implemented") | ||||
| 	// This enables the get-zones subcommand. | ||||
| 	// Implement this by extracting the code from GetDomainCorrections into | ||||
| 	// a single function.  For most providers this should be relatively easy. | ||||
| } | ||||
| func (c *exoscaleProvider) GetZoneRecords(domainName string) (models.Records, error) { | ||||
| 	//dc.Punycode() | ||||
|  | ||||
| // GetDomainCorrections returns a list of corretions for the  domain. | ||||
| func (c *exoscaleProvider) GetDomainCorrections(dc *models.DomainConfig) ([]*models.Correction, error) { | ||||
| 	dc.Punycode() | ||||
|  | ||||
| 	domain, err := c.findDomainByName(dc.Name) | ||||
| 	domain, err := c.findDomainByName(domainName) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
|  | ||||
| 	domainID := *domain.ID | ||||
|  | ||||
| 	ctx := context.Background() | ||||
| @@ -165,7 +156,7 @@ func (c *exoscaleProvider) GetDomainCorrections(dc *models.DomainConfig) ([]*mod | ||||
| 		if record.TTL != nil { | ||||
| 			rc.TTL = uint32(*record.TTL) | ||||
| 		} | ||||
| 		rc.SetLabel(rname, dc.Name) | ||||
| 		rc.SetLabel(rname, domainName) | ||||
|  | ||||
| 		switch rtype { | ||||
| 		case "ALIAS", "URL": | ||||
| @@ -178,7 +169,7 @@ func (c *exoscaleProvider) GetDomainCorrections(dc *models.DomainConfig) ([]*mod | ||||
| 			} | ||||
| 			err = rc.SetTargetMX(prio, rcontent) | ||||
| 		default: | ||||
| 			err = rc.PopulateFromString(rtype, rcontent, dc.Name) | ||||
| 			err = rc.PopulateFromString(rtype, rcontent, domainName) | ||||
| 		} | ||||
| 		if err != nil { | ||||
| 			return nil, fmt.Errorf("unparsable record received from exoscale: %w", err) | ||||
| @@ -186,25 +177,33 @@ func (c *exoscaleProvider) GetDomainCorrections(dc *models.DomainConfig) ([]*mod | ||||
|  | ||||
| 		existingRecords = append(existingRecords, rc) | ||||
| 	} | ||||
| 	removeOtherNS(dc) | ||||
|  | ||||
| 	// Normalize | ||||
| 	models.PostProcessRecords(existingRecords) | ||||
| 	return existingRecords, nil | ||||
| } | ||||
|  | ||||
| // GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records. | ||||
| func (c *exoscaleProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, existingRecords models.Records) ([]*models.Correction, error) { | ||||
|  | ||||
| 	removeOtherNS(dc) | ||||
| 	domain, err := c.findDomainByName(dc.Name) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	domainID := *domain.ID | ||||
|  | ||||
| 	var corrections []*models.Correction | ||||
| 	var create, delete, modify diff.Changeset | ||||
| 	var differ diff.Differ | ||||
| 	if !diff2.EnableDiff2 { | ||||
| 		differ = diff.New(dc) | ||||
| 	} else { | ||||
| 		differ = diff.NewCompat(dc) | ||||
| 	} | ||||
| 	_, create, delete, modify, err = differ.IncrementalDiff(existingRecords) | ||||
| 	_, create, toDelete, modify, err := differ.IncrementalDiff(existingRecords) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
|  | ||||
| 	for _, del := range delete { | ||||
| 	for _, del := range toDelete { | ||||
| 		record := del.Existing.Original.(*egoscale.DNSDomainRecord) | ||||
| 		corrections = append(corrections, &models.Correction{ | ||||
| 			Msg: del.String(), | ||||
|   | ||||
		Reference in New Issue
	
	Block a user