mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2025-01-12 02:17:43 +08:00
GANDI-LIVE: Print actual changes to be pushed (#546)
* gandi/livedns: Print actual changes to be pushed Currently, preview & push output prints all domain records values: $ dnscontrol preview ----- DNS Provider: gandi...1 correction #1: Setting dns records for example.com: mail.example.com. 1.2.3.4 "ga" "bu" "zo" With this change, it would only show what changes from current state: $ dnscontrol preview ----- DNS Provider: gandi...1 correction #1: Setting dns records for example.com: CREATE TXT ga.example.com "ga" ttl=10800 MODIFY TXT bu.example.com "bu" ttl=10800 DELETE TXT meu.example.com "meu" ttl=10800 * Add import
This commit is contained in:
parent
2ee086d41c
commit
b968de3ef7
1 changed files with 20 additions and 4 deletions
|
@ -1,6 +1,7 @@
|
||||||
package gandi
|
package gandi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -103,11 +104,26 @@ func (c *liveClient) GetDomainCorrections(dc *models.DomainConfig) ([]*models.Co
|
||||||
differ := diff.New(dc)
|
differ := diff.New(dc)
|
||||||
|
|
||||||
_, create, del, mod := differ.IncrementalDiff(foundRecords)
|
_, create, del, mod := differ.IncrementalDiff(foundRecords)
|
||||||
if len(create)+len(del)+len(mod) > 0 {
|
|
||||||
|
buf := &bytes.Buffer{}
|
||||||
|
// Print a list of changes. Generate an actual change that is the zone
|
||||||
|
changes := false
|
||||||
|
for _, i := range create {
|
||||||
|
changes = true
|
||||||
|
fmt.Fprintln(buf, i)
|
||||||
|
}
|
||||||
|
for _, i := range del {
|
||||||
|
changes = true
|
||||||
|
fmt.Fprintln(buf, i)
|
||||||
|
}
|
||||||
|
for _, i := range mod {
|
||||||
|
changes = true
|
||||||
|
fmt.Fprintln(buf, i)
|
||||||
|
}
|
||||||
|
|
||||||
|
if changes {
|
||||||
message := fmt.Sprintf("Setting dns records for %s:", dc.Name)
|
message := fmt.Sprintf("Setting dns records for %s:", dc.Name)
|
||||||
for _, record := range dc.Records {
|
message += "\n" + buf.String()
|
||||||
message += "\n" + record.GetTargetCombined()
|
|
||||||
}
|
|
||||||
return []*models.Correction{
|
return []*models.Correction{
|
||||||
{
|
{
|
||||||
Msg: message,
|
Msg: message,
|
||||||
|
|
Loading…
Reference in a new issue