mirror of
https://github.com/vxcontrol/external-dns.git
synced 2026-07-19 18:23:33 -04:00
Merge pull request #94 from jeanlouisboudart/patch-1
Upgrade gandi-api due to breaking change in zonerecord api
This commit is contained in:
+1
-1
@@ -19,7 +19,7 @@ github.com/juju/ratelimit 77ed1c8
|
||||
github.com/kolo/xmlrpc 0826b98
|
||||
github.com/miekg/dns 48ab660
|
||||
github.com/pkg/errors ff09b13
|
||||
github.com/prasmussen/gandi-api 13205dc
|
||||
github.com/prasmussen/gandi-api 2dd22da
|
||||
github.com/rancher/go-rancher-metadata/metadata 11a77c2
|
||||
github.com/rancher/go-rancher/v2 939fd85
|
||||
github.com/tent/http-link-go ac974c6
|
||||
|
||||
+18
-9
@@ -35,16 +35,25 @@ func (self *Domain) Info(name string) (*DomainInfo, error) {
|
||||
|
||||
// List domains associated to the contact represented by apikey
|
||||
func (self *Domain) List() ([]*DomainInfoBase, error) {
|
||||
var res []interface{}
|
||||
params := []interface{}{self.Key}
|
||||
if err := self.Call("domain.list", params, &res); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
opts := &struct {
|
||||
Page int `xmlrpc:"page"`
|
||||
}{0}
|
||||
const perPage = 100
|
||||
params := []interface{}{self.Key, opts}
|
||||
domains := make([]*DomainInfoBase, 0)
|
||||
for _, r := range res {
|
||||
domain := ToDomainInfoBase(r.(map[string]interface{}))
|
||||
domains = append(domains, domain)
|
||||
for {
|
||||
var res []interface{}
|
||||
if err := self.Call("domain.list", params, &res); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, r := range res {
|
||||
domain := ToDomainInfoBase(r.(map[string]interface{}))
|
||||
domains = append(domains, domain)
|
||||
}
|
||||
if len(res) < perPage {
|
||||
break
|
||||
}
|
||||
opts.Page++
|
||||
}
|
||||
return domains, nil
|
||||
}
|
||||
|
||||
+23
-12
@@ -1,6 +1,8 @@
|
||||
package record
|
||||
|
||||
import "github.com/prasmussen/gandi-api/client"
|
||||
import (
|
||||
"github.com/prasmussen/gandi-api/client"
|
||||
)
|
||||
|
||||
type Record struct {
|
||||
*client.Client
|
||||
@@ -22,16 +24,25 @@ func (self *Record) Count(zoneId, version int64) (int64, error) {
|
||||
|
||||
// List records of a version of a DNS zone
|
||||
func (self *Record) List(zoneId, version int64) ([]*RecordInfo, error) {
|
||||
var res []interface{}
|
||||
params := []interface{}{self.Key, zoneId, version}
|
||||
if err := self.Call("domain.zone.record.list", params, &res); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
opts := &struct {
|
||||
Page int `xmlrpc:"page"`
|
||||
}{0}
|
||||
const perPage = 100
|
||||
params := []interface{}{self.Key, zoneId, version, opts}
|
||||
records := make([]*RecordInfo, 0)
|
||||
for _, r := range res {
|
||||
record := ToRecordInfo(r.(map[string]interface{}))
|
||||
records = append(records, record)
|
||||
for {
|
||||
var res []interface{}
|
||||
if err := self.Call("domain.zone.record.list", params, &res); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, r := range res {
|
||||
record := ToRecordInfo(r.(map[string]interface{}))
|
||||
records = append(records, record)
|
||||
}
|
||||
if len(res) < perPage {
|
||||
break
|
||||
}
|
||||
opts.Page++
|
||||
}
|
||||
return records, nil
|
||||
}
|
||||
@@ -54,7 +65,7 @@ func (self *Record) Add(args RecordAdd) (*RecordInfo, error) {
|
||||
}
|
||||
|
||||
// Remove a record from a zone/version
|
||||
func (self *Record) Delete(zoneId, version, recordId int64) (bool, error) {
|
||||
func (self *Record) Delete(zoneId, version int64, recordId string) (bool, error) {
|
||||
var res int64
|
||||
deleteArgs := map[string]interface{}{"id": recordId}
|
||||
params := []interface{}{self.Key, zoneId, version, deleteArgs}
|
||||
@@ -73,7 +84,7 @@ func (self *Record) Update(args RecordUpdate) ([]*RecordInfo, error) {
|
||||
"value": args.Value,
|
||||
"ttl": args.Ttl,
|
||||
}
|
||||
updateOpts := map[string]int64{
|
||||
updateOpts := map[string]string{
|
||||
"id": args.Id,
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package record
|
||||
|
||||
type RecordInfo struct {
|
||||
Id int64
|
||||
Id string
|
||||
Name string
|
||||
Ttl int64
|
||||
Type string
|
||||
@@ -24,7 +24,7 @@ type RecordUpdate struct {
|
||||
Type string `goptions:"-t, --type, obligatory, description='Record type'"`
|
||||
Value string `goptions:"-V, --value, obligatory, description='Value for record. Semantics depends on the record type.'"`
|
||||
Ttl int64 `goptions:"-T, --ttl, description='Time to live, in seconds, between 5 minutes and 30 days'"`
|
||||
Id int64 `goptions:"-r, --record, obligatory, description='Record id'"`
|
||||
Id string `goptions:"-r, --record, obligatory, description='Record id'"`
|
||||
}
|
||||
|
||||
type RecordSet map[string]interface{}
|
||||
|
||||
+8
-9
@@ -1,16 +1,15 @@
|
||||
package record
|
||||
|
||||
import (
|
||||
"github.com/prasmussen/gandi-api/util"
|
||||
"github.com/prasmussen/gandi-api/util"
|
||||
)
|
||||
|
||||
|
||||
func ToRecordInfo(res map[string]interface{}) *RecordInfo {
|
||||
return &RecordInfo{
|
||||
Id: util.ToInt64(res["id"]),
|
||||
Name: util.ToString(res["name"]),
|
||||
Ttl: util.ToInt64(res["ttl"]),
|
||||
Type: util.ToString(res["type"]),
|
||||
Value: util.ToString(res["value"]),
|
||||
}
|
||||
return &RecordInfo{
|
||||
Id: util.ToString(res["id"]),
|
||||
Name: util.ToString(res["name"]),
|
||||
Ttl: util.ToInt64(res["ttl"]),
|
||||
Type: util.ToString(res["type"]),
|
||||
Value: util.ToString(res["value"]),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user