Get list of DNS records before deleting to retrieve ID of recently added record
This commit is contained in:
parent
53a04d6a94
commit
6e06fbd42e
16
client.go
16
client.go
@ -64,12 +64,26 @@ func (p *Provider) addDNSRecord(ctx context.Context, domain string, record libdn
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *Provider) removeDNSRecord(ctx context.Context, domain string, record libdns.Record) (libdns.Record, error) {
|
func (p *Provider) removeDNSRecord(ctx context.Context, domain string, record libdns.Record) (libdns.Record, error) {
|
||||||
|
records, err := p.getDNSEntries(ctx, domain)
|
||||||
|
if err != nil {
|
||||||
|
return record, err
|
||||||
|
}
|
||||||
|
|
||||||
p.client.mutex.Lock()
|
p.client.mutex.Lock()
|
||||||
defer p.client.mutex.Unlock()
|
defer p.client.mutex.Unlock()
|
||||||
|
|
||||||
p.getClient()
|
p.getClient()
|
||||||
|
|
||||||
err := p.client.vultr.DNSRecord.Delete(ctx, domain, record.ID)
|
var recordId string
|
||||||
|
|
||||||
|
for _, rec := range records {
|
||||||
|
if rec.Name == record.Name && rec.Value == strconv.Quote(record.Value) {
|
||||||
|
recordId = rec.ID
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
err = p.client.vultr.DNSRecord.Delete(ctx, domain, recordId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return record, err
|
return record, err
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user