-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclient.go
36 lines (31 loc) · 989 Bytes
/
client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package dreamhost
import (
"strings"
"github.com/adamantal/go-dreamhost/api"
"github.com/libdns/libdns"
)
func (p *Provider) init() error {
client, err := api.NewClient(p.APIKey, nil)
if err != nil {
return err
}
p.client = *client
return nil
}
func recordFromApiDnsRecord(apiDnsRecord api.DNSRecord) libdns.Record {
var rec libdns.Record
rec.Type = string(apiDnsRecord.Type)
rec.Value = apiDnsRecord.Value
// We need to get the name minus the zone to match what libdns expects
rec.Name = libdns.RelativeName(apiDnsRecord.Record, apiDnsRecord.Zone)
return rec
}
func apiDnsRecordInputFromRecord(record libdns.Record, zone string) api.DNSRecordInput {
var recordInput api.DNSRecordInput
recordInput.Type = api.RecordType(record.Type)
recordInput.Value = record.Value
// Dreamhost expects the record name to be absolute, without a dot at the end
zone = strings.TrimRight(zone, ".")
recordInput.Record = libdns.AbsoluteName(record.Name, zone)
return recordInput
}