1
0
Fork 0
mirror of https://gitlab.com/pnx-tools/dns-updater.git synced 2026-06-15 21:53:08 +02:00

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)
}

2
go.mod
View file

@ -28,3 +28,5 @@ require (
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.30.0 // indirect
)
replace github.com/vultr/govultr/v3 v3.24.0 => github.com/pnx/govultr/v3 v3.24.1-pnx

4
go.sum
View file

@ -33,6 +33,8 @@ github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pnx/govultr/v3 v3.24.1-pnx h1:8VZHSE9OVWAK6f2MHa1N5YFXunRu7uNcdvK1XLfH4qk=
github.com/pnx/govultr/v3 v3.24.1-pnx/go.mod h1:9WwnWGCKnwDlNjHjtt+j+nP+0QWq6hQXzaHgddqrLWY=
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/rs/zerolog v1.30.0 h1:SymVODrcRsaRaSInD9yQtKbtWqwsfoPcRff/oRXLj4c=
github.com/rs/zerolog v1.30.0/go.mod h1:/tk+P47gFdPXq4QYjvCmT5/Gsug2nagsFWBWhAiSi1w=
@ -43,8 +45,6 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/vultr/govultr/v3 v3.24.0 h1:fTTTj0VBve+Miy+wGhlb90M2NMDfpGFi6Frlj3HVy6M=
github.com/vultr/govultr/v3 v3.24.0/go.mod h1:9WwnWGCKnwDlNjHjtt+j+nP+0QWq6hQXzaHgddqrLWY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM=