mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2025-08-07 01:56:57 +02:00
Keep copied structs to module
This commit is contained in:
parent
b5f7570c35
commit
2287fbb9d6
@ -22,31 +22,31 @@ type DomainClientAdapter interface {
|
|||||||
ListDomains() (domains []domain.ListResponse, err error)
|
ListDomains() (domains []domain.ListResponse, err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type DomainClient struct {
|
type domainClient struct {
|
||||||
Client *domain.Domain
|
Client *domain.Domain
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *DomainClient) ListDomains() (domains []domain.ListResponse, err error) {
|
func (p *domainClient) ListDomains() (domains []domain.ListResponse, err error) {
|
||||||
return p.Client.ListDomains()
|
return p.Client.ListDomains()
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDomainClient(client *domain.Domain) DomainClientAdapter {
|
func NewDomainClient(client *domain.Domain) DomainClientAdapter {
|
||||||
return &DomainClient{client}
|
return &domainClient{client}
|
||||||
}
|
}
|
||||||
|
|
||||||
// StandardResponse copied from go-gandi/internal/gandi.go
|
// standardResponse copied from go-gandi/internal/gandi.go
|
||||||
type StandardResponse struct {
|
type standardResponse struct {
|
||||||
Code int `json:"code,omitempty"`
|
Code int `json:"code,omitempty"`
|
||||||
Message string `json:"message,omitempty"`
|
Message string `json:"message,omitempty"`
|
||||||
UUID string `json:"uuid,omitempty"`
|
UUID string `json:"uuid,omitempty"`
|
||||||
Object string `json:"object,omitempty"`
|
Object string `json:"object,omitempty"`
|
||||||
Cause string `json:"cause,omitempty"`
|
Cause string `json:"cause,omitempty"`
|
||||||
Status string `json:"status,omitempty"`
|
Status string `json:"status,omitempty"`
|
||||||
Errors []StandardError `json:"errors,omitempty"`
|
Errors []standardError `json:"errors,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// StandardError copied from go-gandi/internal/gandi.go
|
// standardError copied from go-gandi/internal/gandi.go
|
||||||
type StandardError struct {
|
type standardError struct {
|
||||||
Location string `json:"location"`
|
Location string `json:"location"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
@ -54,9 +54,9 @@ type StandardError struct {
|
|||||||
|
|
||||||
type LiveDNSClientAdapter interface {
|
type LiveDNSClientAdapter interface {
|
||||||
GetDomainRecords(fqdn string) (records []livedns.DomainRecord, err error)
|
GetDomainRecords(fqdn string) (records []livedns.DomainRecord, err error)
|
||||||
CreateDomainRecord(fqdn, name, recordtype string, ttl int, values []string) (response StandardResponse, err error)
|
CreateDomainRecord(fqdn, name, recordtype string, ttl int, values []string) (response standardResponse, err error)
|
||||||
DeleteDomainRecord(fqdn, name, recordtype string) (err error)
|
DeleteDomainRecord(fqdn, name, recordtype string) (err error)
|
||||||
UpdateDomainRecordByNameAndType(fqdn, name, recordtype string, ttl int, values []string) (response StandardResponse, err error)
|
UpdateDomainRecordByNameAndType(fqdn, name, recordtype string, ttl int, values []string) (response standardResponse, err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type LiveDNSClient struct {
|
type LiveDNSClient struct {
|
||||||
@ -71,18 +71,18 @@ func (p *LiveDNSClient) GetDomainRecords(fqdn string) (records []livedns.DomainR
|
|||||||
return p.Client.GetDomainRecords(fqdn)
|
return p.Client.GetDomainRecords(fqdn)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *LiveDNSClient) CreateDomainRecord(fqdn, name, recordtype string, ttl int, values []string) (response StandardResponse, err error) {
|
func (p *LiveDNSClient) CreateDomainRecord(fqdn, name, recordtype string, ttl int, values []string) (response standardResponse, err error) {
|
||||||
res, err := p.Client.CreateDomainRecord(fqdn, name, recordtype, ttl, values)
|
res, err := p.Client.CreateDomainRecord(fqdn, name, recordtype, ttl, values)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return StandardResponse{}, err
|
return standardResponse{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// response needs to be copied as the Standard* structs are internal
|
// response needs to be copied as the Standard* structs are internal
|
||||||
var errors []StandardError
|
var errors []standardError
|
||||||
for _, e := range res.Errors {
|
for _, e := range res.Errors {
|
||||||
errors = append(errors, StandardError(e))
|
errors = append(errors, standardError(e))
|
||||||
}
|
}
|
||||||
return StandardResponse{
|
return standardResponse{
|
||||||
Code: res.Code,
|
Code: res.Code,
|
||||||
Message: res.Message,
|
Message: res.Message,
|
||||||
UUID: res.UUID,
|
UUID: res.UUID,
|
||||||
@ -97,18 +97,18 @@ func (p *LiveDNSClient) DeleteDomainRecord(fqdn, name, recordtype string) (err e
|
|||||||
return p.Client.DeleteDomainRecord(fqdn, name, recordtype)
|
return p.Client.DeleteDomainRecord(fqdn, name, recordtype)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *LiveDNSClient) UpdateDomainRecordByNameAndType(fqdn, name, recordtype string, ttl int, values []string) (response StandardResponse, err error) {
|
func (p *LiveDNSClient) UpdateDomainRecordByNameAndType(fqdn, name, recordtype string, ttl int, values []string) (response standardResponse, err error) {
|
||||||
res, err := p.Client.UpdateDomainRecordByNameAndType(fqdn, name, recordtype, ttl, values)
|
res, err := p.Client.UpdateDomainRecordByNameAndType(fqdn, name, recordtype, ttl, values)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return StandardResponse{}, err
|
return standardResponse{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// response needs to be copied as the Standard* structs are internal
|
// response needs to be copied as the Standard* structs are internal
|
||||||
var errors []StandardError
|
var errors []standardError
|
||||||
for _, e := range res.Errors {
|
for _, e := range res.Errors {
|
||||||
errors = append(errors, StandardError(e))
|
errors = append(errors, standardError(e))
|
||||||
}
|
}
|
||||||
return StandardResponse{
|
return standardResponse{
|
||||||
Code: res.Code,
|
Code: res.Code,
|
||||||
Message: res.Message,
|
Message: res.Message,
|
||||||
UUID: res.UUID,
|
UUID: res.UUID,
|
||||||
|
@ -102,7 +102,7 @@ func (m *mockGandiClient) GetDomainRecords(fqdn string) (records []livedns.Domai
|
|||||||
return m.RecordsToReturn, err
|
return m.RecordsToReturn, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockGandiClient) CreateDomainRecord(fqdn, name, recordtype string, ttl int, values []string) (response StandardResponse, err error) {
|
func (m *mockGandiClient) CreateDomainRecord(fqdn, name, recordtype string, ttl int, values []string) (response standardResponse, err error) {
|
||||||
m.Actions = append(m.Actions, MockAction{
|
m.Actions = append(m.Actions, MockAction{
|
||||||
Name: "CreateDomainRecord",
|
Name: "CreateDomainRecord",
|
||||||
FQDN: fqdn,
|
FQDN: fqdn,
|
||||||
@ -114,10 +114,10 @@ func (m *mockGandiClient) CreateDomainRecord(fqdn, name, recordtype string, ttl
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
if m.FunctionToFail == "CreateDomainRecord" {
|
if m.FunctionToFail == "CreateDomainRecord" {
|
||||||
return StandardResponse{}, fmt.Errorf("injected error")
|
return standardResponse{}, fmt.Errorf("injected error")
|
||||||
}
|
}
|
||||||
|
|
||||||
return StandardResponse{}, nil
|
return standardResponse{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockGandiClient) DeleteDomainRecord(fqdn, name, recordtype string) (err error) {
|
func (m *mockGandiClient) DeleteDomainRecord(fqdn, name, recordtype string) (err error) {
|
||||||
@ -137,7 +137,7 @@ func (m *mockGandiClient) DeleteDomainRecord(fqdn, name, recordtype string) (err
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockGandiClient) UpdateDomainRecordByNameAndType(fqdn, name, recordtype string, ttl int, values []string) (response StandardResponse, err error) {
|
func (m *mockGandiClient) UpdateDomainRecordByNameAndType(fqdn, name, recordtype string, ttl int, values []string) (response standardResponse, err error) {
|
||||||
m.Actions = append(m.Actions, MockAction{
|
m.Actions = append(m.Actions, MockAction{
|
||||||
Name: "UpdateDomainRecordByNameAndType",
|
Name: "UpdateDomainRecordByNameAndType",
|
||||||
FQDN: fqdn,
|
FQDN: fqdn,
|
||||||
@ -150,10 +150,10 @@ func (m *mockGandiClient) UpdateDomainRecordByNameAndType(fqdn, name, recordtype
|
|||||||
})
|
})
|
||||||
|
|
||||||
if m.FunctionToFail == "UpdateDomainRecordByNameAndType" {
|
if m.FunctionToFail == "UpdateDomainRecordByNameAndType" {
|
||||||
return StandardResponse{}, fmt.Errorf("injected error")
|
return standardResponse{}, fmt.Errorf("injected error")
|
||||||
}
|
}
|
||||||
|
|
||||||
return StandardResponse{}, nil
|
return standardResponse{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockGandiClient) ListDomains() (domains []domain.ListResponse, err error) {
|
func (m *mockGandiClient) ListDomains() (domains []domain.ListResponse, err error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user