mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
HEXONET: Implement get-zones, fix module problem (#898)
* VULTR: Update govultr to v1.0.0 (fixes #892) (#897) * go get -u github.com/hexonet/go-sdk * Fix HEXONET providers.json entry * providers.json: json commma * providers.json: fmtjson * HEXONET: Implement get-zones. Fix tests and docs. * fixup! * Update azure test failures * Move version info into its own package * Use new version system
This commit is contained in:
@@ -37,30 +37,34 @@ type HXRecord struct {
|
||||
|
||||
// GetZoneRecords gets the records of a zone and returns them in RecordConfig format.
|
||||
func (n *HXClient) 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.
|
||||
}
|
||||
|
||||
// GetDomainCorrections gathers correctios that would bring n to match dc.
|
||||
func (n *HXClient) GetDomainCorrections(dc *models.DomainConfig) ([]*models.Correction, error) {
|
||||
dc.Punycode()
|
||||
records, err := n.getRecords(dc.Name)
|
||||
records, err := n.getRecords(domain)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
actual := make([]*models.RecordConfig, len(records))
|
||||
for i, r := range records {
|
||||
actual[i] = toRecord(r, dc.Name)
|
||||
actual[i] = toRecord(r, domain)
|
||||
}
|
||||
|
||||
for _, rec := range dc.Records {
|
||||
for _, rec := range actual {
|
||||
if rec.Type == "ALIAS" {
|
||||
return nil, fmt.Errorf("we support realtime ALIAS RR over our X-DNS service, please get in touch with us")
|
||||
}
|
||||
}
|
||||
|
||||
return actual, nil
|
||||
|
||||
}
|
||||
|
||||
// GetDomainCorrections gathers correctios that would bring n to match dc.
|
||||
func (n *HXClient) GetDomainCorrections(dc *models.DomainConfig) ([]*models.Correction, error) {
|
||||
dc.Punycode()
|
||||
|
||||
actual, err := n.GetZoneRecords(dc.Name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
//checkNSModifications(dc)
|
||||
|
||||
// Normalize
|
||||
@@ -77,7 +81,7 @@ func (n *HXClient) GetDomainCorrections(dc *models.DomainConfig) ([]*models.Corr
|
||||
buf := &bytes.Buffer{}
|
||||
// Print a list of changes. Generate an actual change that is the zone
|
||||
changes := false
|
||||
params := map[string]string{}
|
||||
params := map[string]interface{}{}
|
||||
delrridx := 0
|
||||
addrridx := 0
|
||||
for _, cre := range create {
|
||||
@@ -161,9 +165,9 @@ func (n *HXClient) showCommand(cmd map[string]string) {
|
||||
fmt.Print(string(b))
|
||||
}
|
||||
|
||||
func (n *HXClient) updateZoneBy(params map[string]string, domain string) error {
|
||||
func (n *HXClient) updateZoneBy(params map[string]interface{}, domain string) error {
|
||||
zone := domain + "."
|
||||
cmd := map[string]string{
|
||||
cmd := map[string]interface{}{
|
||||
"COMMAND": "UpdateDNSZone",
|
||||
"DNSZONE": zone,
|
||||
"INCSERIAL": "1",
|
||||
@@ -182,7 +186,7 @@ func (n *HXClient) updateZoneBy(params map[string]string, domain string) error {
|
||||
func (n *HXClient) getRecords(domain string) ([]*HXRecord, error) {
|
||||
var records []*HXRecord
|
||||
zone := domain + "."
|
||||
cmd := map[string]string{
|
||||
cmd := map[string]interface{}{
|
||||
"COMMAND": "QueryDNSZoneRRList",
|
||||
"DNSZONE": zone,
|
||||
"SHORT": "1",
|
||||
|
||||
Reference in New Issue
Block a user