Skip to content

Commit

Permalink
exoscale: update to latest egoscale version (go-acme#468)
Browse files Browse the repository at this point in the history
Signed-off-by: Yoan Blanc <[email protected]>
  • Loading branch information
greut authored and xenolf committed Jan 15, 2018
1 parent b929aa5 commit 62e0f10
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions providers/dns/exoscale/exoscale.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,25 @@ func (c *DNSProvider) Present(domain, token, keyAuth string) error {
return err
}

recordId, err := c.FindExistingRecordId(zone, recordName)
recordID, err := c.FindExistingRecordId(zone, recordName)
if err != nil {
return err
}

record := egoscale.DNSRecord{
Name: recordName,
Ttl: ttl,
TTL: ttl,
Content: value,
RecordType: "TXT",
}

if recordId == 0 {
if recordID == 0 {
_, err := c.client.CreateRecord(zone, record)
if err != nil {
return errors.New("Error while creating DNS record: " + err.Error())
}
} else {
record.Id = recordId
record.ID = recordID
_, err := c.client.UpdateRecord(zone, record)
if err != nil {
return errors.New("Error while updating DNS record: " + err.Error())
Expand All @@ -84,17 +84,13 @@ func (c *DNSProvider) CleanUp(domain, token, keyAuth string) error {
return err
}

recordId, err := c.FindExistingRecordId(zone, recordName)
recordID, err := c.FindExistingRecordId(zone, recordName)
if err != nil {
return err
}

if recordId != 0 {
record := egoscale.DNSRecord{
Id: recordId,
}

err = c.client.DeleteRecord(zone, record)
if recordID != 0 {
err = c.client.DeleteRecord(zone, recordID)
if err != nil {
return errors.New("Error while deleting DNS record: " + err.Error())
}
Expand All @@ -106,13 +102,13 @@ func (c *DNSProvider) CleanUp(domain, token, keyAuth string) error {
// Query Exoscale to find an existing record for this name.
// Returns nil if no record could be found
func (c *DNSProvider) FindExistingRecordId(zone, recordName string) (int64, error) {
responses, err := c.client.GetRecords(zone)
records, err := c.client.GetRecords(zone)
if err != nil {
return -1, errors.New("Error while retrievening DNS records: " + err.Error())
}
for _, response := range responses {
if response.Record.Name == recordName {
return response.Record.Id, nil
for _, record := range records {
if record.Name == recordName {
return record.ID, nil
}
}
return 0, nil
Expand Down

0 comments on commit 62e0f10

Please sign in to comment.