mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2025-10-06 11:56:50 +08:00
TRANSIP: For modifications always remove and re-add records (#1920)
Co-authored-by: Tom Limoncelli <tlimoncelli@stackoverflow.com>
This commit is contained in:
parent
481137d964
commit
01829a2dc0
1 changed files with 16 additions and 23 deletions
|
@ -133,31 +133,24 @@ func (n *transipProvider) GetDomainCorrections(dc *models.DomainConfig) ([]*mode
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// TransIP identifies records by (Label, TTL Type), we can only update it if only the contents
|
// TransIP identifies records by (Label, TTL Type), we can only update it if only the contents has changed and there exists no records with the same name.
|
||||||
// has changed. Otherwise we delete the old record and create the new one
|
// In diff2 this is solved by diffing against the recordset for the old diff mechanism we always remove the record and re-add it.
|
||||||
if canUpdateDNSEntry(mod.Desired, mod.Existing) {
|
oldEntry, err := recordToNative(mod.Existing)
|
||||||
corrections = append(corrections, &models.Correction{
|
if err != nil {
|
||||||
Msg: mod.String(),
|
return nil, err
|
||||||
F: func() error { return n.domains.UpdateDNSEntry(dc.Name, targetEntry) },
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
oldEntry, err := recordToNative(mod.Existing)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
corrections = append(corrections,
|
|
||||||
&models.Correction{
|
|
||||||
Msg: mod.String() + "[1/2]",
|
|
||||||
F: func() error { return n.domains.RemoveDNSEntry(dc.Name, oldEntry) },
|
|
||||||
},
|
|
||||||
&models.Correction{
|
|
||||||
Msg: mod.String() + "[2/2]",
|
|
||||||
F: func() error { return n.domains.AddDNSEntry(dc.Name, targetEntry) },
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
corrections = append(corrections,
|
||||||
|
&models.Correction{
|
||||||
|
Msg: mod.String() + "[1/2]",
|
||||||
|
F: func() error { return n.domains.RemoveDNSEntry(dc.Name, oldEntry) },
|
||||||
|
},
|
||||||
|
&models.Correction{
|
||||||
|
Msg: mod.String() + "[2/2]",
|
||||||
|
F: func() error { return n.domains.AddDNSEntry(dc.Name, targetEntry) },
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return corrections, nil
|
return corrections, nil
|
||||||
|
|
Loading…
Add table
Reference in a new issue