mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2025-08-06 17:46:57 +02:00
Simplify exoscale provider
This commit is contained in:
parent
4d0411349d
commit
a5cd0d6f5c
@ -33,7 +33,6 @@ import (
|
|||||||
type EgoscaleClientI interface {
|
type EgoscaleClientI interface {
|
||||||
ListDNSDomainRecords(context.Context, string, string) ([]egoscale.DNSDomainRecord, error)
|
ListDNSDomainRecords(context.Context, string, string) ([]egoscale.DNSDomainRecord, error)
|
||||||
ListDNSDomains(context.Context, string) ([]egoscale.DNSDomain, error)
|
ListDNSDomains(context.Context, string) ([]egoscale.DNSDomain, error)
|
||||||
GetDNSDomainRecord(context.Context, string, string, string) (*egoscale.DNSDomainRecord, error)
|
|
||||||
CreateDNSDomainRecord(context.Context, string, string, *egoscale.DNSDomainRecord) (*egoscale.DNSDomainRecord, error)
|
CreateDNSDomainRecord(context.Context, string, string, *egoscale.DNSDomainRecord) (*egoscale.DNSDomainRecord, error)
|
||||||
DeleteDNSDomainRecord(context.Context, string, string, *egoscale.DNSDomainRecord) error
|
DeleteDNSDomainRecord(context.Context, string, string, *egoscale.DNSDomainRecord) error
|
||||||
UpdateDNSDomainRecord(context.Context, string, string, *egoscale.DNSDomainRecord) error
|
UpdateDNSDomainRecord(context.Context, string, string, *egoscale.DNSDomainRecord) error
|
||||||
@ -160,16 +159,11 @@ func (ep *ExoscaleProvider) ApplyChanges(ctx context.Context, changes *plan.Chan
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, r := range records {
|
for _, record := range records {
|
||||||
if *r.Name != name {
|
if *record.Name != name {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
record, err := ep.client.GetDNSDomainRecord(ctx, ep.apiZone, zoneID, *r.ID)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
record.Type = &epoint.RecordType
|
record.Type = &epoint.RecordType
|
||||||
record.Content = &epoint.Targets[0]
|
record.Content = &epoint.Targets[0]
|
||||||
if epoint.RecordTTL != 0 {
|
if epoint.RecordTTL != 0 {
|
||||||
@ -177,7 +171,7 @@ func (ep *ExoscaleProvider) ApplyChanges(ctx context.Context, changes *plan.Chan
|
|||||||
record.TTL = &ttl
|
record.TTL = &ttl
|
||||||
}
|
}
|
||||||
|
|
||||||
err = ep.client.UpdateDNSDomainRecord(ctx, ep.apiZone, zoneID, record)
|
err = ep.client.UpdateDNSDomainRecord(ctx, ep.apiZone, zoneID, &record)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -240,11 +234,7 @@ func (ep *ExoscaleProvider) Records(ctx context.Context) ([]*endpoint.Endpoint,
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, r := range records {
|
for _, record := range records {
|
||||||
record, err := ep.client.GetDNSDomainRecord(ctx, ep.apiZone, *domain.ID, *r.ID)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
switch *record.Type {
|
switch *record.Type {
|
||||||
case "A", "CNAME", "TXT":
|
case "A", "CNAME", "TXT":
|
||||||
break
|
break
|
||||||
@ -252,7 +242,7 @@ func (ep *ExoscaleProvider) Records(ctx context.Context) ([]*endpoint.Endpoint,
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
e := endpoint.NewEndpointWithTTL((*record.Name)+"."+(*domain.UnicodeName), *record.Type, endpoint.TTL(*r.TTL), *record.Content)
|
e := endpoint.NewEndpointWithTTL((*record.Name)+"."+(*domain.UnicodeName), *record.Type, endpoint.TTL(*record.TTL), *record.Content)
|
||||||
endpoints = append(endpoints, e)
|
endpoints = append(endpoints, e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ package exoscale
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
egoscale "github.com/exoscale/egoscale/v2"
|
egoscale "github.com/exoscale/egoscale/v2"
|
||||||
@ -93,17 +92,6 @@ func (ep *ExoscaleClientStub) ListDNSDomainRecords(ctx context.Context, _, domai
|
|||||||
return groups[domainID], nil
|
return groups[domainID], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ep *ExoscaleClientStub) GetDNSDomainRecord(ctx context.Context, _, domainID, recordID string) (*egoscale.DNSDomainRecord, error) {
|
|
||||||
group := groups[domainID]
|
|
||||||
for _, record := range group {
|
|
||||||
if *record.ID == recordID {
|
|
||||||
return &record, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil, errors.New("not found")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ep *ExoscaleClientStub) CreateDNSDomainRecord(ctx context.Context, _, domainID string, record *egoscale.DNSDomainRecord) (*egoscale.DNSDomainRecord, error) {
|
func (ep *ExoscaleClientStub) CreateDNSDomainRecord(ctx context.Context, _, domainID string, record *egoscale.DNSDomainRecord) (*egoscale.DNSDomainRecord, error) {
|
||||||
createExoscale = append(createExoscale, createRecordExoscale{domainID: domainID, record: record})
|
createExoscale = append(createExoscale, createRecordExoscale{domainID: domainID, record: record})
|
||||||
return record, nil
|
return record, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user