mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
Eliminate models.StringsToNameservers() (#1486)
* Eliminate StringsToNameservers() * update comments
This commit is contained in:
@@ -43,32 +43,23 @@ type DNSProviderConfig struct {
|
||||
Metadata json.RawMessage `json:"meta,omitempty"`
|
||||
}
|
||||
|
||||
// FIXME(tal): In hindsight, the Nameserver struct is overkill. We
|
||||
// could have just used []string. Now every provider calls StringsToNameservers
|
||||
// and ever user calls StringsToNameservers. We should refactor this
|
||||
// some day. https://github.com/StackExchange/dnscontrol/issues/577
|
||||
|
||||
// Nameserver describes a nameserver.
|
||||
type Nameserver struct {
|
||||
Name string `json:"name"` // Normalized to a FQDN with NO trailing "."
|
||||
// NB(tlim): DomainConfig.Nameservers are stored WITH a trailing "." (Sorry!)
|
||||
}
|
||||
|
||||
// FIXME(tal): In hindsight the Nameserver struct is overkill. We
|
||||
// could have just used string. Currently there are very few places
|
||||
// that refer to the .Name field directly. All new code should use
|
||||
// ToNameservers/ToNameserversStripTD and NameserversToStrings to make
|
||||
// future refactoring easier. See
|
||||
// https://github.com/StackExchange/dnscontrol/issues/577
|
||||
|
||||
func (n *Nameserver) String() string {
|
||||
return n.Name
|
||||
}
|
||||
|
||||
// StringsToNameservers constructs a list of *Nameserver structs using a list of FQDNs.
|
||||
// Deprecated. Please use ToNameservers, or maybe ToNameserversStripTD instead.
|
||||
// See https://github.com/StackExchange/dnscontrol/issues/491
|
||||
func StringsToNameservers(nss []string) []*Nameserver {
|
||||
nservers := []*Nameserver{}
|
||||
for _, ns := range nss {
|
||||
nservers = append(nservers, &Nameserver{Name: ns})
|
||||
}
|
||||
return nservers
|
||||
}
|
||||
|
||||
// ToNameservers turns a list of strings into a list of Nameservers.
|
||||
// It is an error if any string has a trailing dot. Either remove the
|
||||
// trailing dot before you call this or (much preferred) use ToNameserversStripTD.
|
||||
|
||||
Reference in New Issue
Block a user