exoscale: update to latest egoscale version (#468)

Signed-off-by: Yoan Blanc <yoan.blanc@exoscale.ch>
This commit is contained in:
Yoan Blanc 2018-01-15 21:58:24 +01:00 committed by xenolf
parent b929aa5aab
commit 62e0f1096f

View file

@ -48,25 +48,25 @@ func (c *DNSProvider) Present(domain, token, keyAuth string) error {
return err return err
} }
recordId, err := c.FindExistingRecordId(zone, recordName) recordID, err := c.FindExistingRecordId(zone, recordName)
if err != nil { if err != nil {
return err return err
} }
record := egoscale.DNSRecord{ record := egoscale.DNSRecord{
Name: recordName, Name: recordName,
Ttl: ttl, TTL: ttl,
Content: value, Content: value,
RecordType: "TXT", RecordType: "TXT",
} }
if recordId == 0 { if recordID == 0 {
_, err := c.client.CreateRecord(zone, record) _, err := c.client.CreateRecord(zone, record)
if err != nil { if err != nil {
return errors.New("Error while creating DNS record: " + err.Error()) return errors.New("Error while creating DNS record: " + err.Error())
} }
} else { } else {
record.Id = recordId record.ID = recordID
_, err := c.client.UpdateRecord(zone, record) _, err := c.client.UpdateRecord(zone, record)
if err != nil { if err != nil {
return errors.New("Error while updating DNS record: " + err.Error()) return errors.New("Error while updating DNS record: " + err.Error())
@ -84,17 +84,13 @@ func (c *DNSProvider) CleanUp(domain, token, keyAuth string) error {
return err return err
} }
recordId, err := c.FindExistingRecordId(zone, recordName) recordID, err := c.FindExistingRecordId(zone, recordName)
if err != nil { if err != nil {
return err return err
} }
if recordId != 0 { if recordID != 0 {
record := egoscale.DNSRecord{ err = c.client.DeleteRecord(zone, recordID)
Id: recordId,
}
err = c.client.DeleteRecord(zone, record)
if err != nil { if err != nil {
return errors.New("Error while deleting DNS record: " + err.Error()) return errors.New("Error while deleting DNS record: " + err.Error())
} }
@ -106,13 +102,13 @@ func (c *DNSProvider) CleanUp(domain, token, keyAuth string) error {
// Query Exoscale to find an existing record for this name. // Query Exoscale to find an existing record for this name.
// Returns nil if no record could be found // Returns nil if no record could be found
func (c *DNSProvider) FindExistingRecordId(zone, recordName string) (int64, error) { func (c *DNSProvider) FindExistingRecordId(zone, recordName string) (int64, error) {
responses, err := c.client.GetRecords(zone) records, err := c.client.GetRecords(zone)
if err != nil { if err != nil {
return -1, errors.New("Error while retrievening DNS records: " + err.Error()) return -1, errors.New("Error while retrievening DNS records: " + err.Error())
} }
for _, response := range responses { for _, record := range records {
if response.Record.Name == recordName { if record.Name == recordName {
return response.Record.Id, nil return record.ID, nil
} }
} }
return 0, nil return 0, nil