func (p *dnsimpleProvider) submitChanges(changes []*dnsimpleChange) error {
	if len(changes) == 0 {
		log.Infof("All records are already up to date")
		return nil
	}
	zones, err := p.Zones()
	if err != nil {
		return err
	}
	for _, change := range changes {
		zone := dnsimpleSuitableZone(change.ResourceRecordSet.Name, zones)
		if zone == nil {
			log.Debugf("Skipping record %s because no hosted zone matching record DNS Name was detected ", change.ResourceRecordSet.Name)
			continue
		}

		log.Infof("Changing records: %s %v in zone: %s", change.Action, change.ResourceRecordSet, zone.Name)

		change.ResourceRecordSet.Name = strings.TrimSuffix(change.ResourceRecordSet.Name, "."+zone.Name)
		if !p.dryRun {
			switch change.Action {
			case dnsimpleCreate:
				_, err := p.client.CreateRecord(p.accountID, zone.Name, change.ResourceRecordSet)
				if err != nil {
					return err
				}
			case dnsimpleDelete:
				recordID, err := p.GetRecordID(zone.Name, change.ResourceRecordSet.Name)
				if err != nil {
					return err
				}
				_, err = p.client.DeleteRecord(p.accountID, zone.Name, recordID)
				if err != nil {
					return err
				}
			case dnsimpleUpdate:
				recordID, err := p.GetRecordID(zone.Name, change.ResourceRecordSet.Name)
				if err != nil {
					return err
				}
				_, err = p.client.UpdateRecord(p.accountID, zone.Name, recordID, change.ResourceRecordSet)
				if err != nil {
					return err
				}
			}
		}
	}
	return nil
}
func (p *dnsimpleProvider) submitChanges(changes []*dnsimpleChange) error {
	if len(changes) == 0 {
		log.Infof("All records are already up to date")
		return nil
	}
	zones, err := p.Zones()
	if err != nil {
		return err
	}
	for _, change := range changes {
		zone := dnsimpleSuitableZone(change.ResourceRecordSet.Name, zones)
		if zone == nil {
			log.Debugf("Skipping record %s because no hosted zone matching record DNS Name was detected ", change.ResourceRecordSet.Name)
			continue
		}

		log.Infof("Changing records: %s %v in zone: %s", change.Action, change.ResourceRecordSet, zone.Name)

		change.ResourceRecordSet.Name = strings.TrimSuffix(change.ResourceRecordSet.Name, "."+zone.Name)
		if !p.dryRun {
			switch change.Action {
			case dnsimpleCreate:
				_, err := p.client.CreateRecord(p.accountID, zone.Name, change.ResourceRecordSet)
				if err != nil {
					return err
				}
			case dnsimpleDelete:
				recordID, err := p.GetRecordID(zone.Name, change.ResourceRecordSet.Name)
				if err != nil {
					return err
				}
				_, err = p.client.DeleteRecord(p.accountID, zone.Name, recordID)
				if err != nil {
					return err
				}
			case dnsimpleUpdate:
				recordID, err := p.GetRecordID(zone.Name, change.ResourceRecordSet.Name)
				if err != nil {
					return err
				}
				_, err = p.client.UpdateRecord(p.accountID, zone.Name, recordID, change.ResourceRecordSet)
				if err != nil {
					return err
				}
			}
		}
	}
	return nil
}
func ( p * dnsimpleProvider ) submitChanges ( changes [ ] * dnsimpleChange ) error { if len ( changes ) == 0 { log . Infof ( " " ) return nil } zones , err := p . Zones ( ) if err != nil { return err } for _ , change := range changes { zone := dnsimpleSuitableZone ( change . ResourceRecordSet . Name , zones ) if zone == nil { log . Debugf ( " " , change . ResourceRecordSet . Name ) continue } log . Infof ( " " , change . Action , change . ResourceRecordSet , zone . Name ) change . ResourceRecordSet . Name = strings . TrimSuffix ( change . ResourceRecordSet . Name , " " + zone . Name ) if ! p . dryRun { switch change . Action { case dnsimpleCreate : _ , err := p . client . CreateRecord ( p . accountID , zone . Name , change . ResourceRecordSet ) if err != nil { return err } case dnsimpleDelete : recordID , err := p . GetRecordID ( zone . Name , change . ResourceRecordSet . Name ) if err != nil { return err } _ , err = p . client . DeleteRecord ( p . accountID , zone . Name , recordID ) if err != nil { return err } case dnsimpleUpdate : recordID , err := p . GetRecordID ( zone . Name , change . ResourceRecordSet . Name ) if err != nil { return err } _ , err = p . client . UpdateRecord ( p . accountID , zone . Name , recordID , change . ResourceRecordSet ) if err != nil { return err } } } } return nil }
// submitChanges takes a zone and a collection of changes and makes all changes from the collection
submitChanges takes a zone and a collection of changes and makes all changes from the collection