diff --git a/client.go b/client.go index 906c7df..fdad71e 100644 --- a/client.go +++ b/client.go @@ -2,7 +2,6 @@ package vultr import ( "context" - "fmt" "sync" "golang.org/x/oauth2" @@ -28,6 +27,9 @@ func (p *Provider) getClient() error { } func (p *Provider) getDNSEntries(ctx context.Context, domain string) ([]libdns.Record, error) { + p.client.mutex.Lock() + defer p.client.mutex.Unlock() + p.getClient() listOptions := &govultr.ListOptions{} @@ -80,17 +82,7 @@ func (p *Provider) removeDNSRecord(ctx context.Context, domain string, record li recordId, err := getRecordId(record) if err != nil { - // try to get the ID from API if we don't have it - records, err := p.getDNSEntries(ctx, domain) - if err != nil { - return record, fmt.Errorf("could not get record ID from API") - } - - for _, rec := range records { - if rec.RR().Name == record.RR().Name { - recordId = rec.(VultrRecord).ID - } - } + return record, err } err = p.client.vultr.DomainRecord.Delete(ctx, domain, recordId) @@ -109,17 +101,7 @@ func (p *Provider) updateDNSRecord(ctx context.Context, domain string, record li recordId, err := getRecordId(record) if err != nil { - // try to get the ID from API if we don't have it - records, err := p.getDNSEntries(ctx, domain) - if err != nil { - return record, fmt.Errorf("could not get record ID from API") - } - - for _, rec := range records { - if rec.RR().Data == record.RR().Data { - recordId = rec.(VultrRecord).ID - } - } + return record, err } domainRecordReq := toDomainRecordReq(record)