CHORE: Remove dead code: txtutil.SplitSingleLongTxt() and txtutil.Segment() (#2685)

This commit is contained in:
Tom Limoncelli 2023-12-05 09:47:52 -05:00 committed by GitHub
parent 3ed24a9af6
commit 76d93acaf5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 0 additions and 68 deletions

View file

@ -1,20 +1,10 @@
package txtutil
// SplitSingleLongTxt does nothing.
// Deprecated: This is a no-op for backwards compatibility.
func SplitSingleLongTxt(records any) {
}
// ToChunks returns the string as chunks of 255-octet strings (the last string being the remainder).
func ToChunks(s string) []string {
return splitChunks(s, 255)
}
// Segment returns the string as 255-octet segments, the last being the remainder.
func Segment(s string) []string {
return splitChunks(s, 255)
}
func splitChunks(buf string, lim int) []string {
var chunk string
chunks := make([]string, 0, len(buf)/lim+1)

View file

@ -17,7 +17,6 @@ import (
"github.com/StackExchange/dnscontrol/v4/models"
"github.com/StackExchange/dnscontrol/v4/pkg/diff"
"github.com/StackExchange/dnscontrol/v4/pkg/printer"
"github.com/StackExchange/dnscontrol/v4/pkg/txtutil"
"github.com/StackExchange/dnscontrol/v4/providers"
)
@ -106,8 +105,6 @@ func (a *edgeDNSProvider) EnsureZoneExists(domain string) error {
// GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records.
func (a *edgeDNSProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, existingRecords models.Records) ([]*models.Correction, error) {
txtutil.SplitSingleLongTxt(existingRecords)
keysToUpdate, toReport, err := diff.NewCompat(dc).ChangedGroups(existingRecords)
if err != nil {
return nil, err

View file

@ -11,7 +11,6 @@ import (
"github.com/StackExchange/dnscontrol/v4/models"
"github.com/StackExchange/dnscontrol/v4/pkg/diff2"
"github.com/StackExchange/dnscontrol/v4/pkg/txtutil"
"github.com/StackExchange/dnscontrol/v4/providers"
)
@ -68,7 +67,6 @@ func New(settings map[string]string, _ json.RawMessage) (providers.DNSServicePro
// GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records.
func (api *autoDNSProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, existingRecords models.Records) ([]*models.Correction, error) {
domain := dc.Name
txtutil.SplitSingleLongTxt(dc.Records) // Autosplit long TXT records
var corrections []*models.Correction

View file

@ -25,7 +25,6 @@ import (
"github.com/StackExchange/dnscontrol/v4/models"
"github.com/StackExchange/dnscontrol/v4/pkg/diff2"
"github.com/StackExchange/dnscontrol/v4/pkg/printer"
"github.com/StackExchange/dnscontrol/v4/pkg/txtutil"
"github.com/StackExchange/dnscontrol/v4/providers"
"github.com/fatih/color"
"github.com/miekg/dns"
@ -410,8 +409,6 @@ func hasNSDeletion(changes diff2.ChangeList) bool {
// GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records.
func (c *axfrddnsProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, foundRecords models.Records) ([]*models.Correction, error) {
txtutil.SplitSingleLongTxt(foundRecords) // Autosplit long TXT records
// Ignoring the SOA, others providers don't manage it either.
if len(foundRecords) >= 1 && foundRecords[0].Type == "SOA" {
foundRecords = foundRecords[1:]

View file

@ -14,7 +14,6 @@ import (
"github.com/StackExchange/dnscontrol/v4/models"
"github.com/StackExchange/dnscontrol/v4/pkg/diff2"
"github.com/StackExchange/dnscontrol/v4/pkg/printer"
"github.com/StackExchange/dnscontrol/v4/pkg/txtutil"
"github.com/StackExchange/dnscontrol/v4/providers"
)
@ -183,8 +182,6 @@ func (a *azurednsProvider) getExistingRecords(domain string) (models.Records, []
// GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records.
func (a *azurednsProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, existingRecords models.Records) ([]*models.Correction, error) {
txtutil.SplitSingleLongTxt(existingRecords) // Autosplit long TXT records
var corrections []*models.Correction
changes, err := diff2.ByRecordSet(existingRecords, dc, nil)

View file

@ -14,7 +14,6 @@ import (
"github.com/StackExchange/dnscontrol/v4/models"
"github.com/StackExchange/dnscontrol/v4/pkg/diff2"
"github.com/StackExchange/dnscontrol/v4/pkg/printer"
"github.com/StackExchange/dnscontrol/v4/pkg/txtutil"
"github.com/StackExchange/dnscontrol/v4/providers"
)
@ -193,8 +192,6 @@ func (a *azurednsProvider) getExistingRecords(domain string) (models.Records, []
// GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records.
func (a *azurednsProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, existingRecords models.Records) ([]*models.Correction, error) {
txtutil.SplitSingleLongTxt(existingRecords) // Autosplit long TXT records
var corrections []*models.Correction
// Azure is a "ByRecordSet" API.

View file

@ -25,7 +25,6 @@ import (
"github.com/StackExchange/dnscontrol/v4/pkg/diff2"
"github.com/StackExchange/dnscontrol/v4/pkg/prettyzone"
"github.com/StackExchange/dnscontrol/v4/pkg/printer"
"github.com/StackExchange/dnscontrol/v4/pkg/txtutil"
"github.com/StackExchange/dnscontrol/v4/providers"
"github.com/miekg/dns"
)
@ -210,7 +209,6 @@ func ParseZoneContents(content string, zoneName string, zonefileName string) (mo
// GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records.
func (c *bindProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, foundRecords models.Records) ([]*models.Correction, error) {
txtutil.SplitSingleLongTxt(dc.Records)
var corrections []*models.Correction
changes := false

View file

@ -6,7 +6,6 @@ import (
"net"
"github.com/StackExchange/dnscontrol/v4/models"
"github.com/StackExchange/dnscontrol/v4/pkg/printer"
)
// nativeToRecordA takes an A record from DNS and returns a native RecordConfig struct.
@ -65,7 +64,6 @@ func nativeToRecordTXT(nr nativeRecordTXT, origin string, defaultTTL uint32) *mo
TTL: ttl,
}
rc.SetLabel(nr.Key, origin)
printer.Printf("DEBUG: inbound raw s=%s\n", nr.Value)
rc.SetTargetTXT(nr.Value)
return rc
}

View file

@ -8,7 +8,6 @@ import (
"github.com/StackExchange/dnscontrol/v4/models"
"github.com/StackExchange/dnscontrol/v4/pkg/diff"
"github.com/StackExchange/dnscontrol/v4/pkg/printer"
"github.com/StackExchange/dnscontrol/v4/pkg/txtutil"
"github.com/StackExchange/dnscontrol/v4/providers"
"github.com/miekg/dns/dnsutil"
)
@ -150,8 +149,6 @@ func PrepDesiredRecords(dc *models.DomainConfig, minTTL uint32) {
// GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records.
func (c *desecProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, existing models.Records) ([]*models.Correction, error) {
txtutil.SplitSingleLongTxt(dc.Records)
var minTTL uint32
c.mutex.Lock()
if ttl, ok := c.domainIndex[dc.Name]; !ok {

View file

@ -10,7 +10,6 @@ import (
"github.com/StackExchange/dnscontrol/v4/models"
"github.com/StackExchange/dnscontrol/v4/pkg/diff"
"github.com/StackExchange/dnscontrol/v4/pkg/txtutil"
"github.com/StackExchange/dnscontrol/v4/providers"
"github.com/digitalocean/godo"
"github.com/miekg/dns/dnsutil"
@ -168,8 +167,6 @@ func (api *digitaloceanProvider) GetZoneRecords(domain string, meta map[string]s
// GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records.
func (api *digitaloceanProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, existingRecords models.Records) ([]*models.Correction, error) {
txtutil.SplitSingleLongTxt(dc.Records) // Autosplit long TXT records
ctx := context.Background()
toReport, toCreate, toDelete, toModify, err := diff.NewCompat(dc).IncrementalDiff(existingRecords)

View file

@ -8,7 +8,6 @@ import (
"github.com/StackExchange/dnscontrol/v4/models"
"github.com/StackExchange/dnscontrol/v4/pkg/diff"
"github.com/StackExchange/dnscontrol/v4/pkg/txtutil"
"github.com/StackExchange/dnscontrol/v4/providers"
)
@ -99,8 +98,6 @@ func New(settings map[string]string, _ json.RawMessage) (providers.DNSServicePro
// }
func (api *dnsMadeEasyProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, existingRecords models.Records) ([]*models.Correction, error) {
txtutil.SplitSingleLongTxt(dc.Records) // Autosplit long TXT records
domainName := dc.Name
domain, err := api.findDomain(domainName)
if err != nil {

View file

@ -24,7 +24,6 @@ import (
"github.com/StackExchange/dnscontrol/v4/models"
"github.com/StackExchange/dnscontrol/v4/pkg/diff2"
"github.com/StackExchange/dnscontrol/v4/pkg/printer"
"github.com/StackExchange/dnscontrol/v4/pkg/txtutil"
"github.com/StackExchange/dnscontrol/v4/providers"
"github.com/go-gandi/go-gandi"
"github.com/go-gandi/go-gandi/config"
@ -195,7 +194,6 @@ func (client *gandiv5Provider) GetZoneRecordsCorrections(dc *models.DomainConfig
}
PrepDesiredRecords(dc)
txtutil.SplitSingleLongTxt(dc.Records) // Autosplit long TXT records
g := gandi.NewLiveDNSClient(config.Config{
APIKey: client.apikey,

View file

@ -259,8 +259,6 @@ type correctionValues struct {
// GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records.
func (g *gcloudProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, existingRecords models.Records) ([]*models.Correction, error) {
txtutil.SplitSingleLongTxt(dc.Records) // Autosplit long TXT records
oldRRs, ok := g.oldRRsMap[dc.Name]
if !ok {
return nil, fmt.Errorf("oldRRsMap: no zone named %q", dc.Name)

View file

@ -191,9 +191,6 @@ func (c *hednsProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, recor
}
}
// Normalize
txtutil.SplitSingleLongTxt(dc.Records) // Autosplit long TXT records
return c.getDiff2DomainCorrections(dc, zoneID, prunedRecords)
}

View file

@ -7,7 +7,6 @@ import (
"github.com/StackExchange/dnscontrol/v4/models"
"github.com/StackExchange/dnscontrol/v4/pkg/diff"
"github.com/StackExchange/dnscontrol/v4/pkg/txtutil"
"github.com/StackExchange/dnscontrol/v4/providers"
)
@ -72,8 +71,6 @@ func (api *hetznerProvider) EnsureZoneExists(domain string) error {
func (api *hetznerProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, existingRecords models.Records) ([]*models.Correction, error) {
domain := dc.Name
txtutil.SplitSingleLongTxt(dc.Records) // Autosplit long TXT records
toReport, create, del, modify, err := diff.NewCompat(dc).IncrementalDiff(existingRecords)
if err != nil {
return nil, err

View file

@ -57,8 +57,6 @@ func (n *HXClient) GetZoneRecords(domain string, meta map[string]string) (models
// GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records.
func (n *HXClient) GetZoneRecordsCorrections(dc *models.DomainConfig, actual models.Records) ([]*models.Correction, error) {
txtutil.SplitSingleLongTxt(dc.Records)
toReport, create, del, mod, err := diff.NewCompat(dc).IncrementalDiff(actual)
if err != nil {
return nil, err

View file

@ -10,7 +10,6 @@ import (
"github.com/StackExchange/dnscontrol/v4/models"
"github.com/StackExchange/dnscontrol/v4/pkg/diff"
"github.com/StackExchange/dnscontrol/v4/pkg/printer"
"github.com/StackExchange/dnscontrol/v4/pkg/txtutil"
"github.com/StackExchange/dnscontrol/v4/providers"
"github.com/nrdcg/goinwx"
"github.com/pquerna/otp/totp"
@ -226,9 +225,6 @@ func checkRecords(records models.Records) error {
// GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records.
func (api *inwxAPI) GetZoneRecordsCorrections(dc *models.DomainConfig, foundRecords models.Records) ([]*models.Correction, error) {
txtutil.SplitSingleLongTxt(dc.Records) // Autosplit long TXT records
err := checkRecords(dc.Records)
if err != nil {
return nil, err

View file

@ -25,7 +25,6 @@ import (
"github.com/StackExchange/dnscontrol/v4/models"
"github.com/StackExchange/dnscontrol/v4/pkg/diff"
"github.com/StackExchange/dnscontrol/v4/pkg/printer"
"github.com/StackExchange/dnscontrol/v4/pkg/txtutil"
"github.com/StackExchange/dnscontrol/v4/providers"
"github.com/miekg/dns/dnsutil"
)
@ -271,8 +270,6 @@ func (c *APIClient) GetZoneRecordsCorrections(dc *models.DomainConfig, existingR
debugRecords("GenerateZoneRecordsCorrections input:\n", existingRecords)
}
// Normalize
txtutil.SplitSingleLongTxt(dc.Records) // Autosplit long TXT records
PrepDesiredRecords(dc)
var keysToUpdate map[models.RecordKey][]string

View file

@ -5,16 +5,13 @@ import (
"github.com/StackExchange/dnscontrol/v4/models"
"github.com/StackExchange/dnscontrol/v4/pkg/diff2"
"github.com/StackExchange/dnscontrol/v4/pkg/txtutil"
)
// GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records.
func (client *msdnsProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, foundRecords models.Records) ([]*models.Correction, error) {
var corrections []*models.Correction
// Normalize
models.PostProcessRecords(foundRecords)
txtutil.SplitSingleLongTxt(dc.Records) // Autosplit long TXT records
changes, err := diff2.ByRecord(foundRecords, dc, nil)
if err != nil {

View file

@ -71,9 +71,6 @@ func (api *netcupProvider) GetNameservers(domain string) ([]*models.Nameserver,
func (api *netcupProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, existingRecords models.Records) ([]*models.Correction, error) {
domain := dc.Name
// no need for txtutil.SplitSingleLongTxt in function GetDomainCorrections
// txtutil.SplitSingleLongTxt(dc.Records) // Autosplit long TXT records
// Setting the TTL is not supported for netcup
for _, r := range dc.Records {
r.TTL = 0

View file

@ -9,7 +9,6 @@ import (
"github.com/StackExchange/dnscontrol/v4/models"
"github.com/StackExchange/dnscontrol/v4/pkg/diff"
"github.com/StackExchange/dnscontrol/v4/pkg/printer"
"github.com/StackExchange/dnscontrol/v4/pkg/txtutil"
"github.com/StackExchange/dnscontrol/v4/providers"
"github.com/oracle/oci-go-sdk/v32/common"
"github.com/oracle/oci-go-sdk/v32/dns"
@ -204,7 +203,6 @@ func (o *oracleProvider) GetZoneRecords(zone string, meta map[string]string) (mo
// GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records.
func (o *oracleProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, existingRecords models.Records) ([]*models.Correction, error) {
var err error
txtutil.SplitSingleLongTxt(dc.Records) // Autosplit long TXT records
// Ensure we don't emit changes for attempted modification of built-in apex NSs
for _, rec := range dc.Records {

View file

@ -279,8 +279,6 @@ func (r *route53Provider) getZoneRecords(zone r53Types.HostedZone) (models.Recor
// GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records.
func (r *route53Provider) GetZoneRecordsCorrections(dc *models.DomainConfig, existingRecords models.Records) ([]*models.Correction, error) {
txtutil.SplitSingleLongTxt(dc.Records) // Autosplit long TXT records
zone, err := r.getZone(dc)
if err != nil {
return nil, err

View file

@ -5,7 +5,6 @@ import (
"github.com/StackExchange/dnscontrol/v4/models"
"github.com/StackExchange/dnscontrol/v4/pkg/diff"
"github.com/StackExchange/dnscontrol/v4/pkg/txtutil"
)
// RWTHDefaultNs is the default DNS NS for this provider.
@ -31,7 +30,6 @@ func (api *rwthProvider) GetNameservers(domain string) ([]*models.Nameserver, er
// GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records.
func (api *rwthProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, existingRecords models.Records) ([]*models.Correction, error) {
txtutil.SplitSingleLongTxt(dc.Records) // Autosplit long TXT records
domain := dc.Name
toReport, create, del, modify, err := diff.NewCompat(dc).IncrementalDiff(existingRecords)