CLOUDFLARE: get-zones --ttl flag should handle CF's magic TTLs better (#657)

Fixes https://github.com/StackExchange/dnscontrol/issues/630
This commit is contained in:
Tom Limoncelli 2020-02-27 11:11:59 -05:00 committed by GitHub
parent 7789b4dbdc
commit 798cdffd81
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View file

@ -165,7 +165,7 @@ func GetZone(args GetZoneArgs) error {
if defaultTTL == 0 {
defaultTTL = prettyzone.MostCommonTTL(recs)
}
if defaultTTL != models.DefaultTTL {
if defaultTTL != models.DefaultTTL && defaultTTL != 0 {
fmt.Fprintf(w, "\n\tDefaultTTL(%d)", defaultTTL)
}
for _, rec := range recs {

View file

@ -79,6 +79,9 @@ func PrettySort(records models.Records, origin string, defaultTTL uint32, commen
DefaultTTL: defaultTTL,
Comments: comments,
}
if z.DefaultTTL == 0 {
z.DefaultTTL = 300
}
z.Records = nil
for _, r := range records {
z.Records = append(z.Records, r)
@ -92,6 +95,9 @@ func (z *zoneGenData) generateZoneFileHelper(w io.Writer) error {
nameShortPrevious := ""
sort.Sort(z)
if z.DefaultTTL == 0 {
z.DefaultTTL = 300
}
fmt.Fprintln(w, "$TTL", z.DefaultTTL)
for _, comment := range z.Comments {
for _, line := range strings.Split(comment, "\n") {