1
0
Fork 0

use custom govultr to domain record update bug

This commit is contained in:
Henrik Hautakoski 2025-10-16 13:02:44 +02:00
parent 4591f89f5f
commit 961f3951a8
3 changed files with 6 additions and 18 deletions

View file

@ -13,11 +13,6 @@ import (
type Service struct {
api govultr.DomainRecordService
// HACK(domainreq): govultr does not set "omitempty" on the govultr.DomainRecordReq.Name field
// this makes the api call update the name of the record to a empty string.
// workaround is to keep a map of recordID's and their names so we can set it
// in Update()
names map[string]string
}
func New(token string) Service {
@ -27,8 +22,7 @@ func New(token string) Service {
client := govultr.NewClient(oauth2.NewClient(ctx, ts))
return Service{
api: client.DomainRecord,
names: map[string]string{},
api: client.DomainRecord,
}
}
@ -46,7 +40,7 @@ func Factory(args map[string]any) (any, error) {
return New(token), nil
}
func (p *Service) List(domain_name string) (dns.RecordList, error) {
func (p Service) List(domain_name string) (dns.RecordList, error) {
fetchedRecords, _, _, err := p.api.List(context.Background(), domain_name, nil)
if err != nil {
return nil, err
@ -59,9 +53,6 @@ func (p *Service) List(domain_name string) (dns.RecordList, error) {
continue
}
// HACK(domainreq):
p.names[record.ID] = record.Name
records.Add(dns.Record{
Id: record.ID,
Name: record.Name,
@ -76,10 +67,5 @@ func (p Service) Update(domain, recordID, ip string) error {
Data: ip,
}
// HACK(domainreq):
if name, ok := p.names[recordID]; ok {
req.Name = name
}
return p.api.Update(context.Background(), domain, recordID, req)
}