1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

AZURE_DNS: Add support for Alias: AZURE_ALIAS() (#675)

* Add support for Alias in Azure

* Actioned comments and added parse tests

* GetTargetDebug

* Go formatting
This commit is contained in:
Vatsalya Goel
2020-03-02 20:25:42 +04:00
committed by GitHub
parent 56b448f329
commit 884118f6dd
16 changed files with 384 additions and 130 deletions

View File

@@ -79,7 +79,7 @@ func (dc *DomainConfig) Punycode() error {
if err != nil {
return err
}
case "A", "AAAA", "CAA", "NAPTR", "SOA", "SSHFP", "TXT", "TLSA":
case "A", "AAAA", "CAA", "NAPTR", "SOA", "SSHFP", "TXT", "TLSA", "AZURE_ALIAS":
// Nothing to do.
default:
msg := fmt.Sprintf("Punycode rtype %v unimplemented", rec.Type)

View File

@@ -95,6 +95,7 @@ type RecordConfig struct {
TlsaMatchingType uint8 `json:"tlsamatchingtype,omitempty"`
TxtStrings []string `json:"txtstrings,omitempty"` // TxtStrings stores all strings (including the first). Target stores only the first one.
R53Alias map[string]string `json:"r53_alias,omitempty"`
AzureAlias map[string]string `json:"azure_alias,omitempty"`
Original interface{} `json:"-"` // Store pointer to provider-specific record object. Used in diffing.
}
@@ -307,6 +308,12 @@ func (rc *RecordConfig) Key() RecordKey {
// label with different alias types are considered separate.
t = fmt.Sprintf("%s_%s", t, v)
}
} else if rc.AzureAlias != nil {
if v, ok := rc.AzureAlias["type"]; ok {
// Azure aliases append their alias type, so that records for the same
// label with different alias types are considered separate.
t = fmt.Sprintf("%s_%s", t, v)
}
}
return RecordKey{rc.NameFQDN, t}
}

View File

@@ -52,6 +52,9 @@ func (rc *RecordConfig) GetTargetCombined() string {
case "R53_ALIAS":
// Differentiate between multiple R53_ALIASs on the same label.
return fmt.Sprintf("%s atype=%s zone_id=%s", rc.Target, rc.R53Alias["type"], rc.R53Alias["zone_id"])
case "AZURE_ALIAS":
// Differentiate between multiple AZURE_ALIASs on the same label.
return fmt.Sprintf("%s atype=%s", rc.Target, rc.AzureAlias["type"])
case "SOA":
return fmt.Sprintf("%s %v %d %d %d %d %d", rc.Target, rc.SoaMbox, rc.SoaSerial, rc.SoaRefresh, rc.SoaRetry, rc.SoaExpire, rc.SoaMinttl)
default:
@@ -101,6 +104,8 @@ func (rc *RecordConfig) GetTargetDebug() string {
content += fmt.Sprintf(" caatag=%s caaflag=%d", rc.CaaTag, rc.CaaFlag)
case "R53_ALIAS":
content += fmt.Sprintf(" type=%s zone_id=%s", rc.R53Alias["type"], rc.R53Alias["zone_id"])
case "AZURE_ALIAS":
content += fmt.Sprintf(" type=%s", rc.AzureAlias["type"])
default:
panic(fmt.Errorf("rc.String rtype %v unimplemented", rc.Type))
// We panic so that we quickly find any switch statements