mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2025-08-06 01:26:59 +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)
|
||||
}
|
||||
|
||||
type DomainClient struct {
|
||||
type domainClient struct {
|
||||
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()
|
||||
}
|
||||
|
||||
func NewDomainClient(client *domain.Domain) DomainClientAdapter {
|
||||
return &DomainClient{client}
|
||||
return &domainClient{client}
|
||||
}
|
||||
|
||||
// StandardResponse copied from go-gandi/internal/gandi.go
|
||||
type StandardResponse struct {
|
||||
// standardResponse copied from go-gandi/internal/gandi.go
|
||||
type standardResponse struct {
|
||||
Code int `json:"code,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
UUID string `json:"uuid,omitempty"`
|
||||
Object string `json:"object,omitempty"`
|
||||
Cause string `json:"cause,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
Errors []StandardError `json:"errors,omitempty"`
|
||||
Errors []standardError `json:"errors,omitempty"`
|
||||
}
|
||||
|
||||
// StandardError copied from go-gandi/internal/gandi.go
|
||||
type StandardError struct {
|
||||
// standardError copied from go-gandi/internal/gandi.go
|
||||
type standardError struct {
|
||||
Location string `json:"location"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
@ -54,9 +54,9 @@ type StandardError struct {
|
||||
|
||||
type LiveDNSClientAdapter interface {
|
||||
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)
|
||||
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 {
|
||||
@ -71,18 +71,18 @@ func (p *LiveDNSClient) GetDomainRecords(fqdn string) (records []livedns.DomainR
|
||||
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)
|
||||
if err != nil {
|
||||
return StandardResponse{}, err
|
||||
return standardResponse{}, err
|
||||
}
|
||||
|
||||
// response needs to be copied as the Standard* structs are internal
|
||||
var errors []StandardError
|
||||
var errors []standardError
|
||||
for _, e := range res.Errors {
|
||||
errors = append(errors, StandardError(e))
|
||||
errors = append(errors, standardError(e))
|
||||
}
|
||||
return StandardResponse{
|
||||
return standardResponse{
|
||||
Code: res.Code,
|
||||
Message: res.Message,
|
||||
UUID: res.UUID,
|
||||
@ -97,18 +97,18 @@ func (p *LiveDNSClient) DeleteDomainRecord(fqdn, name, recordtype string) (err e
|
||||
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)
|
||||
if err != nil {
|
||||
return StandardResponse{}, err
|
||||
return standardResponse{}, err
|
||||
}
|
||||
|
||||
// response needs to be copied as the Standard* structs are internal
|
||||
var errors []StandardError
|
||||
var errors []standardError
|
||||
for _, e := range res.Errors {
|
||||
errors = append(errors, StandardError(e))
|
||||
errors = append(errors, standardError(e))
|
||||
}
|
||||
return StandardResponse{
|
||||
return standardResponse{
|
||||
Code: res.Code,
|
||||
Message: res.Message,
|
||||
UUID: res.UUID,
|
||||
|
@ -102,7 +102,7 @@ func (m *mockGandiClient) GetDomainRecords(fqdn string) (records []livedns.Domai
|
||||
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{
|
||||
Name: "CreateDomainRecord",
|
||||
FQDN: fqdn,
|
||||
@ -114,10 +114,10 @@ func (m *mockGandiClient) CreateDomainRecord(fqdn, name, recordtype string, ttl
|
||||
},
|
||||
})
|
||||
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) {
|
||||
@ -137,7 +137,7 @@ func (m *mockGandiClient) DeleteDomainRecord(fqdn, name, recordtype string) (err
|
||||
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{
|
||||
Name: "UpdateDomainRecordByNameAndType",
|
||||
FQDN: fqdn,
|
||||
@ -150,10 +150,10 @@ func (m *mockGandiClient) UpdateDomainRecordByNameAndType(fqdn, name, recordtype
|
||||
})
|
||||
|
||||
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) {
|
||||
|
Loading…
Reference in New Issue
Block a user