mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2025-09-04 12:14:23 +08:00
parent
b7b0b20798
commit
6c316993ec
3 changed files with 24 additions and 22 deletions
|
@ -1002,8 +1002,8 @@
|
|||
<td class="info">
|
||||
<i class="fa fa-circle-o text-info" aria-hidden="true"></i>
|
||||
</td>
|
||||
<td class="info">
|
||||
<i class="fa fa-circle-o text-info" aria-hidden="true"></i>
|
||||
<td class="success">
|
||||
<i class="fa fa-check text-success" aria-hidden="true"></i>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
|
|
@ -59,7 +59,7 @@ func TestConversion(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, record := range records {
|
||||
rc, err := toRecordConfig(dc, record)
|
||||
rc, err := toRecordConfig(dc.Name, record)
|
||||
if err != nil {
|
||||
t.Error("Error converting Vultr record", record)
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ var features = providers.DocumentationNotes{
|
|||
providers.CanUseSSHFP: providers.Can(),
|
||||
providers.DocCreateDomains: providers.Can(),
|
||||
providers.DocOfficiallySupported: providers.Cannot(),
|
||||
providers.CanGetZones: providers.Unimplemented(),
|
||||
providers.CanGetZones: providers.Can(),
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
@ -68,31 +68,33 @@ func NewProvider(m map[string]string, metadata json.RawMessage) (providers.DNSSe
|
|||
}
|
||||
|
||||
// GetZoneRecords gets the records of a zone and returns them in RecordConfig format.
|
||||
func (client *Provider) GetZoneRecords(domain string) (models.Records, error) {
|
||||
return nil, fmt.Errorf("not implemented")
|
||||
// This enables the get-zones subcommand.
|
||||
// Implement this by extracting the code from GetDomainCorrections into
|
||||
// a single function. For most providers this should be relatively easy.
|
||||
func (api *Provider) GetZoneRecords(domain string) (models.Records, error) {
|
||||
records, err := api.client.DNSRecord.List(context.Background(), domain)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
curRecords := make(models.Records, len(records))
|
||||
for i := range records {
|
||||
r, err := toRecordConfig(domain, &records[i])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
curRecords[i] = r
|
||||
}
|
||||
|
||||
return curRecords, nil
|
||||
}
|
||||
|
||||
// GetDomainCorrections gets the corrections for a DomainConfig.
|
||||
func (api *Provider) GetDomainCorrections(dc *models.DomainConfig) ([]*models.Correction, error) {
|
||||
dc.Punycode()
|
||||
|
||||
records, err := api.client.DNSRecord.List(context.Background(), dc.Name)
|
||||
curRecords, err := api.GetZoneRecords(dc.Name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
curRecords := make([]*models.RecordConfig, len(records))
|
||||
for i := range records {
|
||||
r, err := toRecordConfig(dc, &records[i])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
curRecords[i] = r
|
||||
}
|
||||
|
||||
models.PostProcessRecords(curRecords)
|
||||
|
||||
differ := diff.New(dc)
|
||||
|
@ -164,13 +166,13 @@ func (api *Provider) isDomainInAccount(domain string) (bool, error) {
|
|||
}
|
||||
|
||||
// toRecordConfig converts a Vultr DNSRecord to a RecordConfig. #rtype_variations
|
||||
func toRecordConfig(dc *models.DomainConfig, r *govultr.DNSRecord) (*models.RecordConfig, error) {
|
||||
origin, data := dc.Name, r.Data
|
||||
func toRecordConfig(domain string, r *govultr.DNSRecord) (*models.RecordConfig, error) {
|
||||
origin, data := domain, r.Data
|
||||
rc := &models.RecordConfig{
|
||||
TTL: uint32(r.TTL),
|
||||
Original: r,
|
||||
}
|
||||
rc.SetLabel(r.Name, dc.Name)
|
||||
rc.SetLabel(r.Name, domain)
|
||||
|
||||
switch rtype := r.Type; rtype {
|
||||
case "CNAME", "NS":
|
||||
|
|
Loading…
Add table
Reference in a new issue