mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-11-10 09:12:47 +08:00
diff2: Add a "hints" when change is TTL-only (#2249)
Co-authored-by: Tom Limoncelli <tal@whatexit.org>
This commit is contained in:
parent
6ac1961341
commit
f676c4956e
3 changed files with 12 additions and 3 deletions
|
@ -170,10 +170,12 @@ func findTTLChanges(existing, desired []targetConfig) ([]targetConfig, []targetC
|
|||
|
||||
if ecomp == dcomp && er.TTL != dr.TTL {
|
||||
m := color.YellowString("± MODIFY-TTL %s %s %s", dr.NameFQDN, dr.Type, humanDiff(existing[ei], desired[di]))
|
||||
instructions = append(instructions, mkChange(dr.NameFQDN, dr.Type, []string{m},
|
||||
v := mkChange(dr.NameFQDN, dr.Type, []string{m},
|
||||
models.Records{er},
|
||||
models.Records{dr},
|
||||
))
|
||||
)
|
||||
v.HintOnlyTTL = true
|
||||
instructions = append(instructions, v)
|
||||
ei++
|
||||
di++
|
||||
} else if ecomp < dcomp {
|
||||
|
|
|
@ -670,7 +670,7 @@ func Test_splitTTLOnly(t *testing.T) {
|
|||
},
|
||||
wantExistDiff: nil,
|
||||
wantDesireDiff: nil,
|
||||
wantChanges: "ChangeList: len=1\n00: Change: verb=CHANGE\n key={laba.f.com A}\n old=[1.2.3.4]\n new=[1.2.3.4]\n msg=[\"± MODIFY-TTL laba.f.com A 1.2.3.4 ttl=(300->700)\"]\n",
|
||||
wantChanges: "ChangeList: len=1\n00: Change: verb=CHANGE\n key={laba.f.com A}\n Hints=OnlyTTL\n{laba.f.com A} old=[1.2.3.4]\n new=[1.2.3.4]\n msg=[\"± MODIFY-TTL laba.f.com A 1.2.3.4 ttl=(300->700)\"]\n",
|
||||
},
|
||||
|
||||
{
|
||||
|
|
|
@ -39,6 +39,10 @@ type Change struct {
|
|||
Msgs []string // Human-friendly explanation of what changed
|
||||
MsgsJoined string // strings.Join(Msgs, "\n")
|
||||
MsgsByKey map[models.RecordKey][]string // Messages for a given key
|
||||
|
||||
// HintOnlyTTL is true only if (.Type == diff2.CHANGE) && (there is
|
||||
// exactly 1 record being updated) && (the only change is the TTL)
|
||||
HintOnlyTTL bool
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -223,6 +227,9 @@ func (c Change) String() string {
|
|||
|
||||
fmt.Fprintf(b, "Change: verb=%v\n", c.Type)
|
||||
fmt.Fprintf(b, " key=%v\n", c.Key)
|
||||
if c.HintOnlyTTL {
|
||||
fmt.Fprint(b, " Hints=OnlyTTL\n", c.Key)
|
||||
}
|
||||
if len(c.Old) != 0 {
|
||||
fmt.Fprintf(b, " old=%v\n", c.Old)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue